Commit local changes from server made by Brecht

Never, ever, ever such situation should happen.

From reading the change it seems it's related on making
it possible to build releases from the buildbot.
This commit is contained in:
2019-11-08 09:24:53 +01:00
parent e0cd4f6d15
commit adbc6ebcea
2 changed files with 24 additions and 8 deletions

View File

@@ -4,7 +4,7 @@
# <pep8 compliant> # <pep8 compliant>
# List of the branches being built automatically overnight # List of the branches being built automatically overnight
NIGHT_SCHEDULE_BRANCHES = ["master"] NIGHT_SCHEDULE_BRANCHES = ["master", "blender-v2.81-release"]
# Dictionary that the buildmaster pays attention to. # Dictionary that the buildmaster pays attention to.
c = BuildmasterConfig = {} c = BuildmasterConfig = {}
@@ -76,7 +76,7 @@ def schedule_force_build(name):
name="branch", name="branch",
label="Branch:", label="Branch:",
default="master", default="master",
regex=r'^[a-zA-Z0-9][A-Za-z0-9_-]*$'), regex=r'^[a-zA-Z0-9][A-Za-z0-9\._-]*$'),
# Hide revision. We don't want to allow anyone to overwrite the # Hide revision. We don't want to allow anyone to overwrite the
# master build with an older version. Could be added back once we # master build with an older version. Could be added back once we
# have authentication. # have authentication.

View File

@@ -37,6 +37,7 @@ class Package:
self.filename = os.path.basename(zipname) self.filename = os.path.basename(zipname)
self.platform = self._get_platform(self.filename) self.platform = self._get_platform(self.filename)
self.branch = self._get_branch(self.filename) self.branch = self._get_branch(self.filename)
self.version = self._get_version(self.filename)
# extension stripping # extension stripping
def _strip_extension(self, filename): def _strip_extension(self, filename):
@@ -76,6 +77,18 @@ class Package:
return '-'.join(platform_tokens) return '-'.join(platform_tokens)
def _get_version(self, filename):
tokens = filename.split("-")
use_next_token = False
for token in tokens:
if use_next_token:
return token
elif token == "blender":
use_next_token = True
return ""
def _get_branch(self, filename): def _get_branch(self, filename):
tokens = filename.split("-") tokens = filename.split("-")
branch = "" branch = ""
@@ -128,6 +141,7 @@ def get_branch_platform(packages):
# Extract branch and platform names # Extract branch and platform names
branch = packages[0].branch branch = packages[0].branch
platform = packages[0].platform platform = packages[0].platform
version = packages[0].version
if platform == '': if platform == '':
sys.stderr.write('Failed to detect platform ' + sys.stderr.write('Failed to detect platform ' +
@@ -135,11 +149,11 @@ def get_branch_platform(packages):
sys.exit(1) sys.exit(1)
for package in packages: for package in packages:
if package.branch != branch or package.platform != platform: if package.branch != branch or package.platform != platform or package.version != version:
sys.stderr.write('All packages in the zip file must have the same branch and platform\n') sys.stderr.write('All packages in the zip file must have the same branch and platform\n')
sys.exit(1) sys.exit(1)
return branch, platform return branch, platform, version
def extract_zipfile_packages(zipfile, packages, branch): def extract_zipfile_packages(zipfile, packages, branch):
# Extract packages from zip file # Extract packages from zip file
@@ -160,14 +174,14 @@ def extract_zipfile_packages(zipfile, packages, branch):
sys.stderr.write('Failed to unzip package: %s\n' % str(ex)) sys.stderr.write('Failed to unzip package: %s\n' % str(ex))
sys.exit(1) sys.exit(1)
def remove_replaced_packages(branch, platform, new_packages): def remove_replaced_packages(branch, platform, version, new_packages):
# Remove other files from the same platform and branch that are replaced # Remove other files from the same platform and branch that are replaced
# by the new packages. # by the new packages.
directory = get_download_dir(branch) directory = get_download_dir(branch)
for filename in os.listdir(directory): for filename in os.listdir(directory):
package = Package(filename) package = Package(filename)
if package.platform == platform and package.branch == branch: if package.platform == platform and package.branch == branch and package.version == version:
is_new_package = False is_new_package = False
for new_package in new_packages: for new_package in new_packages:
if package.filename == new_package.filename: if package.filename == new_package.filename:
@@ -175,6 +189,7 @@ def remove_replaced_packages(branch, platform, new_packages):
if not is_new_package: if not is_new_package:
try: try:
print("Removing older package version", filename)
os.remove(os.path.join(directory, filename)) os.remove(os.path.join(directory, filename))
except Exception as ex: except Exception as ex:
sys.stderr.write('Failed to remove replaced package: %s\n' % str(ex)) sys.stderr.write('Failed to remove replaced package: %s\n' % str(ex))
@@ -196,6 +211,7 @@ def remove_old_packages():
file_mtime = os.stat(filepath).st_mtime file_mtime = os.stat(filepath).st_mtime
if file_mtime < cutoff_time: if file_mtime < cutoff_time:
try: try:
print("Removing old branch build", filename)
os.remove(filepath) os.remove(filepath)
except Exception as ex: except Exception as ex:
sys.stderr.write('Failed to remove old package: %s\n' % str(ex)) sys.stderr.write('Failed to remove old package: %s\n' % str(ex))
@@ -207,8 +223,8 @@ if __name__ == "__main__":
with open_zipfile(args.filename) as zipfile: with open_zipfile(args.filename) as zipfile:
packages = get_zipfile_packages(zipfile) packages = get_zipfile_packages(zipfile)
branch, platform = get_branch_platform(packages) branch, platform, version = get_branch_platform(packages)
extract_zipfile_packages(zipfile, packages, branch) extract_zipfile_packages(zipfile, packages, branch)
remove_replaced_packages(branch, platform, version, packages)
remove_replaced_packages(branch, platform, packages)
remove_old_packages() remove_old_packages()