From 3d4e4f40c216fdda02af9cd2b0c6940d56bf2fd8 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Fri, 3 Mar 2023 23:02:55 -0700 Subject: [PATCH] Change parsers to have switches, KPR for branching --- .../generators/generate_prepopulate_from_kpr | 42 +++++++++++++++++++ .../generate_prepopulate_from_pungi | 2 +- .../generate_prepopulate_from_pungi_latest | 2 +- .../generate_prepopulate_from_stream | 2 +- mangle/generators/prepopulate_parser.py | 12 ++++-- 5 files changed, 53 insertions(+), 7 deletions(-) create mode 100755 mangle/generators/generate_prepopulate_from_kpr diff --git a/mangle/generators/generate_prepopulate_from_kpr b/mangle/generators/generate_prepopulate_from_kpr new file mode 100755 index 0000000..c1632c7 --- /dev/null +++ b/mangle/generators/generate_prepopulate_from_kpr @@ -0,0 +1,42 @@ +#!/bin/bash +# Parses a koji tag for a branch out +#set -x + +if [ -n "$1" ]; then + MAJOR=$1 +else + echo "Major version not specified" + exit 1 +fi + +export RLVER=$MAJOR +source common + +drop="${PREPOPDROP}" +current=$(pwd) +tmpdir=$(mktemp -d) +tag_template="c${MAJOR}s-build" +stream_repo_url="${STREAM_KOJI_REPO}/${tag_template}/latest" + +pushd "${tmpdir}" || { echo "Could not change directory"; exit 1; } +for y in "${ARCH[@]}"; do + repodatas=( $(dnf reposync --repofrompath ${tag_template},${stream_repo_url}/${y} --download-metadata --repoid=${tag_template} -p ${tag_template}/${y} --forcearch ${y} --norepopath --remote-time --assumeyes -u | grep repodata) ) + mkdir -p "${tag_template}/${y}/repodata" + pushd "${tag_template}/${y}/repodata" || { echo "Could not change directory"; exit 1; } + for z in "${repodatas[@]}"; do + wget -q -nc "${z}" + done + wget -q -nc "${stream_repo_url}/${y}/repodata/repomd.xml" + popd || { echo "Could not change back..."; exit 1; } +done +/usr/bin/python3 "${current}/prepopulate_parser.py" --version $RLVER --stream +ret_val=$? +popd || { echo "Could not change back..."; exit 1; } + +if [ "$ret_val" -ne "0" ]; then + echo "There was an error running through the parser." + exit 1 +fi + +sed -i "s|${tag_template}|branched|g" $drop +echo "File located at: $drop" diff --git a/mangle/generators/generate_prepopulate_from_pungi b/mangle/generators/generate_prepopulate_from_pungi index 96cff93..fa3771d 100755 --- a/mangle/generators/generate_prepopulate_from_pungi +++ b/mangle/generators/generate_prepopulate_from_pungi @@ -27,7 +27,7 @@ current=$(pwd) compose_dir="${COMPOSE_BASEDIR}/${MAJOR}/Rocky-${MAJOR}-${DATE}/compose" pushd "${compose_dir}" || { echo "Could not change directory"; exit 1; } -/usr/bin/python3 "${current}/prepopulate_parser.py" +/usr/bin/python3 "${current}/prepopulate_parser.py" --version ${RLVER} ret_val=$? popd || { echo "Could not change back..."; exit 1; } diff --git a/mangle/generators/generate_prepopulate_from_pungi_latest b/mangle/generators/generate_prepopulate_from_pungi_latest index 5566fc2..9f84f65 100755 --- a/mangle/generators/generate_prepopulate_from_pungi_latest +++ b/mangle/generators/generate_prepopulate_from_pungi_latest @@ -17,7 +17,7 @@ current=$(pwd) compose_dir="${COMPOSE_BASEDIR}/${MAJOR}/latest-Rocky-${MAJOR}/compose" pushd "${compose_dir}" || { echo "Could not change directory"; exit 1; } -/usr/bin/python3 "${current}/prepopulate_parser.py" --pungi +/usr/bin/python3 "${current}/prepopulate_parser.py" --pungi --version ${RLVER} ret_val=$? popd || { echo "Could not change back..."; exit 1; } diff --git a/mangle/generators/generate_prepopulate_from_stream b/mangle/generators/generate_prepopulate_from_stream index 3d51a5c..f734912 100755 --- a/mangle/generators/generate_prepopulate_from_stream +++ b/mangle/generators/generate_prepopulate_from_stream @@ -41,7 +41,7 @@ for x in "${REPO[@]}"; do popd || { echo "Could not change back..."; exit 1; } done done -/usr/bin/python3 "${current}/prepopulate_parser.py" +/usr/bin/python3 "${current}/prepopulate_parser.py" --version ${MAJOR} ret_val=$? popd || { echo "Could not change back..."; exit 1; } diff --git a/mangle/generators/prepopulate_parser.py b/mangle/generators/prepopulate_parser.py index bf21ea1..cb9046b 100755 --- a/mangle/generators/prepopulate_parser.py +++ b/mangle/generators/prepopulate_parser.py @@ -7,8 +7,6 @@ import dnf import createrepo_c as cr from common import * -REPOS = switcher.rlver((os.environ['RLVER'])) - # Source packages we do not ship or are rocky branded IGNORES = [ 'insights-client', @@ -22,10 +20,16 @@ IGNORES = [ ] parser = argparse.ArgumentParser() +parser.add_argument('--version', type=str, required=True) parser.add_argument("--pungi", help="local pungi is here", action='store_true') -args = parser.parse_args() +parser.add_argument('--stream', action='store_true', help="Stream koji only") -if args.pungi: +results = parser.parse_args() + +REPOS = switcher.rlver(results.version, + stream=results.stream) + +if results.pungi: APPEND_TO_PATH = '/os' else: APPEND_TO_PATH = ''