Skip to content

Commit 336f839

Browse files
liushilongbuaabradh352
authored andcommitted
Fix sonic-slave-* build errors about sudo command not found (sonic-net#13412)
issue sonic-net#13395 Fix a bug about sudo failure. /usr/local/share/buildinfo/scripts/buildinfo_base.sh: line 24: sudo: command not found Fix an issue about warning message. ./scripts/run_with_retry: line 4: [: : integer expression expected
1 parent bb8e9ac commit 336f839

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

scripts/run_with_retry

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

33
run_with_retry(){
4-
[ "$SONIC_BUILD_RETRY_COUNT" -gt 0 ] || SONIC_BUILD_RETRY_COUNT=0
4+
# set default value and change invalid param input to 0
5+
(( SONIC_BUILD_RETRY_COUNT > 0 )) || SONIC_BUILD_RETRY_COUNT=0
6+
(( SONIC_BUILD_RETRY_INTERVAL > 0 )) || SONIC_BUILD_RETRY_INTERVAL=600
57
[[ "$*" == "" ]] && { echo "run_with_retry: input command can't be empty." 1>&2;exit 1; }
68
for ((i=0; i<=$SONIC_BUILD_RETRY_COUNT; i++))
79
do

src/sonic-build-hooks/scripts/buildinfo_base.sh

+10-7
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,27 @@ REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/'
1515
DPKG_INSTALLTION_LOCK_FILE=/tmp/.dpkg_installation.lock
1616

1717
. $BUILDINFO_PATH/config/buildinfo.config
18+
19+
if [ "$(whoami)" != "root" ] && [ -n "$(which sudo)" ];then
20+
SUDO=sudo
21+
else
22+
SUDO=''
23+
fi
24+
1825
if [ -e /vcache ]; then
1926
PKG_CACHE_PATH=/vcache/${IMAGENAME}
2027
else
2128
PKG_CACHE_PATH=/sonic/target/vcache/${IMAGENAME}
2229
fi
2330
PKG_CACHE_FILE_NAME=${PKG_CACHE_PATH}/cache.tgz
24-
mkdir -p ${PKG_CACHE_PATH}
31+
$SUDO mkdir -p ${PKG_CACHE_PATH}
32+
$SUDO chown $USER $PKG_CACHE_PATH
2533

34+
. ${BUILDINFO_PATH}/scripts/utils.sh
2635

2736

2837
URL_PREFIX=$(echo "${PACKAGE_URL_PREFIX}" | sed -E "s#(//[^/]*/).*#\1#")
2938

30-
if [ "$(whoami)" != "root" ] && [ -n "$(which sudo)" ];then
31-
SUDO=sudo
32-
else
33-
SUDO=''
34-
fi
35-
3639
log_err()
3740
{
3841
echo "$1" >> $LOG_PATH/error.log

0 commit comments

Comments
 (0)