Skip to content

Commit c49206a

Browse files
liushilongbuaaqiluo-msft
authored andcommitted
Fix docker-sonic-mgmt reproducible related issue. (#9647)
Reproducible build script breaks docker-sonic-mgmt build.
1 parent 9de6b2c commit c49206a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ DPKG_INSTALLTION_LOCK_FILE=/tmp/.dpkg_installation.lock
1818

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

21+
if [ $USER != 'root' ] && [ -n $(which sudo) ];then
22+
SUDO=sudo
23+
else
24+
SUDO=''
25+
fi
26+
2127
log_err()
2228
{
2329
echo "$1" >> $LOG_PATH/error.log
@@ -73,7 +79,7 @@ set_reproducible_mirrors()
7379

7480
local mirrors="/etc/apt/sources.list $(find /etc/apt/sources.list.d/ -type f)"
7581
for mirror in $mirrors; do
76-
sed -i "$expression" "$mirror"
82+
$SUDO sed -i "$expression" "$mirror"
7783
done
7884
}
7985

@@ -162,7 +168,7 @@ run_pip_command()
162168
install=y
163169
elif [[ "$para" == *.whl ]]; then
164170
package_name=$(echo $para | cut -d- -f1 | tr _ .)
165-
sed "/^${package_name}==/d" -i $tmp_version_file
171+
$SUDO sed "/^${package_name}==/d" -i $tmp_version_file
166172
fi
167173
done
168174

0 commit comments

Comments
 (0)