linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 kbuild-rebased] kheaders: make it possible to override TAR
@ 2025-07-26 15:10 Michał Górny
  2025-07-29 12:44 ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Michał Górny @ 2025-07-26 15:10 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Sam James, Nicolas Schier, linux-kbuild,
	linux-kernel, Michał Górny

Commit 86cdd2fdc4e39c388d39c7ba2396d1a9dfd66226 ("kheaders: make headers
archive reproducible") introduced a number of options specific to GNU
tar to the `tar` invocation in `gen_kheaders.sh` 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.

Add a `TAR` make variable to make it possible to override the tar
executable used, e.g. by specifying:

  make TAR=gtar

Link: https://bugs.gentoo.org/884061
Reported-by: Sam James <sam@gentoo.org>
Tested-by: Sam James <sam@gentoo.org>
Co-developed-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Sam James <sam@gentoo.org>
---
 Makefile               | 3 ++-
 kernel/gen_kheaders.sh | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index ba0827a1fccd..081d494d037a 100644
--- a/Makefile
+++ b/Makefile
@@ -543,6 +543,7 @@ LZMA		= lzma
 LZ4		= lz4
 XZ		= xz
 ZSTD		= zstd
+TAR		= tar
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -622,7 +623,7 @@ export RUSTC RUSTDOC RUSTFMT RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY BINDGEN
 export HOSTRUSTC KBUILD_HOSTRUSTFLAGS
 export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
 export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
-export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
+export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD TAR
 export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS KBUILD_PROCMACROLDFLAGS LDFLAGS_MODULE
 export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
 
diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh
index c64e5a00a3d9..59ec52f62c52 100755
--- a/kernel/gen_kheaders.sh
+++ b/kernel/gen_kheaders.sh
@@ -31,7 +31,7 @@ mkdir "${tmpdir}"
 
 # shellcheck disable=SC2154 # srctree is passed as an env variable
 sed "s:^${srctree}/::" "${srclist}" | tar -c -f - -C "${srctree}" -T - | tar -xf - -C "${tmpdir}"
-tar -c -f - -T "${objlist}" | tar -xf - -C "${tmpdir}"
+${TAR:-tar} -c -f - -T "${objlist}" | tar -xf - -C "${tmpdir}"
 
 # Remove comments except SDPX lines
 # Use a temporary file to store directory contents to prevent find/xargs from
@@ -43,7 +43,7 @@ xargs -0 -P8 -n1 \
 rm -f "${tmpdir}.contents.txt"
 
 # Create archive and try to normalize metadata for reproducibility.
-tar "${timestamp:+--mtime=$timestamp}" \
+${TAR:-tar} "${timestamp:+--mtime=$timestamp}" \
     --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X \
     -I "${XZ}" -cf "${tarfile}" -C "${tmpdir}/" . > /dev/null
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 kbuild-rebased] kheaders: make it possible to override TAR
  2025-07-26 15:10 [PATCH v3 kbuild-rebased] kheaders: make it possible to override TAR Michał Górny
@ 2025-07-29 12:44 ` Masahiro Yamada
  2025-07-29 13:24   ` [PATCH v4] " Michał Górny
  0 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2025-07-29 12:44 UTC (permalink / raw)
  To: Michał Górny
  Cc: Nathan Chancellor, Sam James, Nicolas Schier, linux-kbuild,
	linux-kernel

