Upgrade build container yum to dnf

yum related changes
Use dnf instead of yum

Change-Id: I8b1e0c6d35255b212d13a9806f35f32999fe2bf5
Story: 2006844
Task: 37431
Depends-On: https://review.opendev.org/694761
Signed-off-by: fuyong <fuyong@neusoft.com>
This commit is contained in:
fuyong 2019-11-28 16:25:56 +08:00
parent 202776a187
commit cd3afdb55f
7 changed files with 133 additions and 133 deletions

View File

@ -8,23 +8,23 @@
set -o errexit
set -o nounset
# By default, we use "sudo" and we don't use a local yum.conf. These can
# By default, we use "sudo" and we don't use a local dnf.conf. These can
# be overridden via flags.
SUDOCMD="sudo -E"
RELEASEVER="--releasever=7"
YUMCONFOPT=""
RELEASEVER="--releasever=8"
DNFCONFOPT=""
DL_RPMS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
source $DL_RPMS_DIR/utils.sh
usage() {
echo "$0 [-n] [-c <yum.conf>] <rpms_list> <match_level> "
echo "$0 [-n] [-c <dnf.conf>] <rpms_list> <match_level> "
echo ""
echo "Options:"
echo " -n: Do not use sudo when performing operations"
echo " -c: Use an alternate yum.conf rather than the system file"
echo " -c: Use an alternate dnf.conf rather than the system file"
echo " -x: Clean log files only, do not run."
echo " rpm_list: a list of RPM files to be downloaded."
echo " match_level: value could be L1, L2 or L3:"
@ -34,7 +34,7 @@ usage() {
echo " using vim-7.4.160 to search vim-7.4.160-2.el7.src.rpm"
echo " L3: use name:"
echo " using vim to search vim-7.4.160-2.el7.src.rpm"
echo " K1: Use Koji rather than yum repos as a source."
echo " K1: Use Koji rather than dnf repos as a source."
echo " Koji has a longer retention period than epel mirrors."
echo ""
echo "Returns: 0 = All files downloaded successfully"
@ -85,8 +85,8 @@ while getopts "c:nxD:sSuUh" o; do
CLEAN_LOGS_ONLY=1
;;
c)
# Use an alternate yum.conf
YUMCONFOPT="-c $OPTARG"
# Use an alternate dnf.conf
DNFCONFOPT="-c $OPTARG"
grep -q "releasever=" $OPTARG && RELEASEVER="--$(grep releasever= ${OPTARG})"
;;
D)
@ -253,8 +253,8 @@ download () {
# Prime the cache
loop_count=0
max_loop_count=5
echo "${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache"
while ! ${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache ; do
echo "${SUDOCMD} dnf ${DNFCONFOPT} ${RELEASEVER} makecache"
while ! ${SUDOCMD} dnf ${DNFCONFOPT} ${RELEASEVER} makecache ; do
# To protect against intermittent 404 errors, we'll retry
# a few times. The suspected issue is pulling repodata
# from multiple source that are temporarily inconsistent.
@ -265,8 +265,8 @@ while ! ${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache ; do
echo "makecache retry: $loop_count"
# Wipe the inconsistent data from the last try
echo "yum ${YUMCONFOPT} ${RELEASEVER} clean all"
yum ${YUMCONFOPT} ${RELEASEVER} clean all
echo "dnf ${DNFCONFOPT} ${RELEASEVER} clean all"
dnf ${DNFCONFOPT} ${RELEASEVER} clean all
done

View File

@ -1,15 +1,15 @@
[main]
releasever=7
cachedir=/tmp/cache/yum/$basearch/$releasever
releasever=8
cachedir=/tmp/cache/dnf/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/tmp/log/yum.log
logfile=/tmp/log/dnf.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=dnf
distroverpkg=centos-release
override_install_langs=en_US.utf8
tsflags=nodocs
@ -17,9 +17,9 @@ http_caching=packages
reposdir=yum.repos.d
# This is the default, if you make this bigger yum won't see if the metadata
# This is the default, if you make this bigger dnf won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# download the new metadata and "pay" for it by dnf not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking

View File

@ -4,12 +4,12 @@
#
usage() {
echo "$0 [-n] [-c <yum.conf>] [-g] [-s|-S|-u|-U]"
echo "$0 [-n] [-c <dnf.conf>] [-g] [-s|-S|-u|-U]"
echo ""
echo "Options:"
echo " -n: Do not use sudo when performing operations (option passed on to"
echo " subscripts when appropriate)"
echo " -c: Use an alternate yum.conf rather than the system file (option passed"
echo " -c: Use an alternate dnf.conf rather than the system file (option passed"
echo " on to subscripts when appropriate)"
echo " -g: do not change group IDs of downloaded artifacts"
echo " -s: Download from StarlingX mirror only"
@ -111,7 +111,7 @@ while getopts "c:nghsSuU" o; do
rpm_downloader_extra_args="${rpm_downloader_extra_args} -n"
;;
c)
# Pass -c ("use alternate yum.conf") to rpm downloader
# Pass -c ("use alternate dnf.conf") to rpm downloader
use_system_yum_conf=0
alternate_yum_conf="${OPTARG}"
;;
@ -208,14 +208,14 @@ fi
if ! dl_from_stx; then
# Not using stx mirror
if [ $use_system_yum_conf -eq 0 ]; then
# Use provided yum.conf unaltered.
# Use provided dnf.conf unaltered.
rpm_downloader_extra_args="${rpm_downloader_extra_args} -c ${alternate_yum_conf}"
fi
else
# We want to use stx mirror, so we need to create a new, modified yum.conf and yum.repos.d.
# We want to use stx mirror, so we need to create a new, modified dnf.conf and yum.repos.d.
# The modifications will add or substitute repos pointing to the StralingX mirror.
TEMP_DIR=$(mktemp -d /tmp/stx_mirror_XXXXXX)
TEMP_CONF="$TEMP_DIR/yum.conf"
TEMP_CONF="$TEMP_DIR/dnf.conf"
need_file ${make_stx_mirror_yum_conf}
need_dir ${TEMP_DIR}
@ -230,15 +230,15 @@ else
${make_stx_mirror_yum_conf} -d $TEMP_DIR -y $alternate_yum_conf -r $alternate_repo_dir -D $distro
fi
else
# Modify system yum.conf and yum.repos.d. Remember that we expect to run this
# inside a container, and the system yum.conf has like been modified else where
# Modify system dnf.conf and yum.repos.d. Remember that we expect to run this
# inside a container, and the system dnf.conf has like been modified else where
# in these scripts.
if dl_from_upstream; then
# add
${make_stx_mirror_yum_conf} -R -d $TEMP_DIR -y /etc/yum.conf -r /etc/yum.repos.d -D $distro
${make_stx_mirror_yum_conf} -R -d $TEMP_DIR -y /etc/dnf/dnf.conf -r /etc/yum.repos.d -D $distro
else
# substitute
${make_stx_mirror_yum_conf} -d $TEMP_DIR -y /etc/yum.conf -r /etc/yum.repos.d -D $distro
${make_stx_mirror_yum_conf} -d $TEMP_DIR -y /etc/dnf/dnf.conf -r /etc/yum.repos.d -D $distro
fi
fi
@ -257,7 +257,7 @@ if [ $retcode -ne 0 ];then
success=0
fi
# download RPMs/SRPMs from 3rd_party repos by "yumdownloader"
# download RPMs/SRPMs from 3rd_party repos by "dnf download"
list=${rpms_from_centos_3rd_parties}
level=L1
logfile=$(generate_log_name $list $level)
@ -280,7 +280,7 @@ fi
echo "step #2: start 1st round of downloading RPMs and SRPMs with L1 match criteria..."
#download RPMs/SRPMs from CentOS repos by "yumdownloader"
#download RPMs/SRPMs from CentOS repos by "dnf download"
list=${rpms_from_centos_repo}
level=L1
logfile=$(generate_log_name $list $level)

View File

@ -5,35 +5,35 @@
#
#
# Replicate a yum.conf and yum.repo.d under a temporary directory and
# Replicate a dnf.conf and yum.repo.d under a temporary directory and
# then modify the files to point to equivalent repos in the StarlingX mirror.
# This script was originated by Scott Little
#
MAKE_STX_MIRROR_YUM_CONF_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
MAKE_STX_MIRROR_DNF_CONF_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
source "$MAKE_STX_MIRROR_YUM_CONF_DIR/url_utils.sh"
source "$MAKE_STX_MIRROR_DNF_CONF_DIR/url_utils.sh"
DISTRO="centos"
TEMP_DIR=""
SRC_REPO_DIR="$MAKE_STX_MIRROR_YUM_CONF_DIR/yum.repos.d"
SRC_YUM_CONF="$MAKE_STX_MIRROR_YUM_CONF_DIR/yum.conf.sample"
SRC_REPO_DIR="$MAKE_STX_MIRROR_DNF_CONF_DIR/yum.repos.d"
SRC_DNF_CONF="$MAKE_STX_MIRROR_DNF_CONF_DIR/dnf.conf.sample"
RETAIN_REPODIR=0
usage () {
echo ""
echo "$0 -d <dest_dir> [-D <distro>] [-y <src_yum_conf>] [-r <src_repos_dir>] [-R]"
echo "$0 -d <dest_dir> [-D <distro>] [-y <src_dnf_conf>] [-r <src_repos_dir>] [-R]"
echo ""
echo "Replicate a yum.conf and yum.repo.d under a new directory and"
echo "Replicate a dnf.conf and yum.repo.d under a new directory and"
echo "then modify the files to point to equivalent repos in the StarlingX"
echo "mirror."
echo ""
echo "-d <dest_dir> = Place modified yum.conf and yum.repo.d into this directory"
echo "-d <dest_dir> = Place modified dnf.conf and yum.repo.d into this directory"
echo "-D <distro> = Target distro on StarlingX mirror. Default is 'centos'"
echo "-y <yum_conf> = Path to yum.conf file that we will modify. Default is"
echo " 'yum.conf.sample' in same directory as this script"
echo "-y <dnf_conf> = Path to dnf.conf file that we will modify. Default is"
echo " 'dnf.conf.sample' in same directory as this script"
echo "-r <repos_dir> = Path to yum.repos.d that we will modify. Default is"
echo " 'yum.repos.d' in same directory as this script"
}
@ -57,7 +57,7 @@ while getopts "D:d:Rr:y:" o; do
RETAIN_REPODIR=1
;;
y)
SRC_YUM_CONF="${OPTARG}"
SRC_DNF_CONF="${OPTARG}"
;;
*)
usage
@ -69,8 +69,8 @@ done
#
# option validation
#
if [ ! -f $SRC_YUM_CONF ]; then
echo "Error: yum.conf not found at '$SRC_YUM_CONF'"
if [ ! -f $SRC_DNF_CONF ]; then
echo "Error: dnf.conf not found at '$SRC_DNF_CONF'"
exit 1
fi
@ -93,32 +93,32 @@ fi
#
# Get the value of the $releasever variable.
#
# If the source yum.conf has a releasever= setting, we will honor
# that, even though yum will not.
# If the source dnf.conf has a releasever= setting, we will honor
# that, even though dnf will not.
#
# Otherwise use yum to query the host environment (Docker).
# Otherwise use dnf to query the host environment (Docker).
# This assumes the host environmnet has the same releasever
# as that which will be used inside StarlingX.
#
# NOTE: In other scripts we will read releasever= out of yum.conf
# and push it back into yum via --releasever=<#>.
# NOTE: In other scripts we will read releasever= out of dnf.conf
# and push it back into dnf via --releasever=<#>.
#
get_releasever () {
if [ -f $SRC_YUM_CONF ] && grep -q '^releasever=' $SRC_YUM_CONF; then
grep '^releasever=' $SRC_YUM_CONF | cut -d '=' -f 2
if [ -f $SRC_DNF_CONF ] && grep -q '^releasever=' $SRC_DNF_CONF; then
grep '^releasever=' $SRC_DNF_CONF | cut -d '=' -f 2
else
yum version nogroups | grep Installed | cut -d ' ' -f 2 | cut -d '/' -f 1
dnf version nogroups | grep Installed | cut -d ' ' -f 2 | cut -d '/' -f 1
fi
}
#
# Get the value of the $basearch variable.
#
# Just use yum to query the host environment (Docker) as we don't support
# Just use dnf to query the host environment (Docker) as we don't support
# cross compiling.
#
get_arch () {
yum version nogroups | grep Installed | cut -d ' ' -f 2 | cut -d '/' -f 2
dnf version nogroups | grep Installed | cut -d ' ' -f 2 | cut -d '/' -f 2
}
@ -126,60 +126,60 @@ get_arch () {
# Global variables we will use later.
#
CENGN_REPOS_DIR="$TEMP_DIR/yum.repos.d"
CENGN_YUM_CONF="$TEMP_DIR/yum.conf"
CENGN_YUM_LOG="$TEMP_DIR/yum.log"
CENGN_YUM_CACHDIR="$TEMP_DIR/cache/yum/\$basearch/\$releasever"
CENGN_DNF_CONF="$TEMP_DIR/dnf.conf"
CENGN_DNF_LOG="$TEMP_DIR/dnf.log"
CENGN_DNF_CACHDIR="$TEMP_DIR/cache/dnf/\$basearch/\$releasever"
RELEASEVER=$(get_releasever)
ARCH=$(get_arch)
#
# Copy as yet unmodified yum.conf and yum.repos.d from source to dest.
# Copy as yet unmodified dnf.conf and yum.repos.d from source to dest.
#
echo "\cp -r '$SRC_REPO_DIR' '$CENGN_REPOS_DIR'"
\cp -r "$SRC_REPO_DIR" "$CENGN_REPOS_DIR"
echo "\cp '$SRC_YUM_CONF' '$CENGN_YUM_CONF'"
\cp "$SRC_YUM_CONF" "$CENGN_YUM_CONF"
echo "\cp '$SRC_DNF_CONF' '$CENGN_DNF_CONF'"
\cp "$SRC_DNF_CONF" "$CENGN_DNF_CONF"
#
# Add or modify reposdir= value in our new yum.conf
# Add or modify reposdir= value in our new dnf.conf
#
if grep -q '^reposdir=' $CENGN_YUM_CONF; then
if grep -q '^reposdir=' $CENGN_DNF_CONF; then
# reposdir= already exists, modify it
if [ $RETAIN_REPODIR -eq 1 ]; then
# Append CENGN_REPOS_DIR
sed "s#^reposdir=\(.*\)\$#reposdir=\1 $CENGN_REPOS_DIR#" -i $CENGN_YUM_CONF
sed "s#^reposdir=\(.*\)\$#reposdir=\1 $CENGN_REPOS_DIR#" -i $CENGN_DNF_CONF
else
# replace with CENGN_REPOS_DIR
sed "s#^reposdir=.*\$#reposdir=$CENGN_REPOS_DIR#" -i $CENGN_YUM_CONF
sed "s#^reposdir=.*\$#reposdir=$CENGN_REPOS_DIR#" -i $CENGN_DNF_CONF
fi
else
# reposdir= doeas not yet exist, add it
if [ $RETAIN_REPODIR -eq 1 ]; then
# Add both SRC_REPO_DIR and CENGN_REPOS_DIR
echo "reposdir=$SRC_REPO_DIR $CENGN_REPOS_DIR" >> $CENGN_YUM_CONF
echo "reposdir=$SRC_REPO_DIR $CENGN_REPOS_DIR" >> $CENGN_DNF_CONF
else
# Add CENGN_REPOS_DIR only
echo "reposdir=$CENGN_REPOS_DIR" >> $CENGN_YUM_CONF
echo "reposdir=$CENGN_REPOS_DIR" >> $CENGN_DNF_CONF
fi
fi
#
# modify or add logfile= value in our new yum.conf
# modify or add logfile= value in our new dnf.conf
#
if grep -q '^logfile=' $CENGN_YUM_CONF; then
sed "s#^logfile=.*\$#logfile=$CENGN_YUM_LOG#" -i $CENGN_YUM_CONF
if grep -q '^logfile=' $CENGN_DNF_CONF; then
sed "s#^logfile=.*\$#logfile=$CENGN_DNF_LOG#" -i $CENGN_DNF_CONF
else
echo "logfile=$CENGN_YUM_LOG" >> $CENGN_YUM_CONF
echo "logfile=$CENGN_DNF_LOG" >> $CENGN_DNF_CONF
fi
#
# modify or add cachedir= value in our new yum.conf
# modify or add cachedir= value in our new dnf.conf
#
if grep -q '^cachedir=' $CENGN_YUM_CONF; then
sed "s#^cachedir=.*\$#cachedir=$CENGN_YUM_CACHDIR#" -i $CENGN_YUM_CONF
if grep -q '^cachedir=' $CENGN_DNF_CONF; then
sed "s#^cachedir=.*\$#cachedir=$CENGN_DNF_CACHDIR#" -i $CENGN_DNF_CONF
else
echo "cachedir=$CENGN_YUM_CACHDIR" >> $CENGN_YUM_CONF
echo "cachedir=$CENGN_DNF_CACHDIR" >> $CENGN_DNF_CONF
fi

View File

@ -11,7 +11,7 @@
# We can find this problems in an early stage without the need to
# download all the packages.
#
# The yum cache contains this information, more specific the primary_db
# The dnf cache contains this information, more specific the primary_db
# files, so iterating over the content of .lst, parse the name of the
# package and get the information on what is available to download
# should be enough to know the status of the mirror.
@ -43,10 +43,10 @@ extra_opts=""
usage() {
echo "$0 [-c <yum.conf>]"
echo "$0 [-c <dnf.conf>]"
echo ""
echo "Options:"
echo " -c: Use an alternate yum.conf rather than the system file (option passed"
echo " -c: Use an alternate dnf.conf rather than the system file (option passed"
echo " on to subscripts when appropriate)"
echo ""
}
@ -127,9 +127,9 @@ while getopts "c:" opt; do
esac
done
info "Getting yum cache"
if ! yum $extra_opts ${RELEASEVER} makecache; then
error "There was a problem getting yum cache"
info "Getting dnf cache"
if ! dnf $extra_opts ${RELEASEVER} makecache; then
error "There was a problem getting dnf cache"
exit 1
fi

View File

@ -23,11 +23,11 @@
#
LOGFILE="/export/log/repo_update.log"
YUM_CONF_DIR="/export/config"
# YUM_CONF_DIR="/tmp/config"
YUM_CONF="$YUM_CONF_DIR/yum.conf"
YUM_REPOS_DIR="$YUM_CONF_DIR/yum.repos.d"
GPG_KEYS_DIR="$YUM_CONF_DIR/rpm-gpg-keys"
DNF_CONF_DIR="/export/config"
# DNF_CONF_DIR="/tmp/config"
DNF_CONF="$DNF_CONF_DIR/dnf.conf"
DNF_REPOS_DIR="$DNF_CONF_DIR/dnf.repos.d"
GPG_KEYS_DIR="$DNF_CONF_DIR/rpm-gpg-keys"
DOWNLOAD_PATH_ROOT=/export/mirror/centos
STX_TOOLS_BRANCH="master"
STX_TOOLS_BRANCH_ROOT_DIR="$HOME/stx-tools"
@ -90,8 +90,8 @@ done
STX_TOOLS_DL_ROOT_DIR="$STX_TOOLS_BRANCH_ROOT_DIR/$STX_TOOLS_BRANCH"
STX_TOOLS_DL_DIR="$STX_TOOLS_DL_ROOT_DIR/stx-tools"
UPSTREAM_YUM_REPOS_DIR="$STX_TOOLS_DL_DIR/$STX_TOOLS_OS_SUBDIR/yum.repos.d"
UPSTREAM_YUM_CONF="$STX_TOOLS_DL_DIR/$STX_TOOLS_OS_SUBDIR/yum.conf.sample"
UPSTREAM_DNF_REPOS_DIR="$STX_TOOLS_DL_DIR/$STX_TOOLS_OS_SUBDIR/yum.repos.d"
UPSTREAM_DNF_CONF="$STX_TOOLS_DL_DIR/$STX_TOOLS_OS_SUBDIR/dnf.conf.sample"
UPSTREAM_GPG_KEYS_DIR="$STX_TOOLS_DL_DIR/$STX_TOOLS_OS_SUBDIR/rpm-gpg-keys"
@ -125,18 +125,18 @@ update_gpg_keys () {
}
get_repo_url () {
local YUM_CONF="$1"
local DNF_CONF="$1"
local REPO_ID="$2"
local URL=""
URL=$(cd $(dirname $YUM_CONF);
yum repoinfo --config="$(basename $YUM_CONF)" --disablerepo="*" --enablerepo="$REPO_ID" | \
URL=$(cd $(dirname $DNF_CONF);
dnf repoinfo --config="$(basename $DNF_CONF)" --disablerepo="*" --enablerepo="$REPO_ID" | \
grep Repo-baseurl | \
cut -d ' ' -f 3;
exit ${PIPESTATUS[0]}
)
if [ $? != 0 ]; then
>&2 echo "ERROR: yum repoinfo --config='$YUM_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
>&2 echo "ERROR: dnf repoinfo --config='$DNF_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
return 1
fi
@ -145,18 +145,18 @@ get_repo_url () {
}
get_repo_name () {
local YUM_CONF="$1"
local DNF_CONF="$1"
local REPO_ID="$2"
local NAME=""
NAME=$(cd $(dirname $YUM_CONF);
yum repoinfo --config="$(basename $YUM_CONF)" --disablerepo="*" --enablerepo="$REPO_ID" | \
NAME=$(cd $(dirname $DNF_CONF);
dnf repoinfo --config="$(basename $DNF_CONF)" --disablerepo="*" --enablerepo="$REPO_ID" | \
grep Repo-name | \
cut -d ' ' -f 3;
exit ${PIPESTATUS[0]}
)
if [ $? != 0 ]; then
>&2 echo "ERROR: yum repoinfo --config='$YUM_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
>&2 echo "ERROR: dnf repoinfo --config='$DNF_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
return 1
fi
@ -166,14 +166,14 @@ get_repo_name () {
archive_repo_id () {
local REPO_ID="$1"
local YUM_CONF="$2"
local DNF_CONF="$2"
local REPO="$3"
local REPO_NAME=""
local TEMP=""
local EXTRA=""
if [ ! -f "$YUM_CONF" ]; then
>&2 echo "ERROR: invalid file YUM_CONF='$YUM_CONF'"
if [ ! -f "$DNF_CONF" ]; then
>&2 echo "ERROR: invalid file DNF_CONF='$DNF_CONF'"
return 1
fi
@ -182,7 +182,7 @@ archive_repo_id () {
return 1
fi
REPO_NAME=$(get_repo_name "$YUM_CONF" "$REPO_ID")
REPO_NAME=$(get_repo_name "$DNF_CONF" "$REPO_ID")
if [ $? != 0 ]; then
return 1
fi
@ -245,7 +245,7 @@ copy_repo_id () {
return 0
}
update_yum_repos_d () {
update_dnf_repos_d () {
local UPSTREAM_REPO=""
local REPO=""
local UPSTREAM_REPO_ID=""
@ -258,8 +258,8 @@ update_yum_repos_d () {
local DOWNLOAD_PATH=""
local TEMPDIR=""
for UPSTREAM_REPO in $(find $UPSTREAM_YUM_REPOS_DIR -name '*.repo' | sort ); do
REPO=$YUM_REPOS_DIR/$(basename $UPSTREAM_REPO)
for UPSTREAM_REPO in $(find $UPSTREAM_DNF_REPOS_DIR -name '*.repo' | sort ); do
REPO=$DNF_REPOS_DIR/$(basename $UPSTREAM_REPO)
if [ ! -f $REPO ]; then
# New repo file
echo "Copy new repo file '$UPSTREAM_REPO' to '$REPO'"
@ -268,12 +268,12 @@ update_yum_repos_d () {
fi
for UPSTREAM_REPO_ID in $(grep '^[[]' $UPSTREAM_REPO | sed 's#[][]##g'); do
UPSTREAM_REPO_URL=$(get_repo_url "$UPSTREAM_YUM_CONF" "$UPSTREAM_REPO_ID")
UPSTREAM_REPO_URL=$(get_repo_url "$UPSTREAM_DNF_CONF" "$UPSTREAM_REPO_ID")
if [ $? != 0 ]; then
return 1
fi
UPSTREAM_REPO_NAME=$(get_repo_name "$UPSTREAM_YUM_CONF" "$UPSTREAM_REPO_ID")
UPSTREAM_REPO_NAME=$(get_repo_name "$UPSTREAM_DNF_CONF" "$UPSTREAM_REPO_ID")
if [ $? != 0 ]; then
return 1
fi
@ -298,24 +298,24 @@ update_yum_repos_d () {
return 1
fi
# REPO_URL=$(cd $(dirname $YUM_CONF);
# yum repoinfo --config="$(basename $YUM_CONF)" --disablerepo="*" --enablerepo="$REPO_ID" | \
# REPO_URL=$(cd $(dirname $DNF_CONF);
# dnf repoinfo --config="$(basename $DNF_CONF)" --disablerepo="*" --enablerepo="$REPO_ID" | \
# grep Repo-baseurl | \
# cut -d ' ' -f 3;
# exit ${PIPESTATUS[0]})
REPO_URL=$(get_repo_url "$YUM_CONF" "$REPO_ID")
REPO_URL=$(get_repo_url "$DNF_CONF" "$REPO_ID")
if [ $? != 0 ]; then
# >&2 echo "ERROR: yum repoinfo --config='$YUM_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
# >&2 echo "ERROR: dnf repoinfo --config='$DNF_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
return 1
fi
REPO_NAME=$(get_repo_name "$YUM_CONF" "$REPO_ID")
REPO_NAME=$(get_repo_name "$DNF_CONF" "$REPO_ID")
if [ $? != 0 ]; then
# >&2 echo "ERROR: yum repoinfo --config='$YUM_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
# >&2 echo "ERROR: dnf repoinfo --config='$DNF_CONF' --disablerepo='*' --enablerepo='$REPO_ID'"
return 1
fi
REPO_URL=$(yum repoinfo --config="$YUM_CONF" --disablerepo="*" --enablerepo="$REPO_ID" | grep Repo-baseurl | cut -d ' ' -f 3)
REPO_URL=$(dnf repoinfo --config="$DNF_CONF" --disablerepo="*" --enablerepo="$REPO_ID" | grep Repo-baseurl | cut -d ' ' -f 3)
DOWNLOAD_PATH="$DOWNLOAD_PATH_ROOT/$(repo_url_to_sub_path "$REPO_URL")"
# Check critical content is the same
@ -333,7 +333,7 @@ update_yum_repos_d () {
>&2 echo "Warning: Existing download path has changed: file:$UPSTREAM_REPO, id:$UPSTREAM_REPO_ID, path:$UPSTREAM_DOWNLOAD_PATH -> $DOWNLOAD_PATH"
fi
archive_repo_id "$REPO_ID" "$YUM_CONF" "$REPO"
archive_repo_id "$REPO_ID" "$DNF_CONF" "$REPO"
copy_repo_id "$UPSTREAM_REPO_ID" "$UPSTREAM_REPO" "$REPO"
if [ $? != 0 ]; then
>&2 echo "Error: copy_repo_id '$UPSTREAM_REPO_ID' '$UPSTREAM_REPO' '$REPO'"
@ -355,21 +355,21 @@ fi
(
ERR_COUNT=0
mkdir -p "$YUM_CONF_DIR"
mkdir -p "$DNF_CONF_DIR"
if [ $? -ne 0 ]; then
>&2 echo "Error: mkdir -p '$YUM_CONF_DIR'"
>&2 echo "Error: mkdir -p '$DNF_CONF_DIR'"
exit 1
fi
mkdir -p "$YUM_REPOS_DIR"
mkdir -p "$DNF_REPOS_DIR"
if [ $? -ne 0 ]; then
>&2 echo "Error: mkdir -p '$YUM_CONF_DIR'"
>&2 echo "Error: mkdir -p '$DNF_CONF_DIR'"
exit 1
fi
mkdir -p "$GPG_KEYS_DIR"
if [ $? -ne 0 ]; then
>&2 echo "Error: mkdir -p '$YUM_CONF_DIR'"
>&2 echo "Error: mkdir -p '$DNF_CONF_DIR'"
exit 1
fi
@ -379,11 +379,11 @@ if [ $? -ne 0 ]; then
exit 1
fi
if [ ! -f "$YUM_CONF" ]; then
echo "Copy yum.conf: '$UPSTREAM_YUM_CONF' -> '$YUM_CONF'"
cat $UPSTREAM_YUM_CONF | sed "s#=/tmp/#=$YUM_CONF_DIR/#" | \
sed "s#reposdir=yum.repos.d#reposdir=$YUM_CONF_DIR/yum.repos.d#" | \
sed 's#/etc/pki/rpm-gpg/#$GPG_KEYS_DIR/#' >> $YUM_CONF
if [ ! -f "$DNF_CONF" ]; then
echo "Copy dnf.conf: '$UPSTREAM_DNF_CONF' -> '$DNF_CONF'"
cat $UPSTREAM_DNF_CONF | sed "s#=/tmp/#=$DNF_CONF_DIR/#" | \
sed "s#reposdir=yum.repos.d#reposdir=$DNF_CONF_DIR/yum.repos.d#" | \
sed 's#/etc/pki/rpm-gpg/#$GPG_KEYS_DIR/#' >> $DNF_CONF
fi
update_gpg_keys
@ -392,9 +392,9 @@ if [ $? -ne 0 ]; then
exit 1
fi
update_yum_repos_d
update_dnf_repos_d
if [ $? -ne 0 ]; then
>&2 echo "Error: Failed in update_yum_repos_d. Can't continue."
>&2 echo "Error: Failed in update_dnf_repos_d. Can't continue."
exit 1
fi

View File

@ -8,22 +8,22 @@ UTILS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
source $UTILS_DIR/url_utils.sh
get_yum_command() {
get_dnf_command() {
local _file=$1
local _level=$2
local rpm_name=""
local arr=( $(split_filename $_file) )
local arch=${arr[3]}
local yumdownloader_extra_opts=""
local dnf_download_extra_opts=""
rpm_name="$(get_rpm_level_name $_file $_level)"
if [ "$arch" == "src" ]; then
yumdownloader_extra_opts="--source"
dnf_download_extra_opts="--source"
else
yumdownloader_extra_opts="--archlist=noarch,x86_64"
dnf_download_extra_opts="--archlist=noarch,x86_64"
fi
echo "yumdownloader -q -C ${YUMCONFOPT} ${RELEASEVER} $yumdownloader_extra_opts $rpm_name"
echo "dnf download -q ${DNFCONFOPT} ${RELEASEVER} $dnf_download_extra_opts $rpm_name"
}
get_wget_command() {
@ -66,9 +66,9 @@ get_url() {
_ret="$(url_to_stx_mirror_url $_ret $distro)"
fi
else
_url_cmd="$(get_yum_command $_name $_level)"
_url_cmd="$(get_dnf_command $_name $_level)"
# When we add --url to the yum download command,
# When we add --url to the dnf download command,
# --archlist is no longer enforced. Multiple
# url's might be returned. So use grep to
# filter urls for the desitered arch.
@ -166,14 +166,14 @@ get_download_cmd() {
local ff="$1"
local _level="$2"
# Decide if the list will be downloaded using yumdownloader or wget
# Decide if the list will be downloaded using dnf download or wget
if [[ $ff != *"#"* ]]; then
rpm_name=$ff
if [ $_level == "K1" ]; then
download_cmd="$(get_wget_command $rpm_name)"
else
# yumdownloader with the appropriate flag for src, noarch or x86_64
download_cmd="${SUDOCMD} $(get_yum_command $rpm_name $_level)"
# dnf download with the appropriate flag for src, noarch or x86_64
download_cmd="${SUDOCMD} $(get_dnf_command $rpm_name $_level)"
fi
else
# Build wget command