File tree 1 file changed +8
-2
lines changed
src/sonic-build-hooks/scripts
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/debian'
17
17
18
18
URL_PREFIX=$( echo " ${PACKAGE_URL_PREFIX} " | sed -E " s#(//[^/]*/).*#\1#" )
19
19
20
+ if [ $USER != ' root' ] && [ -n $( which sudo) ]; then
21
+ SUDO=sudo
22
+ else
23
+ SUDO=' '
24
+ fi
25
+
20
26
log_err ()
21
27
{
22
28
echo " $1 " >> $LOG_PATH /error.log
@@ -72,7 +78,7 @@ set_reproducible_mirrors()
72
78
73
79
local mirrors=" /etc/apt/sources.list $( find /etc/apt/sources.list.d/ -type f) "
74
80
for mirror in $mirrors ; do
75
- sed -i " $expression " " $mirror "
81
+ $SUDO sed -i " $expression " " $mirror "
76
82
done
77
83
}
78
84
@@ -161,7 +167,7 @@ run_pip_command()
161
167
install=y
162
168
elif [[ " $para " == * .whl ]]; then
163
169
package_name=$( echo $para | cut -d- -f1 | tr _ .)
164
- sed " /^${package_name} ==/d" -i $tmp_version_file
170
+ $SUDO sed " /^${package_name} ==/d" -i $tmp_version_file
165
171
fi
166
172
done
167
173
You can’t perform that action at this time.
0 commit comments