* [PATCH] image/populate_sdk: Ensure symlinks in target sysroot are relative
@ 2013-09-11 9:42 Richard Purdie
2013-09-12 7:48 ` Hans Beckérus
0 siblings, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2013-09-11 9:42 UTC (permalink / raw)
To: openembedded-core
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]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 4a0946c..f1e62f14 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -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"
diff --git a/scripts/sysroot-relativelinks.py b/scripts/sysroot-relativelinks.py
new file mode 100755
index 0000000..2e13744
--- /dev/null
+++ b/scripts/sysroot-relativelinks.py
@@ -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)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] image/populate_sdk: Ensure symlinks in target sysroot are relative
2013-09-11 9:42 [PATCH] image/populate_sdk: Ensure symlinks in target sysroot are relative Richard Purdie
@ 2013-09-12 7:48 ` Hans Beckérus
2013-09-12 8:02 ` Richard Purdie
0 siblings, 1 reply; 5+ messages in thread
From: Hans Beckérus @ 2013-09-12 7:48 UTC (permalink / raw)
To: Richard Purdie; +Cc: openembedded-core
I have a slight problem with this patch. The new
sysroot-relativelinks.py does not obtain the proper access protection
bits!?
Which results in the following error when packaging the SDK
/home/poky/build/tmp/work/zynq_zc706-poky-linux-gnueabi/rootfs-default/1.0-r0/temp/run.populate_sdk_image.20803:
line 496: /home/poky/scripts/sysroot-relativelinks.py: Permission
denied
[home/poky]: ls -l scripts/sysroot-relativelinks.py
-rw-rw-r-- 1 poky poky 959 Sep 12 09:38 scripts/sysroot-relativelinks.py
The execution bit is missing!?
I can of course apply the execution bit manually, but what may cause
the patch to not set the bits properly in my scripts folder for new
files? Please advise.
Thanks.
Hans
On Wed, Sep 11, 2013 at 11:42 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> 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]
>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 4a0946c..f1e62f14 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -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"
> diff --git a/scripts/sysroot-relativelinks.py b/scripts/sysroot-relativelinks.py
> new file mode 100755
> index 0000000..2e13744
> --- /dev/null
> +++ b/scripts/sysroot-relativelinks.py
> @@ -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)
>
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] image/populate_sdk: Ensure symlinks in target sysroot are relative
2013-09-12 7:48 ` Hans Beckérus
@ 2013-09-12 8:02 ` Richard Purdie
2013-09-12 8:29 ` Hans Beckérus
0 siblings, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2013-09-12 8:02 UTC (permalink / raw)
To: Hans Beckérus; +Cc: openembedded-core
On Thu, 2013-09-12 at 09:48 +0200, Hans Beckérus wrote:
> I have a slight problem with this patch. The new
> sysroot-relativelinks.py does not obtain the proper access protection
> bits!?
> Which results in the following error when packaging the SDK
>
> /home/poky/build/tmp/work/zynq_zc706-poky-linux-gnueabi/rootfs-default/1.0-r0/temp/run.populate_sdk_image.20803:
> line 496: /home/poky/scripts/sysroot-relativelinks.py: Permission
> denied
>
> [home/poky]: ls -l scripts/sysroot-relativelinks.py
> -rw-rw-r-- 1 poky poky 959 Sep 12 09:38 scripts/sysroot-relativelinks.py
>
> The execution bit is missing!?
>
> I can of course apply the execution bit manually, but what may cause
> the patch to not set the bits properly in my scripts folder for new
> files? Please advise.
I checked the poky and oe-core trees and they have a+x:
http://git.yoctoproject.org/cgit.cgi/poky/tree/scripts
http://git.openembedded.org/openembedded-core/tree/scripts
so I'm a bit puzzled. How did you update your tree?
Cheers,
Richard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] image/populate_sdk: Ensure symlinks in target sysroot are relative
2013-09-12 8:02 ` Richard Purdie
@ 2013-09-12 8:29 ` Hans Beckérus
2013-09-12 14:54 ` Hans Beckérus
0 siblings, 1 reply; 5+ messages in thread
From: Hans Beckérus @ 2013-09-12 8:29 UTC (permalink / raw)
To: Richard Purdie; +Cc: openembedded-core
On Thu, Sep 12, 2013 at 10:02 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> On Thu, 2013-09-12 at 09:48 +0200, Hans Beckérus wrote:
>> I have a slight problem with this patch. The new
>> sysroot-relativelinks.py does not obtain the proper access protection
>> bits!?
>> Which results in the following error when packaging the SDK
>>
>> /home/poky/build/tmp/work/zynq_zc706-poky-linux-gnueabi/rootfs-default/1.0-r0/temp/run.populate_sdk_image.20803:
>> line 496: /home/poky/scripts/sysroot-relativelinks.py: Permission
>> denied
>>
>> [home/poky]: ls -l scripts/sysroot-relativelinks.py
>> -rw-rw-r-- 1 poky poky 959 Sep 12 09:38 scripts/sysroot-relativelinks.py
>>
>> The execution bit is missing!?
>>
>> I can of course apply the execution bit manually, but what may cause
>> the patch to not set the bits properly in my scripts folder for new
>> files? Please advise.
>
> I checked the poky and oe-core trees and they have a+x:
>
> http://git.yoctoproject.org/cgit.cgi/poky/tree/scripts
> http://git.openembedded.org/openembedded-core/tree/scripts
>
> so I'm a bit puzzled. How did you update your tree?
>
All the other scripts in the scripts folder has a+x, it is only the
new .py file added by your patch that does not obtain it in my local
tree.
> Cheers,
>
> Richard
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] image/populate_sdk: Ensure symlinks in target sysroot are relative
2013-09-12 8:29 ` Hans Beckérus
@ 2013-09-12 14:54 ` Hans Beckérus
0 siblings, 0 replies; 5+ messages in thread
From: Hans Beckérus @ 2013-09-12 14:54 UTC (permalink / raw)
To: openembedded-core
On Thu, Sep 12, 2013 at 10:29 AM, Hans Beckérus <hans.beckerus@gmail.com> wrote:
> On Thu, Sep 12, 2013 at 10:02 AM, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
>> On Thu, 2013-09-12 at 09:48 +0200, Hans Beckérus wrote:
>>> I have a slight problem with this patch. The new
>>> sysroot-relativelinks.py does not obtain the proper access protection
>>> bits!?
>>> Which results in the following error when packaging the SDK
>>>
>>> /home/poky/build/tmp/work/zynq_zc706-poky-linux-gnueabi/rootfs-default/1.0-r0/temp/run.populate_sdk_image.20803:
>>> line 496: /home/poky/scripts/sysroot-relativelinks.py: Permission
>>> denied
>>>
>>> [home/poky]: ls -l scripts/sysroot-relativelinks.py
>>> -rw-rw-r-- 1 poky poky 959 Sep 12 09:38 scripts/sysroot-relativelinks.py
>>>
>>> The execution bit is missing!?
>>>
>>> I can of course apply the execution bit manually, but what may cause
>>> the patch to not set the bits properly in my scripts folder for new
>>> files? Please advise.
>>
>> I checked the poky and oe-core trees and they have a+x:
>>
>> http://git.yoctoproject.org/cgit.cgi/poky/tree/scripts
>> http://git.openembedded.org/openembedded-core/tree/scripts
>>
>> so I'm a bit puzzled. How did you update your tree?
>>
> All the other scripts in the scripts folder has a+x, it is only the
> new .py file added by your patch that does not obtain it in my local
> tree.
>
As Richard so correctly pointed out to me, this is expected when I use
'patch' to bring it in :(
I must learn my lesson and start using 'git am' instead.
Thanks.
Hans
>> Cheers,
>>
>> Richard
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-09-12 14:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 9:42 [PATCH] image/populate_sdk: Ensure symlinks in target sysroot are relative Richard Purdie
2013-09-12 7:48 ` Hans Beckérus
2013-09-12 8:02 ` Richard Purdie
2013-09-12 8:29 ` Hans Beckérus
2013-09-12 14:54 ` Hans Beckérus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox