From f7bf479a58f3faf3f29b88d4559fba5627b0d9f4 Mon Sep 17 00:00:00 2001 From: Saul Wold Date: Thu, 30 Aug 2018 14:35:53 -0700 Subject: [PATCH] read releasever from yum.conf iff -c yum.conf is set This solves a problem when the default releasever is not set for distros that dont have a YUM as a standard tool. Read from the yum.conf if set on the command line since that is mostly likely going to be when we need to know this, in the default case (no -c yum.conf) it will get the correct value from the system. Change-Id: I21b0e8f881d054d8cdf6cdd831836a7f3e3020b2 Signed-off-by: Saul Wold --- centos-mirror-tools/dl_rpms.sh | 12 +++++++----- centos-mirror-tools/mirror-check.sh | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/centos-mirror-tools/dl_rpms.sh b/centos-mirror-tools/dl_rpms.sh index 29c0ae48..67cf7924 100755 --- a/centos-mirror-tools/dl_rpms.sh +++ b/centos-mirror-tools/dl_rpms.sh @@ -40,6 +40,7 @@ get_from() { # By default, we use "sudo" and we don't use a local yum.conf. These can # be overridden via flags. SUDOCMD="sudo -E" +RELEASEVER="--releasever=7" YUMCONFOPT="" CLEAN_LOGS_ONLY=0 @@ -59,6 +60,7 @@ while getopts "c:nxh" o; do c) # Use an alternate yum.conf YUMCONFOPT="-c $OPTARG" + RELEASEVER="--$(grep releasever= ${OPTARG})" ;; h) # Help @@ -215,11 +217,11 @@ download () { echo " ------ using $SFILE to search $rpm_name ------" # Yumdownloader with the appropriate flag for src, noarch or x86_64 if [ "$_type" == "src" ];then - download_cmd="${SUDOCMD} yumdownloader -q ${YUMCONFOPT} -C --source $SFILE" - download_url_cmd="${SUDOCMD} yumdownloader --urls -q ${YUMCONFOPT}-C --source $SFILE" + download_cmd="${SUDOCMD} yumdownloader -q ${YUMCONFOPT} ${RELEASEVER} -C --source $SFILE" + download_url_cmd="${SUDOCMD} yumdownloader --urls -q ${YUMCONFOPT} ${RELEASEVER} -C --source $SFILE" else - download_cmd="${SUDOCMD} yumdownloader -q -C ${YUMCONFOPT} $SFILE --archlist=noarch,x86_64" - download_url_cmd="${SUDOCMD} yumdownloader --urls -q -C ${YUMCONFOPT} $SFILE --archlist=noarch,x86_64" + download_cmd="${SUDOCMD} yumdownloader -q -C ${YUMCONFOPT} ${RELEASEVER} $SFILE --arcgglist=noarch,x86_64" + download_url_cmd="${SUDOCMD} yumdownloader --urls -q -C ${YUMCONFOPT} ${RELEASEVER} $SFILE --archlist=noarch,x86_64" fi fi else @@ -296,7 +298,7 @@ download () { } # Prime the cache -${SUDOCMD} yum ${YUMCONFOPT} makecache +${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache # Download files if [ -s "$rpms_list" ];then diff --git a/centos-mirror-tools/mirror-check.sh b/centos-mirror-tools/mirror-check.sh index 6a8c4776..43a92a17 100755 --- a/centos-mirror-tools/mirror-check.sh +++ b/centos-mirror-tools/mirror-check.sh @@ -39,6 +39,7 @@ truncate -s 0 $ERROR_LOG_FILE retcode=0 extra_opts="" + usage() { echo "$0 [-c ]" echo "" @@ -76,7 +77,7 @@ get_repoquery_info() { else repoquery_opts= fi - repoquery $extra_opts -C --qf '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}' \ + repoquery $extra_opts ${RELEASEVER} -C --qf '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}' \ $repoquery_opts "$_package_name" } @@ -114,6 +115,7 @@ while getopts "c:" opt; do case $opt in c) extra_opts="-c ${OPTARG}" + RELEASEVER="--$(grep releasever= ${OPTARG})" ;; \?) echo "Invalid option: -$OPTARG" >&2 @@ -124,7 +126,7 @@ while getopts "c:" opt; do done info "Getting yum cache" -if ! yum $extra_opts makecache; then +if ! yum $extra_opts ${RELEASEVER} makecache; then error "There was a problem getting yum cache" exit 1 fi