]> code.ossystems Code Review - openembedded-core.git/commitdiff
relocate_sdk.py: remove hardcoded SDK path
authorRuslan Bilovol <rbilovol@cisco.com>
Wed, 22 Nov 2017 11:20:05 +0000 (13:20 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 24 Jul 2018 10:52:07 +0000 (11:52 +0100)
This patch removes hardcodes added to relocate_sdk.py
during SDK build, making it flexible and reusable.
Now default SDK path is passed to the script as
parameter rather then harcoded inside it.

This allows to reuse this script for multiple
relocations, and adds possibility to relocate
SDK multiple times

Signed-off-by: Ruslan Bilovol <rbilovol@cisco.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/populate_sdk_base.bbclass
meta/files/toolchain-shar-relocate.sh
scripts/relocate_sdk.py

index 7ffaf84a45d4cf49e1e6575b318510dd0077cddd..e27ee036a24aae71b8ca8572df978bbaad67737d 100644 (file)
@@ -161,11 +161,6 @@ do_populate_sdk[stamp-extra-info] = "${MACHINE_ARCH}${SDKMACHINE}"
 
 fakeroot create_sdk_files() {
        cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/
-
-       # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern.
-       # Escape special characters like '+' and '.' in the SDKPATH
-       escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
-       sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
 }
 
 python check_sdk_sysroots() {
index e3c10018ef12964d27957c38830c428a83c83fca..f82ff2be48cd8431e049c9ce735a42c3dc7d7bfa 100644 (file)
@@ -36,7 +36,7 @@ if [ x\${PYTHON} = "x"  ]; then
        echo "SDK could not be relocated.  No python found."
        exit 1
 fi
-\${PYTHON} ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files
+\${PYTHON} ${env_setup_script%/*}/relocate_sdk.py $DEFAULT_INSTALL_DIR $target_sdk_dir $dl_path $executable_files
 EOF
 
 $SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh
index c752fa2c6192c9246dce89bf5c68244d54482e9a..0d5a6f5161c2e3fa14d63f514fb694053c3c0be8 100755 (executable)
@@ -38,8 +38,6 @@ else:
     def b(x):
         return x.encode(sys.getfilesystemencoding())
 
-old_prefix = re.compile(b("##DEFAULT_INSTALL_DIR##"))
-
 def get_arch():
     f.seek(0)
     e_ident =f.read(16)
@@ -212,19 +210,22 @@ def change_dl_sysdirs(elf_file_name):
         f.write(sysdirslen)
 
 # MAIN
-if len(sys.argv) < 4:
+if len(sys.argv) < 5:
     sys.exit(-1)
 
 # In python > 3, strings may also contain Unicode characters. So, convert
 # them to bytes
 if sys.version_info < (3,):
-    new_prefix = sys.argv[1]
-    new_dl_path = sys.argv[2]
+    new_prefix = sys.argv[2]
+    new_dl_path = sys.argv[3]
 else:
-    new_prefix = sys.argv[1].encode()
-    new_dl_path = sys.argv[2].encode()
+    new_prefix = sys.argv[2].encode()
+    new_dl_path = sys.argv[3].encode()
+
+executables_list = sys.argv[4:]
 
-executables_list = sys.argv[3:]
+old_prefix_ne = b(sys.argv[1])
+old_prefix = re.compile(re.escape(old_prefix_ne));
 
 for e in executables_list:
     perms = os.stat(e)[stat.ST_MODE]