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>
This commit is contained in:
parent
e7f3fee059
commit
bd3164b9e6
|
@ -4,7 +4,7 @@ inherit populate_sdk_base
|
|||
|
||||
TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
|
||||
TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
|
||||
POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_install_complementary populate_sdk; "
|
||||
POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_install_complementary populate_sdk; rootfs_sysroot_relativelinks; "
|
||||
|
||||
inherit gzipnative
|
||||
|
||||
|
@ -617,6 +617,11 @@ rootfs_trim_schemas () {
|
|||
done
|
||||
}
|
||||
|
||||
# Make any absolute links in a sysroot relative
|
||||
rootfs_sysroot_relativelinks () {
|
||||
sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}
|
||||
}
|
||||
|
||||
EXPORT_FUNCTIONS zap_root_password remove_init_link do_rootfs make_zimage_symlink_relative set_image_autologin rootfs_update_timestamp rootfs_no_x_startup
|
||||
|
||||
do_fetch[noexec] = "1"
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Take a sysroot directory and turn all the abolute symlinks and turn them into
|
||||
# relative ones such that the sysroot is usable within another system.
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage is " + sys.argv[0] + "<directory>")
|
||||
sys.exit(1)
|
||||
|
||||
topdir = sys.argv[1]
|
||||
topdir = os.path.abspath(topdir)
|
||||
|
||||
def handlelink(filep, subdir):
|
||||
link = os.readlink(filep)
|
||||
if link[0] != "/":
|
||||
return
|
||||
if link.startswith(topdir):
|
||||
return
|
||||
#print("Replacing %s with %s for %s" % (link, topdir+link, filep))
|
||||
print("Replacing %s with %s for %s" % (link, os.path.relpath(topdir+link, subdir), filep))
|
||||
os.unlink(filep)
|
||||
os.symlink(os.path.relpath(topdir+link, subdir), filep)
|
||||
|
||||
for subdir, dirs, files in os.walk(topdir):
|
||||
for f in files:
|
||||
filep = os.path.join(subdir, f)
|
||||
if os.path.islink(filep):
|
||||
#print("Considering %s" % filep)
|
||||
handlelink(filep, subdir)
|
Loading…
Reference in New Issue