Skip to contentSkip to conversation

meta: toolchain-shar-relocate.sh: Do not use $target_sdk_dir as regex

PATCH New Marek Vasut 1 participant 2 messages Dec 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 meta: toolchain-shar-relocate.sh: Do not use $target_sdk_dir as regex

The $target_sdk_dir path might contain special characters, for example if the path is /opt/poky/3.2+snapshot . Prevent grep from interpreting those as part of the regex by using the -F parameter and multiple -e parameters to specify which strings to filter out. Also note that the previous regex was using asterisk as wildcard (e.g. environment-setup-*), but that should have been regex (e.g. environment-setup-.*, with dot) to match correctly, this is also fixed by this change.

Fixes 9721378688 ("toolchain-shar-template.sh: Make relocation optional.")
Cc Joshua Watt <[email protected]>
Cc Krzysztof Zawadzki <[email protected]>
Cc Randy Witt <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Ross Burton <[email protected]>
---
 meta/files/toolchain-shar-relocate.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/files/toolchain-shar-relocate.sh +3 -1
index e3c10018ef..9c358a53e2 100644
@@ -56,7 +56,9 @@ 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}' | \
-    grep -Ev "$target_sdk_dir/(environment-setup-*|relocate_sdk*|${0##*/})" | \
+    grep -Fv -e "$target_sdk_dir/environment-setup-" \
+             -e "$target_sdk_dir/relocate_sdk" \
+             -e "$target_sdk_dir/${0##*/}" | \
     xargs -n100 $SUDO_EXEC sed -i \
         -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" \
         -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" \
Signature · 1 line
2.29.2
#1 lore raw

PATCH 2/2 meta: toolchain-shar-relocate.sh: Filter out post-relocate-setup script

The toolchain-shar-extract.sh script updates the SDK relocation paths in post-relocate-setup.sh, so avoid doing this twice. This is generally not a problem, unless the SDK path is a subset of the SDK relocation path, in which case the resulting path is substituted twice. To trigger the issue,

  $ ./tmp/deploy/sdk/poky-glibc-x86_64-core-image-base-core2-64-qemux86-64-toolchain-3.2+snapshot.sh -y -d /home/oe/.local/opt/poky/3.2+snapshot
which generates relocation path
  /home/oe/.local/home/oe/.local/opt/poky/3.2+snapshot
instead of
  /home/oe/.local/opt/poky/3.2+snapshot
Fixes 93ec145f42 ("toolchain-shar-extract: Add post-relocate scripts")
Cc Joshua Watt <[email protected]>
Cc Krzysztof Zawadzki <[email protected]>
Cc Randy Witt <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Ross Burton <[email protected]>
---
 meta/files/toolchain-shar-relocate.sh | 1 +
 1 file changed, 1 insertion(+)
meta/files/toolchain-shar-relocate.sh +1 -0
index 9c358a53e2..94d288ce05 100644
@@ -58,6 +58,7 @@ done | xargs -n100 file | grep ":.*\(ASCII\|script\|source\).*text" | \
     awk -F':' '{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" \
              -e "$target_sdk_dir/${0##*/}" | \
     xargs -n100 $SUDO_EXEC sed -i \
         -e "s:$DEFAULT_INSTALL_DIR:$target_sdk_dir:g" \
Signature · 1 line
2.29.2