From 7ae5ac182a36eff4ab8bf7885a0b20f40ad52d67 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Thu, 31 Mar 2022 02:12:46 +0200 Subject: [PATCH] Correzione logica di esecuzione e assegnazione attributi. --- loaih/__init__.py | 44 +++++++++++++++++++------------------------- scripts/loaih-build | 29 +++++++++++++++++------------ 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/loaih/__init__.py b/loaih/__init__.py index 3eb19c5..ea0728a 100644 --- a/loaih/__init__.py +++ b/loaih/__init__.py @@ -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] == '-': diff --git a/scripts/loaih-build b/scripts/loaih-build index 76de886..7a1ead4 100644 --- a/scripts/loaih-build +++ b/scripts/loaih-build @@ -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()