livepatch-build-tools: fix misuse of script directory as work directory
PATCH 1/1 livepatch-build-tools: fix misuse of script directory as work directory
It's incorrect to assume that the script directory will always match the directory the script is executed from. Instead cache the directory at the start of script execution in order to be able to get back to it if needed.
--- livepatch-build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
livepatch-build +2 -1
@@ -25,6 +25,7 @@ # script. SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" +WORKDIR="$(readlink -f -- .)" CPUS="$(getconf _NPROCESSORS_ONLN)" DEBUG=n XEN_DEBUG=n
@@ -459,7 +460,7 @@ if [ "${SKIP}" != "build" ]; then fi if [ "${SKIP}" != "diff" ]; then - cd "${SCRIPTDIR}" || die + cd "${WORKDIR}" || die [ -d "$outputarg" ] || die "Output directory does not exist" OUTPUT="$(readlink -f -- "$outputarg")"
base-commit: 0ed8ef88dc300750696a64e89efa3b82502f6dc7
prerequisite-patch-id: 20327fdf775db3903c8067a0642254d67c495806
Signature · 1 line
2.43.0
Quoted 33 lines · Roger Pau Monne
It's incorrect to assume that the script directory will always match the directory the script is executed from. Instead cache the directory at the start of script execution in order to be able to get back to it if needed.
Fixes 629ab8ddb775 ('livepatch-build-tools: do not use readlink -m option')Signed-off-by Roger Pau Monné <[email protected]>--- livepatch-build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)livepatch-build +2
-1@@ -25,6 +25,7 @@ # script. SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" +WORKDIR="$(readlink -f -- .)" CPUS="$(getconf _NPROCESSORS_ONLN)" DEBUG=n XEN_DEBUG=n@@ -459,7 +460,7 @@ if [ "${SKIP}" != "build" ]; then fi if [ "${SKIP}" != "diff" ]; then - cd "${SCRIPTDIR}" || die + cd "${WORKDIR}" || die [ -d "$outputarg" ] || die "Output directory does not exist" OUTPUT="$(readlink -f -- "$outputarg")"
Quoted 5 lines
base-commit:
0ed8ef88dc300750696a64e89efa3b82502f6dc7
prerequisite-patch-id:20327fdf775db3903c8067a0642254d67c495806--
2.43.0
Thanks,
Ross
livepatch-build line 28
Quoted 7 lines · Roger Pau Monne
livepatch-build +1
-0@@ -25,6 +25,7 @@ # script. SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" +WORKDIR="$(readlink -f -- .)"
More for my own education than anything else: Isn't the (standard) pwd utility intended to be the "canonical" way of getting at the current directory? Its -P option (apparently what would be needed to match the -f used above) is also a standard one afaict.
Jan
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Roger Pau Monne
livepatch-build +0
-0@@ -25,6 +25,7 @@ # script.
Quoted 7 lines
livepatch-build line 28
Quoted 2 lines
livepatch-build +1
-0SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))" +WORKDIR="$(readlink -f -- .)"More for my own education than anything else: Isn't the (standard) pwd utility intended to be the "canonical" way of getting at the current directory? Its -P option (apparently what would be needed to match the -f used above) is also a standard one afaict.
Hm, yes, having looked at it pwd -P would also be fine. I've used readlink because that's what is used thorough the script.
Thanks, Roger.