1
0

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.full_path = ''
def version_strings(self):
"""Build version strings based on the information received."""
def calculate(self):
"""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
self.languagepart = "."
if ',' in self.language:
@ -68,25 +83,8 @@ class Build(object):
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."""
# 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 generalized builds, we need to check if there are .ver file
@ -138,12 +136,8 @@ class Build(object):
fullpath_arr.extend(self.relative_path)
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."""
# 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:
# Checking if a valid path has been provided
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.
obj = loaih.Build(build['query'], arches)
# Configuration phase
obj.language = build['language']
obj.offline_help = build['offline_help']
obj.portable = build['portable']
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']:
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'])
# Build phase
obj.calculate()
if not 'force' in config['data'] or not config['data']['force']:
obj.check()
obj.download(config['data']['download'])
obj.download()
obj.build()
obj.checksums()
obj.publish()
@ -60,21 +62,24 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
else:
obj = loaih.Build(query, arches)
# Configuration phase
obj.language = language
obj.offline_help = offline
obj.portable = portable
obj.updatable = updatable
obj.storage_path = repo_path
obj.download_path = download_path
if sign:
obj.sign = True
if check:
obj.check(repo_path)
else:
obj.storage_path = repo_path
obj.version_strings()
# Running phase
obj.calculate()
obj.download(download_path)
if check:
obj.check()
obj.download()
obj.build()
obj.checksums()
obj.publish()