[build] Add environment when using dpkg hook to avoid lock loop. (#13233)
Why I did it In some cases, dpkg will call dpkg to validate version. dpkg hook will get stuck in a loop to lock. How I did it How to verify it
This commit is contained in:
parent
33bf592f09
commit
933bf06058
8
src/sonic-build-hooks/hooks/dpkg
Normal file → Executable file
8
src/sonic-build-hooks/hooks/dpkg
Normal file → Executable file
@ -3,8 +3,16 @@
|
||||
. /usr/local/share/buildinfo/scripts/buildinfo_base.sh
|
||||
REAL_COMMAND=$(get_command dpkg)
|
||||
COMMAND_INFO="Locked by command: $REAL_COMMAND $@"
|
||||
NEED_RELEASE_LOCK=n
|
||||
if [[ "$DPKG_HOOK_LOCKED" != "y" ]];then
|
||||
lock_result=$(acquire_apt_installation_lock "$COMMAND_INFO" )
|
||||
export DPKG_HOOK_LOCKED=y
|
||||
NEED_RELEASE_LOCK=y
|
||||
fi
|
||||
$REAL_COMMAND "$@"
|
||||
command_result=$?
|
||||
if [[ "$NEED_RELEASE_LOCK" == "y" ]];then
|
||||
unset DPKG_HOOK_LOCKED
|
||||
fi
|
||||
[ "$lock_result" == y ] && release_apt_installation_lock
|
||||
exit $command_result
|
||||
|
Reference in New Issue
Block a user