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 <sgw@linux.intel.com>
This commit is contained in:
Saul Wold 2018-08-30 14:35:53 -07:00
parent 29ac41fded
commit f7bf479a58
2 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -39,6 +39,7 @@ truncate -s 0 $ERROR_LOG_FILE
retcode=0
extra_opts=""
usage() {
echo "$0 [-c <yum.conf>]"
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