From e4955719c0e1d2c0c0fe385fa8692b89d6f497b1 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Tue, 28 Nov 2023 12:44:24 -0700 Subject: [PATCH] use cmd var --- func/core/o_basic/README.md | 1 + func/core/o_basic/repos.py | 56 ++++++++++++++++++++++++++ iso/empanadas/empanadas/util/shared.py | 2 +- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 func/core/o_basic/README.md create mode 100755 func/core/o_basic/repos.py diff --git a/func/core/o_basic/README.md b/func/core/o_basic/README.md new file mode 100644 index 0000000..34e2a26 --- /dev/null +++ b/func/core/o_basic/README.md @@ -0,0 +1 @@ +Basic tests, such as repos diff --git a/func/core/o_basic/repos.py b/func/core/o_basic/repos.py new file mode 100755 index 0000000..6078a74 --- /dev/null +++ b/func/core/o_basic/repos.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# label +import datetime +import sys +import dnf +import dnf.exceptions + +# pylint: disable=unnecessary-lambda-assignment +now = datetime.datetime.today().strftime("%m-%d-%Y %T") + +class DnfQuiet(dnf.Base): + """ + DNF object + + This is in the event we need special functions + """ + def __init__(self): + dnf.Base.__init__(self) + +def main(): + """ + Main run + """ + dnfobj = DnfQuiet() + releasever = dnfobj.conf.releasever + try: + dnfobj.read_all_repos() + # pylint: disable=bare-except + except: + print(f'[-] {now} -> Could not read repos', file=sys.stderr) + sys.exit(1) + + rocky_default_repos = { + '8': ['baseos', 'appstream', 'extras'], + '9': ['baseos', 'appstream', 'extras'] + }.get(releasever, None) + + if not rocky_default_repos: + print(f'[-] {now} -> Not a Rocky Linux system') + sys.exit(1) + + print(f'[-] {now} -> Checking if non-default repo is enabled') + _not_allowed=False + for repo in list(dnfobj.repos.iter_enabled()): + if not repo.id in rocky_default_repos: + print(f'[-] {now} -> {repo.id} is enabled and should be disabled') + _not_allowed=True + if _not_allowed: + print(f'[-] {now} -> FAIL - There are extra repos enabled') + sys.exit(1) + + print(f'[-] {now} -> PASS') + sys.exit(0) + +if __name__ == "__main__": + main() diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index 130b78c..1712857 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -583,7 +583,7 @@ class Shared: #parallel_cmd = '/usr/bin/parallel' cmd = '/usr/bin/rsync' switches = '-vrlptDSH --chown=10004:10005 --progress --human-readable' - rsync_command = f'{Shared.rsync_cmd} {switches} {src}/ {dest}' + rsync_command = f'{cmd} {switches} {src}/ {dest}' #os.makedirs(dest, exist_ok=True) process = subprocess.call(