diff options
author | Andrey Mozzhuhin <amozzhuhin@yandex.ru> | 2021-01-16 11:18:41 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-01-27 09:32:45 +0000 |
commit | a4d614791ba9b7e98e4b7a67657fadf82b88a345 (patch) | |
tree | 13698fcf214869d3c2251a9d5022d60b9bacd3f8 /meta/files/toolchain-shar-extract.sh | |
parent | f643bfd10eafbc7bcbd7b453b6c7c5b99c20ca8e (diff) | |
download | poky-a4d614791ba9b7e98e4b7a67657fadf82b88a345.tar.gz |
toolchain-shar-extract.sh: Handle special characters in script path
Extracting SDK archive may fail if the script is run using a path with
special characters such as space or asterisk. This is because the shell
interprets such characters after expanding the $0 variable.
Added quotes to all uses of the shell variable $0 to fix this.
(From OE-Core rev: 7d17f261347366a8723691a4a2cb77a1d5992d69)
Signed-off-by: Andrey Mozzhuhin <amozzhuhin@yandex.ru>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 0453acbbd45604537090ec7a3295b34309e6eecb)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/files/toolchain-shar-extract.sh')
-rw-r--r-- | meta/files/toolchain-shar-extract.sh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/meta/files/toolchain-shar-extract.sh b/meta/files/toolchain-shar-extract.sh index bea6d4189a..dd9342758b 100644 --- a/meta/files/toolchain-shar-extract.sh +++ b/meta/files/toolchain-shar-extract.sh | |||
@@ -95,7 +95,7 @@ while getopts ":yd:npDRSl" OPT; do | |||
95 | listcontents=1 | 95 | listcontents=1 |
96 | ;; | 96 | ;; |
97 | *) | 97 | *) |
98 | echo "Usage: $(basename $0) [-y] [-d <dir>]" | 98 | echo "Usage: $(basename "$0") [-y] [-d <dir>]" |
99 | echo " -y Automatic yes to all prompts" | 99 | echo " -y Automatic yes to all prompts" |
100 | echo " -d <dir> Install the SDK to <dir>" | 100 | echo " -d <dir> Install the SDK to <dir>" |
101 | echo "======== Extensible SDK only options ============" | 101 | echo "======== Extensible SDK only options ============" |
@@ -111,17 +111,17 @@ while getopts ":yd:npDRSl" OPT; do | |||
111 | esac | 111 | esac |
112 | done | 112 | done |
113 | 113 | ||
114 | payload_offset=$(($(grep -na -m1 "^MARKER:$" $0|cut -d':' -f1) + 1)) | 114 | payload_offset=$(($(grep -na -m1 "^MARKER:$" "$0"|cut -d':' -f1) + 1)) |
115 | if [ "$listcontents" = "1" ] ; then | 115 | if [ "$listcontents" = "1" ] ; then |
116 | if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then | 116 | if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then |
117 | tail -n +$payload_offset $0 > sdk.zip | 117 | tail -n +$payload_offset "$0" > sdk.zip |
118 | if unzip -l sdk.zip;then | 118 | if unzip -l sdk.zip;then |
119 | rm sdk.zip | 119 | rm sdk.zip |
120 | else | 120 | else |
121 | rm sdk.zip && exit 1 | 121 | rm sdk.zip && exit 1 |
122 | fi | 122 | fi |
123 | else | 123 | else |
124 | tail -n +$payload_offset $0| tar tvJ || exit 1 | 124 | tail -n +$payload_offset "$0"| tar tvJ || exit 1 |
125 | fi | 125 | fi |
126 | exit | 126 | exit |
127 | fi | 127 | fi |
@@ -242,14 +242,14 @@ fi | |||
242 | 242 | ||
243 | printf "Extracting SDK..." | 243 | printf "Extracting SDK..." |
244 | if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then | 244 | if [ @SDK_ARCHIVE_TYPE@ = "zip" ]; then |
245 | tail -n +$payload_offset $0 > sdk.zip | 245 | tail -n +$payload_offset "$0" > sdk.zip |
246 | if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then | 246 | if $SUDO_EXEC unzip $EXTRA_TAR_OPTIONS sdk.zip -d $target_sdk_dir;then |
247 | rm sdk.zip | 247 | rm sdk.zip |
248 | else | 248 | else |
249 | rm sdk.zip && exit 1 | 249 | rm sdk.zip && exit 1 |
250 | fi | 250 | fi |
251 | else | 251 | else |
252 | tail -n +$payload_offset $0| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 | 252 | tail -n +$payload_offset "$0"| $SUDO_EXEC tar mxJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1 |
253 | fi | 253 | fi |
254 | echo "done" | 254 | echo "done" |
255 | 255 | ||