diff --git a/src/sonic-build-hooks/hooks/apt-get b/src/sonic-build-hooks/hooks/apt-get index db75ddf5c4..58563ce36b 100755 --- a/src/sonic-build-hooks/hooks/apt-get +++ b/src/sonic-build-hooks/hooks/apt-get @@ -20,7 +20,7 @@ if [ "$INSTALL" == y ]; then [ "$lock_result" == y ] && release_apt_installation_lock exit $command_result else - if [[ "$1" == "purge" || "$@" == *" purge "* || "$@" == *" remove "* ]]; then + if [[ " $@ " == *" purge "* || " $@ " == *" remove "* ]]; then # When running the purge command, collect the debian versions dpkg-query -W -f '${Package}==${Version}\n' >> $POST_VERSION_PATH/purge-versions-deb chmod a+wr $POST_VERSION_PATH/purge-versions-deb