1
0
Fork 0

Refactoring di determinato codice, vediamo se potrebbe funzionare.

This commit is contained in:
Emiliano Vavassori 2022-03-31 01:19:51 +02:00
parent 5ce7f5cc07
commit c88e10b2ac
2 changed files with 20 additions and 51 deletions

View File

@ -8,6 +8,7 @@ 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' ]
LANGBASIC = [ 'en-GB' ]
ARCHSTD = [ u'x86', u'x86_64' ]
def __init__(self, query, arch):
"""Build all versions that can be found in the indicated repo."""
@ -35,7 +36,7 @@ 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 = { 'x86': False, 'x86_64': False }
self.built = { u'x86': False, u'x86_64': False }
# Preparing the default for the relative path on the storage for
# different versions.
@ -73,12 +74,10 @@ 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['x86'] = self.appname + '-' + self.genappversion + '-x86.AppImage'
self.genappimagefilename['x86_64'] = self.appname + '-' + self.genappversion + '-x86_64.AppImage'
self.appversion = self.version + self.languagepart + self.helppart
self.appimagefilename['x86'] = self.appname + '-' + self.appversion + '-x86.AppImage'
self.appimagefilename['x86_64'] = self.appname + '-' + self.appversion + '-x86_64.AppImage'
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 generalized builds, we need to check if there are .ver file

View File

@ -2,7 +2,6 @@
# encoding: utf-8
import click
import yaml
import loaih
@click.command()
@ -21,56 +20,27 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
arches = []
if arch.lower() == 'all':
# We need to build it twice.
arches = [ 'x86', 'x86_64' ]
arches = [ u'x86', u'x86_64' ]
else:
arches = [ arch.lower().decode('utf-8') ]
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)
obj = loaih.Build(query, arches)
# 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 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
obj.language = language
obj.offline_help = offline
obj.portable = portable
obj.updatable = updatable
if check:
obj.check(repo_path)
else:
obj = loaih.Build(query, arches)
obj.storage_path = repo_path
obj.language = language
obj.offline_help = offline
obj.portable = portable
obj.updatable = updatable
if check:
obj.check(repo_path)
else:
obj.storage_path = repo_path
obj.download(download_path)
obj.build()
obj.checksums()
obj.publish()
del obj
obj.download(download_path)
obj.build()
obj.checksums()
obj.publish()
del obj
if __name__ == '__main__':
build()