forked from sig_core/toolkit
add GenericArm support for SIG/AltArch
This commit is contained in:
parent
f473dbc010
commit
48a4171ebd
2 changed files with 57 additions and 44 deletions
|
@ -1,17 +1,17 @@
|
||||||
# All imports are here
|
# All imports are here
|
||||||
|
import glob
|
||||||
|
import hashlib
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import time
|
import time
|
||||||
import glob
|
|
||||||
import rpm
|
|
||||||
import yaml
|
|
||||||
import logging
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
|
import rpm
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
# An implementation from the Fabric python library
|
# An implementation from the Fabric python library
|
||||||
class AttributeDict(defaultdict):
|
class AttributeDict(defaultdict):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -26,29 +26,31 @@ class AttributeDict(defaultdict):
|
||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
self[key] = value
|
self[key] = value
|
||||||
|
|
||||||
|
|
||||||
# These are a bunch of colors we may use in terminal output
|
# These are a bunch of colors we may use in terminal output
|
||||||
class Color:
|
class Color:
|
||||||
RED = '\033[91m'
|
RED = "\033[91m"
|
||||||
GREEN = '\033[92m'
|
GREEN = "\033[92m"
|
||||||
PURPLE = '\033[95m'
|
PURPLE = "\033[95m"
|
||||||
CYAN = '\033[96m'
|
CYAN = "\033[96m"
|
||||||
DARKCYAN = '\033[36m'
|
DARKCYAN = "\033[36m"
|
||||||
BLUE = '\033[94m'
|
BLUE = "\033[94m"
|
||||||
YELLOW = '\033[93m'
|
YELLOW = "\033[93m"
|
||||||
UNDERLINE = '\033[4m'
|
UNDERLINE = "\033[4m"
|
||||||
BOLD = '\033[1m'
|
BOLD = "\033[1m"
|
||||||
END = '\033[0m'
|
END = "\033[0m"
|
||||||
INFO = '[' + BOLD + GREEN + 'INFO' + END + '] '
|
INFO = "[" + BOLD + GREEN + "INFO" + END + "] "
|
||||||
WARN = '[' + BOLD + YELLOW + 'WARN' + END + '] '
|
WARN = "[" + BOLD + YELLOW + "WARN" + END + "] "
|
||||||
FAIL = '[' + BOLD + RED + 'FAIL' + END + '] '
|
FAIL = "[" + BOLD + RED + "FAIL" + END + "] "
|
||||||
STAT = '[' + BOLD + CYAN + 'STAT' + END + '] '
|
STAT = "[" + BOLD + CYAN + "STAT" + END + "] "
|
||||||
|
|
||||||
|
|
||||||
# vars and additional checks
|
# vars and additional checks
|
||||||
rldict = AttributeDict()
|
rldict = AttributeDict()
|
||||||
sigdict = AttributeDict()
|
sigdict = AttributeDict()
|
||||||
config = {
|
config = {
|
||||||
"rlmacro": rpm.expandMacro('%rhel'),
|
"rlmacro": rpm.expandMacro("%rhel"),
|
||||||
"dist": 'el' + rpm.expandMacro('%rhel'),
|
"dist": "el" + rpm.expandMacro("%rhel"),
|
||||||
"arch": platform.machine(),
|
"arch": platform.machine(),
|
||||||
"date_stamp": time.strftime("%Y%m%d.%H%M%S", time.localtime()),
|
"date_stamp": time.strftime("%Y%m%d.%H%M%S", time.localtime()),
|
||||||
"compose_root": "/mnt/compose",
|
"compose_root": "/mnt/compose",
|
||||||
|
@ -66,28 +68,29 @@ config = {
|
||||||
"aarch64": "arm64",
|
"aarch64": "arm64",
|
||||||
"ppc64le": "ppc64le",
|
"ppc64le": "ppc64le",
|
||||||
"s390x": "s390x",
|
"s390x": "s390x",
|
||||||
"i686": "386"
|
"i686": "386",
|
||||||
},
|
},
|
||||||
"aws_region": "us-east-2",
|
"aws_region": "us-east-2",
|
||||||
"bucket": "resf-empanadas",
|
"bucket": "resf-empanadas",
|
||||||
"bucket_url": "https://resf-empanadas.s3.us-east-2.amazonaws.com"
|
"bucket_url": "https://resf-empanadas.s3.us-east-2.amazonaws.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Importing the config from yaml
|
# Importing the config from yaml
|
||||||
import importlib_resources
|
import importlib_resources
|
||||||
|
|
||||||
_rootdir = importlib_resources.files("empanadas")
|
_rootdir = importlib_resources.files("empanadas")
|
||||||
|
|
||||||
for conf in glob.iglob(f"{_rootdir}/configs/*.yaml"):
|
for conf in glob.iglob(f"{_rootdir}/configs/*.yaml"):
|
||||||
with open(conf, 'r', encoding="utf-8") as file:
|
with open(conf, "r", encoding="utf-8") as file:
|
||||||
rldict.update(yaml.safe_load(file))
|
rldict.update(yaml.safe_load(file))
|
||||||
|
|
||||||
# Import all SIG configs from yaml
|
# Import all SIG configs from yaml
|
||||||
for conf in glob.iglob(f"{_rootdir}/sig/*.yaml"):
|
for conf in glob.iglob(f"{_rootdir}/sig/*.yaml"):
|
||||||
with open(conf, 'r', encoding="utf-8") as file:
|
with open(conf, "r", encoding="utf-8") as file:
|
||||||
sigdict.update(yaml.safe_load(file))
|
sigdict.update(yaml.safe_load(file))
|
||||||
|
|
||||||
# The system needs to be a RHEL-like system. It cannot be Fedora or SuSE.
|
# The system needs to be a RHEL-like system. It cannot be Fedora or SuSE.
|
||||||
#if "%rhel" in config['rlmacro']:
|
# if "%rhel" in config['rlmacro']:
|
||||||
# raise SystemExit(Color.BOLD + 'This is not a RHEL-like system.' + Color.END
|
# 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 '
|
# + '\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 '
|
# 'not Fedora nor SuSE. This means that the %rhel macro will be '
|
||||||
|
@ -96,10 +99,10 @@ for conf in glob.iglob(f"{_rootdir}/sig/*.yaml"):
|
||||||
|
|
||||||
|
|
||||||
# These will be set in their respective var files
|
# These will be set in their respective var files
|
||||||
#REVISION = rlvars['revision'] + '-' + rlvars['rclvl']
|
# REVISION = rlvars['revision'] + '-' + rlvars['rclvl']
|
||||||
#rlvars = rldict[rlver]
|
# rlvars = rldict[rlver]
|
||||||
#rlvars = rldict[rlmacro]
|
# rlvars = rldict[rlmacro]
|
||||||
#COMPOSE_ISO_WORKDIR = COMPOSE_ROOT + "work/" + arch + "/" + date_stamp
|
# COMPOSE_ISO_WORKDIR = COMPOSE_ROOT + "work/" + arch + "/" + date_stamp
|
||||||
|
|
||||||
|
|
||||||
ALLOWED_TYPE_VARIANTS = {
|
ALLOWED_TYPE_VARIANTS = {
|
||||||
|
@ -110,8 +113,11 @@ ALLOWED_TYPE_VARIANTS = {
|
||||||
"Vagrant": ["Libvirt", "Vbox", "VMware"],
|
"Vagrant": ["Libvirt", "Vbox", "VMware"],
|
||||||
"OCP": ["Base"],
|
"OCP": ["Base"],
|
||||||
"RPI": None,
|
"RPI": None,
|
||||||
|
"GenericArm": ["Minimal"],
|
||||||
}
|
}
|
||||||
def valid_type_variant(_type: str, variant: str="") -> bool:
|
|
||||||
|
|
||||||
|
def valid_type_variant(_type: str, variant: str = "") -> bool:
|
||||||
if _type not in ALLOWED_TYPE_VARIANTS:
|
if _type not in ALLOWED_TYPE_VARIANTS:
|
||||||
raise Exception(f"Type is invalid: ({_type}, {variant})")
|
raise Exception(f"Type is invalid: ({_type}, {variant})")
|
||||||
if ALLOWED_TYPE_VARIANTS[_type] == None:
|
if ALLOWED_TYPE_VARIANTS[_type] == None:
|
||||||
|
@ -120,11 +126,18 @@ def valid_type_variant(_type: str, variant: str="") -> bool:
|
||||||
return True
|
return True
|
||||||
if variant not in ALLOWED_TYPE_VARIANTS[_type]:
|
if variant not in ALLOWED_TYPE_VARIANTS[_type]:
|
||||||
if variant and variant.capitalize() in ALLOWED_TYPE_VARIANTS[_type]:
|
if variant and variant.capitalize() in ALLOWED_TYPE_VARIANTS[_type]:
|
||||||
raise Exception(f"Capitalization mismatch. Found: ({_type}, {variant}). Expected: ({_type}, {variant.capitalize()})")
|
raise Exception(
|
||||||
raise Exception(f"Type/Variant Combination is not allowed: ({_type}, {variant})")
|
f"Capitalization mismatch. Found: ({_type}, {variant}). Expected: ({_type}, {variant.capitalize()})"
|
||||||
|
)
|
||||||
|
raise Exception(
|
||||||
|
f"Type/Variant Combination is not allowed: ({_type}, {variant})"
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
from attrs import define, field
|
from attrs import define, field
|
||||||
|
|
||||||
|
|
||||||
@define(kw_only=True)
|
@define(kw_only=True)
|
||||||
class Architecture:
|
class Architecture:
|
||||||
name: str = field()
|
name: str = field()
|
||||||
|
|
|
@ -133,7 +133,7 @@ class ImageBuild:
|
||||||
["cp", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.raw"],
|
["cp", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.raw"],
|
||||||
["xz", f"{self.outdir}/{self.outname}.raw"]
|
["xz", f"{self.outdir}/{self.outname}.raw"]
|
||||||
]
|
]
|
||||||
if self.image_type in ["GenericCloud", "OCP"]:
|
if self.image_type in ["GenericCloud", "OCP", "GenericArm"]:
|
||||||
self.stage_commands = [
|
self.stage_commands = [
|
||||||
["qemu-img", "convert", "-c", "-f", "raw", "-O", "qcow2", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.qcow2"]
|
["qemu-img", "convert", "-c", "-f", "raw", "-O", "qcow2", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.qcow2"]
|
||||||
]
|
]
|
||||||
|
@ -244,7 +244,7 @@ class ImageBuild:
|
||||||
args = []
|
args = []
|
||||||
if self.image_type in ["Container"]:
|
if self.image_type in ["Container"]:
|
||||||
args = ["--parameter", "offline_icicle", "true"]
|
args = ["--parameter", "offline_icicle", "true"]
|
||||||
if self.image_type in ["GenericCloud", "EC2", "Vagrant", "Azure", "OCP", "RPI"]:
|
if self.image_type in ["GenericCloud", "EC2", "Vagrant", "Azure", "OCP", "RPI", "GenericArm"]:
|
||||||
args = ["--parameter", "generate_icicle", "false"]
|
args = ["--parameter", "generate_icicle", "false"]
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue