From b0bd9a8367d66887bf38c95319dce8c40f11706e Mon Sep 17 00:00:00 2001 From: nazunalika Date: Fri, 20 May 2022 01:13:57 -0700 Subject: [PATCH] start python conversion --- iso/py/.gitignore | 4 +++ iso/py/README.md | 19 ++++++++++++ iso/py/common.py | 57 +++++++++++++++++++++++++++++++++++ iso/py/configs/el8.yaml | 45 ++++++++++++++++++++++++++++ iso/py/configs/el9.yaml | 66 +++++++++++++++++++++++++++++++++++++++++ iso/py/test.py | 6 ++++ iso/py/test2.py | 38 ++++++++++++++++++++++++ iso/{ => sh}/common | 0 iso/{ => sh}/common_8 | 0 iso/{ => sh}/common_9 | 0 10 files changed, 235 insertions(+) create mode 100644 iso/py/.gitignore create mode 100644 iso/py/README.md create mode 100644 iso/py/common.py create mode 100644 iso/py/configs/el8.yaml create mode 100644 iso/py/configs/el9.yaml create mode 100644 iso/py/test.py create mode 100644 iso/py/test2.py rename iso/{ => sh}/common (100%) rename iso/{ => sh}/common_8 (100%) rename iso/{ => sh}/common_9 (100%) diff --git a/iso/py/.gitignore b/iso/py/.gitignore new file mode 100644 index 0000000..961321b --- /dev/null +++ b/iso/py/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +*.py[cod] +*$py.class +*.so diff --git a/iso/py/README.md b/iso/py/README.md new file mode 100644 index 0000000..99f6dac --- /dev/null +++ b/iso/py/README.md @@ -0,0 +1,19 @@ +iso +=== + +scripts +------- + +* sync-variant-pungi +* sync-variant-peridot +* sync-all-pungi +* sync-all-peridot +* sync-sig +* build-all-iso +* sign-repos-only + +wrappers +-------- + +* lorax-generators +* sync-generators diff --git a/iso/py/common.py b/iso/py/common.py new file mode 100644 index 0000000..d8e59a4 --- /dev/null +++ b/iso/py/common.py @@ -0,0 +1,57 @@ +# 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'] diff --git a/iso/py/configs/el8.yaml b/iso/py/configs/el8.yaml new file mode 100644 index 0000000..8176f67 --- /dev/null +++ b/iso/py/configs/el8.yaml @@ -0,0 +1,45 @@ +--- +'8': + revision: '8.6' + rclvl: 'RC2' + allowed_arches: + - x86_64 + - aarch64 + provide_multilib: False + repo_url_list: [] + required_packages: + - 'lorax' + - 'genisoimage' + - 'isomd5sum' + symlink_refs: + devel: 'Devel' + NFV: 'nfv' + all_repos: + - 'BaseOS' + - 'AppStream' + - 'HighAvailability' + - 'ResilientStorage' + - 'PowerTools' + - 'RT' + - 'NFV' + - 'extras' + - 'devel' + - 'plus' + - 'rockyrpi' + no_comps_or_groups: + - 'extras' + - 'devel' + - 'plus' + - 'rockyrpi' + comps_or_groups: + - 'BaseOS' + - 'AppStream' + - 'HighAvailability' + - 'ResilientStorage' + - 'PowerTools' + - 'RT' + - 'NFV' + has_modules: + - 'AppStream' + - 'PowerTools' +... diff --git a/iso/py/configs/el9.yaml b/iso/py/configs/el9.yaml new file mode 100644 index 0000000..4672fdb --- /dev/null +++ b/iso/py/configs/el9.yaml @@ -0,0 +1,66 @@ +--- +'9': + revision: '9.0' + rclvl: 'RC1' + allowed_arches: + - x86_64 + - aarch64 + - ppc64le + - s390x + provide_multilib: True + repo_url_list: + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/all' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/BaseOS' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/AppStream' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/CRB' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/HighAvailability' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/ResilientStorage' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/RT' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/NFV' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/SAP' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/SAPHANA' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/extras' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/devel' + - 'https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/plus' + required_packages: + - 'lorax' + - 'genisoimage' + - 'isomd5sum' + symlink_refs: + devel: 'Devel' + NFV: 'nfv' + renames: + all: 'nplb' + all_repos: + - 'nplb' + - 'BaseOS' + - 'AppStream' + - 'HighAvailability' + - 'ResilientStorage' + - 'CRB' + - 'RT' + - 'NFV' + - 'SAP' + - 'SAPHANA' + - 'extras' + - 'devel' + - 'plus' + no_comps_or_groups: + - 'nplb' + - 'extras' + - 'devel' + - 'plus' + comps_or_groups: + - 'BaseOS' + - 'AppStream' + - 'HighAvailability' + - 'ResilientStorage' + - 'CRB' + - 'RT' + - 'NFV' + - 'SAP' + - 'SAPHANA' + has_modules: + - 'AppStream' + - 'CRB' +... diff --git a/iso/py/test.py b/iso/py/test.py new file mode 100644 index 0000000..29d2cd2 --- /dev/null +++ b/iso/py/test.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +from common import * + +print(platform.machine()) +print(arch) diff --git a/iso/py/test2.py b/iso/py/test2.py new file mode 100644 index 0000000..afda7dc --- /dev/null +++ b/iso/py/test2.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import desert +from attrs import define, field +import typing as t + +CONFIG = { + "8": { + "allowed_arches": ["x86_64", "aarch64"], + "repo_url_list": ["some", "shit", "here"] + }, + "9": { + "allowed_arches": ["x86_64", "aarch64", "ppc64le", "s390x"], + "repo_url_list": ["some", "other", "shit", "here"] + } +} + +@define +class VersionConfig: + allowed_arches: t.List[str] = field() + repo_url_list: t.List[str] = field() + + @allowed_arches.validator + def check(self, attribute, value): + if not all(v in ["x86_64", "aarch64", "ppc64le", "s390x"] for v in value): + raise ValueError("Architecture list does not match") + +def new(version): + schema = desert.schema(VersionConfig) + config = CONFIG[str(version)] + return schema.load(config) + +eight = new(8) +nine = new(9) + +print(eight) +print(eight.allowed_arches) +print(nine) diff --git a/iso/common b/iso/sh/common similarity index 100% rename from iso/common rename to iso/sh/common diff --git a/iso/common_8 b/iso/sh/common_8 similarity index 100% rename from iso/common_8 rename to iso/sh/common_8 diff --git a/iso/common_9 b/iso/sh/common_9 similarity index 100% rename from iso/common_9 rename to iso/sh/common_9