base.bbclass: Try harder to find a compatible tar implementation
PATCH 1/1 base.bbclass: Try harder to find a compatible tar implementation
From: Bernhard Rosenkränzer <[email protected]>
base.bbclass currently symlinks the first copy of tar on the PATH to hosttools.
If that copy of tar isn't GNU tar (some Linux distributions use libarchive tar for the fact that it can handle zip files etc. as well; some others probably use busybox or toybox tar for space issues), the build fails early on because path.py uses --xattrs and --xattrs-include
With this patch, base.bbclass checks if tar supports --xattrs-include, and checks for gtar if the first tar found doesn't support it.
--- meta/classes-global/base.bbclass | 10 ++++++++++ 1 file changed, 10 insertions(+)
meta/classes-global/base.bbclass +10 -0
@@ -135,6 +135,16 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True): if os.path.islink(desttool): os.unlink(desttool) srctool = bb.utils.which(path, tool, executable=True) + # copytree() uses tar options such as --xattrs and + # --xattrs-include that are currently specific to GNU tar. + # If the first tar in PATH is libarchive tar or busybox/toybox + # tar, GNU tar may well be available as gtar. + if (tool == "tar"): + import subprocess + if not b'--xattrs-include' in subprocess.check_output([srctool, '--help']): + gtar = bb.utils.which(path, "gtar", executable=True) + if gtar: + srctool = gtar # gcc/g++ may link to ccache on some hosts, e.g., # /usr/local/bin/ccache/gcc -> /usr/bin/ccache, then which(gcc) # would return /usr/local/bin/ccache/gcc, but what we need is
Signature · 1 line
2.38.1
Interesting. I think the more common approach is just to compile a native tar with Yocto and add it with EXTRANATIVEPATH (iirc),
like suggested here: https://stackoverflow.com/a/43109887
Regards
//Ernst
Den fre 28 okt. 2022 kl 01:14 skrev Bernhard Rosenkränzer via lists.openembedded.org <[email protected]>:
Quoted 59 lines
From: Bernhard Rosenkränzer <[email protected]>
base.bbclass currently symlinks the first copy of tar on the PATH to hosttools.
If that copy of tar isn't GNU tar (some Linux distributions use libarchive tar for the fact that it can handle zip files etc. as well; some others probably use busybox or toybox tar for space issues), the build fails early on because
path.pyuses --xattrs and --xattrs-includeWith this patch, base.bbclass checks if tar supports --xattrs-include, and checks for gtar if the first tar found doesn't support it.
Signed-off-by Bernhard Rosenkränzer <[email protected]>--- meta/classes-global/base.bbclass | 10 ++++++++++ 1 file changed, 10 insertions(+)meta/classes-global/base.bbclass +0
-0@@ -135,6 +135,16 @@ def setup_hosttools_dir(dest, toolsvar, d,fatal=True):
ifos.path.islink(desttool):
os.unlink(desttool)
srctool =bb.utils.which(path, tool, executable=True)meta/classes-global/base.bbclass +7
-0+ # copytree() uses tar options such as --xattrs and + # --xattrs-include that are currently specific to GNU tar. + # If the first tar in PATH is libarchive tar or busybox/toybox + # tar, GNU tar may well be available as gtar. + if (tool == "tar"): + import subprocess + if not b'--xattrs-include' in
subprocess.check_output([srctool, '--help']):meta/classes-global/base.bbclass +3
-0+ gtar = bb.utils.which(path, "gtar", executable=True) + if gtar: + srctool = gtar # gcc/g++ may link to ccache on some hosts, e.g., # /usr/local/bin/ccache/gcc -> /usr/bin/ccache, thenwhich(gcc)
# would return /usr/local/bin/ccache/gcc, but what we need is -- 2.38.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#172229):
https://lists.openembedded.org/g/openembedded-core/message/172229
Mute This Topic: https://lists.openembedded.org/mt/94616037/4947266
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 5 lines · Bernhard Rosenkränzer via lists.openembedded.org
If that copy of tar isn't GNU tar (some Linux distributions use libarchive tar for the fact that it can handle zip files etc. as well; some others probably use busybox or toybox tar for space issues), the build fails early on because
path.pyuses --xattrs and --xattrs-include
Can we name what linux distribution that is?
Ross
Quoted 11 lines · Bernhard Rosenkränzer via lists.openembedded.org
From: Bernhard Rosenkränzer <[email protected]>
base.bbclass currently symlinks the first copy of tar on the PATH to hosttools.
If that copy of tar isn't GNU tar (some Linux distributions use libarchive tar for the fact that it can handle zip files etc. as well; some others probably use busybox or toybox tar for space issues), the build fails early on because
path.pyuses --xattrs and --xattrs-include
Quoted 7 lines
With this patch, base.bbclass checks if tar supports --xattrs-include, and checks for gtar if the first tar found doesn't support it.
Signed-off-by Bernhard Rosenkränzer <[email protected]>--- meta/classes-global/base.bbclass | 10 ++++++++++ 1 file changed, 10 insertions(+)
This feels like a rather dangerous path to start down.
HOSTTOOLS is there for host isolation, not to remap the tools to different things depending on the distro we're on or versions etc.
I can see the attraction in using it to manipulate it but I'd kind of prefer to error if tar isn't compatible and allow the user to change their distro setup rather than magic...
Cheers,
Richard
Quoted 8 lines · Richard Purdie via lists.openembedded.org
This feels like a rather dangerous path to start down.
HOSTTOOLS is there for host isolation, not to remap the tools to different things depending on the distro we're on or versions etc.
I can see the attraction in using it to manipulate it but I'd kind of prefer to error if tar isn't compatible and allow the user to change their distro setup rather than magic…
Patch incoming to detect a tar that doesn’t support —xattrs and abort early, instead of mysteriously later.
Ross