diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-09-11 10:42:44 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-09-11 11:05:05 +0100 |
commit | bd3164b9e65a96b2aac1061365597442eac5559c (patch) | |
tree | 858604e5e525d02c96981a03337c0953b1b777ce | |
parent | e7f3fee059472cfce383b6fb44bed8190037a3c0 (diff) | |
download | poky-bd3164b9e65a96b2aac1061365597442eac5559c.tar.gz |
image/populate_sdk: Ensure symlinks in target sysroot are relative
In the target sysroot of an SDK we can have target system absolute links
which don't make sense. This adds a script which fixes them up to become relative
paths instead.
[YOCTO #5020]
(From OE-Core rev: 57d6bdcad55c119e9ab8089d23d462436a0e4440)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/image.bbclass | 7 | ||||
-rwxr-xr-x | scripts/sysroot-relativelinks.py | 31 |
2 files changed, 37 insertions, 1 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 4a0946c8e3..f1e62f1454 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass | |||
@@ -4,7 +4,7 @@ inherit populate_sdk_base | |||
4 | 4 | ||
5 | TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}" | 5 | TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}" |
6 | TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}" | 6 | TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}" |
7 | POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_install_complementary populate_sdk; " | 7 | POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_install_complementary populate_sdk; rootfs_sysroot_relativelinks; " |
8 | 8 | ||
9 | inherit gzipnative | 9 | inherit gzipnative |
10 | 10 | ||
@@ -617,6 +617,11 @@ rootfs_trim_schemas () { | |||
617 | done | 617 | done |
618 | } | 618 | } |
619 | 619 | ||
620 | # Make any absolute links in a sysroot relative | ||
621 | rootfs_sysroot_relativelinks () { | ||
622 | sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT} | ||
623 | } | ||
624 | |||
620 | EXPORT_FUNCTIONS zap_root_password remove_init_link do_rootfs make_zimage_symlink_relative set_image_autologin rootfs_update_timestamp rootfs_no_x_startup | 625 | EXPORT_FUNCTIONS zap_root_password remove_init_link do_rootfs make_zimage_symlink_relative set_image_autologin rootfs_update_timestamp rootfs_no_x_startup |
621 | 626 | ||
622 | do_fetch[noexec] = "1" | 627 | do_fetch[noexec] = "1" |
diff --git a/scripts/sysroot-relativelinks.py b/scripts/sysroot-relativelinks.py new file mode 100755 index 0000000000..ac26367e77 --- /dev/null +++ b/scripts/sysroot-relativelinks.py | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/usr/bin/env python | ||
2 | import sys | ||
3 | import os | ||
4 | |||
5 | # Take a sysroot directory and turn all the abolute symlinks and turn them into | ||
6 | # relative ones such that the sysroot is usable within another system. | ||
7 | |||
8 | if len(sys.argv) != 2: | ||
9 | print("Usage is " + sys.argv[0] + "<directory>") | ||
10 | sys.exit(1) | ||
11 | |||
12 | topdir = sys.argv[1] | ||
13 | topdir = os.path.abspath(topdir) | ||
14 | |||
15 | def handlelink(filep, subdir): | ||
16 | link = os.readlink(filep) | ||
17 | if link[0] != "/": | ||
18 | return | ||
19 | if link.startswith(topdir): | ||
20 | return | ||
21 | #print("Replacing %s with %s for %s" % (link, topdir+link, filep)) | ||
22 | print("Replacing %s with %s for %s" % (link, os.path.relpath(topdir+link, subdir), filep)) | ||
23 | os.unlink(filep) | ||
24 | os.symlink(os.path.relpath(topdir+link, subdir), filep) | ||
25 | |||
26 | for subdir, dirs, files in os.walk(topdir): | ||
27 | for f in files: | ||
28 | filep = os.path.join(subdir, f) | ||
29 | if os.path.islink(filep): | ||
30 | #print("Considering %s" % filep) | ||
31 | handlelink(filep, subdir) | ||