1
0
Fork 0

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.

This commit is contained in:
Emiliano Vavassori 2022-03-26 02:32:02 +01:00
parent 8c298e85de
commit da8adc785f
1 changed files with 37 additions and 10 deletions

View File

@ -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"""