From 26f1680affc6e494fe5eeb45ad6dd206afcf98df Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Sun, 26 Nov 2023 20:08:39 -0700 Subject: [PATCH] add X.Y-A.B check --- func/core/pkg_release/50-release-ver.sh | 19 +++++++++++++++ iso/empanadas/empanadas/util/shared.py | 31 +++++++++++++++++++++---- 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100755 func/core/pkg_release/50-release-ver.sh diff --git a/func/core/pkg_release/50-release-ver.sh b/func/core/pkg_release/50-release-ver.sh new file mode 100755 index 0000000..cdb17b8 --- /dev/null +++ b/func/core/pkg_release/50-release-ver.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Check that the release package is 1.X +r_log "rocky release" "Checking that the package is at least X.Y-1.B" + +RELEASE_VER="$(rpm -q rocky-release --qf '%{RELEASE}')" +RELNUM="${RELEASE_VER:0:1}" +if [ "${RELNUM}" -ge "1" ]; then + if [ "${RELEASE_VER:0:3}" == [${RELNUM}.[:digit:]] ]; then + ret_val="0" + else + r_log "rocky release" "FAIL: The release package is not in X.Y-A.B format" + ret_val="1" + fi +else + r_log "rocky release" "FAIL: The release package likely starts with 0 and is not considered production ready." + ret_val="1" +fi + +r_checkExitStatus $ret_val diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index 999d468..130b78c 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -415,6 +415,23 @@ class Shared: ) return cmd + @staticmethod + def rsync_cmd(logger) -> str: + """ + This generates the rsync command. This is used for general syncing + operations. + """ + cmd = None + if os.path.exists("/usr/bin/rsync"): + cmd = "/usr/bin/rsync" + else: + logger.error(Color.FAIL + '/usr/bin/rsync was not found. Good bye.') + raise SystemExit("\n\n/usr/bin/rsync was not found.\n\nPlease " + " ensure that you have installed the necessary packages on " + " this system. " + ) + return cmd + @staticmethod def generate_conf( shortname, @@ -562,15 +579,15 @@ class Shared: Returns a string for the rsync command plus parallel. Yes, this is a hack. """ - find_cmd = '/usr/bin/find' - parallel_cmd = '/usr/bin/parallel' + #find_cmd = '/usr/bin/find' + #parallel_cmd = '/usr/bin/parallel' cmd = '/usr/bin/rsync' switches = '-vrlptDSH --chown=10004:10005 --progress --human-readable' - rsync_cmd = '{} {} {}/ {}'.format(cmd, switches, src, dest) + rsync_command = f'{Shared.rsync_cmd} {switches} {src}/ {dest}' #os.makedirs(dest, exist_ok=True) process = subprocess.call( - shlex.split(rsync_cmd), + shlex.split(rsync_command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) @@ -588,6 +605,7 @@ class Shared: return message, retval + # pylint: disable=too-many-locals,too-many-arguments @staticmethod def s3_determine_latest(s3_bucket, release, arches, filetype, name, logger): """ @@ -1424,3 +1442,8 @@ class Idents: """ Gets a volume ID """ + +class Syncs: + """ + Various rsync abilities, converted from the sync dir in the toolkit + """