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 @@ -18,6 +18,12 @@ DPKG_INSTALLTION_LOCK_FILE=/tmp/.dpkg_installation.lock
18
18
19
19
URL_PREFIX=$( echo " ${PACKAGE_URL_PREFIX} " | sed -E " s#(//[^/]*/).*#\1#" )
20
20
21
+ if [ $USER != ' root' ] && [ -n $( which sudo) ]; then
22
+ SUDO=sudo
23
+ else
24
+ SUDO=' '
25
+ fi
26
+
21
27
log_err ()
22
28
{
23
29
echo " $1 " >> $LOG_PATH /error.log
@@ -73,7 +79,7 @@ set_reproducible_mirrors()
73
79
74
80
local mirrors=" /etc/apt/sources.list $( find /etc/apt/sources.list.d/ -type f) "
75
81
for mirror in $mirrors ; do
76
- sed -i " $expression " " $mirror "
82
+ $SUDO sed -i " $expression " " $mirror "
77
83
done
78
84
}
79
85
@@ -162,7 +168,7 @@ run_pip_command()
162
168
install=y
163
169
elif [[ " $para " == * .whl ]]; then
164
170
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
166
172
fi
167
173
done
168
174
You can’t perform that action at this time.
0 commit comments