Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix docker-sonic-mgmt reproducible related issue. #9647

Merged
merged 2 commits into from
Jan 5, 2022
Merged
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
10 changes: 8 additions & 2 deletions src/sonic-build-hooks/scripts/buildinfo_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/debian'

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

if [ $USER != 'root' ] && [ -n $(which sudo) ];then
SUDO=sudo
else
SUDO=''
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified to
[ $USER != 'root' ] && [ -n $(which sudo) ] && SUDO=sudo


log_err()
{
echo "$1" >> $LOG_PATH/error.log
Expand Down Expand Up @@ -72,7 +78,7 @@ set_reproducible_mirrors()

local mirrors="/etc/apt/sources.list $(find /etc/apt/sources.list.d/ -type f)"
for mirror in $mirrors; do
sed -i "$expression" "$mirror"
$SUDO sed -i "$expression" "$mirror"
done
}

Expand Down Expand Up @@ -161,7 +167,7 @@ run_pip_command()
install=y
elif [[ "$para" == *.whl ]]; then
package_name=$(echo $para | cut -d- -f1 | tr _ .)
sed "/^${package_name}==/d" -i $tmp_version_file
$SUDO sed "/^${package_name}==/d" -i $tmp_version_file
fi
done

Expand Down