From 8cb5c525b00417f02f48e56191aeba46b10415ba Mon Sep 17 00:00:00 2001 From: Dustin Nemes <39643802+some-things@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:48:48 -0500 Subject: [PATCH] fix: rename user-defined repo filename and improve parsing --- bundles/redhat8.6/bundle.sh.gotmpl | 12 ++++++------ bundles/redhat8.8/bundle.sh.gotmpl | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bundles/redhat8.6/bundle.sh.gotmpl b/bundles/redhat8.6/bundle.sh.gotmpl index 3e2efe36b..e491faa14 100755 --- a/bundles/redhat8.6/bundle.sh.gotmpl +++ b/bundles/redhat8.6/bundle.sh.gotmpl @@ -78,12 +78,12 @@ if [[ -n "${KUBERNETES_REPOS}" ]]; then ENABLED_REPOS="${ENABLED_REPOS},kubernetes" fi -if [[ -f /etc/yum.repos.d/user-repos.repo ]]; then - USER_REPOS="$(awk -F '[][]' '/^\[.*\]/ {print $2}' /etc/yum.repos.d/user-repos.repo | paste -sd, -)" - if [[ -n "${ENABLED_REPOS}" ]] && [[ -n "${USER_REPOS}" ]]; then - ENABLED_REPOS="${ENABLED_REPOS},${USER_REPOS}" - elif [[ -z "${ENABLED_REPOS}" ]] && [[ -n "${USER_REPOS}" ]]; then - ENABLED_REPOS="${USER_REPOS}" +if [[ -f /etc/yum.repos.d/additional-repos.repo ]]; then + ADDITIONAL_REPOS="$(/usr/libexec/platform-python3.6 -c "import configparser; config = configparser.ConfigParser(); config.read('/etc/yum.repos.d/additional-repos.repo'); print(','.join(config.sections()) if config.sections() else '')")" + if [[ -n "${ENABLED_REPOS}" ]] && [[ -n "${ADDITIONAL_REPOS}" ]]; then + ENABLED_REPOS="${ENABLED_REPOS},${ADDITIONAL_REPOS}" + elif [[ -z "${ENABLED_REPOS}" ]] && [[ -n "${ADDITIONAL_REPOS}" ]]; then + ENABLED_REPOS="${ADDITIONAL_REPOS}" fi fi diff --git a/bundles/redhat8.8/bundle.sh.gotmpl b/bundles/redhat8.8/bundle.sh.gotmpl index b74df65ea..952cb38bd 100755 --- a/bundles/redhat8.8/bundle.sh.gotmpl +++ b/bundles/redhat8.8/bundle.sh.gotmpl @@ -78,12 +78,12 @@ if [[ -n "${KUBERNETES_REPOS}" ]]; then ENABLED_REPOS="${ENABLED_REPOS},kubernetes" fi -if [[ -f /etc/yum.repos.d/user-repos.repo ]]; then - USER_REPOS="$(awk -F '[][]' '/^\[.*\]/ {print $2}' /etc/yum.repos.d/user-repos.repo | paste -sd, -)" - if [[ -n "${ENABLED_REPOS}" ]] && [[ -n "${USER_REPOS}" ]]; then - ENABLED_REPOS="${ENABLED_REPOS},${USER_REPOS}" - elif [[ -z "${ENABLED_REPOS}" ]] && [[ -n "${USER_REPOS}" ]]; then - ENABLED_REPOS="${USER_REPOS}" +if [[ -f /etc/yum.repos.d/additional-repos.repo ]]; then + ADDITIONAL_REPOS="$(/usr/libexec/platform-python3.6 -c "import configparser; config = configparser.ConfigParser(); config.read('/etc/yum.repos.d/additional-repos.repo'); print(','.join(config.sections()) if config.sections() else '')")" + if [[ -n "${ENABLED_REPOS}" ]] && [[ -n "${ADDITIONAL_REPOS}" ]]; then + ENABLED_REPOS="${ENABLED_REPOS},${ADDITIONAL_REPOS}" + elif [[ -z "${ENABLED_REPOS}" ]] && [[ -n "${ADDITIONAL_REPOS}" ]]; then + ENABLED_REPOS="${ADDITIONAL_REPOS}" fi fi