forked from sig_core/toolkit
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
|
# All imports are here
|
||
|
import platform
|
||
|
import time
|
||
|
import glob
|
||
|
import rpm
|
||
|
import yaml
|
||
|
|
||
|
# These are a bunch of colors we may use in terminal output
|
||
|
class Color:
|
||
|
RED = '\033[91m'
|
||
|
GREEN = '\033[92m'
|
||
|
PURPLE = '\033[95m'
|
||
|
CYAN = '\033[96m'
|
||
|
DARKCYAN = '\033[36m'
|
||
|
BLUE = '\033[94m'
|
||
|
YELLOW = '\033[93m'
|
||
|
UNDERLINE = '\033[4m'
|
||
|
BOLD = '\033[1m'
|
||
|
END = '\033[0m'
|
||
|
|
||
|
# vars and additional checks
|
||
|
#RLVER = rpm.expandMacro('%rhel')
|
||
|
RLVER = '9'
|
||
|
rldict = {}
|
||
|
arch = platform.machine()
|
||
|
|
||
|
# Importing the config from yaml
|
||
|
for conf in glob.iglob('configs/*.yaml'):
|
||
|
with open(conf, 'r', encoding="utf-8") as file:
|
||
|
rldict.update(yaml.safe_load(file))
|
||
|
|
||
|
# The system needs to be a RHEL-like system. It cannot be Fedora or SuSE.
|
||
|
#if "%rhel" in RLVER:
|
||
|
# raise SystemExit(Color.BOLD + 'This is not a RHEL-like system.' + Color.END
|
||
|
# + '\n\nPlease verify you are running on a RHEL-like system that is '
|
||
|
# 'not Fedora nor SuSE. This means that the %rhel macro will be '
|
||
|
# 'defined with a value equal to the version you are targetting. RHEL'
|
||
|
# ' and its derivatives have this set.')
|
||
|
|
||
|
# Generic rlvars for the particular EL release we're on. This does not have to
|
||
|
# be used. A different one can be assigned based on script need.
|
||
|
rlvars = rldict[RLVER]
|
||
|
|
||
|
# Is our arch allowed for this particular release? Some previous releases do
|
||
|
# not support ppc or s390x
|
||
|
if arch not in rlvars['allowed_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.')
|
||
|
|
||
|
date_stamp = time.strftime("%Y%m%d", time.localtime())
|
||
|
COMPOSE_ROOT = "/mnt/compose/" + RLVER
|
||
|
COMPOSE_ISO_WORKDIR = COMPOSE_ROOT + "work/" + arch + "/" + date_stamp
|
||
|
STAGING_ROOT = "/mnt/repos-staging"
|
||
|
PRODUCTION_ROOT = "/mnt/repos-production"
|
||
|
CATEGORY_STUB = "/mirror/pub/rocky"
|
||
|
REVISION = rlvars['revision'] + '-' + rlvars['rclvl']
|