On Sun, Jul 27, 2025 at 12:10 AM Michał Górny <mgorny@gentoo.org> wrote:
>
> Commit 86cdd2fdc4e39c388d39c7ba2396d1a9dfd66226 ("kheaders: make headers
> archive reproducible") introduced a number of options specific to GNU
> tar to the `tar` invocation in `gen_kheaders.sh` 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.
>
> Add a `TAR` make variable to make it possible to override the tar
> executable used, e.g. by specifying:
>
>   make TAR=gtar
>
> Link: https://bugs.gentoo.org/884061
> Reported-by: Sam James <sam@gentoo.org>
> Tested-by: Sam James <sam@gentoo.org>
> Co-developed-by: Masahiro Yamada <masahiroy@kernel.org>
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> Signed-off-by: Sam James <sam@gentoo.org>
> ---
>  Makefile               | 3 ++-
>  kernel/gen_kheaders.sh | 4 ++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index ba0827a1fccd..081d494d037a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -543,6 +543,7 @@ LZMA                = lzma
>  LZ4            = lz4
>  XZ             = xz
>  ZSTD           = zstd
> +TAR            = tar
>
>  CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
>                   -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
> @@ -622,7 +623,7 @@ export RUSTC RUSTDOC RUSTFMT RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY BINDGEN
>  export HOSTRUSTC KBUILD_HOSTRUSTFLAGS
>  export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
>  export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
> -export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
> +export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD TAR
>  export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS KBUILD_PROCMACROLDFLAGS LDFLAGS_MODULE
>  export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
>
> diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh
> index c64e5a00a3d9..59ec52f62c52 100755
> --- a/kernel/gen_kheaders.sh
> +++ b/kernel/gen_kheaders.sh
> @@ -31,7 +31,7 @@ mkdir "${tmpdir}"
>
>  # shellcheck disable=SC2154 # srctree is passed as an env variable
>  sed "s:^${srctree}/::" "${srclist}" | tar -c -f - -C "${srctree}" -T - | tar -xf - -C "${tmpdir}"

Please replace two more 'tar' with ${TAR} in this line.


> -tar -c -f - -T "${objlist}" | tar -xf - -C "${tmpdir}"
> +${TAR:-tar} -c -f - -T "${objlist}" | tar -xf - -C "${tmpdir}"

Please replace one more 'tar' with ${TAR} in this line.


I think ${TAR:-tar} is distracting.

I think ${TAR} should be OK because we have ${XZ} instead of ${XZ:-xz}
in this file.


>
>  # Remove comments except SDPX lines
>  # Use a temporary file to store directory contents to prevent find/xargs from
> @@ -43,7 +43,7 @@ xargs -0 -P8 -n1 \
>  rm -f "${tmpdir}.contents.txt"
>
>  # Create archive and try to normalize metadata for reproducibility.
> -tar "${timestamp:+--mtime=$timestamp}" \
> +${TAR:-tar} "${timestamp:+--mtime=$timestamp}" \
>      --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X \
>      -I "${XZ}" -cf "${tarfile}" -C "${tmpdir}/" . > /dev/null
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4] kheaders: make it possible to override TAR
  2025-07-29 12:44 ` Masahiro Yamada
@ 2025-07-29 13:24   ` Michał Górny
  2025-07-29 13:43     ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Michał Górny @ 2025-07-29 13:24 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Sam James, Nicolas Schier, linux-kbuild,
	linux-kernel, Michał Górny

