From 8c298e85dede887d06217561c7e0352291808236 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:10:25 +0100 Subject: [PATCH 1/2] Ancora cambio logica build nominali. --- loaih/__init__.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 725e47d..a734ebe 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -21,6 +21,7 @@ class Build(object): self.updatable = True self.storage_path = '/srv/http/appimage.sys42.eu' self.download_path = '/var/tmp/downloads' + self.appversion = '' self.appimagefilename = {} # Getting versions and so on @@ -46,15 +47,12 @@ class Build(object): # If the build was called by queried name, build from latest release available but build with the most generic name if self.queried_name: myver = str.join('.', self.version.split('.')[0:2]) - - self.appimagefilename[u'x86'] = self.appname + '-' + myver + self.languagepart + self.helppart + '-x86.AppImage' - self.appimagefilename[u'x86_64'] = self.appname + '-' + myver + self.languagepart + self.helppart + '-x86_64.AppImage' - + self.appversion = myver + self.languagepart + self.helppart else: - self.appimagefilename[u'x86'] = self.appname + '-' + self.version + self.languagepart + self.helppart + '-x86.AppImage' - self.appimagefilename[u'x86_64'] = self.appname + '-' + v.version + self.languagepart + self.helppart + '-x86_64.AppImage' - + self.appversion = self.version + self.languagepart + self.helppart + self.appimagefilename[u'x86'] = self.appname + '-' + self.version + self.languagepart + self.helppart + '-x86.AppImage' + self.appimagefilename[u'x86_64'] = self.appname + '-' + self.version + self.languagepart + self.helppart + '-x86_64.AppImage' def check(self, storage_path): @@ -212,23 +210,18 @@ class Build(object): urllib.request.urlretrieve(apprunurl, dest) os.chmod(dest, 0o755) - # Setting app version - appversion = self.version + '.' + (self.language if not ',' in self.language else self.language.replace(',', '-')) - if self.offline_help: - appversion += '.help' - # Building app if self.updatable and self.queried_name: # Updatable make sense only for generic images for fresh, still, # daily. If a request was for a specific version, I'd not build an # updatable version. # zsync name was generated already - subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = self.appimagefilename[arch] + '.zsync', appname = self.appname), shell=True) + subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.appversion, zsync = self.appimagefilename[arch] + '.zsync', appname = self.appname), shell=True) else: - subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = appversion, appname = self.appname), shell=True) + subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = self.appversion, appname = self.appname), shell=True) - print("Built AppImage version {version}".format(version = appversion)) + print("Built AppImage version {version}".format(version = self.appversion)) # Cleanup phase, before new run. for deb in glob.glob(self.appnamedir + '/*.deb'): From da8adc785fa1e14b53a1d51e0b0a46be3e843883 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:32:02 +0100 Subject: [PATCH 2/2] Cambiata la logica di verifica della versione. Ogni versione nominale viene buildata due volte, una con nome generico e una con specifico con versione completa. --- loaih/__init__.py | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index a734ebe..ee99036 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -23,6 +23,8 @@ class Build(object): self.download_path = '/var/tmp/downloads' self.appversion = '' self.appimagefilename = {} + self.genappversion = '' + self.genappimagefilename = {} # Getting versions and so on v = versions.BuildVersion(self.query) @@ -45,12 +47,12 @@ class Build(object): self.helppart = '.help' if self.offline_help else '' # If the build was called by queried name, build from latest release available but build with the most generic name - if self.queried_name: - myver = str.join('.', self.version.split('.')[0:2]) - self.appversion = myver + self.languagepart + self.helppart - else: - self.appversion = self.version + self.languagepart + self.helppart + myver = str.join('.', self.version.split('.')[0:2]) + self.genappversion = myver + self.languagepart + self.helppart + self.genappimagefilename[u'x86'] = self.appname + '-' + self.genappversion + self.languagepart + self.helppart + '-x86.AppImage' + self.genappimagefilename[u'x86_64'] = self.appname + '-' + self.genappversion + self.languagepart + self.helppart + '-x86_64.AppImage' + self.appversion = self.version + self.languagepart + self.helppart self.appimagefilename[u'x86'] = self.appname + '-' + self.version + self.languagepart + self.helppart + '-x86.AppImage' self.appimagefilename[u'x86_64'] = self.appname + '-' + self.version + self.languagepart + self.helppart + '-x86_64.AppImage' @@ -73,6 +75,16 @@ class Build(object): self.updatable = False for arch in self.arch: + # For generalized builds, we need to check if there are .ver file + # and it contains the specific version found. + res = subprocess.check_output("find {path} -name {appimage}'".format( + path = self.storage_path, + appimage = self.genappimagefilename[arch] + '.ver' + ), shell=True).decode('utf-8').strip('\n') + for file in res: + if self.version in open(file, 'r').read(): + self.built = True + res = subprocess.check_output("find {path} -name '{appimage}'".format( path = self.storage_path, appimage = self.appimagefilename[arch] @@ -151,9 +163,11 @@ class Build(object): os.chmod('appimagetool', 0o755) # Build the requested version. + if self.queried_name: + self.__unpackbuild__(arch, True) self.__unpackbuild__(arch) - def __unpackbuild__(self, arch): + def __unpackbuild__(self, arch, generalize = False): # We start by filtering out tarballs from the list buildtarballs = [ self.tarballs[arch][0] ] @@ -211,15 +225,28 @@ class Build(object): os.chmod(dest, 0o755) # Building app - if self.updatable and self.queried_name: + if self.updatable: # Updatable make sense only for generic images for fresh, still, # daily. If a request was for a specific version, I'd not build an # updatable version. # zsync name was generated already - subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.appversion, zsync = self.appimagefilename[arch] + '.zsync', appname = self.appname), shell=True) + + # If asked to do a generalized build: + if generalize: + subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.genappversion, zsync = self.genappimagefilename[arch] + '.zsync', appname = self.appname), shell=True) + # Build version file management + with open(self.appimagefilename[arch] + '.ver', 'w') as v: + v.write(self.version) + else: + subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.appversion, zsync = self.appimagefilename[arch] + '.zsync', appname = self.appname), shell=True) else: - subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = self.appversion, appname = self.appname), shell=True) + if generalize: + subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = self.genappversion, appname = self.appname), shell=True) + with open(self.appimagefilename[arch] + '.ver', 'w') as v: + v.write(self.version) + else: + subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = self.appversion, appname = self.appname), shell=True) print("Built AppImage version {version}".format(version = self.appversion)) @@ -246,7 +273,7 @@ class Build(object): return os.chdir(self.appnamedir) - subprocess.run("find . -iname '*.AppImage*' -exec cp {} %s \;" % self.storage_path, shell=True) + subprocess.run("find . -iname '*.AppImage*' -exec cp -f {} %s \;" % self.storage_path, shell=True) def __del__(self): """Destructor"""