]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
toolchain-shar-relocate.sh: fix the replacing commands
authorChen Qi <Qi.Chen@windriver.com>
Thu, 5 Dec 2024 07:32:06 +0000 (23:32 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 9 Dec 2024 09:17:50 +0000 (09:17 +0000)
There're two cases that the current replacing commands cannot handle well:
1. Files with whitespace in their names
2. Installation path with keyword such as 'script'

This results in installation failure of a buildtools. We can use the following
commands to reproduce the problem.
1. bitbake buildtools-tarball
2. ./tmp/deploy/sdk/x86_64-buildtools-nativesdk-standalone-5.1.sh -d dir-with-keyword-script -y

The error message is like below:

  Setting it up...sed: can't read /PATH/TO/dir-with-keyword-script/sysroots/x86_64-wrlinuxsdk-linux
    /usr/lib/python3.13/site-packages/setuptools/_vendor/jaraco/text/Lorem: No such file or directory
  Failed to replace perl. Relocate script failed. Abort!

The actual file name is /PATH/TO/dir-with-keyword-script/sysroots/x86_64-pokysdk-linux/usr/lib/python3.13
/site-packages/setuptools/_vendor/jaraco/text/Lorem ipsum.txt

Note that the file path matches "script.*text". In fact, if we install the SDK into
some directory containing both 'script' and 'text', all files will be matched. This
is not expected.

This patch fixes the replacing commands by doing the following two things:
1. Use '\n' as the field separator for xargs so that files with white spaces are not splitted.
2. Use awk to match the second filed of the file command's output so that the file
   path does not mess up with the matching process.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/files/toolchain-shar-relocate.sh

index b017714df07743b5bc46c216be5dbefc0be381ee..69ea063c8ce0a87931fc43e7d004cd21bda9b4c0 100644 (file)
@@ -57,8 +57,8 @@ fi
 # replace the host perl with SDK perl.
 for replace in "$target_sdk_dir -maxdepth 1" "$native_sysroot"; do
        $SUDO_EXEC find $replace -type f
-done | xargs -n100 file | grep ":.*\(ASCII\|script\|source\).*text" | \
-    awk -F': ' '{printf "\"%s\"\n", $1}' | \
+done | xargs -d '\n' -n100 file | \
+    awk -F': ' '{if (match($2, ".*(ASCII|script|source).*text")) {printf "\"%s\"\n", $1}}' | \
     grep -Fv -e "$target_sdk_dir/environment-setup-" \
              -e "$target_sdk_dir/relocate_sdk" \
              -e "$target_sdk_dir/post-relocate-setup" \