diff --git a/README.md b/README.md index 7e929a7..9495108 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,39 @@ sig-core-toolkit Release Engineering toolkit for repeatable operations or functionality testing. +Currently mirrored at our [github](https://github.com/rocky-linux), +[Rocky Linux Git Service](https://git.rockylinux.org), and the +[RESF Git Service](https://git.resf.org). Changes either occur at the Rocky +Linux Git Service or RESF Git Service. + +What does this have? +-------------------- + +* analyze -> Analysis utilities (such as download stats) +* chat -> mattermost related utilities +* func -> (mostly defunct) testing scripts and tools to test base functionality +* iso -> ISO related utilities +* live -> Live image related utilities +* mangle -> Manglers and other misc stuff +* sync -> Sync tools, primarily for Rocky Linux 8 + +How can I help? +--------------- + +Fork this repository and open a PR with your changes. Keep these things in mind +when you make changes: + +* Have pre-commit installed +* Have shellcheck installed +* Shell Scripts: These must pass a shellcheck test! +* Python scripts: Try your best to follow PEP8 guidelines + +Your PR should be against the devel branch at all times. PR's against the main +branch will be closed. + +Will some of this be moved into separate repositories? +------------------------------------------------------ + There may be some things that will be moved to its own repository in the near -future. This repository may be mirrored to github. Currently changes in the -[Rocky Linux](https://git.rockylinux.org) are allowed - Changes in the github -repository will not be synced. +future. From a SIG/Core standpoint, we believe a good chunk of this should stay +here as it makes it easier for us to maintain and manage. diff --git a/analyze/common b/analyze/common new file mode 100644 index 0000000..e69de29 diff --git a/analyze/common_8 b/analyze/common_8 new file mode 100644 index 0000000..e69de29 diff --git a/analyze/gen_download_statistics.sh b/analyze/gen_download_statistics.sh new file mode 100644 index 0000000..de9a142 --- /dev/null +++ b/analyze/gen_download_statistics.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +log () { + printf "[LOG] %s\n" "$1" +} + + +log "Begin generation" +log "Generating intermediary ISO logfile" + +# Generate intermediary iso log +if [[ ! -f intermediary_isos.log ]]; then + awk '/Rocky-8.4-(aarch64|x86_64)-.*?\.iso/ {if ($12==200 && $4!="3.134.114.30") print $0}' *.log **/*.log > intermediary_isos.log +else + log "Skipped ISO intermediary" +fi + +log "Done" +log "Generating intermediary mirrorlist stats" + +# Generate intermediary mirrorlist stats +if [[ ! -f intermediary_mirrorlist.log || ! -f mirrorlist_parsed ]]; then + awk '/GET \/mirrorlist/ { if ($12==200 && $4!="3.134.114.30") print $0}' *.log **/*.log > intermediary_mirrorlist.log + awk '{ date=substr($7,2,11); ip=$4; path=$10; match(path, /arch=(x86_64|aarch64|source)/, arch_matches); match(path,/repo=([a-zA-z\-0-9]+)/, repo_matches); arch=arch_matches[1]; repository=repo_matches[1] } { print date, arch, repository, ip }' intermediary_mirrorlist.log > mirrorlist_parsed +else + log "Skipped mirrorlist intermediary" +fi + + +log "Done" + +log "Count unique and nonunique requests" + +# "Unique" count by IP addresses +totaldls_u=$(awk '{print $4}' intermediary_isos.log | sort | uniq | wc -l) + +# Total count +totaldls=$(wc -l intermediary_isos.log | awk '{print $1}') + + +log "Generate download stats for every date" + +# Get all the dates +declare -a dates +dates=( $(awk '{print substr($7,2,11)}' intermediary_isos.log | sort | uniq) ) +download_res="" +for date in "${dates[@]}"; do + total_count=$(grep "${date}" intermediary_isos.log | wc -l) + download_res="${download_res}${date} ${total_count}\n" +done + +log "Done" +log "Generate mirrorlist stats for every date" +dates=( $(awk '{print $1}' mirrorlist_parsed | sort | uniq) ) +#repositories=( $(awk '{print $3}' mirrorlist_parsed | sort | uniq ) ) +repositories=({AppStream,BaseOS,PowerTools,ResilientStorage,Minimal,Devel,HighAvailability,extras,rockyplus,NFV}-{8,8-source}) + + +mirror_res="Date Total x86_64 aarch64 source ${repositories[@]}\n" +for date in "${dates[@]}"; do + today=$(grep "${date}" mirrorlist_parsed) + total_count=$(echo "${today}" | wc -l) + arches=($(echo "${today}" | awk 'BEGIN {source=0; x86=0; a64=0; }{ if ($2=="x86_64") { x86+=1 } else if ($2=="aarch64") { a64+=1 } else if ($2=="source") { source+=1 } } END { print x86, a64, source }')) + declare -A repos + for repo in "${repositories[@]}"; do + repos["${repo}"]=$(echo "${today}" | grep "${repo}" | wc -l) + done + mirror_res="${mirror_res}${date} ${total_count} ${arches[@]} ${repos[@]}\n" +done + +log "Done" +log "End processing. Begin output" + +# Output shit +echo -e "Download Information\n------------------" +echo -e "Total: ${totaldls}\nUnique: ${totaldls_u}\n\n\n" +echo -e "Downloads by date\n------------------" +echo -e "${download_res}" | column -t +echo -e "Mirror requests by date\n------------------" +# Sort by date +echo -e "${mirror_res}" | column -t | sort -t'/' -Mk2 diff --git a/chat/.gitignore b/chat/.gitignore new file mode 100644 index 0000000..a84ff4b --- /dev/null +++ b/chat/.gitignore @@ -0,0 +1,2 @@ +.envrc + diff --git a/chat/common b/chat/common new file mode 100644 index 0000000..02d46ab --- /dev/null +++ b/chat/common @@ -0,0 +1 @@ +SERVICE_ID=7mRT77Q5CL2BNpM5zxse2v diff --git a/chat/fetch_mattermost_client_release b/chat/fetch_mattermost_client_release new file mode 100755 index 0000000..d7eb1cf --- /dev/null +++ b/chat/fetch_mattermost_client_release @@ -0,0 +1,25 @@ +#!/bin/bash + +version=$1 + +if [[ -z "$1" ]]; then + printf "usage: $0 mmversion\n"; exit 2 +fi + +#tmpdir=$(mktemp -d) +tmpdir=/tmp/ +outfile="${tmpdir}/mattermost-${version}.tar.gz" + +if [[ ! -f "${outfile}" ]]; then + curl -Lo "$outfile" "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz" || exit 1 +fi + +outdir="${tmpdir}mattermost-${version}/" + +if [[ ! -d "${outdir}" ]]; then + mkdir "${outdir}" +fi + +tar --strip-components 2 -C "${outdir}" -xvf "$outfile" mattermost/client + +echo "Wrote to ${outdir}" diff --git a/func/core/pkg_kernel/10-test-kernel-keyring.sh b/func/core/pkg_kernel/10-test-kernel-keyring.sh index c1e4ff3..9c71043 100644 --- a/func/core/pkg_kernel/10-test-kernel-keyring.sh +++ b/func/core/pkg_kernel/10-test-kernel-keyring.sh @@ -4,7 +4,7 @@ r_log "kernel" "Testing the kernel keyring (GPG)" ARCH=$(uname -m) #KERNEL=$(uname -r | cut -d'-' -f1) -if [ "${ARCH}" == "aarch64" ]; then +if [ "${ARCH}" == "aarch64" ] || [ "${ARCH}" == "ppc64le" ] || [ "${ARCH}" == "s390x" ]; then r_log "kernel" "Architecture not tested: $ARCH" exit 0 fi diff --git a/func/core/pkg_release/10-name-sanity-check.sh b/func/core/pkg_release/10-name-sanity-check.sh index 4a88af5..da590da 100755 --- a/func/core/pkg_release/10-name-sanity-check.sh +++ b/func/core/pkg_release/10-name-sanity-check.sh @@ -4,7 +4,7 @@ r_log "release" "Ensure the release is actually where it should be" case $RELEASE_NAME in rocky) r_log "rocky release" "Base Repo Check" - grep -q 'name=Rocky' /etc/yum.repos.d/Rocky*-Base*.repo + grep -q 'name=Rocky' /etc/yum.repos.d/*ocky*.repo r_checkExitStatus $? r_log "rocky release" "Check /etc/rocky-release" grep -q "Rocky" /etc/rocky-release diff --git a/func/core/pkg_release/20-check-gpg-keys.sh b/func/core/pkg_release/20-check-gpg-keys.sh index e8ea65c..d99b178 100755 --- a/func/core/pkg_release/20-check-gpg-keys.sh +++ b/func/core/pkg_release/20-check-gpg-keys.sh @@ -1,6 +1,11 @@ #!/bin/bash r_log "rocky" "Check the GPG keys" -file /etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial > /dev/null 2>&1 && \ - file /etc/pki/rpm-gpg/RPM-GPG-KEY-rockytesting > /dev/null 2>&1 +if [ "$RL_VER" -eq 8 ]; then + file /etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial > /dev/null 2>&1 && \ + file /etc/pki/rpm-gpg/RPM-GPG-KEY-rockytesting > /dev/null 2>&1 +else + file "/etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-${RL_VER}" > /ev/null 2>&1 && \ + file "/etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-${RL_VER}-Testing" > /ev/null 2>&1 +fi r_checkExitStatus $? diff --git a/func/debrand.list b/func/debrand.list index 12b4af3..a851fae 100644 --- a/func/debrand.list +++ b/func/debrand.list @@ -1,25 +1 @@ -# Place packages that were modified for debranding, regardless if their -# release tag was modified. -# -# The format is this: -# -> Rocky Version ($RL_VER, so major version) -# -> Package Name -# X|name -ALL|abrt -ALL|anaconda -8|cloud-init -8|cockpit -ALL|dhcp -ALL|firefox -ALL|fwupdate -ALL|httpd -ALL|initial-setup -ALL|kernel -ALL|libreport -ALL|nginx -ALL|PackageKit -ALL|redhat-rpm-config -ALL|shim -ALL|sos -ALL|subscription-manager -ALL|thunderbird +# Packages that have been debranded will be in the rocky/metadata git repository 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..41f3a41 --- /dev/null +++ b/iso/py/README.md @@ -0,0 +1,56 @@ +# iso + +## TODO + +Verbose mode should exist to output everything that's being called or ran. + +There should be additional logging regardless, not just to stdout, but also to a file. + +## scripts + +* sync-variant-pungi +* sync-variant-peridot +* sync-from-pungi +* sync-from-peridot +* sync-sig +* build-all-iso +* sign-repos-only + +## wrappers + +* lorax-generators +* sync-generators + +## rules + +### imports + +When making a script, you *must* import common. This is insanely bad practice, +but we would prefer if we started out this way: + +``` +from common import * +import argparse +``` + +Whatever is imported in common will effectively be imported in your scripts as +well, but there is nothing stopping you from defining them again, even out of +habit. `argparse` is there because you better have a very, *very* good reason +to not be writing scripts that are major version specific. + +If you are writing something that could be arch specific based on the major +version (which is likely), make sure to import the util module and use it arch +checker appropriately. Small (but weak) example. + +``` +from util import Checks + +rlvars = rldict['9'] +r = Checks(rlvars, arch) +r.check_valid_arch() +``` + +### script names and permissions + +* Callable scripts should *not* end in `.py` +* They should have at least `775` or `+x` permissions diff --git a/iso/py/build-iso b/iso/py/build-iso new file mode 100644 index 0000000..a8c6f34 --- /dev/null +++ b/iso/py/build-iso @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +# builds ISO's + +import argparse +from common import * +from util import Checks +from util import IsoBuild diff --git a/iso/py/common.py b/iso/py/common.py new file mode 100644 index 0000000..1d07574 --- /dev/null +++ b/iso/py/common.py @@ -0,0 +1,56 @@ +# All imports are here +import os +import platform +import time +import glob +import rpm +import yaml +import logging + +# 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 +rldict = {} +config = { + "rlmacro": rpm.expandMacro('%rhel'), + "arch": platform.machine(), + "date_stamp": time.strftime("%Y%m%d.%H%M%S", time.localtime()), + "compose_root": "/mnt/compose", + "staging_root": "/mnt/repos-staging", + "production_root": "/mnt/repos-production", + "category_stub": "mirror/pub/rocky", + "sig_category_stub": "mirror/pub/sig", + "repo_base_url": "https://yumrepofs.build.resf.org/v1/projects", + "container": "centos:stream9" +} + +# 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 config['rlmacro']: +# 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.') + + +# These will be set in their respective var files +#REVISION = rlvars['revision'] + '-' + rlvars['rclvl'] +#rlvars = rldict[rlver] +#rlvars = rldict[rlmacro] +#COMPOSE_ISO_WORKDIR = COMPOSE_ROOT + "work/" + arch + "/" + date_stamp diff --git a/iso/py/configs/.el9.yaml.swp b/iso/py/configs/.el9.yaml.swp new file mode 100644 index 0000000..d235db3 Binary files /dev/null and b/iso/py/configs/.el9.yaml.swp differ diff --git a/iso/py/configs/el8.yaml b/iso/py/configs/el8.yaml new file mode 100644 index 0000000..c232bb0 --- /dev/null +++ b/iso/py/configs/el8.yaml @@ -0,0 +1,89 @@ +--- +'8': + revision: '8.6' + rclvl: 'RC2' + allowed_arches: + - x86_64 + - aarch64 + provide_multilib: False + project_id: '' + required_packages: + - 'lorax' + - 'genisoimage' + - 'isomd5sum' + repo_symlinks: + devel: 'Devel' + NFV: 'nfv' + renames: {} + all_repos: + - 'BaseOS' + - 'AppStream' + - 'PowerTools' + - 'HighAvailability' + - 'ResilientStorage' + - 'RT' + - 'NFV' + - 'extras' + - 'devel' + - 'plus' + - 'rockyrpi' + no_comps_or_groups: + - 'extras' + - 'devel' + - 'plus' + - 'rockyrpi' + comps_or_groups: + - 'BaseOS' + - 'AppStream' + - 'PowerTools' + - 'HighAvailability' + - 'ResilientStorage' + - 'RT' + - 'NFV' + has_modules: + - 'AppStream' + - 'PowerTools' + iso_map: + hosts: + x86_64: '' + aarch64: '' + ppc64le: '' + s390x: '' + images: + - dvd1 + - minimal + - boot + repoclosure_map: + arches: + x86_64: '--arch=x86_64 --arch=athlon --arch=i686 --arch=i586 --arch=i486 --arch=i386 --arch=noarch' + aarch64: '--arch=aarch64 --arch=noarch' + ppc64le: '--arch=ppc64le --arch=noarch' + s390x: '--arch=s390x --arch=noarch' + repos: + BaseOS: [] + AppStream: + - BaseOS + PowerTools: + - BaseOS + - AppStream + HighAvailability: + - BaseOS + - AppStream + ResilientStorage: + - BaseOS + - AppStream + RT: + - BaseOS + - AppStream + NFV: + - BaseOS + - AppStream + extra_files: + git_repo: 'https://git.rockylinux.org/staging/src/rocky-release.git' + branch: 'r8' + list: + - 'SOURCES/COMMUNITY-CHARTER' + - 'SOURCES/EULA' + - 'SOURCES/LICENSE' + - 'SOURCES/RPM-GPG-KEY-rockyofficial' +... diff --git a/iso/py/configs/el9.yaml b/iso/py/configs/el9.yaml new file mode 100644 index 0000000..d6553a8 --- /dev/null +++ b/iso/py/configs/el9.yaml @@ -0,0 +1,109 @@ +--- +'9': + revision: '9.0' + rclvl: 'RC1' + allowed_arches: + - x86_64 + - aarch64 + - ppc64le + - s390x + provide_multilib: True + project_id: '55b17281-bc54-4929-8aca-a8a11d628738' + required_packages: + - 'lorax' + - 'genisoimage' + - 'isomd5sum' + repo_symlinks: + devel: 'Devel' + NFV: 'nfv' + renames: + all: 'nplb' + all_repos: + - 'all' + - 'BaseOS' + - 'AppStream' + - 'CRB' + - 'HighAvailability' + - 'ResilientStorage' + - 'RT' + - 'NFV' + - 'SAP' + - 'SAPHANA' + - 'extras' + - 'devel' + - 'plus' + no_comps_or_groups: + - 'all' + - 'extras' + - 'devel' + - 'plus' + comps_or_groups: + - 'BaseOS' + - 'AppStream' + - 'CRB' + - 'HighAvailability' + - 'ResilientStorage' + - 'RT' + - 'NFV' + - 'SAP' + - 'SAPHANA' + has_modules: + - 'AppStream' + - 'CRB' + iso_map: + hosts: + x86_64: '' + aarch64: '' + ppc64le: '' + s390x: '' + images: + - dvd1 + - minimal + - boot + repos: + - 'BaseOS' + - 'AppStream' + repoclosure_map: + arches: + x86_64: '--forcearch=x86_64 --arch=x86_64 --arch=athlon --arch=i686 --arch=i586 --arch=i486 --arch=i386 --arch=noarch' + aarch64: '--forcearch=aarch64 --arch=aarch64 --arch=noarch' + ppc64le: '--forcearch=ppc64le --arch=ppc64le --arch=noarch' + s390x: '--forcearch=s390x --arch=s390x --arch=noarch' + repos: + nplb: [] + BaseOS: [] + AppStream: + - BaseOS + CRB: + - BaseOS + - AppStream + HighAvailability: + - BaseOS + - AppStream + ResilientStorage: + - BaseOS + - AppStream + RT: + - BaseOS + - AppStream + NFV: + - BaseOS + - AppStream + SAP: + - BaseOS + - AppStream + - HighAvailability + SAPHANA: + - BaseOS + - AppStream + - HighAvailability + extra_files: + git_repo: 'https://git.rockylinux.org/staging/src/rocky-release.git' + branch: 'r9' + list: + - 'SOURCES/COMMUNITY-CHARTER' + - 'SOURCES/EULA' + - 'SOURCES/LICENSE' + - 'SOURCES/RPM-GPG-KEY-Rocky-9' + - 'SOURCES/RPM-GPG-KEY-Rocky-9-Testing' +... diff --git a/iso/py/sig/altarch.yaml b/iso/py/sig/altarch.yaml new file mode 100644 index 0000000..0eb9d4e --- /dev/null +++ b/iso/py/sig/altarch.yaml @@ -0,0 +1,12 @@ +--- +'8': + rockyrpi: + project_id: '' + additional_dirs: + - 'images' +'9': + rockyrpi: + project_id: '' + additional_dirs: + - 'images' +... diff --git a/iso/py/sig/cloud.yaml b/iso/py/sig/cloud.yaml new file mode 100644 index 0000000..985a405 --- /dev/null +++ b/iso/py/sig/cloud.yaml @@ -0,0 +1,10 @@ +--- +'8': + cloud-kernel: + project_id: 'f91da90d-5bdb-4cf2-80ea-e07f8dae5a5c' + cloud-common: + project_id: '' +'9': + cloud-common: + project_id: '' +... diff --git a/iso/py/sig/core.yaml b/iso/py/sig/core.yaml new file mode 100644 index 0000000..0047ac0 --- /dev/null +++ b/iso/py/sig/core.yaml @@ -0,0 +1,12 @@ +--- +'8': + core-common: + project_id: '' + core-infra: + project_id: '' +'9': + core-common: + project_id: '' + core-infra: + project_id: '' +... diff --git a/iso/py/sync-from-peridot b/iso/py/sync-from-peridot new file mode 100755 index 0000000..56ba74d --- /dev/null +++ b/iso/py/sync-from-peridot @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 + +# This script can be called to do single syncs or full on syncs. + +import argparse +from common import * +from util import Checks +from util import RepoSync + +#rlvars = rldict['9'] +#r = Checks(rlvars, config['arch']) +#r.check_valid_arch() + +# Start up the parser baby +parser = argparse.ArgumentParser(description="Peridot Sync and Compose") + +# All of our options +parser.add_argument('--release', type=str, help="Major Release Version", required=True) +parser.add_argument('--repo', type=str, help="Repository name") +parser.add_argument('--arch', type=str, help="Architecture") +parser.add_argument('--ignore-debug', action='store_true') +parser.add_argument('--ignore-source', action='store_true') +parser.add_argument('--repoclosure', action='store_true') +parser.add_argument('--skip-all', action='store_true') +parser.add_argument('--dry-run', action='store_true') +parser.add_argument('--full-run', action='store_true') +parser.add_argument('--no-fail', action='store_true') +# I am aware this is confusing, I want podman to be the default option +parser.add_argument('--simple', action='store_false') +parser.add_argument('--logger', type=str) + +# Parse them +results = parser.parse_args() + +rlvars = rldict[results.release] +r = Checks(rlvars, config['arch']) +r.check_valid_arch() + +# Send them and do whatever I guess +a = RepoSync( + rlvars, + config, + major=results.release, + repo=results.repo, + arch=results.arch, + ignore_debug=results.ignore_debug, + ignore_source=results.ignore_source, + repoclosure=results.repoclosure, + skip_all=results.skip_all, + parallel=results.simple, + dryrun=results.dry_run, + fullrun=results.full_run, + nofail=results.no_fail, + logger=results.logger +) + +a.run() diff --git a/iso/py/sync-from-peridot-test b/iso/py/sync-from-peridot-test new file mode 100755 index 0000000..34cd4b6 --- /dev/null +++ b/iso/py/sync-from-peridot-test @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +# This is a testing script to ensure the RepoSync class is working as intended. + +from common import * +import argparse +from util import Checks +from util import RepoSync + +rlvars = rldict['9'] +r = Checks(rlvars, config['arch']) +r.check_valid_arch() + +#a = RepoSync(rlvars, config, major="9", repo="ResilientStorage", parallel=True, ignore_debug=False, ignore_source=False) +a = RepoSync(rlvars, config, major="9", repo="ResilientStorage", parallel=True, ignore_debug=False, ignore_source=False) +a.run() diff --git a/iso/py/test.py b/iso/py/test.py new file mode 100644 index 0000000..871e88e --- /dev/null +++ b/iso/py/test.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +from common import * +import argparse +from util import Checks + +rlvars = rldict['9'] +r = Checks(rlvars, arch) +r.check_valid_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/py/util/__init__.py b/iso/py/util/__init__.py new file mode 100644 index 0000000..0cbbf89 --- /dev/null +++ b/iso/py/util/__init__.py @@ -0,0 +1,21 @@ +""" +Imports all of our classes for this local module +""" + +from .check import ( + Checks, +) + +from .dnf_utils import ( + RepoSync, +) + +from .iso_utils import ( + IsoBuild, + LiveBuild +) + +__all__ = [ + 'Checks', + 'RepoSync' +] diff --git a/iso/py/util/check.py b/iso/py/util/check.py new file mode 100644 index 0000000..a87d86f --- /dev/null +++ b/iso/py/util/check.py @@ -0,0 +1,14 @@ +# Is our arch allowed for this particular release? Some previous releases do +# not support ppc or s390x +from common import Color +class Checks: + """This class helps check some things""" + def __init__(self, rlvars, arch): + self.arches = rlvars['allowed_arches'] + self.arch = arch + + def check_valid_arch(self): + if self.arch not in self.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.') diff --git a/iso/py/util/dnf_utils.py b/iso/py/util/dnf_utils.py new file mode 100644 index 0000000..2882d95 --- /dev/null +++ b/iso/py/util/dnf_utils.py @@ -0,0 +1,912 @@ +""" +Syncs yum repos for mirroring and composing. + +Louis Abel