1
0
Fork 0

Sistemazione logica per costruzione buildopts.

This commit is contained in:
Emiliano Vavassori 2022-03-31 09:38:00 +02:00
parent 72c36521f6
commit 2f8b4c444a
1 changed files with 12 additions and 5 deletions

View File

@ -48,6 +48,7 @@ class Build(object):
self.relative_path = [] self.relative_path = []
self.full_path = '' self.full_path = ''
def calculate(self): def calculate(self):
"""Calculate exclusions and other variables.""" """Calculate exclusions and other variables."""
# Incompatibilities - if portable and updatable are asked together, # Incompatibilities - if portable and updatable are asked together,
@ -118,6 +119,7 @@ class Build(object):
if self.built[arch]: if self.built[arch]:
print("The requested AppImage already exists on storage for {arch}. I'll skip downloading, building and moving the results.".format(arch=arch)) print("The requested AppImage already exists on storage for {arch}. I'll skip downloading, building and moving the results.".format(arch=arch))
def __calculate_full_path__(self): def __calculate_full_path__(self):
"""Calculate relative path of the build, based on internal other variables.""" """Calculate relative path of the build, based on internal other variables."""
if len(self.relative_path) == 0: if len(self.relative_path) == 0:
@ -136,6 +138,7 @@ class Build(object):
fullpath_arr.extend(self.relative_path) fullpath_arr.extend(self.relative_path)
self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr)) self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr))
def download(self): def download(self):
"""Downloads the contents of the URL as it was a folder.""" """Downloads the contents of the URL as it was a folder."""
for arch in self.arch: for arch in self.arch:
@ -171,6 +174,7 @@ class Build(object):
print("Got %s." % archive) print("Got %s." % archive)
def build(self): def build(self):
"""Building all the versions.""" """Building all the versions."""
# We have 4 builds to do: # We have 4 builds to do:
@ -201,6 +205,7 @@ class Build(object):
self.__unpackbuild__(arch, True) self.__unpackbuild__(arch, True)
self.__unpackbuild__(arch) self.__unpackbuild__(arch)
def __unpackbuild__(self, arch, generalize = False): def __unpackbuild__(self, arch, generalize = False):
if generalize and self.portable: if generalize and self.portable:
# Doesn't particularly make sense to build a generic portable # Doesn't particularly make sense to build a generic portable
@ -270,6 +275,11 @@ class Build(object):
dest = os.path.join(self.appimagedir, 'AppRun') dest = os.path.join(self.appimagedir, 'AppRun')
urllib.request.urlretrieve(apprunurl, dest) urllib.request.urlretrieve(apprunurl, dest)
os.chmod(dest, 0o755) os.chmod(dest, 0o755)
# Dealing with extra options
buildopts = []
if self.sign:
buildopts.append('--sign')
# Building app # Building app
if self.updatable: if self.updatable:
@ -278,11 +288,6 @@ class Build(object):
# updatable version. # updatable version.
# zsync name was generated already # zsync name was generated already
# Dealing with extra options
buildopts = []
if self.sign:
buildopts.append('--sign')
# If asked to do a generalized build: # If asked to do a generalized build:
if generalize: if generalize:
subprocess.run("VERSION={version} ./appimagetool {buildopts} -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.genappversion, buildopts = str.join(' ', buildopts), zsync = self.genappimagefilename[arch] + '.zsync', appname = self.appname), shell=True) subprocess.run("VERSION={version} ./appimagetool {buildopts} -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.genappversion, buildopts = str.join(' ', buildopts), zsync = self.genappimagefilename[arch] + '.zsync', appname = self.appname), shell=True)
@ -307,6 +312,7 @@ class Build(object):
os.remove(deb) os.remove(deb)
subprocess.run("find . -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \+", shell=True) subprocess.run("find . -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \+", shell=True)
def checksums(self): def checksums(self):
"""Create checksums of the built versions.""" """Create checksums of the built versions."""
if all(self.built.values()): if all(self.built.values()):
@ -338,6 +344,7 @@ class Build(object):
os.makedirs(self.full_path, exist_ok = True) os.makedirs(self.full_path, exist_ok = True)
subprocess.run("find . -iname '*.AppImage*' -exec cp -f {} %s \;" % self.full_path, shell=True) subprocess.run("find . -iname '*.AppImage*' -exec cp -f {} %s \;" % self.full_path, shell=True)
def __del__(self): def __del__(self):
"""Destructor""" """Destructor"""
# Cleaning up build directory # Cleaning up build directory