1
0
Fork 0

Prima versione finale di build.

This commit is contained in:
Emiliano Vavassori 2022-03-19 22:08:20 +01:00
parent c7648c520b
commit fb2f9fac45
1 changed files with 51 additions and 15 deletions

View File

@ -2,10 +2,10 @@
import urllib.request
from lxml import etree
import tempfile, os, subprocess
import tempfile, os, sys, subprocess, shutils
class Build:
LANGSTD = [ 'en-GB', 'it', 'ar', 'zh-CN', 'zh-TW', 'fr', 'de', 'ja', 'ko', 'pt', 'pt-BR', 'es', 'ru' ]
class Build():
LANGSTD = ['ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW']
def __init__(self, query, arch, url):
"""Build all versions that can be found in the indicated repo."""
@ -47,7 +47,7 @@ class Build:
print("Got %s." % archive)
def build(self, langset = 'full')
def build(self, outdir):
"""Building all the versions."""
# We have 4 builds to do:
# * standard languages, no help
@ -74,24 +74,60 @@ class Build:
# Unpacking the tarballs
for archive in buildtarballs:
subprocess.call("tar xzf ../%s.tar.gz" % archive, shell=True)
subprocess.run("tar xzf ../%s.tar.gz" % archive, shell=True)
# At this point, let's decompress the deb packages
os.chdir(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppImage'))
subprocess.call("find .. -iname '*.deb' -exec dpkg -x {} . \+", shell=True)
subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \+", shell=True)
# Changing desktop file
subprocess.call("find . -iname startcenter.desktop -exec cp {} . \+", shell=True)
subprocess.call("sed -i -e 's|Name=.*|Name=%s|g' startcenter.desktop" % self.__appname__, shell=True)
subprocess.call("find . -name startcenter.png -path '*hicolor*48x48*' -exec cp {} \;", shell=True)
binaryname = subprocess.check_output("cat startcenter.desktop | awk 'BEGIN { FS = \"=\" } /^Exec/ { print $2; exit }' | awk '{ print $1 }'", shell=True).strip('\n')
subprocess.call("rm -f usr/bin/%s" % binaryname, shell=True)
subprocess.call("find opt -name soffice -path '*programm*' -exec ln -s {} usr/bin/%si \;" % binaryname, shell=True)
# Arrivato a riga 501
subprocess.run("find . -iname startcenter.desktop -exec cp {} . \+", shell=True)
subprocess.run("sed -i -e 's|Name=.*|Name=%s|g' startcenter.desktop" % self.__appname__, shell=True)
subprocess.run("find . -name startcenter.png -path '*hicolor*48x48*' -exec cp {} \;", shell=True)
binaryname = subprocess.check_output("awk 'BEGIN { FS = \"=\" } /^Exec/ { print $2; exit }' startcenter.desktop | awk '{ print $1 }'", shell=True).strip('\n')
subprocess.run("rm -f usr/bin/%s" % binaryname, shell=True)
os.chdir(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppImage', 'usr', 'bin'))
subprocess.run("find ../../opt -name soffice -path '*programm*' -exec ln -s {} %si \;" % binaryname, shell=True)
os.chdir(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppImage'))
# Download AppRun from github
apprunurl = "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-{arch}".format(arch = self.__arch__)
urllib.request.urlretrieve(apprunurl, 'AppRun')
os.chmod('AppRun', 0o755)
os.chdir(os.path.join(self.__builddir__, self.__appname__))
# Download appimagetool from probonopd repo on github
appimagetoolurl = "https://github.com/probonopd/AppImageKit/releases/download/continuous/appimagetool-{arch}.AppImage".format(arch = self.__arch__)
urllib.request.urlretrieve(appimagetoolurl, 'appimagetool')
os.chmod('appimagetool', 0o755)
# Setting app version
appversion = self.__version__ + '.standard'
# Building app
subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = appversion, appname = self.__appname__), shell=True)
# Copying built image to final directory
subprocess.run("find . -iname '*.AppImage' -exec cp {} %s \;" % outdir, shell = True)
def __del__(self):
"""Destructor for the class."""
# Cleanup
shutils.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("/var/tmp/rundeck/AppImageStorage/")
del b