From 9fa51f10deab525712d9cb786a28f1dcfaef8653 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Thu, 20 Oct 2022 15:27:30 -0700 Subject: [PATCH] BugFix: Fix profile validity checking --- iso/empanadas/README.md | 2 +- .../empanadas/scripts/finalize_compose.py | 2 +- .../empanadas/scripts/generate_compose.py | 2 +- .../empanadas/scripts/peridot_repoclosure.py | 2 +- .../empanadas/scripts/sync_from_peridot.py | 2 +- .../scripts/sync_from_peridot_test.py | 2 +- iso/empanadas/empanadas/scripts/sync_sig.py | 4 ++-- .../empanadas/scripts/test_module.py | 2 +- iso/empanadas/empanadas/util/check.py | 22 +++++++++++++++++++ 9 files changed, 31 insertions(+), 9 deletions(-) diff --git a/iso/empanadas/README.md b/iso/empanadas/README.md index e8b3548..28a136e 100644 --- a/iso/empanadas/README.md +++ b/iso/empanadas/README.md @@ -85,7 +85,7 @@ from util import Checks rlvars = rldict['9'] r = Checks(rlvars, arch) -r.check_valid_arch() +r.check_validity() ``` ### script names and permissions diff --git a/iso/empanadas/empanadas/scripts/finalize_compose.py b/iso/empanadas/empanadas/scripts/finalize_compose.py index 9cc8139..d9422fe 100755 --- a/iso/empanadas/empanadas/scripts/finalize_compose.py +++ b/iso/empanadas/empanadas/scripts/finalize_compose.py @@ -20,7 +20,7 @@ rlvars = rldict[results.release] major = rlvars['major'] r = Checks(rlvars, config['arch']) -r.check_valid_arch() +r.check_validity() # Send them and do whatever I guess a = RepoSync( diff --git a/iso/empanadas/empanadas/scripts/generate_compose.py b/iso/empanadas/empanadas/scripts/generate_compose.py index f388a7e..e39ab8f 100755 --- a/iso/empanadas/empanadas/scripts/generate_compose.py +++ b/iso/empanadas/empanadas/scripts/generate_compose.py @@ -24,7 +24,7 @@ rlvars = rldict[results.release] major = rlvars['major'] r = Checks(rlvars, config['arch']) -r.check_valid_arch() +r.check_validity() # Send them and do whatever I guess def run(): diff --git a/iso/empanadas/empanadas/scripts/peridot_repoclosure.py b/iso/empanadas/empanadas/scripts/peridot_repoclosure.py index b19757f..a246e26 100755 --- a/iso/empanadas/empanadas/scripts/peridot_repoclosure.py +++ b/iso/empanadas/empanadas/scripts/peridot_repoclosure.py @@ -22,7 +22,7 @@ rlvars = rldict[results.release] major = rlvars['major'] r = Checks(rlvars, config['arch']) -r.check_valid_arch() +r.check_validity() a = RepoSync( rlvars, diff --git a/iso/empanadas/empanadas/scripts/sync_from_peridot.py b/iso/empanadas/empanadas/scripts/sync_from_peridot.py index 2f7f44a..482a72a 100755 --- a/iso/empanadas/empanadas/scripts/sync_from_peridot.py +++ b/iso/empanadas/empanadas/scripts/sync_from_peridot.py @@ -40,7 +40,7 @@ rlvars = rldict[results.release] major = rlvars['major'] r = Checks(rlvars, config['arch']) -r.check_valid_arch() +r.check_validity() # Send them and do whatever I guess a = RepoSync( diff --git a/iso/empanadas/empanadas/scripts/sync_from_peridot_test.py b/iso/empanadas/empanadas/scripts/sync_from_peridot_test.py index 5a3dbb1..96ff596 100755 --- a/iso/empanadas/empanadas/scripts/sync_from_peridot_test.py +++ b/iso/empanadas/empanadas/scripts/sync_from_peridot_test.py @@ -9,7 +9,7 @@ from empanadas.util import RepoSync rlvars = rldict['9-lookahead'] r = Checks(rlvars, config['arch']) -r.check_valid_arch() +r.check_validity() #a = RepoSync(rlvars, config, major="9", repo="ResilientStorage", parallel=True, ignore_debug=False, ignore_source=False) a = RepoSync(rlvars, config, major="9", repo="BaseOS", parallel=True, ignore_debug=False, ignore_source=False, hashed=True) diff --git a/iso/empanadas/empanadas/scripts/sync_sig.py b/iso/empanadas/empanadas/scripts/sync_sig.py index 1cfb70f..70731a0 100755 --- a/iso/empanadas/empanadas/scripts/sync_sig.py +++ b/iso/empanadas/empanadas/scripts/sync_sig.py @@ -7,7 +7,7 @@ from empanadas.util import SigRepoSync #rlvars = rldict['9'] #r = Checks(rlvars, config['arch']) -#r.check_valid_arch() +#r.check_validity() # Start up the parser baby parser = argparse.ArgumentParser(description="Peridot Sync and Compose") @@ -39,7 +39,7 @@ results = parser.parse_args() rlvars = rldict[results.release] sigvars = sigdict[results.sig][results.release] r = Checks(rlvars, config['arch']) -r.check_valid_arch() +r.check_validity() # Send them and do whatever I guess a = SigRepoSync( diff --git a/iso/empanadas/empanadas/scripts/test_module.py b/iso/empanadas/empanadas/scripts/test_module.py index 7735157..769900d 100755 --- a/iso/empanadas/empanadas/scripts/test_module.py +++ b/iso/empanadas/empanadas/scripts/test_module.py @@ -20,7 +20,7 @@ rlvars = rldict[results.release] major = rlvars['major'] r = Checks(rlvars, config['arch']) -r.check_valid_arch() +r.check_validity() def run(): print(sys.path) diff --git a/iso/empanadas/empanadas/util/check.py b/iso/empanadas/empanadas/util/check.py index b491a61..d79ddca 100644 --- a/iso/empanadas/empanadas/util/check.py +++ b/iso/empanadas/empanadas/util/check.py @@ -5,11 +5,33 @@ from empanadas.common import Color class Checks: """This class helps check some things""" def __init__(self, rlvars, arch): + self.profile = rlvars self.arches = rlvars['allowed_arches'] self.arch = arch + def check_validity(self): + """ + Does the arch and profile check for us + """ + self.check_valid_profile() + self.check_valid_arch() + def check_valid_arch(self): + """ + Validates if the arch we're running on is technically supported. + """ if self.arch not in self.arches: raise SystemExit(Color.BOLD + 'This architecture is not supported.' + Color.END + '\n\nEnsure that the architecture you are ' 'building for is supported for this compose process.') + + def check_valid_profile(self): + """ + Validates if the profile we've selected actually exists + """ + if len(self.profile['major']) == 0: + raise SystemExit(Color.BOLD + 'Profile does not exist or major ' + 'version is not defined.' + Color.END + '\n\nEnsure that ' + 'the profile you are loading exists or is configured ' + 'correctly.\n\nNote: A major version MUST exist even for ' + 'SIG syncs.')