From 5f8fc4e7b3e0fea7bc1e7918a2b914fd153e7baf Mon Sep 17 00:00:00 2001 From: Scott Little Date: Mon, 4 Jul 2022 12:56:06 -0400 Subject: [PATCH] Fix download_mirror.sh without -n download_mirror.sh fails when run without '-n'. It seems that some functions were relocated to utils.sh that require the 'SUDO' variable to be defined. Those common utilities are called from both download_mirror.sh and dl_rpms.sh. download_mirror.sh sets it correctly, but dl_rpms.sh does not. Instead dl_rpms.sh is setting 'SUDOCMD', which the utils.sh ignores. The result is that some yum commands are runs under sudo, while others are not. Eventually yumdownloader failes with ... Permission denied: '/var/lib/rpm/.dbenv.lock' The fix is to convert dl_rpms.sh to use SUDO rather than SUDOCMD. Closes-Bug: 1980684 Signed-off-by: Scott Little Change-Id: Ib4afdba0260e67f06997c360272f40f28fb11834 --- centos-mirror-tools/dl_rpms.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/centos-mirror-tools/dl_rpms.sh b/centos-mirror-tools/dl_rpms.sh index f6672951..2637baa6 100755 --- a/centos-mirror-tools/dl_rpms.sh +++ b/centos-mirror-tools/dl_rpms.sh @@ -11,7 +11,7 @@ # By default, we use "sudo" and we don't use a local yum.conf. These can # be overridden via flags. -SUDOCMD="sudo -E" +SUDO="sudo -E" RELEASEVER="--releasever=7" YUMCONFOPT="" @@ -84,7 +84,7 @@ while getopts "c:nxD:sSuUh" o; do case "${o}" in n) # No-sudo - SUDOCMD="" + SUDO="" ;; x) # Clean only @@ -425,8 +425,8 @@ init_dl_env # Prime the cache loop_count=0 max_loop_count=5 -echo "${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache" -while ! ${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache fast ; do +echo "${SUDO} yum ${YUMCONFOPT} ${RELEASEVER} makecache" +while ! ${SUDO} yum ${YUMCONFOPT} ${RELEASEVER} makecache fast ; 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.