Commit 86cdd2fdc4e39c388d39c7ba2396d1a9dfd66226 ("kheaders: make headers
archive reproducible") introduced a number of options specific to GNU
tar to the `tar` invocation in `gen_kheaders.sh` 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.

Add a `TAR` make variable to make it possible to override the tar
executable used, e.g. by specifying:

  make TAR=gtar

Link: https://bugs.gentoo.org/884061
Reported-by: Sam James <sam@gentoo.org>
Tested-by: Sam James <sam@gentoo.org>
Co-developed-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Sam James <sam@gentoo.org>
---
 Makefile               | 3 ++-
 kernel/gen_kheaders.sh | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index ba0827a1fccd..081d494d037a 100644
--- a/Makefile
+++ b/Makefile
@@ -543,6 +543,7 @@ LZMA		= lzma
 LZ4		= lz4
 XZ		= xz
 ZSTD		= zstd
+TAR		= tar
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -622,7 +623,7 @@ export RUSTC RUSTDOC RUSTFMT RUSTC_OR_CLIPPY_QUIET RUSTC_OR_CLIPPY BINDGEN
 export HOSTRUSTC KBUILD_HOSTRUSTFLAGS
 export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
 export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
-export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
+export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD TAR
 export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS KBUILD_PROCMACROLDFLAGS LDFLAGS_MODULE
 export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
 
diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh
index c64e5a00a3d9..896a503dfb29 100755
--- a/kernel/gen_kheaders.sh
+++ b/kernel/gen_kheaders.sh
@@ -30,8 +30,8 @@ rm -rf "${tmpdir}"
 mkdir "${tmpdir}"
 
 # shellcheck disable=SC2154 # srctree is passed as an env variable
-sed "s:^${srctree}/::" "${srclist}" | tar -c -f - -C "${srctree}" -T - | tar -xf - -C "${tmpdir}"
-tar -c -f - -T "${objlist}" | tar -xf - -C "${tmpdir}"
+sed "s:^${srctree}/::" "${srclist}" | ${TAR} -c -f - -C "${srctree}" -T - | ${TAR} -xf - -C "${tmpdir}"
+${TAR} -c -f - -T "${objlist}" | ${TAR} -xf - -C "${tmpdir}"
 
 # Remove comments except SDPX lines
 # Use a temporary file to store directory contents to prevent find/xargs from
@@ -43,7 +43,7 @@ xargs -0 -P8 -n1 \
 rm -f "${tmpdir}.contents.txt"
 
 # Create archive and try to normalize metadata for reproducibility.
-tar "${timestamp:+--mtime=$timestamp}" \
+${TAR} "${timestamp:+--mtime=$timestamp}" \
     --owner=0 --group=0 --sort=name --numeric-owner --mode=u=rw,go=r,a+X \
     -I "${XZ}" -cf "${tarfile}" -C "${tmpdir}/" . > /dev/null
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] kheaders: make it possible to override TAR
  2025-07-29 13:24   ` [PATCH v4] " Michał Górny
@ 2025-07-29 13:43     ` Masahiro Yamada
  2025-07-29 15:33       ` Michał Górny
  0 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2025-07-29 13:43 UTC (permalink / raw)
  To: Michał Górny
  Cc: Nathan Chancellor, Sam James, Nicolas Schier, linux-kbuild,
	linux-kernel

On Tue, Jul 29, 2025 at 10:25 PM Michał Górny <mgorny@gentoo.org> wrote:
>
> Commit 86cdd2fdc4e39c388d39c7ba2396d1a9dfd66226 ("kheaders: make headers
> archive reproducible") introduced a number of options specific to GNU
> tar to the `tar` invocation in `gen_kheaders.sh` 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.
>
> Add a `TAR` make variable to make it possible to override the tar
> executable used, e.g. by specifying:
>
>   make TAR=gtar
>
> Link: https://bugs.gentoo.org/884061
> Reported-by: Sam James <sam@gentoo.org>
> Tested-by: Sam James <sam@gentoo.org>
> Co-developed-by: Masahiro Yamada <masahiroy@kernel.org>
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> Signed-off-by: Sam James <sam@gentoo.org>
> ---


Applied to linux-kbuild.
Thanks.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] kheaders: make it possible to override TAR
  2025-07-29 13:43     ` Masahiro Yamada
@ 2025-07-29 15:33       ` Michał Górny
  0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2025-07-29 15:33 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nathan Chancellor, Sam James, Nicolas Schier, linux-kbuild,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]

On Tue, 2025-07-29 at 22:43 +0900, Masahiro Yamada wrote:
> On Tue, Jul 29, 2025 at 10:25 PM Michał Górny <mgorny@gentoo.org> wrote:
> > 
> > Commit 86cdd2fdc4e39c388d39c7ba2396d1a9dfd66226 ("kheaders: make headers
> > archive reproducible") introduced a number of options specific to GNU
> > tar to the `tar` invocation in `gen_kheaders.sh` 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.
> > 
> > Add a `TAR` make variable to make it possible to override the tar
> > executable used, e.g. by specifying:
> > 
> >   make TAR=gtar
> > 
> > Link: https://bugs.gentoo.org/884061
> > Reported-by: Sam James <sam@gentoo.org>
> > Tested-by: Sam James <sam@gentoo.org>
> > Co-developed-by: Masahiro Yamada <masahiroy@kernel.org>
> > Signed-off-by: Michał Górny <mgorny@gentoo.org>
> > Signed-off-by: Sam James <sam@gentoo.org>
> > ---
> 
> 
> Applied to linux-kbuild.
> Thanks.

Thanks a lot.  I'll try to find some time in the future to look into
other uses of tar, for consistency.

-- 
Best regards,
Michał Górny

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-29 15:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-26 15:10 [PATCH v3 kbuild-rebased] kheaders: make it possible to override TAR Michał Górny
2025-07-29 12:44 ` Masahiro Yamada
2025-07-29 13:24   ` [PATCH v4] " Michał Górny
2025-07-29 13:43     ` Masahiro Yamada
2025-07-29 15:33       ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).