Commit con funzionalità di firma complete.
This commit is contained in:
parent
2c60de03cb
commit
544d805b50
@ -20,11 +20,14 @@ class Build(object):
|
|||||||
self.offline_help = False
|
self.offline_help = False
|
||||||
self.portable = False
|
self.portable = False
|
||||||
self.updatable = True
|
self.updatable = True
|
||||||
|
self.sign = False
|
||||||
self.storage_path = '/srv/http/appimage.sys42.eu'
|
self.storage_path = '/srv/http/appimage.sys42.eu'
|
||||||
self.download_path = '/var/tmp/downloads'
|
self.download_path = '/var/tmp/downloads'
|
||||||
|
|
||||||
|
# Specific build version
|
||||||
self.appversion = ''
|
self.appversion = ''
|
||||||
self.appimagefilename = {}
|
|
||||||
self.genappversion = ''
|
self.genappversion = ''
|
||||||
|
self.appimagefilename = {}
|
||||||
self.genappimagefilename = {}
|
self.genappimagefilename = {}
|
||||||
|
|
||||||
# Getting versions and so on
|
# Getting versions and so on
|
||||||
@ -45,6 +48,26 @@ class Build(object):
|
|||||||
self.relative_path = []
|
self.relative_path = []
|
||||||
self.full_path = ''
|
self.full_path = ''
|
||||||
|
|
||||||
|
def version_strings(self):
|
||||||
|
"""Build version strings based on the information received."""
|
||||||
|
# Building expected AppImageName
|
||||||
|
self.languagepart = "."
|
||||||
|
if ',' in self.language:
|
||||||
|
self.languagepart += self.language.replace(',', '-')
|
||||||
|
else:
|
||||||
|
self.languagepart += self.language
|
||||||
|
|
||||||
|
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
|
||||||
|
self.appversion = self.version + self.languagepart + self.helppart
|
||||||
|
myver = str.join('.', self.version.split('.')[0:2])
|
||||||
|
self.genappversion = myver + self.languagepart + self.helppart
|
||||||
|
for arch in ARCHSTD:
|
||||||
|
self.appimagefilename[arch] = self.appname + '-' + self.appversion + f'-{arch}.AppImage'
|
||||||
|
self.genappimagefilename[arch] = self.appname + '-' + self.genappversion + f'-{arch}.AppImage'
|
||||||
|
|
||||||
|
|
||||||
def check(self, storage_path):
|
def check(self, storage_path):
|
||||||
"""Checking if the requested AppImage has been already built."""
|
"""Checking if the requested AppImage has been already built."""
|
||||||
# Mandate to the private function to calculate the full_path available
|
# Mandate to the private function to calculate the full_path available
|
||||||
@ -62,22 +85,8 @@ class Build(object):
|
|||||||
# to build an updatable version.
|
# to build an updatable version.
|
||||||
self.updatable = False
|
self.updatable = False
|
||||||
|
|
||||||
# Building expected AppImageName
|
# Call the build for queries
|
||||||
self.languagepart = "."
|
self.version_strings()
|
||||||
if ',' in self.language:
|
|
||||||
self.languagepart += self.language.replace(',', '-')
|
|
||||||
else:
|
|
||||||
self.languagepart += self.language
|
|
||||||
|
|
||||||
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
|
|
||||||
myver = str.join('.', self.version.split('.')[0:2])
|
|
||||||
self.genappversion = myver + self.languagepart + self.helppart
|
|
||||||
self.appversion = self.version + self.languagepart + self.helppart
|
|
||||||
for arch in ARCHSTD:
|
|
||||||
self.genappimagefilename[arch] = self.appname + '-' + self.genappversion + f'-{arch}.AppImage'
|
|
||||||
self.appimagefilename[arch] = self.appname + '-' + self.appversion + f'-{arch}.AppImage'
|
|
||||||
|
|
||||||
for arch in self.arch:
|
for arch in self.arch:
|
||||||
# For generalized builds, we need to check if there are .ver file
|
# For generalized builds, we need to check if there are .ver file
|
||||||
@ -193,7 +202,8 @@ class Build(object):
|
|||||||
os.chmod('appimagetool', 0o755)
|
os.chmod('appimagetool', 0o755)
|
||||||
|
|
||||||
# Build the requested version.
|
# Build the requested version.
|
||||||
if self.queried_name:
|
if self.queried_name and not self.portable:
|
||||||
|
# If it is portable, do not generate a generalized version
|
||||||
self.__unpackbuild__(arch, True)
|
self.__unpackbuild__(arch, True)
|
||||||
self.__unpackbuild__(arch)
|
self.__unpackbuild__(arch)
|
||||||
|
|
||||||
@ -274,22 +284,27 @@ class Build(object):
|
|||||||
# updatable version.
|
# updatable version.
|
||||||
# zsync name was generated already
|
# zsync name was generated already
|
||||||
|
|
||||||
|
# Dealing with extra options
|
||||||
|
buildopts = []
|
||||||
|
if self.sign:
|
||||||
|
buildopts.append('--sign')
|
||||||
|
|
||||||
# If asked to do a generalized build:
|
# If asked to do a generalized build:
|
||||||
if generalize:
|
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)
|
subprocess.run("VERSION={version} ./appimagetool {buildopts} -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.genappversion, buildopts = str.join(' ', buildopts), zsync = self.genappimagefilename[arch] + '.zsync', appname = self.appname), shell=True)
|
||||||
# Build version file management
|
# Build version file management
|
||||||
with open(self.genappimagefilename[arch] + '.ver', 'w') as v:
|
with open(self.genappimagefilename[arch] + '.ver', 'w') as v:
|
||||||
v.write(self.version)
|
v.write(self.version)
|
||||||
else:
|
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)
|
subprocess.run("VERSION={version} ./appimagetool {buildopts} -u 'zsync|{zsync}' -v ./{appname}.AppDir/".format(version = self.appversion, buildopts = str.join(' ', buildopts), zsync = self.appimagefilename[arch] + '.zsync', appname = self.appname), shell=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if generalize:
|
if generalize:
|
||||||
subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = self.genappversion, appname = self.appname), shell=True)
|
subprocess.run("VERSION={version} ./appimagetool {buildopts} -v ./{appname}.AppDir/".format(version = self.genappversion, buildopts = str.join(' ', buildopts), appname = self.appname), shell=True)
|
||||||
with open(self.genappimagefilename[arch] + '.ver', 'w') as v:
|
with open(self.genappimagefilename[arch] + '.ver', 'w') as v:
|
||||||
v.write(self.version)
|
v.write(self.version)
|
||||||
else:
|
else:
|
||||||
subprocess.run("VERSION={version} ./appimagetool -v ./{appname}.AppDir/".format(version = self.appversion, appname = self.appname), shell=True)
|
subprocess.run("VERSION={version} ./appimagetool {buildopts} -v ./{appname}.AppDir/".format(version = self.appversion, buildopts = str.join(' ', buildopts), appname = self.appname), shell=True)
|
||||||
|
|
||||||
print("Built AppImage version {version}".format(version = self.appversion))
|
print("Built AppImage version {version}".format(version = self.appversion))
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
import yaml
|
||||||
import loaih
|
import loaih
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@ -12,7 +13,7 @@ import loaih
|
|||||||
@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('-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('-p/-P', '--portable/--no-portable', 'portable', default = False, help="Create a portable version of the AppImage or not. Default: no portable")
|
||||||
@click.option('-r', '--repo-path', 'repo_path', 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('-r', '--repo-path', 'repo_path', 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('-s/-S', '--sign/--no-sign', 'sign', default=False, help="Whether to sign the build. Default: no-sign")
|
@click.option('-s/-S', '--sign/--no-sign', 'sign', default=False, help="Wether to sign the build. Default: no-sign")
|
||||||
@click.option('-u/-U', '--updatable/--no-updatable', 'updatable', default = True, help="Create an updatable version of the AppImage or not. Default: updatable")
|
@click.option('-u/-U', '--updatable/--no-updatable', 'updatable', default = True, help="Create an updatable version of the AppImage or not. Default: updatable")
|
||||||
@click.argument('query')
|
@click.argument('query')
|
||||||
def build(arch, language, offline, portable, updatable, download_path, repo_path, check, sign, query):
|
def build(arch, language, offline, portable, updatable, download_path, repo_path, check, sign, query):
|
||||||
@ -24,6 +25,39 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
|
|||||||
else:
|
else:
|
||||||
arches = [ arch.lower() ]
|
arches = [ arch.lower() ]
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
# 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'], arches)
|
||||||
|
|
||||||
|
obj.language = build['language']
|
||||||
|
obj.offline_help = build['offline_help']
|
||||||
|
obj.portable = build['portable']
|
||||||
|
obj.updatable = True
|
||||||
|
|
||||||
|
if 'sign' in config['data'] and config['data']['sign']:
|
||||||
|
obj.sign = True
|
||||||
|
|
||||||
|
if 'force' in config['data'] and config['data']['force']:
|
||||||
|
obj.storage_path = config['data']['repo']
|
||||||
|
obj.version_strings()
|
||||||
|
else:
|
||||||
|
obj.check(config['data']['repo'])
|
||||||
|
|
||||||
|
obj.download(config['data']['download'])
|
||||||
|
obj.build()
|
||||||
|
obj.checksums()
|
||||||
|
obj.publish()
|
||||||
|
del obj
|
||||||
|
|
||||||
|
else:
|
||||||
obj = loaih.Build(query, arches)
|
obj = loaih.Build(query, arches)
|
||||||
|
|
||||||
obj.language = language
|
obj.language = language
|
||||||
@ -31,10 +65,14 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
|
|||||||
obj.portable = portable
|
obj.portable = portable
|
||||||
obj.updatable = updatable
|
obj.updatable = updatable
|
||||||
|
|
||||||
|
if sign:
|
||||||
|
obj.sign = True
|
||||||
|
|
||||||
if check:
|
if check:
|
||||||
obj.check(repo_path)
|
obj.check(repo_path)
|
||||||
else:
|
else:
|
||||||
obj.storage_path = repo_path
|
obj.storage_path = repo_path
|
||||||
|
obj.version_strings()
|
||||||
|
|
||||||
obj.download(download_path)
|
obj.download(download_path)
|
||||||
obj.build()
|
obj.build()
|
||||||
|
Reference in New Issue
Block a user