Fix py3 version changed even version control enabled issue (#6422)

* Fix py3 version changed even version control enabled issue

* Add some comments and simplify the script

* Add the comment to explain how to get the not hooked command
This commit is contained in:
xumia 2021-01-13 18:40:39 +08:00 committed by GitHub
parent 674fac21c1
commit 1dcab4d1e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -22,15 +22,20 @@ log_err()
echo "$1" 1>&2
}
# Get the real command not hooked by sonic-build-hook package
get_command()
{
local path=$(echo $PATH | sed 's#[^:]*buildinfo/scripts:##' | sed "s#/usr/sbin:##")
# Change the PATH env to get the real command by excluding the command in the hooked folders
local path=$(echo $PATH | sed 's#[^:]*buildinfo/scripts:##' | sed "s#/usr/local/sbin:##")
local command=$(PATH=$path which $1)
echo $command
}
check_version_control()
{
# The env variable SONIC_VERSION_CONTROL_COMPONENTS examples:
# all -- match all components
# py2,py3,deb -- match py2, py3 and deb only
if [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,all,* ]] || [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,$1,* ]]; then
echo "y"
else

View File

@ -1,7 +1,7 @@
#!/bin/bash
HOOK_PATH=/usr/local/share/buildinfo/hooks
TARGET_PATH=/usr/sbin
TARGET_PATH=/usr/local/sbin
FILES=$(ls $HOOK_PATH)
usage()