add X.Y-A.B check

This commit is contained in:
Louis Abel 2023-11-26 20:08:39 -07:00
parent b394a4d74e
commit 26f1680aff
Signed by untrusted user: label
GPG Key ID: B37E62D143879B36
2 changed files with 46 additions and 4 deletions

View File

@ -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

View File

@ -415,6 +415,23 @@ class Shared:
) )
return cmd 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 @staticmethod
def generate_conf( def generate_conf(
shortname, shortname,
@ -562,15 +579,15 @@ class Shared:
Returns a string for the rsync command plus parallel. Yes, this is a Returns a string for the rsync command plus parallel. Yes, this is a
hack. hack.
""" """
find_cmd = '/usr/bin/find' #find_cmd = '/usr/bin/find'
parallel_cmd = '/usr/bin/parallel' #parallel_cmd = '/usr/bin/parallel'
cmd = '/usr/bin/rsync' cmd = '/usr/bin/rsync'
switches = '-vrlptDSH --chown=10004:10005 --progress --human-readable' 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) #os.makedirs(dest, exist_ok=True)
process = subprocess.call( process = subprocess.call(
shlex.split(rsync_cmd), shlex.split(rsync_command),
stdout=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
) )
@ -588,6 +605,7 @@ class Shared:
return message, retval return message, retval
# pylint: disable=too-many-locals,too-many-arguments
@staticmethod @staticmethod
def s3_determine_latest(s3_bucket, release, arches, filetype, name, logger): def s3_determine_latest(s3_bucket, release, arches, filetype, name, logger):
""" """
@ -1424,3 +1442,8 @@ class Idents:
""" """
Gets a volume ID Gets a volume ID
""" """
class Syncs:
"""
Various rsync abilities, converted from the sync dir in the toolkit
"""