Fixing multiple query build not working.
This commit is contained in:
parent
608eeb6071
commit
5d6c7f2df2
loaih
128
loaih/script.py
128
loaih/script.py
|
@ -44,14 +44,83 @@ def getversion(query, jsonout, default_to_current):
|
||||||
click.echo(value)
|
click.echo(value)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
@click.option('-a', '--arch', 'arch', default='x86_64',
|
||||||
|
type=click.Choice(['x86', 'x86_64', 'all'], case_sensitive=False), help="Build the AppImage for a specific architecture. Default: x86_64")
|
||||||
|
@click.option('--check', '-c', is_flag=True, default=False, help="Checks in the repository path if the queried version is existent. Default: do not check")
|
||||||
|
@click.option('--checksums', '-e', is_flag=True, default=False, help="Create checksums for each created file (AppImage). Default: do not create checksums.")
|
||||||
|
@click.option('--keep-downloads', '-k', 'keep', is_flag=True, default=False, help="Keep the downloads folder after building the AppImage. Default: do not keep.")
|
||||||
|
@click.option('--languages', '-l', '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('--offline-help', '-o', 'offline', is_flag=True, default=False, help="Include the offline help pages for the chosen languages. Default: no offline help")
|
||||||
|
@click.option('--portable', '-p', 'portable', is_flag=True, default=False, help="Create a portable version of the AppImage or not. Default: no portable")
|
||||||
|
@click.option('--sign', '-s', is_flag=True, default=False, help="Sign the build with your default GPG key. Default: do not sign")
|
||||||
|
@click.option('--updatable', '-u', is_flag=True, default=False, help="Create an updatable AppImage (compatible with zsync2). Default: not updatable")
|
||||||
|
@click.option('--download-path', '-d', default='./downloads', type=str, help="Path to the download folder. Default: ./downloads")
|
||||||
|
@click.option('--repo-path', '-r', default='.', type=str, help="Path to the final storage of the AppImage. Default: current directory")
|
||||||
|
@click.argument('query')
|
||||||
|
def build(arch, language, offline, portable, updatable, download_path, repo_path, check, checksums, sign, keep, query):
|
||||||
|
"""Builds an Appimage with the provided options."""
|
||||||
|
|
||||||
|
# Multiple query support
|
||||||
|
queries = []
|
||||||
|
if ',' in query:
|
||||||
|
queries.extend(query.split(','))
|
||||||
|
else:
|
||||||
|
queries.append(query)
|
||||||
|
|
||||||
|
# Parsing options
|
||||||
|
arches = []
|
||||||
|
if arch.lower() == 'all':
|
||||||
|
# We need to build it twice.
|
||||||
|
arches = ['x86', 'x86_64']
|
||||||
|
else:
|
||||||
|
arches = [arch.lower()]
|
||||||
|
|
||||||
|
# Other more global variables
|
||||||
|
repopath = os.path.abspath(repo_path)
|
||||||
|
if not os.path.exists(repopath):
|
||||||
|
os.makedirs(repopath, exist_ok=True)
|
||||||
|
downloadpath = os.path.abspath(download_path)
|
||||||
|
if not os.path.exists(downloadpath):
|
||||||
|
os.makedirs(downloadpath, exist_ok=True)
|
||||||
|
|
||||||
|
for myquery in queries:
|
||||||
|
for appbuild in loaih.build.Collection(myquery, arches):
|
||||||
|
# Configuration phase
|
||||||
|
appbuild.tidy_folder = False
|
||||||
|
appbuild.language = language
|
||||||
|
appbuild.offline_help = offline
|
||||||
|
appbuild.portable = portable
|
||||||
|
appbuild.updatable = updatable
|
||||||
|
appbuild.storage_path = repopath
|
||||||
|
appbuild.download_path = downloadpath
|
||||||
|
appbuild.sign = sign
|
||||||
|
|
||||||
|
# Running phase
|
||||||
|
appbuild.calculate()
|
||||||
|
|
||||||
|
if check:
|
||||||
|
appbuild.check()
|
||||||
|
|
||||||
|
appbuild.download()
|
||||||
|
appbuild.build()
|
||||||
|
if checksums:
|
||||||
|
appbuild.checksums()
|
||||||
|
appbuild.publish()
|
||||||
|
|
||||||
|
del appbuild
|
||||||
|
|
||||||
|
if not keep:
|
||||||
|
shutil.rmtree(downloadpath)
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option("--verbose", '-v', is_flag=True, default=False, help="Show building phases.", show_default=True)
|
@click.option("--verbose", '-v', is_flag=True, default=False, help="Show building phases.", show_default=True)
|
||||||
@click.argument("yamlfile")
|
@click.argument("yamlfile")
|
||||||
def batch(yamlfile, verbose):
|
def batch(yamlfile, verbose):
|
||||||
"""Builds a collection of AppImages based on YAML file."""
|
"""Builds a collection of AppImages based on YAML file."""
|
||||||
# Defaults for a batch building is definitely more different than a manual
|
# Defaults for a batch building is definitely more different than a
|
||||||
# one. To reflect this behaviour, I decided to split the commands between
|
# manual one. To reflect this behaviour, I decided to split the commands
|
||||||
# batch (bulk creation) and build (manual building).
|
# between batch (bulk creation) and build (manual building).
|
||||||
|
|
||||||
# Check if yamlfile exists.
|
# Check if yamlfile exists.
|
||||||
if not os.path.exists(os.path.abspath(yamlfile)):
|
if not os.path.exists(os.path.abspath(yamlfile)):
|
||||||
|
@ -95,9 +164,6 @@ def batch(yamlfile, verbose):
|
||||||
# Loop a run for each build.
|
# Loop a run for each build.
|
||||||
collection = loaih.build.Collection(cbuild['query'])
|
collection = loaih.build.Collection(cbuild['query'])
|
||||||
|
|
||||||
# Generic run for the query
|
|
||||||
generic = loaih.Solver.parse(cbuild['query'])
|
|
||||||
|
|
||||||
for obj in collection:
|
for obj in collection:
|
||||||
# Configuration phase
|
# Configuration phase
|
||||||
obj.verbose = verbose
|
obj.verbose = verbose
|
||||||
|
@ -112,31 +178,6 @@ def batch(yamlfile, verbose):
|
||||||
obj.remote_path = gvars['remote_path']
|
obj.remote_path = gvars['remote_path']
|
||||||
obj.sign = gvars['sign']
|
obj.sign = gvars['sign']
|
||||||
|
|
||||||
# Build phase
|
|
||||||
obj.calculate()
|
|
||||||
obj.check()
|
|
||||||
obj.download()
|
|
||||||
obj.build()
|
|
||||||
obj.checksums()
|
|
||||||
if obj.remoterepo and obj.appnamedir:
|
|
||||||
obj.generalize_and_link(obj.appnamedir)
|
|
||||||
obj.publish()
|
|
||||||
if not obj.remoterepo:
|
|
||||||
obj.generalize_and_link()
|
|
||||||
del obj
|
|
||||||
|
|
||||||
# In case prerelease or daily branches are used, cleanup the download
|
|
||||||
# folder after finishing the complete run (to make sure the next run
|
|
||||||
# will redownload all the needed files and is indeed fresh).
|
|
||||||
# we will swipe all the builds inside a collection to understand the files
|
|
||||||
# to delete.
|
|
||||||
for cbuild in config['builds']:
|
|
||||||
# Loop a run for each build.
|
|
||||||
for build in loaih.build.Collection(cbuild['query']):
|
|
||||||
|
|
||||||
if build.version.branch in {'prerelease', 'daily'}:
|
|
||||||
build.version.cleanup_downloads(gvars['download_path'], verbose)
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
@click.option('-a', '--arch', 'arch', default='x86_64',
|
@click.option('-a', '--arch', 'arch', default='x86_64',
|
||||||
|
@ -197,3 +238,28 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
|
||||||
shutil.rmtree(appbuild.download_path)
|
shutil.rmtree(appbuild.download_path)
|
||||||
|
|
||||||
del appbuild
|
del appbuild
|
||||||
|
|
||||||
|
# Build phase
|
||||||
|
obj.calculate()
|
||||||
|
obj.check()
|
||||||
|
obj.download()
|
||||||
|
obj.build()
|
||||||
|
obj.checksums()
|
||||||
|
if obj.remoterepo and obj.appnamedir:
|
||||||
|
obj.generalize_and_link(obj.appnamedir)
|
||||||
|
obj.publish()
|
||||||
|
if not obj.remoterepo:
|
||||||
|
obj.generalize_and_link()
|
||||||
|
del obj
|
||||||
|
|
||||||
|
# In case prerelease or daily branches are used, cleanup the download
|
||||||
|
# folder after finishing the complete run (to make sure the next run
|
||||||
|
# will redownload all the needed files and is indeed fresh).
|
||||||
|
# we will swipe all the builds inside a collection to understand the files
|
||||||
|
# to delete.
|
||||||
|
for cbuild in config['builds']:
|
||||||
|
# Loop a run for each build.
|
||||||
|
for build in loaih.build.Collection(cbuild['query']):
|
||||||
|
|
||||||
|
if build.version.branch in {'prerelease', 'daily'}:
|
||||||
|
build.version.cleanup_downloads(gvars['download_path'], verbose)
|
||||||
|
|
Loading…
Reference in New Issue