From c79cc2abcf9d4bb7aa56ad7a88060f92158b4320 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sun, 20 Mar 2022 14:33:07 +0100 Subject: [PATCH 01/48] Preparato layout cartelle per libreria. --- .../loappimage-helpers/__init__.py | 0 .../loappimage-helpers/versions.py | 0 scripts/loaih-getversion | 88 +++++++++++++++++++ 3 files changed, 88 insertions(+) rename build.py => lib/loappimage-helpers/__init__.py (100%) rename getversions.py => lib/loappimage-helpers/versions.py (100%) create mode 100644 scripts/loaih-getversion diff --git a/build.py b/lib/loappimage-helpers/__init__.py similarity index 100% rename from build.py rename to lib/loappimage-helpers/__init__.py diff --git a/getversions.py b/lib/loappimage-helpers/versions.py similarity index 100% rename from getversions.py rename to lib/loappimage-helpers/versions.py diff --git a/scripts/loaih-getversion b/scripts/loaih-getversion new file mode 100644 index 0000000..b6acdd8 --- /dev/null +++ b/scripts/loaih-getversion @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# encoding: utf-8 + +import urllib.request +from lxml import etree +from packaging.version import parse as parse_version +import re, sys, json + +ARCHIVE = "https://downloadarchive.documentfoundation.org/libreoffice/old/" +RELEASE = "https://download.documentfoundation.org/libreoffice/stable/" +DAILY = "https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb87-TDF/current/" + +def getlatestrel(basever): + """Search in downloadarchive for the latest version matching baseversion.""" + versionlist = etree.HTML(urllib.request.urlopen(ARCHIVE).read()).xpath('//td/a') + # Getting a more polished matching list + cleanlist = list(dict.fromkeys([x.text.strip('/') for x in versionlist if x.text.startswith(basever)])) + + # Sorting, then returning the last version + return sorted(cleanlist)[-1] + +def getbranchrel(branch): + """Based on branch names, get the release number.""" + basedirurl = {} + version = '' + if branch == 'daily': + basedirurl = { 'x86_64': DAILY, 'x86': '-' } + version = etree.HTML(urllib.request.urlopen(DAILY).read()).xpath('//td/a')[1].text.split('_')[1] + + return { 'version': version, 'basedirurl': basedirurl } + + versions = etree.HTML(urllib.request.urlopen(RELEASE).read()).xpath('//td/a') + index = 1 + if branch == 'still': + index = 2 + elif branch == 'fresh': + index = 3 + version = getlatestrel(versions[index].text.strip('/')) + + return { 'version': version, 'basedirurl': getbaseurl(version) } + +def getbaseurl(version): + """Returns the links based on the numeric version.""" + basediriurl = {} + url = ARCHIVE + '/' + version + '/deb/' + # x86 binaries are not anymore offered after 6.3.0. + if parse_version(version) < parse_version('6.3.0'): + basedirurl['x86'] = url + 'x86/' + else: + basedirurl['x86'] = '-' + + basedirurl['x86_64'] = url + 'x86_64/' + + return basedirurl + +if __name__ == '__main__': + # Preparing variables for outputting + version = '' + basedirurl = {} + basever = 'fresh' + + # At the end of the checks, we need a version string and a basedirurl, which + # should be a dictionaly for x86, x86_64 with the base of the directory where + # to download the files. + if len(sys.argv) > 1: + # A version has been specified. + basever = sys.argv[1] + + # Once overridden with Argv, parse the inputs + if '.' in basever: + # Numbered version. Let's check it is a 4 dotted release + if len(basever.split('.')) == 4: + version = basever + else: + version = getlatestrel(basever) + + basedirurl = getbaseurl(version) + else: + # String versions. + a = getbranchrel(basever) + version = a['version'] + basedirurl = a['basedirurl'] + + output = """RUNDECK:DATA: query = %s +RUNDECK:DATA: version = %s +RUNDECK:DATA: x86 = %s +RUNDECK:DATA: x86_64 = %s""" % (basever, version, basedirurl['x86'] or '-', basedirurl['x86_64']) +print(output) From 6aa0b34216c4c10ee7345dae88c5b445c6198a57 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sun, 20 Mar 2022 23:57:45 +0100 Subject: [PATCH 02/48] Prima versione riscritta. --- lib/loappimage-helpers/__init__.py | 187 ----------------------- lib/loappimage-helpers/versions.py | 88 ----------- loaih/__init__.py | 230 +++++++++++++++++++++++++++++ loaih/versions.py | 76 ++++++++++ scripts/loaih-build | 42 ++++++ scripts/loaih-getversion | 102 +++---------- setup.py | 18 +++ 7 files changed, 390 insertions(+), 353 deletions(-) delete mode 100644 lib/loappimage-helpers/__init__.py delete mode 100644 lib/loappimage-helpers/versions.py create mode 100644 loaih/__init__.py create mode 100644 loaih/versions.py create mode 100644 scripts/loaih-build create mode 100644 setup.py diff --git a/lib/loappimage-helpers/__init__.py b/lib/loappimage-helpers/__init__.py deleted file mode 100644 index 1dda163..0000000 --- a/lib/loappimage-helpers/__init__.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/env python3 - -import urllib.request -from lxml import etree -import tempfile, os, sys, glob, subprocess, shutil - -class Build(object): - LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ] - - def __init__(self, query, arch, url, downloaddir = '/var/tmp/downloads'): - """Build all versions that can be found in the indicated repo.""" - self.__query__ = query - self.__arch__ = arch - self.__url__ = url - self.__downloaddir__ = downloaddir - - # Creating a tempfile - self.__builddir__ = tempfile.mkdtemp() - self.__tarballs__ = [] - self.__appname__ = '' - self.__version__ = '' - - if self.__url__ == '-': - print("Cannot find this version for arch {arch}.".format(arch = self.__arch__)) - return False - - - def download(self): - """Downloads the contents of the URL as it was a folder.""" - - # Let's start with defining which files are to be downloaded. - # Let's explore the remote folder. - contents = etree.HTML(urllib.request.urlopen(self.__url__).read()).xpath("//td/a") - self.__tarballs__ = [ x.text for x in contents if x.text.endswith('tar.gz') ] - maintarball = self.__tarballs__[0] - main_arr = maintarball.split('_') - self.__appname__ = main_arr[0] - self.__version__ = main_arr[1] - - os.makedirs(self.__downloaddir__, exist_ok = True) - os.chdir(self.__downloaddir__) - for archive in self.__tarballs__: - # If the archive is already there, do not do anything. - if os.path.exists(os.path.join(self.__downloaddir__, archive)): - print("Archive %s is already there! Sweet" % archive) - continue - - # Download the archive - try: - urllib.request.urlretrieve(self.__url__ + archive, archive) - except: - print("Failed to download {archive}.".format(archive = archive)) - - print("Got %s." % archive) - - - def build(self): - """Building all the versions.""" - # We have 4 builds to do: - # * standard languages, no help - # * standard languages + offline help - # * all languages, no help - # * all languages + offline help - - # Preparation tasks - self.appnamedir = os.path.join(self.__builddir__, self.__appname__) - self.appimagedir = os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir') - os.makedirs(self.appimagedir, exist_ok = True) - # And then cd to the appname folder. - os.chdir(self.appnamedir) - # Download appimagetool from github - appimagetoolurl = "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-{arch}.AppImage".format(arch = self.__arch__) - urllib.request.urlretrieve(appimagetoolurl, 'appimagetool') - os.chmod('appimagetool', 0o755) - - # Run to build standard no help - self.__unpackbuild__('standard', False) - - # Run to build standard full help - self.__unpackbuild__('standard', True) - - # Build full no help - self.__unpackbuild__('full', False) - - # Full with help - self.__unpackbuild__('full', True) - - def __unpackbuild__(self, languageset = 'full', offlinehelp = False): - # We start by filtering out tarballs from the list - buildtarballs = [ self.__tarballs__[0] ] - - # Let's process standard languages and append results to the - # buildtarball - if languageset == 'standard': - for lang in Build.LANGSTD: - buildtarballs.extend([ x for x in self.__tarballs__ if ('langpack_' + lang) in x ]) - if offlinehelp: - buildtarballs.extend([ x for x in self.__tarballs__ if ('helppack_' + lang) in x ]) - else: - # In any other cases, we build with all languages - if not offlinehelp: - buildtarballs.extend([ x for x in self.__tarballs__ if 'langpack_' in x ]) - else: - # We need also all help. Let's replace buildtarball with the - # whole bunch - buildtarballs = self.__tarballs__ - - # Unpacking the tarballs - for archive in buildtarballs: - subprocess.run("tar xzf {folder}/{archive}".format(folder = self.__downloaddir__, archive = archive), shell=True) - - os.chdir(self.appnamedir) - os.makedirs(self.appimagedir, exist_ok = True) - # At this point, let's decompress the deb packages - subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True, cwd=self.appimagedir) - # Changing desktop file - subprocess.run("find . -iname startcenter.desktop -exec cp {} . \;", shell=True, cwd=self.appimagedir) - appname = 'LibreOffice' if not self.__query__ == 'daily' else 'LibreOfficeDev' - subprocess.run("sed -i -e 's:^Name=.*$:Name=%s:' startcenter.desktop" % appname, shell=True, cwd=self.appimagedir) - - subprocess.run("find . -name '*startcenter.png' -path '*hicolor*48x48*' -exec cp {} . \;", shell=True, cwd=self.appimagedir) - - # Find the name of the binary called in the desktop file. - binaryname = subprocess.check_output("awk 'BEGIN { FS = \"=\" } /^Exec/ { print $2; exit }' startcenter.desktop | awk '{ print $1 }'", shell=True, cwd=self.appimagedir).decode('utf-8').strip('\n') - - bindir=os.path.join(self.appimagedir, 'usr', 'bin') - os.makedirs(bindir, exist_ok = True) - subprocess.run("find ../../opt -iname soffice -path '*program*' -exec ln -sf {} ./%s \;" % binaryname, shell=True, cwd=bindir) - - # Download AppRun from github - apprunurl = "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-{arch}".format(arch = self.__arch__) - dest = os.path.join(self.appimagedir, 'AppRun') - urllib.request.urlretrieve(apprunurl, dest) - os.chmod(dest, 0o755) - - # Setting app version - appversion = self.__version__ + '.' + languageset - if offlinehelp: - appversion += '.help' - - # Building app - subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = appversion, appname = self.__appname__), shell=True) - - print("Built AppImage version {version}".format(version = appversion)) - - # Cleanup phase, before new run. - for deb in glob.glob(self.appnamedir + '/*.deb'): - os.remove(deb) - subprocess.run("find . -type d -maxdepth 1 -exec rm -rf {} \+", shell=True) - - def checksums(self): - """Create checksums of the built versions.""" - os.chdir(self.appnamedir) - for appimage in glob.glob('*.AppImage'): - # See if a checksum already exist - if not os.path.exists(appimage + '.md5'): - subprocess.run("md5sum {appimage} > {appimage}.md5".format(appimage = appimage), shell=True) - - - def move(self, outdir): - """Moves built versions to definitive storage.""" - os.chdir(self.appnamedir) - subprocess.run("find . -iname '*.AppImage*' -exec cp {} %s \;" % outdir, shell=True) - - def __del__(self): - """Destructor""" - # Cleaning up build directory - shutil.rmtree(self.__builddir__) - - -if __name__ == '__main__': - # Run if it is run as a program. - # 1 -> query - # 2 -> arch - # 3 -> url - # 4 -> outdir - - if not len(sys.argv) == 5: - print("Please launch with this parameters: build.py query arch url outputdir") - sys.exit(255) - - b = Build(sys.argv[1], sys.argv[2], sys.argv[3]) - b.download() - b.build() - b.checksums() - b.move(sys.argv[4]) - del b diff --git a/lib/loappimage-helpers/versions.py b/lib/loappimage-helpers/versions.py deleted file mode 100644 index b6acdd8..0000000 --- a/lib/loappimage-helpers/versions.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 - -import urllib.request -from lxml import etree -from packaging.version import parse as parse_version -import re, sys, json - -ARCHIVE = "https://downloadarchive.documentfoundation.org/libreoffice/old/" -RELEASE = "https://download.documentfoundation.org/libreoffice/stable/" -DAILY = "https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb87-TDF/current/" - -def getlatestrel(basever): - """Search in downloadarchive for the latest version matching baseversion.""" - versionlist = etree.HTML(urllib.request.urlopen(ARCHIVE).read()).xpath('//td/a') - # Getting a more polished matching list - cleanlist = list(dict.fromkeys([x.text.strip('/') for x in versionlist if x.text.startswith(basever)])) - - # Sorting, then returning the last version - return sorted(cleanlist)[-1] - -def getbranchrel(branch): - """Based on branch names, get the release number.""" - basedirurl = {} - version = '' - if branch == 'daily': - basedirurl = { 'x86_64': DAILY, 'x86': '-' } - version = etree.HTML(urllib.request.urlopen(DAILY).read()).xpath('//td/a')[1].text.split('_')[1] - - return { 'version': version, 'basedirurl': basedirurl } - - versions = etree.HTML(urllib.request.urlopen(RELEASE).read()).xpath('//td/a') - index = 1 - if branch == 'still': - index = 2 - elif branch == 'fresh': - index = 3 - version = getlatestrel(versions[index].text.strip('/')) - - return { 'version': version, 'basedirurl': getbaseurl(version) } - -def getbaseurl(version): - """Returns the links based on the numeric version.""" - basediriurl = {} - url = ARCHIVE + '/' + version + '/deb/' - # x86 binaries are not anymore offered after 6.3.0. - if parse_version(version) < parse_version('6.3.0'): - basedirurl['x86'] = url + 'x86/' - else: - basedirurl['x86'] = '-' - - basedirurl['x86_64'] = url + 'x86_64/' - - return basedirurl - -if __name__ == '__main__': - # Preparing variables for outputting - version = '' - basedirurl = {} - basever = 'fresh' - - # At the end of the checks, we need a version string and a basedirurl, which - # should be a dictionaly for x86, x86_64 with the base of the directory where - # to download the files. - if len(sys.argv) > 1: - # A version has been specified. - basever = sys.argv[1] - - # Once overridden with Argv, parse the inputs - if '.' in basever: - # Numbered version. Let's check it is a 4 dotted release - if len(basever.split('.')) == 4: - version = basever - else: - version = getlatestrel(basever) - - basedirurl = getbaseurl(version) - else: - # String versions. - a = getbranchrel(basever) - version = a['version'] - basedirurl = a['basedirurl'] - - output = """RUNDECK:DATA: query = %s -RUNDECK:DATA: version = %s -RUNDECK:DATA: x86 = %s -RUNDECK:DATA: x86_64 = %s""" % (basever, version, basedirurl['x86'] or '-', basedirurl['x86_64']) -print(output) diff --git a/loaih/__init__.py b/loaih/__init__.py new file mode 100644 index 0000000..76afa7b --- /dev/null +++ b/loaih/__init__.py @@ -0,0 +1,230 @@ +#!/usr/bin/env python3 + +import urllib.request +import loaih.versions as versions +from lxml import etree +import tempfile, os, sys, glob, subprocess, shutil + +class Build(object): + LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ] + LANGBASIC = [ 'en-GB' ] + + def __init__(self, query, arch): + """Build all versions that can be found in the indicated repo.""" + self.query = query + self.arch = arch + self.url = '' + self.language = 'basic' + self.offline_help = False + self.portable = False + self.updatable = True + self.storage_path = '/srv/http/appimage.sys42.eu' + self.download_path = '/var/tmp/downloads' + + # Getting versions and so on + v = versions.BuildVersion(self.query) + + # Building expected AppImageName + languagepart = "." + if ',' in self.language: + languagepart += self.language.replace(',', '-') + + self.appimagefilename['x86'] = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' + '-' + v.version + languagepart + '.help' if self.offline_help else '' + '-x86.AppImage' + self.appimagefilename['x86_64'] = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' + '-' + v.version + languagepart + '.help' if self.offline_help else '' + '-x86_64.AppImage' + + # Creating a tempfile + self.builddir = tempfile.mkdtemp() + self.tarballs = [] + self.appname = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' + self.version = v.version + self.url = v.basedirurl + self.built = False + + def check(self, storage_path): + """Checking if the requested AppImage has been already built.""" + self.storage_path = storage_path + + if self.portable: + self.storage_path += "/portable" + + for arch in self.arch: + res = subprocess.check_output("find {path} -name '{appimage}'".format( + path = self.storage_path, + appimage = self.appimagefilename[arch] + '.zsync' if self.updatable else '' + ), shell=True).decode('utf-8').strip('\n') + if len(res) > 1: + self.built = True + + if self.built: + print("The requested AppImage already exists on storage. I'll skip downloading, building and moving the results.") + + def download(self, download_path): + """Downloads the contents of the URL as it was a folder.""" + if self.built: + return + + # Let's start with defining which files are to be downloaded. + # Let's explore the remote folder. + self.download_path = download_path + + for a in self.arch: + contents = etree.HTML(urllib.request.urlopen(self.url[a]).read()).xpath("//td/a") + self.tarballs = [ x.text for x in contents if x.text.endswith('tar.gz') ] + maintarball = self.tarballs[0] + mainarr = maintarball.split('') + self.appname = mainarr[0] + self.version = mainarr[1] + + os.makedirs(self.downloaddir, existok = True) + os.chdir(self.downloaddir) + for archive in self.tarballs: + # If the archive is already there, do not do anything. + if os.path.exists(os.path.join(self.downloaddir, archive)): + print("Archive %s is already there! Sweet" % archive) + continue + + # Download the archive + try: + urllib.request.urlretrieve(self.url + archive, archive) + except: + print("Failed to download {archive}.".format(archive = archive)) + + print("Got %s." % archive) + + def build(self): + """Building all the versions.""" + if self.built: + return + + # We have 4 builds to do: + # * standard languages, no help + # * standard languages + offline help + # * all languages, no help + # * all languages + offline help + + if self.portable and not 'portable' in self.storage_path: + self.storage_path += "/portable" + + # Incompatibilities - if portable and updatable are asked together, + # only portable will be built. + if self.portable and self.updatable: + print("Upgradable and portable options were required together. Building only portable.") + self.updatable = False + + for arch in self.arch: + # Preparation tasks + self.appnamedir = os.path.join(self.builddir, self.appname) + self.appimagedir = os.path.join(self.builddir, self.appname, self.appname + '.AppDir') + os.makedirs(self.appimagedir, exist_ok = True) + # And then cd to the appname folder. + os.chdir(self.appnamedir) + # Download appimagetool from github + appimagetoolurl = "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-{arch}.AppImage".format(arch = arch) + urllib.request.urlretrieve(appimagetoolurl, 'appimagetool') + os.chmod('appimagetool', 0o755) + + # Build the requested version. + self.__unpackbuild__() + + def __unpackbuild__(self, languageset = 'full', offlinehelp = False): + # We start by filtering out tarballs from the list + buildtarballs = [ self.__tarballs__[0] ] + + # Let's process standard languages and append results to the + # buildtarball + if self.language == 'basic': + buildtarballs.extend([ x for x in self.tarballs if 'langpack_en-GB' in x]) + if self.offline_help: + buildtarballs.extend([ x for x in self.tarballs if 'helppack_en-GB' in x ]) + if self.language == 'standard': + for lang in Build.LANGSTD: + buildtarballs.extend([ x for x in self.tarballs if ('langpack' + lang) in x ]) + if self.offlinehelp: + buildtarballs.extend([ x for x in self.tarballs if ('helppack' + lang) in x ]) + else: + # In any other cases, we build with all languages + if not self.offlinehelp: + buildtarballs.extend([ x for x in self.tarballs if 'langpack' in x ]) + else: + # We need also all help. Let's replace buildtarball with the + # whole bunch + buildtarballs = self.tarballs + + # Unpacking the tarballs + for archive in buildtarballs: + subprocess.run("tar xzf {folder}/{archive}".format(folder = self.download_path, archive = archive), shell=True) + + os.chdir(self.appnamedir) + os.makedirs(self.appimagedir, exist_ok = True) + # At this point, let's decompress the deb packages + subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True, cwd=self.appimagedir) + # Changing desktop file + subprocess.run("find . -iname startcenter.desktop -exec cp {} . \;", shell=True, cwd=self.appimagedir) + appname = 'LibreOffice' if not self.__query__ == 'daily' else 'LibreOfficeDev' + subprocess.run("sed -i -e 's:^Name=.*$:Name=%s:' startcenter.desktop" % appname, shell=True, cwd=self.appimagedir) + + subprocess.run("find . -name '*startcenter.png' -path '*hicolor*48x48*' -exec cp {} . \;", shell=True, cwd=self.appimagedir) + + # Find the name of the binary called in the desktop file. + binaryname = subprocess.check_output("awk 'BEGIN { FS = \"=\" } /^Exec/ { print $2; exit }' startcenter.desktop | awk '{ print $1 }'", shell=True, cwd=self.appimagedir).decode('utf-8').strip('\n') + + bindir=os.path.join(self.appimagedir, 'usr', 'bin') + os.makedirs(bindir, exist_ok = True) + subprocess.run("find ../../opt -iname soffice -path '*program*' -exec ln -sf {} ./%s \;" % binaryname, shell=True, cwd=bindir) + + # Download AppRun from github + apprunurl = "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-{arch}".format(arch = arch) + dest = os.path.join(self.appimagedir, 'AppRun') + 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: + zsync = self.appimagefilename[arch] + '.zsync' + subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = zsync, appname = self.__appname__), shell=True) + + else: + subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = appversion, appname = self.appname), shell=True) + + print("Built AppImage version {version}".format(version = appversion)) + + # Cleanup phase, before new run. + for deb in glob.glob(self.appnamedir + '/*.deb'): + os.remove(deb) + subprocess.run("find . -type d -maxdepth 1 -exec rm -rf {} \+", shell=True) + + def checksums(self): + """Create checksums of the built versions.""" + if self.built: + return + + os.chdir(self.appnamedir) + for appimage in glob.glob('*.AppImage*'): + # See if a checksum already exist + if not os.path.exists(appimage + '.md5'): + subprocess.run("md5sum {appimage} > {appimage}.md5".format(appimage = appimage), shell=True) + + + def move(self, outdir): + """Moves built versions to definitive storage.""" + if self.built: + return + if not outdir in self.storage_path: + # Let's create an updated storage_path + if self.portable: + self.storage_path = outdir + '/portable' + else: + self.storage_path = outdir + + os.chdir(self.appnamedir) + subprocess.run("find . -iname '*.AppImage*' -exec cp {} %s \;" % self.storage_path, shell=True) + + def __del__(self): + """Destructor""" + # Cleaning up build directory + shutil.rmtree(self.builddir) diff --git a/loaih/versions.py b/loaih/versions.py new file mode 100644 index 0000000..7def95d --- /dev/null +++ b/loaih/versions.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# encoding: utf-8 + +import urllib.request +from lxml import etree +from packaging.version import parse as parse_version + +class BuildVersion(object): + ARCHIVE = "https://downloadarchive.documentfoundation.org/libreoffice/old/" + RELEASE = "https://download.documentfoundation.org/libreoffice/stable/" + DAILY = "https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb87-TDF/current/" + + def __init__(self, query): + self.query = query + self.version = '' + self.basedirurl = {} + + # Parsing the query input. + if '.' in self.query: + # Numbered self.version. Let's check it is a 4 dotted release + if len(self.query.split('.')) == 4: + self.version = self.query + else: + # If not 4 dotted, let's search for the 4 dotted version + self.version = self.__getlatestrel(self.query) + + self.basedirurl = self.__getbaseurl(self.version) + else: + # String self.versions. + a = self.__getbranchrel(self.query) + self.version = a['version'] + self.basedirurl = a['basedirurl'] + + def __getlatestrel(self, basever): + """Search in downloadarchive for the latest version matching baseversion.""" + versionlist = etree.HTML(urllib.request.urlopen(BuildVersion.ARCHIVE).read()).xpath('//td/a') + # Getting a more polished matching list + cleanlist = list(dict.fromkeys([x.text.strip('/') for x in versionlist if x.text.startswith(basever)])) + + # Sorting, then returning the last version + return sorted(cleanlist)[-1] + + def __getbranchrel(self, branch): + """Based on branch names, get the release number.""" + basedirurl = {} + version = '' + if branch == 'daily': + basedirurl = { 'x86_64': BuildVersion.DAILY, 'x86': '-' } + version = etree.HTML(urllib.request.urlopen(BuildVersion.DAILY).read()).xpath('//td/a')[1].text.split('_')[1] + + return { 'version': version, 'basedirurl': basedirurl } + + versions = etree.HTML(urllib.request.urlopen(BuildVersion.RELEASE).read()).xpath('//td/a') + index = 1 + if branch == 'still': + index = 2 + elif branch == 'fresh': + index = 3 + version = self.__getlatestrel(versions[index].text.strip('/')) + + return { 'version': version, 'basedirurl': self.__getbaseurl(version) } + + def __getbaseurl(self, version): + """Returns the links based on the numeric version.""" + basedirurl = {} + url = BuildVersion.ARCHIVE + '/' + version + '/deb/' + + # x86 binaries are not anymore offered after 6.3.0. + if parse_version(version) < parse_version('6.3.0'): + basedirurl['x86'] = url + 'x86/' + else: + basedirurl['x86'] = '-' + + basedirurl['x86_64'] = url + 'x86_64/' + + return basedirurl diff --git a/scripts/loaih-build b/scripts/loaih-build new file mode 100644 index 0000000..8392b37 --- /dev/null +++ b/scripts/loaih-build @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# encoding: utf-8 + +import click +import loaih + +@click.command() +@click.option('-a', '--arch', 'arch', type=click.Choice(['x86', 'x86_64', 'all'], case_sensitive=False), default='all', help="Build the AppImage for a specific architecture. If there is no specific options, the process will build for both architectures (if available). Default: all") +@click.option('-l', '--language', 'language', default = 'basic', type=str, help="Languages to be included. Options: basic, standard, full, a language string (e.g. 'it') or a list of languages comma separated (e.g.: 'en-US,en-GB,it'). Default: basic") +@click.option('-o/-O', '--offline-help/--no-offline-help', 'offline', default = False, help="Include or not the offline help for the chosen languages. Default: no offline help") +@click.option('-p/-P', '--portable/--no-portable', 'portable', default = False, help="Create a portable version of the AppImage or not. Default: no portable") +@click.option('-u/-U', '--updatable/--no-updatable', 'updatable', default = True, help="Create an updatable version of the AppImage or not. Default: updatable") +@click.option('-d', '--download-path', 'download', default = '/var/tmp/downloads', type=str, help="Path to the download folder. Default: /var/tmp/downloads") +@click.option('-s', '--storage-path', 'storage', default = '/srv/http/appimage.sys42.eu', type=str, help="Path to the final storage of the AppImage. Default: /srv/http/appimage.sys42.eu") +@click.option('-c/-C', '--check/--no-check', 'check', default=True, help="Check in the final storage if the queried version is existent. Default: check") +@click.argument('query') +def build(arch, language, offline, portable, updatable, download, storage, check, query): + # Parsing options + if arch.lower() == 'all': + # We need to build it twice. + arches = [ 'x86', 'x86_64' ] + else: + arches = [ arch.lower() ] + + for arch in arches: + obj = loaih.build(query, arch) + + obj.language = language + obj.offline_help = offlinehelp + obj.portable = portable + obj.updatable = updatable + + if check: + obj.check(storage) + obj.download(download) + obj.build() + obj.checksums() + obj.move(storage) + del obj + +if __name__ == '__main__': + build() diff --git a/scripts/loaih-getversion b/scripts/loaih-getversion index b6acdd8..59d03ae 100644 --- a/scripts/loaih-getversion +++ b/scripts/loaih-getversion @@ -1,88 +1,34 @@ #!/usr/bin/env python # encoding: utf-8 -import urllib.request -from lxml import etree -from packaging.version import parse as parse_version +import click +from loaih.versions import BuildVersion import re, sys, json -ARCHIVE = "https://downloadarchive.documentfoundation.org/libreoffice/old/" -RELEASE = "https://download.documentfoundation.org/libreoffice/stable/" -DAILY = "https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb87-TDF/current/" +@click.command() +@click.option('-o', '--output', default = 'rundeck', type=click.Choice(['rundeck', 'json', 'text' ], case_sensitive=False), help="Output format, defaulting to Rundeck Key/Value data format. Options: rundeck,json,text") +@click.argument('query') +def getversion(query, output): + b = BuildVersion(query) -def getlatestrel(basever): - """Search in downloadarchive for the latest version matching baseversion.""" - versionlist = etree.HTML(urllib.request.urlopen(ARCHIVE).read()).xpath('//td/a') - # Getting a more polished matching list - cleanlist = list(dict.fromkeys([x.text.strip('/') for x in versionlist if x.text.startswith(basever)])) - - # Sorting, then returning the last version - return sorted(cleanlist)[-1] - -def getbranchrel(branch): - """Based on branch names, get the release number.""" - basedirurl = {} - version = '' - if branch == 'daily': - basedirurl = { 'x86_64': DAILY, 'x86': '-' } - version = etree.HTML(urllib.request.urlopen(DAILY).read()).xpath('//td/a')[1].text.split('_')[1] - - return { 'version': version, 'basedirurl': basedirurl } - - versions = etree.HTML(urllib.request.urlopen(RELEASE).read()).xpath('//td/a') - index = 1 - if branch == 'still': - index = 2 - elif branch == 'fresh': - index = 3 - version = getlatestrel(versions[index].text.strip('/')) - - return { 'version': version, 'basedirurl': getbaseurl(version) } - -def getbaseurl(version): - """Returns the links based on the numeric version.""" - basediriurl = {} - url = ARCHIVE + '/' + version + '/deb/' - # x86 binaries are not anymore offered after 6.3.0. - if parse_version(version) < parse_version('6.3.0'): - basedirurl['x86'] = url + 'x86/' + if output.lower() == 'rundeck': + print("""RUNDECK:DATA: query = {query} +RUNDECK:DATA: version = {version} +RUNDECK:DATA: x86 = {x86_url} +RUNDECK:DATA: x86_64 = {x86_64_url}""".format(query = query, version = b.version, x86_url = b.basedirurl['x86'], x86_64_url = b.basedirurl['x86_64'])) + elif output.lower() == 'json': + output = { + 'query': query, + 'version': b.version, + 'basedirurl': b.basedirurl + } + print(json.dumps(output)) else: - basedirurl['x86'] = '-' - - basedirurl['x86_64'] = url + 'x86_64/' + print("""query: {query} +version: {version} +x86: {x86_url} +x86_64: {x86_64_url}""".format(query = query, version = b.version, x86_url = b.basedirurl['x86'], x86_64_url = b.basedirurl['x86_64'])) - return basedirurl if __name__ == '__main__': - # Preparing variables for outputting - version = '' - basedirurl = {} - basever = 'fresh' - - # At the end of the checks, we need a version string and a basedirurl, which - # should be a dictionaly for x86, x86_64 with the base of the directory where - # to download the files. - if len(sys.argv) > 1: - # A version has been specified. - basever = sys.argv[1] - - # Once overridden with Argv, parse the inputs - if '.' in basever: - # Numbered version. Let's check it is a 4 dotted release - if len(basever.split('.')) == 4: - version = basever - else: - version = getlatestrel(basever) - - basedirurl = getbaseurl(version) - else: - # String versions. - a = getbranchrel(basever) - version = a['version'] - basedirurl = a['basedirurl'] - - output = """RUNDECK:DATA: query = %s -RUNDECK:DATA: version = %s -RUNDECK:DATA: x86 = %s -RUNDECK:DATA: x86_64 = %s""" % (basever, version, basedirurl['x86'] or '-', basedirurl['x86_64']) -print(output) + getversion() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0f9a07d --- /dev/null +++ b/setup.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +# encoding: utf-8 +# vim:sts=4:sw=4 + +from setuptools import setup,find_packages + +setup( + name="loaih", + version="1.0.0", + description="LOAIH - LibreOffice AppImage Helpers, help build a LibreOffice AppImage", + author="Emiliano Vavassori", + author_email="syntaxerrormmm@libreoffice.org", + packages=find_packages(exclude=['contrib', 'docs', 'tests']), + scripts=[ 'scripts/loaih-getversion', 'scripts/loaih-build' ], + install_requires=[ 'click', ], + license='MIT', + url='https://git.libreitalia.org/LibreItalia/loappimage-helpers/', +) From 564a933f65335574b622b36a48608813c2238cd1 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:09:15 +0100 Subject: [PATCH 03/48] Correzione chiamata alla classe di build. --- scripts/loaih-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/loaih-build b/scripts/loaih-build index 8392b37..fb03a43 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -23,7 +23,7 @@ def build(arch, language, offline, portable, updatable, download, storage, check arches = [ arch.lower() ] for arch in arches: - obj = loaih.build(query, arch) + obj = loaih.Build(query, arch) obj.language = language obj.offline_help = offlinehelp From 3557393d385cf4f0ab9c7bba394db9bb9d2968e3 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:18:09 +0100 Subject: [PATCH 04/48] Chiamata sbagliata su appimagefilename. --- loaih/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/loaih/__init__.py b/loaih/__init__.py index 76afa7b..ee0e7c5 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -20,6 +20,7 @@ class Build(object): self.updatable = True self.storage_path = '/srv/http/appimage.sys42.eu' self.download_path = '/var/tmp/downloads' + self.appimagefilename = {} # Getting versions and so on v = versions.BuildVersion(self.query) From da9d9807feea2793f59d8b241437558dfd08853b Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:23:46 +0100 Subject: [PATCH 05/48] Correzione firma di funzione non corretta. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index ee0e7c5..6d0c812 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -127,7 +127,7 @@ class Build(object): # Build the requested version. self.__unpackbuild__() - def __unpackbuild__(self, languageset = 'full', offlinehelp = False): + def __unpackbuild__(self): # We start by filtering out tarballs from the list buildtarballs = [ self.__tarballs__[0] ] From 60db034067a795eadda10464c948ecf73fedffa8 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:25:13 +0100 Subject: [PATCH 06/48] Correzione chiamata in script di build. --- scripts/loaih-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/loaih-build b/scripts/loaih-build index fb03a43..0ce4031 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -26,7 +26,7 @@ def build(arch, language, offline, portable, updatable, download, storage, check obj = loaih.Build(query, arch) obj.language = language - obj.offline_help = offlinehelp + obj.offline_help = offline obj.portable = portable obj.updatable = updatable From c2d3c9d21aedcd611b7a9b9904ba2ac308b9e518 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:30:22 +0100 Subject: [PATCH 07/48] Correzione chiamata di variabile in controllo di esistenza build. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 6d0c812..0792e7d 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -51,7 +51,7 @@ class Build(object): for arch in self.arch: res = subprocess.check_output("find {path} -name '{appimage}'".format( path = self.storage_path, - appimage = self.appimagefilename[arch] + '.zsync' if self.updatable else '' + appimage = self.appimagefilename[arch] + ('.zsync' if self.updatable else '') ), shell=True).decode('utf-8').strip('\n') if len(res) > 1: self.built = True From baa0564c1686d069bf7ce66aac240aee12696833 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:34:38 +0100 Subject: [PATCH 08/48] Correzione a check(). --- loaih/__init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 0792e7d..795b6df 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -43,10 +43,7 @@ class Build(object): def check(self, storage_path): """Checking if the requested AppImage has been already built.""" - self.storage_path = storage_path - - if self.portable: - self.storage_path += "/portable" + self.storage_path = storage_path + ('/portable' if self.portable else '') for arch in self.arch: res = subprocess.check_output("find {path} -name '{appimage}'".format( @@ -187,7 +184,7 @@ class Build(object): # Building app if self.updatable: zsync = self.appimagefilename[arch] + '.zsync' - subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = zsync, appname = self.__appname__), shell=True) + subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = 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) From 5745759488bd483afc73107ea738ad4bff81aac9 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:38:07 +0100 Subject: [PATCH 09/48] Altre correzioni alle chiamate. --- loaih/__init__.py | 8 +------- scripts/loaih-build | 5 ++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 795b6df..522f114 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -208,16 +208,10 @@ class Build(object): subprocess.run("md5sum {appimage} > {appimage}.md5".format(appimage = appimage), shell=True) - def move(self, outdir): + def move(self): """Moves built versions to definitive storage.""" if self.built: return - if not outdir in self.storage_path: - # Let's create an updated storage_path - if self.portable: - self.storage_path = outdir + '/portable' - else: - self.storage_path = outdir os.chdir(self.appnamedir) subprocess.run("find . -iname '*.AppImage*' -exec cp {} %s \;" % self.storage_path, shell=True) diff --git a/scripts/loaih-build b/scripts/loaih-build index 0ce4031..dfbc13a 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -32,10 +32,13 @@ def build(arch, language, offline, portable, updatable, download, storage, check if check: obj.check(storage) + else: + obj.storage_path = storage + obj.download(download) obj.build() obj.checksums() - obj.move(storage) + obj.move() del obj if __name__ == '__main__': From d14a64fa8b95dd2edff5772cbee0e4f63ccc2325 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:40:24 +0100 Subject: [PATCH 10/48] Altre correzioni a appimagefilename. --- loaih/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 522f114..fd96692 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -30,8 +30,8 @@ class Build(object): if ',' in self.language: languagepart += self.language.replace(',', '-') - self.appimagefilename['x86'] = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' + '-' + v.version + languagepart + '.help' if self.offline_help else '' + '-x86.AppImage' - self.appimagefilename['x86_64'] = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' + '-' + v.version + languagepart + '.help' if self.offline_help else '' + '-x86_64.AppImage' + self.appimagefilename['x86'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' + self.appimagefilename['x86_64'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' # Creating a tempfile self.builddir = tempfile.mkdtemp() From 960df20639b0b4cc3e3fb45b79a2caf83e95daa3 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:42:53 +0100 Subject: [PATCH 11/48] Probabile problema con valori di array. --- loaih/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index fd96692..eec2d54 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -30,8 +30,8 @@ class Build(object): if ',' in self.language: languagepart += self.language.replace(',', '-') - self.appimagefilename['x86'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' - self.appimagefilename['x86_64'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' + self.appimagefilename[u'x86'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' + self.appimagefilename[u'x86_64'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' # Creating a tempfile self.builddir = tempfile.mkdtemp() From 8eaa14d4d382d20a48461e0a79432aba9355ebb5 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:44:30 +0100 Subject: [PATCH 12/48] Debug di appimage. --- loaih/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/loaih/__init__.py b/loaih/__init__.py index eec2d54..34199d5 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -46,6 +46,7 @@ class Build(object): self.storage_path = storage_path + ('/portable' if self.portable else '') for arch in self.arch: + print("DEBUG: {appimage}".format(appimage = self.appimagefilename[arch])) res = subprocess.check_output("find {path} -name '{appimage}'".format( path = self.storage_path, appimage = self.appimagefilename[arch] + ('.zsync' if self.updatable else '') From 9ae9585d20624a6a52616eee0488d5bba8a474fb Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:46:07 +0100 Subject: [PATCH 13/48] Debug di appimagefilename. --- loaih/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/loaih/__init__.py b/loaih/__init__.py index 34199d5..180c5d7 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -33,6 +33,8 @@ class Build(object): self.appimagefilename[u'x86'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' self.appimagefilename[u'x86_64'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' + print("DEBUG:") + print(self.appimagefilename) # Creating a tempfile self.builddir = tempfile.mkdtemp() self.tarballs = [] From daff0535d3d03fdc458fc76dc5ee5dd038e08c2e Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:48:42 +0100 Subject: [PATCH 14/48] Trovato forse problema: passaggio di arch. --- loaih/__init__.py | 4 ++-- scripts/loaih-build | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 180c5d7..f6efe2d 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -29,12 +29,12 @@ class Build(object): languagepart = "." if ',' in self.language: languagepart += self.language.replace(',', '-') + else: + languagepart += self.language self.appimagefilename[u'x86'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' self.appimagefilename[u'x86_64'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' - print("DEBUG:") - print(self.appimagefilename) # Creating a tempfile self.builddir = tempfile.mkdtemp() self.tarballs = [] diff --git a/scripts/loaih-build b/scripts/loaih-build index dfbc13a..2e9bcf6 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -18,7 +18,7 @@ def build(arch, language, offline, portable, updatable, download, storage, check # Parsing options if arch.lower() == 'all': # We need to build it twice. - arches = [ 'x86', 'x86_64' ] + arches = [ u'x86', u'x86_64' ] else: arches = [ arch.lower() ] From 0df231e4509e6eae9a7d3bc746ecf53f4848633a Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 00:54:44 +0100 Subject: [PATCH 15/48] Trovato forse problema: passaggio di arch. --- loaih/__init__.py | 5 +---- scripts/loaih-build | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index f6efe2d..2c1c1f2 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -49,10 +49,7 @@ class Build(object): for arch in self.arch: print("DEBUG: {appimage}".format(appimage = self.appimagefilename[arch])) - res = subprocess.check_output("find {path} -name '{appimage}'".format( - path = self.storage_path, - appimage = self.appimagefilename[arch] + ('.zsync' if self.updatable else '') - ), shell=True).decode('utf-8').strip('\n') + res = subprocess.check_output("find {path} -name '{appimage}'".format(path = self.storage_path, appimage = self.appimagefilename[arch] + ('.zsync' if self.updatable else '')), shell=True).decode('utf-8').strip('\n') if len(res) > 1: self.built = True diff --git a/scripts/loaih-build b/scripts/loaih-build index 2e9bcf6..111e64f 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -20,26 +20,25 @@ def build(arch, language, offline, portable, updatable, download, storage, check # We need to build it twice. arches = [ u'x86', u'x86_64' ] else: - arches = [ arch.lower() ] + arches = [ arch.lower().decode('utf-8') ] - for arch in arches: - obj = loaih.Build(query, arch) + obj = loaih.Build(query, arches) - obj.language = language - obj.offline_help = offline - obj.portable = portable - obj.updatable = updatable + obj.language = language + obj.offline_help = offline + obj.portable = portable + obj.updatable = updatable - if check: - obj.check(storage) - else: - obj.storage_path = storage + if check: + obj.check(storage) + else: + obj.storage_path = storage - obj.download(download) - obj.build() - obj.checksums() - obj.move() - del obj + obj.download(download) + obj.build() + obj.checksums() + obj.move() + del obj if __name__ == '__main__': build() From 3422c5e93138f0e1df3fa9cd036da6f0ece0fde1 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:10:17 +0100 Subject: [PATCH 16/48] Alcune pesanti correzioni ai meccanismi di download e alla raccolta dei tarball. --- loaih/__init__.py | 79 +++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 2c1c1f2..be281dc 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -13,7 +13,7 @@ class Build(object): """Build all versions that can be found in the indicated repo.""" self.query = query self.arch = arch - self.url = '' + self.url = {} self.language = 'basic' self.offline_help = False self.portable = False @@ -25,6 +25,14 @@ class Build(object): # Getting versions and so on v = versions.BuildVersion(self.query) + # Creating a tempfile + self.builddir = tempfile.mkdtemp() + self.tarballs = {} + self.appname = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' + self.version = v.version + self.url = v.basedirurl + self.built = False + # Building expected AppImageName languagepart = "." if ',' in self.language: @@ -32,24 +40,19 @@ class Build(object): else: languagepart += self.language - self.appimagefilename[u'x86'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' - self.appimagefilename[u'x86_64'] = ('LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev') + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' + self.appimagefilename[u'x86'] = self.appname + '-' + self.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' + self.appimagefilename[u'x86_64'] = self.appname + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' - # Creating a tempfile - self.builddir = tempfile.mkdtemp() - self.tarballs = [] - self.appname = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' - self.version = v.version - self.url = v.basedirurl - self.built = False def check(self, storage_path): """Checking if the requested AppImage has been already built.""" self.storage_path = storage_path + ('/portable' if self.portable else '') for arch in self.arch: - print("DEBUG: {appimage}".format(appimage = self.appimagefilename[arch])) - res = subprocess.check_output("find {path} -name '{appimage}'".format(path = self.storage_path, appimage = self.appimagefilename[arch] + ('.zsync' if self.updatable else '')), shell=True).decode('utf-8').strip('\n') + res = subprocess.check_output("find {path} -name '{appimage}'".format( + path = self.storage_path, + appimage = self.appimagefilename[arch] + ('.zsync' if self.updatable else '') + ), shell=True).decode('utf-8').strip('\n') if len(res) > 1: self.built = True @@ -65,25 +68,28 @@ class Build(object): # Let's explore the remote folder. self.download_path = download_path - for a in self.arch: - contents = etree.HTML(urllib.request.urlopen(self.url[a]).read()).xpath("//td/a") - self.tarballs = [ x.text for x in contents if x.text.endswith('tar.gz') ] - maintarball = self.tarballs[0] - mainarr = maintarball.split('') - self.appname = mainarr[0] - self.version = mainarr[1] + for arch in self.arch: + # Checking if a valid path has been provided + if self.url[arch] == '-': + print("No build has been provided for the requested AppImage for {arch}. Continue with other options.".format(arch = arch)) + continue - os.makedirs(self.downloaddir, existok = True) - os.chdir(self.downloaddir) - for archive in self.tarballs: + contents = etree.HTML(urllib.request.urlopen(self.url[arch]).read()).xpath("//td/a") + self.tarballs[arch] = [ x.text for x in contents if x.text.endswith('tar.gz') ] + tarballs = self.tarballs[arch] + maintarball = tarballs[0] + + os.makedirs(self.download_path, existok = True) + os.chdir(self.download_path) + for archive in tarballs: # If the archive is already there, do not do anything. - if os.path.exists(os.path.join(self.downloaddir, archive)): + if os.path.exists(os.path.join(self.download_path, archive)): print("Archive %s is already there! Sweet" % archive) continue # Download the archive try: - urllib.request.urlretrieve(self.url + archive, archive) + urllib.request.urlretrieve(self.url[arch] + archive, archive) except: print("Failed to download {archive}.".format(archive = archive)) @@ -110,6 +116,11 @@ class Build(object): self.updatable = False for arch in self.arch: + # Checking if a valid path has been provided + if self.url[arch] == '-': + # User has been warned in download step. + continue + # Preparation tasks self.appnamedir = os.path.join(self.builddir, self.appname) self.appimagedir = os.path.join(self.builddir, self.appname, self.appname + '.AppDir') @@ -122,31 +133,31 @@ class Build(object): os.chmod('appimagetool', 0o755) # Build the requested version. - self.__unpackbuild__() + self.__unpackbuild__(arch) - def __unpackbuild__(self): + def __unpackbuild__(self, arch): # We start by filtering out tarballs from the list - buildtarballs = [ self.__tarballs__[0] ] + buildtarballs = [ self.tarballs[arch][0] ] # Let's process standard languages and append results to the # buildtarball if self.language == 'basic': - buildtarballs.extend([ x for x in self.tarballs if 'langpack_en-GB' in x]) + buildtarballs.extend([ x for x in self.tarballs[arch] if 'langpack_en-GB' in x]) if self.offline_help: - buildtarballs.extend([ x for x in self.tarballs if 'helppack_en-GB' in x ]) + buildtarballs.extend([ x for x in self.tarballs[arch] if 'helppack_en-GB' in x ]) if self.language == 'standard': for lang in Build.LANGSTD: - buildtarballs.extend([ x for x in self.tarballs if ('langpack' + lang) in x ]) + buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack' + lang) in x ]) if self.offlinehelp: - buildtarballs.extend([ x for x in self.tarballs if ('helppack' + lang) in x ]) + buildtarballs.extend([ x for x in self.tarballs[arch] if ('helppack' + lang) in x ]) else: # In any other cases, we build with all languages if not self.offlinehelp: - buildtarballs.extend([ x for x in self.tarballs if 'langpack' in x ]) + buildtarballs.extend([ x for x in self.tarballs[arch] if 'langpack' in x ]) else: # We need also all help. Let's replace buildtarball with the # whole bunch - buildtarballs = self.tarballs + buildtarballs = self.tarballs[arch] # Unpacking the tarballs for archive in buildtarballs: @@ -177,7 +188,7 @@ class Build(object): os.chmod(dest, 0o755) # Setting app version - appversion = self.version + '.' + self.language if not ',' in self.language else self.language.replace(',', '-') + appversion = self.version + '.' + (self.language if not ',' in self.language else self.language.replace(',', '-')) if self.offline_help: appversion += '.help' From 71edb785d2ab168bb81fed70f876e35d1eb8988c Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:11:17 +0100 Subject: [PATCH 17/48] Correzione opzione exist_ok su makedirs() --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index be281dc..4052994 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -79,7 +79,7 @@ class Build(object): tarballs = self.tarballs[arch] maintarball = tarballs[0] - os.makedirs(self.download_path, existok = True) + os.makedirs(self.download_path, exist_ok = True) os.chdir(self.download_path) for archive in tarballs: # If the archive is already there, do not do anything. From e44a70442fe731c442f97d6fda182e9f4a6e3f8c Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:14:28 +0100 Subject: [PATCH 18/48] Correzione flag offline_help. --- loaih/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 4052994..8eccb8f 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -148,11 +148,11 @@ class Build(object): if self.language == 'standard': for lang in Build.LANGSTD: buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack' + lang) in x ]) - if self.offlinehelp: + if self.offline_help: buildtarballs.extend([ x for x in self.tarballs[arch] if ('helppack' + lang) in x ]) else: # In any other cases, we build with all languages - if not self.offlinehelp: + if not self.offline_help: buildtarballs.extend([ x for x in self.tarballs[arch] if 'langpack' in x ]) else: # We need also all help. Let's replace buildtarball with the From 1c46f9846f31fb9a62fa3bec0e398bcc5e58ce93 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:18:37 +0100 Subject: [PATCH 19/48] Sistemato appname. --- loaih/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 8eccb8f..a33726f 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -169,8 +169,7 @@ class Build(object): subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True, cwd=self.appimagedir) # Changing desktop file subprocess.run("find . -iname startcenter.desktop -exec cp {} . \;", shell=True, cwd=self.appimagedir) - appname = 'LibreOffice' if not self.__query__ == 'daily' else 'LibreOfficeDev' - subprocess.run("sed -i -e 's:^Name=.*$:Name=%s:' startcenter.desktop" % appname, shell=True, cwd=self.appimagedir) + subprocess.run("sed -i -e 's:^Name=.*$:Name=%s:' startcenter.desktop" % self.appname, shell=True, cwd=self.appimagedir) subprocess.run("find . -name '*startcenter.png' -path '*hicolor*48x48*' -exec cp {} . \;", shell=True, cwd=self.appimagedir) From ae974e613aea69c002f3d94d56cb717308ddb7a8 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:29:27 +0100 Subject: [PATCH 20/48] Supporto portable. --- loaih/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loaih/__init__.py b/loaih/__init__.py index a33726f..d682d94 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -167,6 +167,10 @@ class Build(object): os.makedirs(self.appimagedir, exist_ok = True) # At this point, let's decompress the deb packages subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True, cwd=self.appimagedir) + if self.portable: + shortversion = self.version.split('.')[0-2].join('.') + subprocess.run("find . -type f -iname 'bootstraprc' -exec sed -i 's|^UserInstallation=.*|UserInstallation=\$SYSUSERCONFIG/libreoffice/{version}|g' {} \+".format(version = shortversion), shell=True, cwd=self.appimagedir) + # Changing desktop file subprocess.run("find . -iname startcenter.desktop -exec cp {} . \;", shell=True, cwd=self.appimagedir) subprocess.run("sed -i -e 's:^Name=.*$:Name=%s:' startcenter.desktop" % self.appname, shell=True, cwd=self.appimagedir) From be24ebf75e2b2a59d99c6300f4f3b49a26c875c8 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:33:47 +0100 Subject: [PATCH 21/48] Ulteriori correzioni per portable. --- loaih/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index d682d94..32643cc 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -47,6 +47,11 @@ class Build(object): def check(self, storage_path): """Checking if the requested AppImage has been already built.""" self.storage_path = storage_path + ('/portable' if self.portable else '') + # Incompatibilities - if portable and updatable are asked together, + # only portable will be built. + if self.portable and self.updatable: + print("Upgradable and portable options were required together. Building only portable.") + self.updatable = False for arch in self.arch: res = subprocess.check_output("find {path} -name '{appimage}'".format( @@ -109,12 +114,6 @@ class Build(object): if self.portable and not 'portable' in self.storage_path: self.storage_path += "/portable" - # Incompatibilities - if portable and updatable are asked together, - # only portable will be built. - if self.portable and self.updatable: - print("Upgradable and portable options were required together. Building only portable.") - self.updatable = False - for arch in self.arch: # Checking if a valid path has been provided if self.url[arch] == '-': From 5430000a32816be8c78f1c9fdf1d0ae8dfd00a2a Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:37:03 +0100 Subject: [PATCH 22/48] Correzione shortversion per portable. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 32643cc..ecd087c 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -167,7 +167,7 @@ class Build(object): # At this point, let's decompress the deb packages subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True, cwd=self.appimagedir) if self.portable: - shortversion = self.version.split('.')[0-2].join('.') + shortversion = str.join('.', self.version.split('.')[:3]) subprocess.run("find . -type f -iname 'bootstraprc' -exec sed -i 's|^UserInstallation=.*|UserInstallation=\$SYSUSERCONFIG/libreoffice/{version}|g' {} \+".format(version = shortversion), shell=True, cwd=self.appimagedir) # Changing desktop file From d1a2b5046180457e272ef3ea36f7ac1893a06d48 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Mon, 21 Mar 2022 01:39:56 +0100 Subject: [PATCH 23/48] Correzione sostituzione della shortversion nella stringa di replacement. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index ecd087c..5c6398e 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -168,7 +168,7 @@ class Build(object): subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True, cwd=self.appimagedir) if self.portable: shortversion = str.join('.', self.version.split('.')[:3]) - subprocess.run("find . -type f -iname 'bootstraprc' -exec sed -i 's|^UserInstallation=.*|UserInstallation=\$SYSUSERCONFIG/libreoffice/{version}|g' {} \+".format(version = shortversion), shell=True, cwd=self.appimagedir) + subprocess.run("find . -type f -iname 'bootstraprc' -exec sed -i 's|^UserInstallation=.*|UserInstallation=\$SYSUSERCONFIG/libreoffice/%s|g' {} \+" % shortversion, shell=True, cwd=self.appimagedir) # Changing desktop file subprocess.run("find . -iname startcenter.desktop -exec cp {} . \;", shell=True, cwd=self.appimagedir) From 66bcd2b39cdf5e2dbf9768d067b3c659dca82f07 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Tue, 22 Mar 2022 01:24:55 +0100 Subject: [PATCH 24/48] Supporto a daily e prerelease. --- loaih/__init__.py | 23 +++++++++++++++-------- loaih/versions.py | 33 +++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 5c6398e..fd94008 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -28,24 +28,26 @@ class Build(object): # Creating a tempfile self.builddir = tempfile.mkdtemp() self.tarballs = {} - self.appname = 'LibreOffice' if not self.query == 'daily' else 'LibreOfficeDev' + self.appname = 'LibreOffice' if not self.query == 'daily' and not self.query == 'prerelease' else 'LibreOfficeDev' self.version = v.version self.url = v.basedirurl self.built = False # Building expected AppImageName - languagepart = "." + self.languagepart = "." if ',' in self.language: - languagepart += self.language.replace(',', '-') + self.languagepart += self.language.replace(',', '-') else: - languagepart += self.language + self.languagepart += self.language - self.appimagefilename[u'x86'] = self.appname + '-' + self.version + languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' - self.appimagefilename[u'x86_64'] = self.appname + '-' + v.version + languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' + self.appimagefilename[u'x86'] = self.appname + '-' + self.version + self.languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' + self.appimagefilename[u'x86_64'] = self.appname + '-' + v.version + self.languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' def check(self, storage_path): """Checking if the requested AppImage has been already built.""" + self.storage_path += ('/daily' if self.query == 'daily' else '') + self.storage_path += ('/prerelease' if self.query == 'prerelease' else '') self.storage_path = storage_path + ('/portable' if self.portable else '') # Incompatibilities - if portable and updatable are asked together, # only portable will be built. @@ -196,8 +198,13 @@ class Build(object): # Building app if self.updatable: - zsync = self.appimagefilename[arch] + '.zsync' - subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = self.appimagefilename[arch] + '.zsync', appname = self.appname), shell=True) + # for the daily build, updatable builds work if the latest one + # provide updates. + if self.query == 'daily': + zsync = self.appname + self.version.split('-')[0] + self.languagepart + ('.help' if self.offline_help else '') + '-' + arch + '.AppImage.zsync' + else: + zsync = self.appimagefilename[arch] + '.zsync' + subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = zsync, appname = self.appname), shell=True) else: subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = appversion, appname = self.appname), shell=True) diff --git a/loaih/versions.py b/loaih/versions.py index 7def95d..fa0d972 100644 --- a/loaih/versions.py +++ b/loaih/versions.py @@ -8,7 +8,8 @@ from packaging.version import parse as parse_version class BuildVersion(object): ARCHIVE = "https://downloadarchive.documentfoundation.org/libreoffice/old/" RELEASE = "https://download.documentfoundation.org/libreoffice/stable/" - DAILY = "https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb87-TDF/current/" + DAILY = "https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb87-TDF/" + PRERELEASE = "https://dev-builds.libreoffice.org/pre-releases/deb/x86_64/" def __init__(self, query): self.query = query @@ -45,17 +46,33 @@ class BuildVersion(object): basedirurl = {} version = '' if branch == 'daily': - basedirurl = { 'x86_64': BuildVersion.DAILY, 'x86': '-' } - version = etree.HTML(urllib.request.urlopen(BuildVersion.DAILY).read()).xpath('//td/a')[1].text.split('_')[1] + # The daily builds can be mostly distinguished by the day of build + # (official version is constant. + + # The last built version is the next-to-last version [-2] on the page. + fulldailypath = etree.HTML(urllib.request.urlopen(BuildVersion.DAILY).read()).xpath('//td/a')[-2].text + dailyversion = fulldailypath.split('_')[0].replace('-', '') + version + newurl = str.join('/', [ BuildVersion.DAILY, fulldailypath, '' ]) + + basedirurl = { u'x86_64': newurl, u'x86': '-' } + version = etree.HTML(urllib.request.urlopen(newurl).read()).xpath('//td/a')[1].text.split('_')[1] + + return { 'version': version + '-' + dailyversion, 'basedirurl': basedirurl } + + if branch == 'prerelease': + version = etree.HTML(urllib.request.urlopen(BuildVersion.PRERELEASE).read()).xpath('//td/a')[1].text.split('_')[1] + basedirurl = { u'x86': '-', u'x86_64': BuildVersion.PRERELEASE } return { 'version': version, 'basedirurl': basedirurl } + # Stable releases. versions = etree.HTML(urllib.request.urlopen(BuildVersion.RELEASE).read()).xpath('//td/a') index = 1 if branch == 'still': - index = 2 + index = -2 elif branch == 'fresh': - index = 3 + index = -1 version = self.__getlatestrel(versions[index].text.strip('/')) return { 'version': version, 'basedirurl': self.__getbaseurl(version) } @@ -67,10 +84,10 @@ class BuildVersion(object): # x86 binaries are not anymore offered after 6.3.0. if parse_version(version) < parse_version('6.3.0'): - basedirurl['x86'] = url + 'x86/' + basedirurl[u'x86'] = url + 'x86/' else: - basedirurl['x86'] = '-' + basedirurl[u'x86'] = '-' - basedirurl['x86_64'] = url + 'x86_64/' + basedirurl[u'x86_64'] = url + 'x86_64/' return basedirurl From 181940b365133ca48a1556b227cc4d6266be3b40 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Tue, 22 Mar 2022 02:04:25 +0100 Subject: [PATCH 25/48] Corretta determinazione storage in cui spostare le build. --- loaih/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index fd94008..2662ec3 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -46,9 +46,10 @@ class Build(object): def check(self, storage_path): """Checking if the requested AppImage has been already built.""" + self.storage_path = storage_path self.storage_path += ('/daily' if self.query == 'daily' else '') self.storage_path += ('/prerelease' if self.query == 'prerelease' else '') - self.storage_path = storage_path + ('/portable' if self.portable else '') + self.storage_path += ('/portable' if self.portable else '') # Incompatibilities - if portable and updatable are asked together, # only portable will be built. if self.portable and self.updatable: @@ -201,9 +202,8 @@ class Build(object): # for the daily build, updatable builds work if the latest one # provide updates. if self.query == 'daily': - zsync = self.appname + self.version.split('-')[0] + self.languagepart + ('.help' if self.offline_help else '') + '-' + arch + '.AppImage.zsync' - else: - zsync = self.appimagefilename[arch] + '.zsync' + appversion = 'daily' + zsync = self.appimagefilename[arch] + '.zsync' subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = zsync, appname = self.appname), shell=True) else: From 2410098953f2336a240199a67f5a9cd2c4b7ac61 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Tue, 22 Mar 2022 02:10:09 +0100 Subject: [PATCH 26/48] Aggiustato build per daily. --- loaih/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 2662ec3..553816f 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -83,7 +83,7 @@ class Build(object): continue contents = etree.HTML(urllib.request.urlopen(self.url[arch]).read()).xpath("//td/a") - self.tarballs[arch] = [ x.text for x in contents if x.text.endswith('tar.gz') ] + self.tarballs[arch] = [ x.text for x in contents if x.text.endswith('tar.gz' and 'deb' in x.text) ] tarballs = self.tarballs[arch] maintarball = tarballs[0] @@ -201,8 +201,6 @@ class Build(object): if self.updatable: # for the daily build, updatable builds work if the latest one # provide updates. - if self.query == 'daily': - appversion = 'daily' zsync = self.appimagefilename[arch] + '.zsync' subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = zsync, appname = self.appname), shell=True) From 425adb5545e998bc7abfb75a6cd4f4ab7f9718e3 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 01:32:15 +0100 Subject: [PATCH 27/48] Corretta logica di build con il discorso updatable: solo se richiesta versione generica o daily. --- loaih/__init__.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 553816f..a1f4d1b 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -12,6 +12,7 @@ class Build(object): def __init__(self, query, arch): """Build all versions that can be found in the indicated repo.""" self.query = query + self.queried_name = False if '.' in self.query else True self.arch = arch self.url = {} self.language = 'basic' @@ -21,6 +22,7 @@ class Build(object): self.storage_path = '/srv/http/appimage.sys42.eu' self.download_path = '/var/tmp/downloads' self.appimagefilename = {} + self.zsyncfilename = {} # Getting versions and so on v = versions.BuildVersion(self.query) @@ -40,8 +42,14 @@ class Build(object): else: self.languagepart += self.language - self.appimagefilename[u'x86'] = self.appname + '-' + self.version + self.languagepart + ('.help' if self.offline_help else '') + '-x86.AppImage' - self.appimagefilename[u'x86_64'] = self.appname + '-' + v.version + self.languagepart + ('.help' if self.offline_help else '') + '-x86_64.AppImage' + self.helppart = '.help' if self.offline_help 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' + + version = str.join('.', self.version.split('.')[0-2]) + self.zsyncfilename[u'x86'] = self.appname + '-' + version + self.languagepart + self.helppart + '-x86.AppImage.zsync' + self.zsyncfilename[u'x86_64'] = self.appname + '-' + version + self.languagepart + self.helppart + '-x86_64.AppImage.zsync' def check(self, storage_path): @@ -56,10 +64,15 @@ class Build(object): print("Upgradable and portable options were required together. Building only portable.") self.updatable = False + if self.updatable and not self.queried_name: + # If the queried version was a numbered version, doesn't make sense + # to build an updatable version. + self.updatable = False + for arch in self.arch: res = subprocess.check_output("find {path} -name '{appimage}'".format( path = self.storage_path, - appimage = self.appimagefilename[arch] + ('.zsync' if self.updatable else '') + appimage = self.appimagefilename[arch] ), shell=True).decode('utf-8').strip('\n') if len(res) > 1: self.built = True @@ -166,9 +179,11 @@ class Build(object): subprocess.run("tar xzf {folder}/{archive}".format(folder = self.download_path, archive = archive), shell=True) os.chdir(self.appnamedir) + os.makedirs(self.appimagedir, exist_ok = True) # At this point, let's decompress the deb packages subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True, cwd=self.appimagedir) + if self.portable: shortversion = str.join('.', self.version.split('.')[:3]) subprocess.run("find . -type f -iname 'bootstraprc' -exec sed -i 's|^UserInstallation=.*|UserInstallation=\$SYSUSERCONFIG/libreoffice/%s|g' {} \+" % shortversion, shell=True, cwd=self.appimagedir) @@ -198,11 +213,12 @@ class Build(object): appversion += '.help' # Building app - if self.updatable: - # for the daily build, updatable builds work if the latest one - # provide updates. - zsync = self.appimagefilename[arch] + '.zsync' - subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = appversion, zsync = zsync, appname = self.appname), shell=True) + 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.zsyncfilename[arch], appname = self.appname), shell=True) else: subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = appversion, appname = self.appname), shell=True) From 5bb82074093a74bbaf09953b19c5b0229b13ea81 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 01:35:06 +0100 Subject: [PATCH 28/48] Corretta sintassi per selezionare solo deb. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index a1f4d1b..c00b62c 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -96,7 +96,7 @@ class Build(object): continue contents = etree.HTML(urllib.request.urlopen(self.url[arch]).read()).xpath("//td/a") - self.tarballs[arch] = [ x.text for x in contents if x.text.endswith('tar.gz' and 'deb' in x.text) ] + self.tarballs[arch] = [ x.text for x in contents if x.text.endswith('tar.gz') and 'deb' in x.text ] tarballs = self.tarballs[arch] maintarball = tarballs[0] From 7afedb2b906815ac0ff70e0397fdcc2ff3f46036 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 01:45:29 +0100 Subject: [PATCH 29/48] Corretto piccolo errore di sintassi. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index c00b62c..b07746c 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -47,7 +47,7 @@ class Build(object): 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' - version = str.join('.', self.version.split('.')[0-2]) + version = str.join('.', self.version.split('.')[0:2]) self.zsyncfilename[u'x86'] = self.appname + '-' + version + self.languagepart + self.helppart + '-x86.AppImage.zsync' self.zsyncfilename[u'x86_64'] = self.appname + '-' + version + self.languagepart + self.helppart + '-x86_64.AppImage.zsync' From f48189e3b33517c5d0ca627ac5c653b09798b3b8 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 01:46:08 +0100 Subject: [PATCH 30/48] Correzione versionamento della appimage con zsync. --- loaih/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index b07746c..b055959 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -47,9 +47,9 @@ class Build(object): 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' - version = str.join('.', self.version.split('.')[0:2]) - self.zsyncfilename[u'x86'] = self.appname + '-' + version + self.languagepart + self.helppart + '-x86.AppImage.zsync' - self.zsyncfilename[u'x86_64'] = self.appname + '-' + version + self.languagepart + self.helppart + '-x86_64.AppImage.zsync' + myver = str.join('.', self.version.split('.')[0:2]) + self.zsyncfilename[u'x86'] = self.appname + '-' + myver + self.languagepart + self.helppart + '-x86.AppImage.zsync' + self.zsyncfilename[u'x86_64'] = self.appname + '-' + myver + self.languagepart + self.helppart + '-x86_64.AppImage.zsync' def check(self, storage_path): From 17fb8bb2b2534465a7b4cd072d293159eb59d6a3 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:04:02 +0100 Subject: [PATCH 31/48] Rivista logica di build per query nominali. --- loaih/__init__.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index b055959..725e47d 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -22,7 +22,6 @@ class Build(object): self.storage_path = '/srv/http/appimage.sys42.eu' self.download_path = '/var/tmp/downloads' self.appimagefilename = {} - self.zsyncfilename = {} # Getting versions and so on v = versions.BuildVersion(self.query) @@ -44,12 +43,18 @@ class Build(object): self.helppart = '.help' if self.offline_help 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' + # 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' + + 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' + - myver = str.join('.', self.version.split('.')[0:2]) - self.zsyncfilename[u'x86'] = self.appname + '-' + myver + self.languagepart + self.helppart + '-x86.AppImage.zsync' - self.zsyncfilename[u'x86_64'] = self.appname + '-' + myver + self.languagepart + self.helppart + '-x86_64.AppImage.zsync' def check(self, storage_path): @@ -218,7 +223,7 @@ class Build(object): # 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.zsyncfilename[arch], appname = self.appname), shell=True) + subprocess.run("VERSION={version} ./appimagetool -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = 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) From 8c298e85dede887d06217561c7e0352291808236 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:10:25 +0100 Subject: [PATCH 32/48] 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 33/48] 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""" From db419bb82596ad0e92bf9e60d8a56b6a963a9dda Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:42:53 +0100 Subject: [PATCH 34/48] Cambio logica codice per trovare file buildati. --- loaih/__init__.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index ee99036..7519b15 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -49,12 +49,12 @@ class Build(object): # If the build was called by queried name, build from latest release available but build with the most generic name 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.genappimagefilename[u'x86'] = self.appname + '-' + self.genappversion + '-x86.AppImage' + self.genappimagefilename[u'x86_64'] = self.appname + '-' + self.genappversion + '-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' + self.appimagefilename[u'x86'] = self.appname + '-' + self.appversion + '-x86.AppImage' + self.appimagefilename[u'x86_64'] = self.appname + '-' + self.appversion + '-x86_64.AppImage' def check(self, storage_path): @@ -77,20 +77,23 @@ class Build(object): 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( + res = subprocess.run("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 + ), shell=True, capture_output=True) + if res.stdout: + # All good, the command was executed fine. + for file in res.stdout.decode('utf-8').strip('\n').split('\n'): + if self.version in open(file, 'r').read(): + self.built = True - res = subprocess.check_output("find {path} -name '{appimage}'".format( + res = subprocess.run("find {path} -name '{appimage}'".format( path = self.storage_path, appimage = self.appimagefilename[arch] - ), shell=True).decode('utf-8').strip('\n') - if len(res) > 1: - self.built = True + ), shell=True, capture_output=True) + if res.stdout: + if len(res.stdout.decode('utf-8').strip('\n')) > 1: + self.built = True if self.built: print("The requested AppImage already exists on storage. I'll skip downloading, building and moving the results.") From 960bab4dee62067dcec983f5b3fb2a15f1bad6fd Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:45:01 +0100 Subject: [PATCH 35/48] Expliciting which file is checking out. --- loaih/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/loaih/__init__.py b/loaih/__init__.py index 7519b15..a00384f 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -77,6 +77,7 @@ class Build(object): for arch in self.arch: # For generalized builds, we need to check if there are .ver file # and it contains the specific version found. + print("Debug: searching for {file}".format(file = self.genappimagefilename[arch] . 'ver')) res = subprocess.run("find {path} -name {appimage}'".format( path = self.storage_path, appimage = self.genappimagefilename[arch] + '.ver' @@ -87,6 +88,7 @@ class Build(object): if self.version in open(file, 'r').read(): self.built = True + print("Debug: searching for {file}".format(file = self.appimagefilename[arch])) res = subprocess.run("find {path} -name '{appimage}'".format( path = self.storage_path, appimage = self.appimagefilename[arch] From 24de2a2d2192c763527d3959649bd1e34869eb6c Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:45:55 +0100 Subject: [PATCH 36/48] Correzione piccolo errore di sintassi. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index a00384f..f8806af 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -77,7 +77,7 @@ class Build(object): for arch in self.arch: # For generalized builds, we need to check if there are .ver file # and it contains the specific version found. - print("Debug: searching for {file}".format(file = self.genappimagefilename[arch] . 'ver')) + print("Debug: searching for {file}".format(file = self.genappimagefilename[arch] + '.ver')) res = subprocess.run("find {path} -name {appimage}'".format( path = self.storage_path, appimage = self.genappimagefilename[arch] + '.ver' From 6fe41c6e765eec90fe4a1f3293de0477426cd188 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 26 Mar 2022 02:54:06 +0100 Subject: [PATCH 37/48] Spostamento codice per calcolo versione. --- loaih/__init__.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index f8806af..fbcfdf0 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -37,6 +37,23 @@ class Build(object): self.url = v.basedirurl self.built = False + def check(self, storage_path): + """Checking if the requested AppImage has been already built.""" + self.storage_path = storage_path + self.storage_path += ('/daily' if self.query == 'daily' else '') + self.storage_path += ('/prerelease' if self.query == 'prerelease' else '') + self.storage_path += ('/portable' if self.portable else '') + # Incompatibilities - if portable and updatable are asked together, + # only portable will be built. + if self.portable and self.updatable: + print("Upgradable and portable options were required together. Building only portable.") + self.updatable = False + + if self.updatable and not self.queried_name: + # If the queried version was a numbered version, doesn't make sense + # to build an updatable version. + self.updatable = False + # Building expected AppImageName self.languagepart = "." if ',' in self.language: @@ -56,24 +73,6 @@ class Build(object): self.appimagefilename[u'x86'] = self.appname + '-' + self.appversion + '-x86.AppImage' self.appimagefilename[u'x86_64'] = self.appname + '-' + self.appversion + '-x86_64.AppImage' - - def check(self, storage_path): - """Checking if the requested AppImage has been already built.""" - self.storage_path = storage_path - self.storage_path += ('/daily' if self.query == 'daily' else '') - self.storage_path += ('/prerelease' if self.query == 'prerelease' else '') - self.storage_path += ('/portable' if self.portable else '') - # Incompatibilities - if portable and updatable are asked together, - # only portable will be built. - if self.portable and self.updatable: - print("Upgradable and portable options were required together. Building only portable.") - self.updatable = False - - if self.updatable and not self.queried_name: - # If the queried version was a numbered version, doesn't make sense - # to build an updatable version. - 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. From 8d8f2b6dc446d1e5c1e646f08d10080c53b4f188 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 00:07:43 +0200 Subject: [PATCH 38/48] Alcuni miglioramenti di ricerca delle build in path specifici. --- loaih/__init__.py | 92 +++++++++++++++++++++++++++++++-------------- scripts/loaih-build | 2 +- setup.py | 2 +- 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index fbcfdf0..55566b9 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -3,7 +3,7 @@ import urllib.request import loaih.versions as versions from lxml import etree -import tempfile, os, sys, glob, subprocess, shutil +import tempfile, os, sys, glob, subprocess, shutil, re class Build(object): LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ] @@ -35,14 +35,21 @@ class Build(object): self.appname = 'LibreOffice' if not self.query == 'daily' and not self.query == 'prerelease' else 'LibreOfficeDev' self.version = v.version self.url = v.basedirurl - self.built = False + self.built = { u'x86': False, u'x86_64': False } + + # Preparing the default for the relative path on the storage for + # different versions. + # The path will evaluated as part of the check() function, as it is + # understood the storage_path can be changed before that phase. + self.relative_path = [] + self.full_path = '' def check(self, storage_path): """Checking if the requested AppImage has been already built.""" - self.storage_path = storage_path - self.storage_path += ('/daily' if self.query == 'daily' else '') - self.storage_path += ('/prerelease' if self.query == 'prerelease' else '') - self.storage_path += ('/portable' if self.portable else '') + # Mandate to the private function to calculate the full_path available + # for the storage and the checks. + self.__calculate_full_path__() + # Incompatibilities - if portable and updatable are asked together, # only portable will be built. if self.portable and self.updatable: @@ -78,32 +85,53 @@ class Build(object): # and it contains the specific version found. print("Debug: searching for {file}".format(file = self.genappimagefilename[arch] + '.ver')) res = subprocess.run("find {path} -name {appimage}'".format( - path = self.storage_path, + path = self.full_path, appimage = self.genappimagefilename[arch] + '.ver' - ), shell=True, capture_output=True) + ), shell=True, capture_output=True, env={ "LC_ALL": "C" }) + + if "No such file or directory" in res.stderr.decode('utf-8'): + # Folder is not existent: so the version was not built + # Build stays false, and we go to the next arch + continue + if res.stdout: # All good, the command was executed fine. for file in res.stdout.decode('utf-8').strip('\n').split('\n'): if self.version in open(file, 'r').read(): - self.built = True + self.built[arch] = True print("Debug: searching for {file}".format(file = self.appimagefilename[arch])) res = subprocess.run("find {path} -name '{appimage}'".format( - path = self.storage_path, + path = self.full_path, appimage = self.appimagefilename[arch] ), shell=True, capture_output=True) if res.stdout: if len(res.stdout.decode('utf-8').strip('\n')) > 1: - self.built = True + self.built[arch] = True - if self.built: - print("The requested AppImage already exists on storage. I'll skip downloading, building and moving the results.") + 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)) + + def __calculate_full_path__(self): + """Calculate relative path of the build, based on internal other variables.""" + if len(self.relative_path) == 0: + if self.query == 'daily': + self.relative_path.append('daily') + elif self.query == 'prerelease': + self.relative_path.append('prerelease') + + # Not the same check, an additional one + if self.portable: + self.relative_path.append('portable') + + fullpath_arr = self.storage_path.split('/') + # Joining relative path only if it is not null + if len(self.relative_path) > 0: + fullpath_arr.expand(self.relative_path) + self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr)) def download(self, download_path): """Downloads the contents of the URL as it was a folder.""" - if self.built: - return - # Let's start with defining which files are to be downloaded. # Let's explore the remote folder. self.download_path = download_path @@ -112,6 +140,12 @@ class Build(object): # Checking if a valid path has been provided if self.url[arch] == '-': print("No build has been provided for the requested AppImage for {arch}. Continue with other options.".format(arch = arch)) + # Faking already built it so to skip other checks. + self.built[arch] = True + continue + + if self.built[arch]: + print("A build for {arch} was already found. Skipping specific packages.".format(arch = arch)) continue contents = etree.HTML(urllib.request.urlopen(self.url[arch]).read()).xpath("//td/a") @@ -137,22 +171,15 @@ class Build(object): def build(self): """Building all the versions.""" - if self.built: - return - # We have 4 builds to do: # * standard languages, no help # * standard languages + offline help # * all languages, no help # * all languages + offline help - if self.portable and not 'portable' in self.storage_path: - self.storage_path += "/portable" - for arch in self.arch: - # Checking if a valid path has been provided - if self.url[arch] == '-': - # User has been warned in download step. + if self.built[arch]: + # Already built for arch or path not available. User has already been warned. continue # Preparation tasks @@ -261,9 +288,13 @@ class Build(object): def checksums(self): """Create checksums of the built versions.""" - if self.built: + if all(self.built.values()): + # All checksums are already created. return + # On the contrary, checksums will be in any case overwritten if + # existent, but generated only for built packages anyways + os.chdir(self.appnamedir) for appimage in glob.glob('*.AppImage*'): # See if a checksum already exist @@ -271,13 +302,16 @@ class Build(object): subprocess.run("md5sum {appimage} > {appimage}.md5".format(appimage = appimage), shell=True) - def move(self): + def publish(self): """Moves built versions to definitive storage.""" - if self.built: + if all(self.built.values()): + # All files are already present in the full_path return os.chdir(self.appnamedir) - subprocess.run("find . -iname '*.AppImage*' -exec cp -f {} %s \;" % self.storage_path, shell=True) + # Forcing creation of subfolders, in case there is a new build + os.makedirs(self.full_path, exist_ok = True) + subprocess.run("find . -iname '*.AppImage*' -exec cp -f {} %s \;" % self.full_path, shell=True) def __del__(self): """Destructor""" diff --git a/scripts/loaih-build b/scripts/loaih-build index 111e64f..69158c9 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -37,7 +37,7 @@ def build(arch, language, offline, portable, updatable, download, storage, check obj.download(download) obj.build() obj.checksums() - obj.move() + obj.publish() del obj if __name__ == '__main__': diff --git a/setup.py b/setup.py index 0f9a07d..032157f 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import setup,find_packages setup( name="loaih", - version="1.0.0", + version="1.0.1", description="LOAIH - LibreOffice AppImage Helpers, help build a LibreOffice AppImage", author="Emiliano Vavassori", author_email="syntaxerrormmm@libreoffice.org", From 8c630cbc560d94a4b11278d3029de361e6d4ee82 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 00:12:15 +0200 Subject: [PATCH 39/48] Aggiustato piccolo typo. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 55566b9..1fe8873 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -127,7 +127,7 @@ class Build(object): fullpath_arr = self.storage_path.split('/') # Joining relative path only if it is not null if len(self.relative_path) > 0: - fullpath_arr.expand(self.relative_path) + fullpath_arr.extend(self.relative_path) self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr)) def download(self, download_path): From cc31d82eb28e1cf637e83d7b3f01946727cfdfb3 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 00:25:42 +0200 Subject: [PATCH 40/48] =?UTF-8?q?Trovato=20e=20fixato=20bug=20per=20cui=20?= =?UTF-8?q?basic=20sono=20pi=C3=B9=20grandi=20di=20standard.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loaih/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 1fe8873..c25c045 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -205,14 +205,16 @@ class Build(object): # Let's process standard languages and append results to the # buildtarball if self.language == 'basic': - buildtarballs.extend([ x for x in self.tarballs[arch] if 'langpack_en-GB' in x]) if self.offline_help: - buildtarballs.extend([ x for x in self.tarballs[arch] if 'helppack_en-GB' in x ]) - if self.language == 'standard': + buildtarballs.extend([ x for x in self.tarballs[arch] if 'pack_en-GB' in x ]) + else: + buildtarballs.extend([ x for x in self.tarballs[arch] if 'langpack_en-GB' in x]) + elif self.language == 'standard': for lang in Build.LANGSTD: - buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack' + lang) in x ]) if self.offline_help: - buildtarballs.extend([ x for x in self.tarballs[arch] if ('helppack' + lang) in x ]) + buildtarballs.extend([ x for x in self.tarballs[arch] if ('pack' + lang) in x ]) + else: + buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack' + lang) in x ]) else: # In any other cases, we build with all languages if not self.offline_help: @@ -284,7 +286,7 @@ class Build(object): # Cleanup phase, before new run. for deb in glob.glob(self.appnamedir + '/*.deb'): os.remove(deb) - subprocess.run("find . -type d -maxdepth 1 -exec rm -rf {} \+", shell=True) + subprocess.run("find . -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \+", shell=True) def checksums(self): """Create checksums of the built versions.""" From f2c64e195fc68892e0b99708bd6ce6544c5677c8 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 00:42:31 +0200 Subject: [PATCH 41/48] Correzione file ver. Spero sistemato problema di lingua. --- loaih/__init__.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index c25c045..6964d1a 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -215,14 +215,20 @@ class Build(object): buildtarballs.extend([ x for x in self.tarballs[arch] if ('pack' + lang) in x ]) else: buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack' + lang) in x ]) - else: - # In any other cases, we build with all languages - if not self.offline_help: - buildtarballs.extend([ x for x in self.tarballs[arch] if 'langpack' in x ]) - else: + elif self.language == 'full': + if self.offline_help: # We need also all help. Let's replace buildtarball with the # whole bunch buildtarballs = self.tarballs[arch] + else: + buildtarballs.extend([ x for x in self.tarballs[arch] if 'langpack' in x ]) + else: + # Looping for each language in self.language + for lang in self.language.split(","): + if self.offline_help: + buildtarballs.extend([ x for x in self.tarballs[arch] if ('pack' + lang) in x ]) + else: + buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack' + lang) in x ]) # Unpacking the tarballs for archive in buildtarballs: @@ -268,7 +274,7 @@ class Build(object): 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: + with open(self.genappimagefilename[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) @@ -276,7 +282,7 @@ class Build(object): else: 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: + with open(self.genappimagefilename[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) From eade74c29a5d04ee15b8afa81ba9ab2c6926471f Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 01:06:38 +0200 Subject: [PATCH 42/48] Script per gli update. Aggiunte directory all'ignore. Non creato checksum per .ver. --- .gitignore | 3 +++ check_updates.sh | 23 +++++++++++++++++++++++ loaih/__init__.py | 9 +++++++++ 3 files changed, 35 insertions(+) create mode 100755 check_updates.sh diff --git a/.gitignore b/.gitignore index 5ceb386..ff7d489 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ venv +build +dist +loaih.egg-info diff --git a/check_updates.sh b/check_updates.sh new file mode 100755 index 0000000..5820256 --- /dev/null +++ b/check_updates.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +pushd $(dirname $0) +# Checking if pull is successfull +git fetch origin +LC_ALL=C git status | grep -q "Your branch is up to date"; retval=$? + +if [[ ${retval} -ne 0 ]]; then + # Let us update the pip installation + git pull + # for the sake of consistency, let's make the check_updates.sh script + # executable + chmod +x check_updates.sh + pip3 uninstall -y loaih + # build the actual toolkit + python3 setup.py bdist_wheel + pip3 install dist/*.whl; rv=$? + + if [[ ${rv} -eq 0 ]]; then + # cleanup + rm -rf dist +fi +popd diff --git a/loaih/__init__.py b/loaih/__init__.py index 6964d1a..30161fa 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -199,6 +199,11 @@ class Build(object): self.__unpackbuild__(arch) def __unpackbuild__(self, arch, generalize = False): + if generalize and self.portable: + # Doesn't particularly make sense to build a generic portable + # version. Just skipping the specific generic build + return + # We start by filtering out tarballs from the list buildtarballs = [ self.tarballs[arch][0] ] @@ -305,6 +310,10 @@ class Build(object): os.chdir(self.appnamedir) for appimage in glob.glob('*.AppImage*'): + if appimage.endswith('.ver'): + # Skipping checksums for .ver files. + continue + # See if a checksum already exist if not os.path.exists(appimage + '.md5'): subprocess.run("md5sum {appimage} > {appimage}.md5".format(appimage = appimage), shell=True) From 6895ec357b9878dfa42501e24af79648460ece9e Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 01:08:39 +0200 Subject: [PATCH 43/48] Corretto script di check_updates.sh. --- check_updates.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_updates.sh b/check_updates.sh index 5820256..fd557b5 100755 --- a/check_updates.sh +++ b/check_updates.sh @@ -18,6 +18,7 @@ if [[ ${retval} -ne 0 ]]; then if [[ ${rv} -eq 0 ]]; then # cleanup - rm -rf dist + rm -rf dist build loaih.egg-info + fi fi popd From b21d14324a07b32176948a33d157a3a34831caf1 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 01:10:36 +0200 Subject: [PATCH 44/48] Trovato problema per build standard non corrette con le lingue. Corretto script di check_updates. --- loaih/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 30161fa..8776d02 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -217,9 +217,9 @@ class Build(object): elif self.language == 'standard': for lang in Build.LANGSTD: if self.offline_help: - buildtarballs.extend([ x for x in self.tarballs[arch] if ('pack' + lang) in x ]) + buildtarballs.extend([ x for x in self.tarballs[arch] if ('pack_' + lang) in x ]) else: - buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack' + lang) in x ]) + buildtarballs.extend([ x for x in self.tarballs[arch] if ('langpack_' + lang) in x ]) elif self.language == 'full': if self.offline_help: # We need also all help. Let's replace buildtarball with the From 42be51b82e9e24ad8ab9150f8b66d43b3ea1bacd Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 01:36:27 +0200 Subject: [PATCH 45/48] Implementato buildfile yml. --- fresh.yml | 65 +++++++++++++++++++++++++++++++++++++++++++++ scripts/loaih-build | 56 +++++++++++++++++++++++++++++--------- 2 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 fresh.yml diff --git a/fresh.yml b/fresh.yml new file mode 100644 index 0000000..1f8735a --- /dev/null +++ b/fresh.yml @@ -0,0 +1,65 @@ +--- +data: + storage: /srv/http/appimage.sys42.eu + download: /var/tmp/downloads + +builds: + - query: fresh + language: basic + offline_help: no + portable: no + + - query: fresh + language: basic + offline_help: yes + portable: no + + - query: fresh + language: basic + offline_help: no + portable: yes + + - query: fresh + language: basic + offline_help: yes + portable: yes + + - query: fresh + language: standard + offline_help: no + portable: no + + - query: fresh + language: standard + offline_help: yes + portable: no + + - query: fresh + language: standard + offline_help: no + portable: yes + + - query: fresh + language: standard + offline_help: yes + portable: yes + + - query: fresh + language: full + offline_help: no + portable: no + + - query: fresh + language: full + offline_help: yes + portable: no + + - query: fresh + language: full + offline_help: no + portable: yes + + - query: fresh + language: full + offline_help: yes + portable: yes diff --git a/scripts/loaih-build b/scripts/loaih-build index 69158c9..f539753 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -2,6 +2,7 @@ # encoding: utf-8 import click +import yaml import loaih @click.command() @@ -22,23 +23,52 @@ def build(arch, language, offline, portable, updatable, download, storage, check else: arches = [ arch.lower().decode('utf-8') ] - obj = loaih.Build(query, arches) + if query.endswith('.yml') or query.endswith('.yaml'): + # This is a buildfile. So we have to load the file and pass the build options ourselves. + config = {} + with open(query, 'r') as file: + config = yaml.safe_load(file) - obj.language = language - obj.offline_help = offline - obj.portable = portable - obj.updatable = updatable + # With the config file, we ignore all the command line options and set + # generic default. + for build in config['builds']: + # Loop a run for each build. + obj = loaih.Build(build['query'], [u'x86', u'x86_64']) + + obj.language = build['language'] + obj.offline_help = build['offline_help'] + obj.portable = build['portable'] + obj.updatable = True + + if check: + obj.check(config['data']['storage']) + else: + obj.storage_path = config['data']['storage'] + + obj.download(config['data']['download']) + obj.build() + obj.checksums() + obj.publish() + del obj - if check: - obj.check(storage) else: - obj.storage_path = storage + obj = loaih.Build(query, arches) - obj.download(download) - obj.build() - obj.checksums() - obj.publish() - del obj + obj.language = language + obj.offline_help = offline + obj.portable = portable + obj.updatable = updatable + + if check: + obj.check(storage) + else: + obj.storage_path = storage + + obj.download(download) + obj.build() + obj.checksums() + obj.publish() + del obj if __name__ == '__main__': build() From 96907ad24b5ba3e251c0aed0c274b8c8d1a0a87e Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 01:47:00 +0200 Subject: [PATCH 46/48] Piccoli fix cosmetici allo script di build. --- scripts/loaih-build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/loaih-build b/scripts/loaih-build index f539753..5ff89a2 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -17,6 +17,7 @@ import loaih @click.argument('query') def build(arch, language, offline, portable, updatable, download, storage, check, query): # Parsing options + arches = [] if arch.lower() == 'all': # We need to build it twice. arches = [ u'x86', u'x86_64' ] @@ -33,7 +34,7 @@ def build(arch, language, offline, portable, updatable, download, storage, check # generic default. for build in config['builds']: # Loop a run for each build. - obj = loaih.Build(build['query'], [u'x86', u'x86_64']) + obj = loaih.Build(build['query'], arches) obj.language = build['language'] obj.offline_help = build['offline_help'] From d5f118f30494660b8653a8e07969bc44cd44116d Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 01:51:13 +0200 Subject: [PATCH 47/48] Adding script for building still. --- still.yml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 still.yml diff --git a/still.yml b/still.yml new file mode 100644 index 0000000..3d86642 --- /dev/null +++ b/still.yml @@ -0,0 +1,65 @@ +--- +data: + storage: /srv/http/appimage.sys42.eu + download: /var/tmp/downloads + +builds: + - query: still + language: basic + offline_help: no + portable: no + + - query: still + language: basic + offline_help: yes + portable: no + + - query: still + language: basic + offline_help: no + portable: yes + + - query: still + language: basic + offline_help: yes + portable: yes + + - query: still + language: standard + offline_help: no + portable: no + + - query: still + language: standard + offline_help: yes + portable: no + + - query: still + language: standard + offline_help: no + portable: yes + + - query: still + language: standard + offline_help: yes + portable: yes + + - query: still + language: full + offline_help: no + portable: no + + - query: still + language: full + offline_help: yes + portable: no + + - query: still + language: full + offline_help: no + portable: yes + + - query: still + language: full + offline_help: yes + portable: yes From 11570940f7a9f6db40c5ebfda4a1b553123e1add Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Wed, 30 Mar 2022 02:06:24 +0200 Subject: [PATCH 48/48] Evito di chiamare una funzione con un controllo if. --- loaih/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 8776d02..89f05d1 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -194,7 +194,7 @@ class Build(object): os.chmod('appimagetool', 0o755) # Build the requested version. - if self.queried_name: + if self.queried_name and not self.portable: self.__unpackbuild__(arch, True) self.__unpackbuild__(arch)