Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sonic-slave-* build errors about sudo command not found #13412

Merged
merged 4 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/run_with_retry
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

run_with_retry(){
[ "$SONIC_BUILD_RETRY_COUNT" -gt 0 ] || SONIC_BUILD_RETRY_COUNT=0
# set default value and change invalid param input to 0
(( SONIC_BUILD_RETRY_COUNT > 0 )) || SONIC_BUILD_RETRY_COUNT=0
liushilongbuaa marked this conversation as resolved.
Show resolved Hide resolved
(( SONIC_BUILD_RETRY_INTERVAL > 0 )) || SONIC_BUILD_RETRY_INTERVAL=600
[[ "$*" == "" ]] && { echo "run_with_retry: input command can't be empty." 1>&2;exit 1; }
for ((i=0; i<=$SONIC_BUILD_RETRY_COUNT; i++))
do
Expand Down
17 changes: 9 additions & 8 deletions src/sonic-build-hooks/scripts/buildinfo_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/'
DPKG_INSTALLTION_LOCK_FILE=/tmp/.dpkg_installation.lock

. $BUILDINFO_PATH/config/buildinfo.config

if [ "$(whoami)" != "root" ] && [ -n "$(which sudo)" ];then
SUDO=sudo
else
SUDO=''
fi

if [ -e /vcache ]; then
PKG_CACHE_PATH=/vcache/${IMAGENAME}
else
PKG_CACHE_PATH=/sonic/target/vcache/${IMAGENAME}
fi
PKG_CACHE_FILE_NAME=${PKG_CACHE_PATH}/cache.tgz
sudo chown $USER $(dirname $PKG_CACHE_PATH)
mkdir -p ${PKG_CACHE_PATH}
$SUDO mkdir -p ${PKG_CACHE_PATH}
$SUDO chown $USER $PKG_CACHE_PATH

. ${BUILDINFO_PATH}/scripts/utils.sh


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

if [ "$(whoami)" != "root" ] && [ -n "$(which sudo)" ];then
SUDO=sudo
else
SUDO=''
fi

log_err()
{
echo "$(date "+%F-%H-%M-%S") ERR $1" >> $LOG_PATH/error.log
Expand Down