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 <scott.little@windriver.com>
Change-Id: Ib4afdba0260e67f06997c360272f40f28fb11834
This commit is contained in:
Scott Little 2022-07-04 12:56:06 -04:00
parent a206f96446
commit 5f8fc4e7b3
1 changed files with 4 additions and 4 deletions

View File

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