Impostazione della classe per fare il build di tutte le versioni di base.
This commit is contained in:
parent
e51cf40b76
commit
e87d4085fb
87
build.py
87
build.py
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import tempfile, os, sys, subprocess, shutil
|
import tempfile, os, sys, glob, subprocess, shutil
|
||||||
|
|
||||||
class Build(object):
|
class Build(object):
|
||||||
LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ]
|
LANGSTD = [ 'ar', 'de', 'en-GB', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'pt-BR', 'ru', 'zh-CN', 'zh-TW' ]
|
||||||
@ -55,63 +55,96 @@ class Build(object):
|
|||||||
# * all languages, no help
|
# * all languages, no help
|
||||||
# * all languages + offline help
|
# * all languages + offline help
|
||||||
|
|
||||||
# Let's start with the quickest build: standard languages, no help.
|
# Preparation tasks
|
||||||
|
appnamedir = os.path.join(self.__builddir__, self.__appname__)
|
||||||
|
appimagedir = os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir')
|
||||||
|
os.makedirs(appimagedir, exist_ok = True)
|
||||||
|
# And then cd to the appname folder.
|
||||||
|
os.chdir(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
|
# We start by filtering out tarballs from the list
|
||||||
buildtarballs = [ self.__tarballs__[0] ]
|
buildtarballs = [ self.__tarballs__[0] ]
|
||||||
|
|
||||||
# Let's process standard languages and append results to the
|
# Let's process standard languages and append results to the
|
||||||
# buildtarball
|
# buildtarball
|
||||||
for lang in Build.LANGSTD:
|
if languageset == 'standard':
|
||||||
buildtarballs.extend([ x for x in self.__tarballs__ if ('langpack_' + lang) in x ])
|
for lang in Build.LANGSTD:
|
||||||
# If it was a build with offline help, another extend would have
|
buildtarballs.extend([ x for x in self.__tarballs__ if ('langpack_' + lang) in x ])
|
||||||
# solved it:
|
if offlinehelp:
|
||||||
#buildtarballs.extend([ x for x in self.__tarballs__ if ('helppack_'+ lang) in x ])
|
buildtarballs.extend([ x for x in self.__tarballs__ if ('helppack_' + lang) in x ])
|
||||||
|
else:
|
||||||
# Creating a subfolder
|
# In any other cases, we build with all languages
|
||||||
os.makedirs(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir'), exist_ok = True)
|
if not offlinehelp:
|
||||||
# And then cd to the appname folder.
|
buildtarballs.extend([ x for x in self.__tarballs__ if 'langpack_' in x ])
|
||||||
os.chdir(os.path.join(self.__builddir__, self.__appname__))
|
else:
|
||||||
|
# We need also all help. Let's replace buildtarball with the
|
||||||
|
# whole bunch
|
||||||
|
buildtarballs = self.__tarballs__
|
||||||
|
|
||||||
# Unpacking the tarballs
|
# Unpacking the tarballs
|
||||||
for archive in buildtarballs:
|
for archive in buildtarballs:
|
||||||
subprocess.run("tar xzf ../%s" % archive, shell=True)
|
subprocess.run("tar xzf ../%s" % archive, shell=True)
|
||||||
|
|
||||||
|
os.chdir(appimagedir)
|
||||||
# At this point, let's decompress the deb packages
|
# At this point, let's decompress the deb packages
|
||||||
os.chdir(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir'))
|
|
||||||
subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True)
|
subprocess.run("find .. -iname '*.deb' -exec dpkg -x {} . \;", shell=True)
|
||||||
# Changing desktop file
|
# Changing desktop file
|
||||||
subprocess.run("find . -iname startcenter.desktop -exec cp {} . \;", shell=True)
|
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)
|
|
||||||
|
|
||||||
binaryname = subprocess.check_output("awk 'BEGIN { FS = \"=\" } /^Exec/ { print $2; exit }' startcenter.desktop | awk '{ print $1 }'", shell=True).decode('utf-8').strip('\n')
|
|
||||||
subprocess.run("find . -name '*startcenter.png' -path '*hicolor*48x48*' -exec cp {} . \;", shell=True)
|
subprocess.run("find . -name '*startcenter.png' -path '*hicolor*48x48*' -exec cp {} . \;", shell=True)
|
||||||
|
|
||||||
os.makedirs(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir', 'usr', 'bin'), exist_ok = True)
|
# Find the name of the binary called in the desktop file.
|
||||||
os.chdir(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir', 'usr', 'bin'))
|
binaryname = subprocess.check_output("awk 'BEGIN { FS = \"=\" } /^Exec/ { print $2; exit }' startcenter.desktop | awk '{ print $1 }'", shell=True).decode('utf-8').strip('\n')
|
||||||
|
|
||||||
|
bindir=os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir', 'usr', 'bin')
|
||||||
|
os.makedirs(bindir, exist_ok = True)
|
||||||
|
os.chdir(bindir)
|
||||||
subprocess.run("find ../../opt -name soffice -path '*programm*' -exec ln -s {} %s \;" % binaryname, shell=True)
|
subprocess.run("find ../../opt -name soffice -path '*programm*' -exec ln -s {} %s \;" % binaryname, shell=True)
|
||||||
os.chdir(os.path.join(self.__builddir__, self.__appname__, self.__appname__ + '.AppDir'))
|
os.chdir(appimagedir)
|
||||||
|
|
||||||
# Download AppRun from github
|
# Download AppRun from github
|
||||||
apprunurl = "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-{arch}".format(arch = self.__arch__)
|
apprunurl = "https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-{arch}".format(arch = self.__arch__)
|
||||||
urllib.request.urlretrieve(apprunurl, 'AppRun')
|
urllib.request.urlretrieve(apprunurl, 'AppRun')
|
||||||
os.chmod('AppRun', 0o755)
|
os.chmod('AppRun', 0o755)
|
||||||
|
|
||||||
os.chdir(os.path.join(self.__builddir__, self.__appname__))
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
# Setting app version
|
# Setting app version
|
||||||
appversion = self.__version__ + '.standard'
|
appversion = self.__version__ + '.' + languageset
|
||||||
|
if offlinehelp:
|
||||||
|
appversion += '.help'
|
||||||
|
|
||||||
# Building app
|
# Building app
|
||||||
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 = appversion, appname = self.__appname__), shell=True)
|
||||||
|
|
||||||
# Copying built image to final directory
|
# Copying built image to final directory
|
||||||
subprocess.run("find . -iname '*.AppImage' -exec cp {} %s \;" % outdir, shell = True)
|
subprocess.run("find . -iname '*.AppImage' -exec cp {} %s \;" % outdir, shell = True)
|
||||||
os.chdir('/tmp')
|
|
||||||
|
# Cleanup phase, before new run.
|
||||||
|
os.chdir(appnamedir)
|
||||||
|
for deb in glob.glob(appnamedir + '/*.deb'):
|
||||||
|
os.remove(deb)
|
||||||
|
shutil.rmtree(appimagedir)
|
||||||
|
os.makedirs(appimagedir)
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
"""Destructor"""
|
||||||
#del self.__builddir__
|
#del self.__builddir__
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user