[lkml]   [2022]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] kheaders: prefer gtar over tar for better compatibility
Commit 86cdd2fdc4e39c388d39c7ba2396d1a9dfd66226 ("kheaders: make headers
archive reproducible") introduced a number of options specific to GNU
tar to the `tar` invocation in `` script. This causes
the script to fail to work on systems where `tar` is not GNU tar. This
can occur e.g. on recent Gentoo Linux installations that support using
bsdtar from libarchive instead.

To achieve better portability, try using `gtar` over `tar` if the former
is available. This is the name frequently used on systems featuring
support for installing GNU tar alongside another tar implementation.
If `gtar` is not present, `tar` is used for compatibility with regular

Reported-by: Sam James <>
Tested-by: Sam James <>
Signed-off-by: Michał Górny <>
kernel/ | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/ b/kernel/
index 473036b43..d2445af7f 100755
--- a/kernel/
+++ b/kernel/
@@ -80,11 +80,20 @@ done | cpio --quiet -pdu $cpio_dir >/dev/null 2>&1
find $cpio_dir -type f -print0 |
xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;'

+# The following tar invocations use options specific to GNU tar. On some
+# systems (e.g. Gentoo), `tar` can be a different tool (e.g. bsdtar), and GNU
+# tar can be found as `gtar`.
+if [ -x "$(command -v gtar)" ]; then
+ tar=gtar
+ tar=tar
# Create archive and try to normalize metadata for reproducibility.
# For compatibility with older versions of tar, files are fed to tar
# pre-sorted, as --sort=name might not be available.
find $cpio_dir -printf "./%P\n" | LC_ALL=C sort | \
--owner=0 --group=0 --numeric-owner --no-recursion \
-I $XZ -cf $tarfile -C $cpio_dir/ -T - > /dev/null

 \ /
  Last update: 2022-12-17 09:43    [W:0.247 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site