Correzione logica di esecuzione e assegnazione attributi.

This commit is contained in:
Emiliano Vavassori 2022-03-31 02:12:46 +02:00
parent b8b80ebdea
commit 7ae5ac182a
2 changed files with 36 additions and 37 deletions

View File

@ -48,8 +48,23 @@ class Build(object):
self.relative_path = [] self.relative_path = []
self.full_path = '' self.full_path = ''
def version_strings(self): def calculate(self):
"""Build version strings based on the information received.""" """Calculate exclusions and other variables."""
# Incompatibilities - if portable and updatable are asked together,
# only portable will be built.
if self.portable and self.updatable:
print("Upgradable and portable options were required together. Building only portable.")
self.updatable = False
if self.updatable and not self.queried_name:
# If the queried version was a numbered version, doesn't make sense
# to build an updatable version.
self.updatable = False
# Mandate to the private function to calculate the full_path available
# for the storage and the checks.
self.__calculate_full_path__()
# Building expected AppImageName # Building expected AppImageName
self.languagepart = "." self.languagepart = "."
if ',' in self.language: if ',' in self.language:
@ -68,25 +83,8 @@ class Build(object):
self.genappimagefilename[arch] = self.appname + '-' + self.genappversion + f'-{arch}.AppImage' self.genappimagefilename[arch] = self.appname + '-' + self.genappversion + f'-{arch}.AppImage'
def check(self, storage_path): def check(self):
"""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
# for the storage and the checks.
self.__calculate_full_path__()
# Incompatibilities - if portable and updatable are asked together,
# only portable will be built.
if self.portable and self.updatable:
print("Upgradable and portable options were required together. Building only portable.")
self.updatable = False
if self.updatable and not self.queried_name:
# If the queried version was a numbered version, doesn't make sense
# to build an updatable version.
self.updatable = False
# Call the build for queries
self.version_strings()
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
@ -138,12 +136,8 @@ class Build(object):
fullpath_arr.extend(self.relative_path) fullpath_arr.extend(self.relative_path)
self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr)) self.full_path = re.sub(r"/+", '/', str.join('/', fullpath_arr))
def download(self, download_path): def download(self):
"""Downloads the contents of the URL as it was a folder.""" """Downloads the contents of the URL as it was a folder."""
# Let's start with defining which files are to be downloaded.
# Let's explore the remote folder.
self.download_path = download_path
for arch in self.arch: for arch in self.arch:
# Checking if a valid path has been provided # Checking if a valid path has been provided
if self.url[arch] == '-': if self.url[arch] == '-':

View File

@ -37,21 +37,23 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
# Loop a run for each build. # Loop a run for each build.
obj = loaih.Build(build['query'], arches) obj = loaih.Build(build['query'], arches)
# Configuration phase
obj.language = build['language'] obj.language = build['language']
obj.offline_help = build['offline_help'] obj.offline_help = build['offline_help']
obj.portable = build['portable'] obj.portable = build['portable']
obj.updatable = True obj.updatable = True
obj.storage_path = config['data']['repo'] if 'repo' in config['data'] and config['data']['repo'] else '/srv/http/appimage.sys42.eu'
obj.download_path = config['data']['download'] if 'download' in config['data'] and config['data']['download'] else '/var/tmp/downloads'
if 'sign' in config['data'] and config['data']['sign']: if 'sign' in config['data'] and config['data']['sign']:
obj.sign = True obj.sign = True
if 'force' in config['data'] and config['data']['force']: # Build phase
obj.storage_path = config['data']['repo'] obj.calculate()
obj.version_strings() if not 'force' in config['data'] or not config['data']['force']:
else: obj.check()
obj.check(config['data']['repo'])
obj.download(config['data']['download']) obj.download()
obj.build() obj.build()
obj.checksums() obj.checksums()
obj.publish() obj.publish()
@ -60,21 +62,24 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
else: else:
obj = loaih.Build(query, arches) obj = loaih.Build(query, arches)
# Configuration phase
obj.language = language obj.language = language
obj.offline_help = offline obj.offline_help = offline
obj.portable = portable obj.portable = portable
obj.updatable = updatable obj.updatable = updatable
obj.storage_path = repo_path
obj.download_path = download_path
if sign: if sign:
obj.sign = True obj.sign = True
if check: # Running phase
obj.check(repo_path) obj.calculate()
else:
obj.storage_path = repo_path
obj.version_strings()
obj.download(download_path) if check:
obj.check()
obj.download()
obj.build() obj.build()
obj.checksums() obj.checksums()
obj.publish() obj.publish()