From ef16128ce8b0eab60f96f9f90732a4362651b2d9 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Wed, 13 Jan 2021 18:40:39 +0800 Subject: [PATCH] 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 --- src/sonic-build-hooks/scripts/buildinfo_base.sh | 7 ++++++- src/sonic-build-hooks/scripts/symlink_build_hooks | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sonic-build-hooks/scripts/buildinfo_base.sh b/src/sonic-build-hooks/scripts/buildinfo_base.sh index d19558c544..94b7678614 100755 --- a/src/sonic-build-hooks/scripts/buildinfo_base.sh +++ b/src/sonic-build-hooks/scripts/buildinfo_base.sh @@ -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 diff --git a/src/sonic-build-hooks/scripts/symlink_build_hooks b/src/sonic-build-hooks/scripts/symlink_build_hooks index 7218575ee9..2ce5ec2772 100755 --- a/src/sonic-build-hooks/scripts/symlink_build_hooks +++ b/src/sonic-build-hooks/scripts/symlink_build_hooks @@ -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()