everywhere: use $(TAR) not tar (branch yem/tarTAR)
cover everywhere: use $(TAR) not tar (branch yem/tarTAR)
Hello All!
To allow for reproducible archives, and to ensure we can extract all archives, we require that we use tar 1.35 or above.
There are then two cases:
1. the system has a suitable tar: we use that;
2. the system has no suitable tar: we build our own host-tar, and use that (it ends up in HOST_DIR/bin so is in the PATH).
However, to avoid building host-tar again and again, people can set the TAR environment variable, to point to a tar version they believe is suitable (if it is not, we fallback to case 2, above). If the user provides a suitable tar, then we do not build our own host-tar and use the one provided by the user.
However, there are a few places where we do hard-code calls to 'tar' without considering the one provided by the user. This breaks cases where an unsuitable tar is available on the system, as that unsuitable tar is then used to create and extract tarballs. This breaks generatign tarballs from VCS (git, svn) or from vendoring (cargo, go).
Fix all those cases.
How to find calls to tar:
$ git grep -E '\<tar '
There are a lot of false positive:
- CHANGES
- comments
- docs
- patches
- misc (e.g. a script with a $tar variable)
After this series, we still have a very few locations which directly call to a plain tar:
- Makefile: the 'release' target
- scripts not called as part of the build
- boards readmes
- patches
The first will be addressed in a separate patch, as it is not critical (users do not nromally cut Buildroot releases!). The others can't be changed, as they execute outside Buildroot's control.
Regards,
Yann E. MORIN.
----------------------------------------------------------------
Yann E. MORIN (9):
fs/tar: use appropriate TAR
package/cvs: use appropriate TAR package/flutter-engine: use appropriate TAR package/pkg-download: export TAR for download backends support/download/helpers: use appropriate TAR support/download/cvs: fix shellcheck support/download/cvs: use appropriate TAR support/scripts/apply-patches: use appropriate TAR package/sunxi-mali-utgard-driver: handle patching the Buildroot way
.checkpackageignore | 1 - fs/tar/tar.mk | 2 +- package/Makefile.in | 2 +- package/cvs/cvs.mk | 2 +- package/flutter-engine/flutter-engine.mk | 1 + package/flutter-engine/gen-tarball | 2 +- package/pkg-download.mk | 4 ++- .../0001-build.sh-do-not-apply-patches.patch | 39 ++++++++++++++++++++++ .../sunxi-mali-utgard-driver.mk | 3 +- support/download/cvs | 5 +-- support/download/helpers | 4 +-- support/scripts/apply-patches.sh | 2 +- 12 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 package/sunxi-mali-utgard-driver/0001-build.sh-do-not-apply-patches.patch
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 1/9 fs/tar: use appropriate TAR
--- fs/tar/tar.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/tar/tar.mk +1 -1
@@ -13,7 +13,7 @@ TAR_OPTS += --pax-option=exthdr.name=%d/PaxHeaders/%f,atime:=0,ctime:=0 define ROOTFS_TAR_CMD (cd $(TARGET_DIR); find -print0 | LC_ALL=C sort -z | \ - tar $(TAR_OPTS) -cf $@ --null --xattrs-include='*' --no-recursion -T - --numeric-owner) + $(TAR) $(TAR_OPTS) -cf $@ --null --xattrs-include='*' --no-recursion -T - --numeric-owner) endef $(eval $(rootfs))
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/9 package/cvs: use appropriate TAR
In reply to Yann E. MORIN--- package/cvs/cvs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/cvs/cvs.mk +1 -1
@@ -31,7 +31,7 @@ CVS_CONF_OPTS += --with-external-zlib endif define CVS_BZIP_UNPACK - $(BZCAT) $(@D)/cvs-$(CVS_VERSION).tar.bz2 | tar -C $(BUILD_DIR) $(TAR_OPTIONS) - + $(BZCAT) $(@D)/cvs-$(CVS_VERSION).tar.bz2 | $(TAR) -C $(BUILD_DIR) $(TAR_OPTIONS) - rm -f $(@D)/cvs-$(CVS_VERSION).tar.bz2 endef
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 4/9 package/pkg-download: export TAR for download backends
In reply to Yann E. MORIN--- package/pkg-download.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
package/pkg-download.mk +3 -1
@@ -109,7 +109,9 @@ endif define DOWNLOAD $(Q)mkdir -p $($(2)_DL_DIR) - $(Q)$(EXTRA_ENV) $($(2)_DL_ENV) \ + $(Q)$(EXTRA_ENV) \ + $($(2)_DL_ENV) \ + TAR=$(TAR) \ BR_NO_CHECK_HASH_FOR="$(if $(BR2_DOWNLOAD_FORCE_CHECK_HASHES),,$(BR_NO_CHECK_HASH_FOR))" \ flock $($(2)_DL_DIR)/.lock $(DL_WRAPPER) \ -c '$($(2)_DL_VERSION)' \
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/9 package/flutter-engine: use appropriate TAR
In reply to Yann E. MORIN--- package/flutter-engine/flutter-engine.mk | 1 + package/flutter-engine/gen-tarball | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
package/flutter-engine/flutter-engine.mk +1 -0
@@ -176,6 +176,7 @@ endif # Generate a tarball if one does not already exist. define FLUTTER_ENGINE_GENERATE_TARBALL + TAR=$(TAR) \ PATH=$(HOST_DIR)/share/depot_tools:$(BR_PATH) \ PYTHONPATH=$(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR) \ PUB_CACHE=$(FLUTTER_SDK_BIN_PUB_CACHE) \
package/flutter-engine/gen-tarball +1 -1
@@ -70,7 +70,7 @@ gen_tarball() { # - it insists on having a full git repositoy, with .git et al., which means # we can't generate a reproducible archive anyway. # So we jsut create a plain tarball. - tar -C "${SCRATCH_DIR}"/src -czf "${TARBALL_NAME}" . + ${TAR} -C "${SCRATCH_DIR}"/src -czf "${TARBALL_NAME}" . mv "${TARBALL_NAME}" "${TARBALL_DL_PATH}" }
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 7/9 support/download/cvs: use appropriate TAR
In reply to Yann E. MORIN--- support/download/cvs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
support/download/cvs +1 -1
@@ -68,4 +68,4 @@ export TZ=UTC _cvs ${quiet} -z3 -d"'${uri}'" \ co "${@}" -d "'${basename}'" ${select} "'${rev}'" -P "'${rawname}'" -tar czf "${output}" "${basename}" +${TAR} czf "${output}" "${basename}"
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 6/9 support/download/cvs: fix shellcheck
In reply to Yann E. MORIN--- .checkpackageignore | 1 - support/download/cvs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
.checkpackageignore +0 -1
@@ -1653,7 +1653,6 @@ support/dependencies/check-host-xzcat.sh Shellcheck support/dependencies/dependencies.sh Shellcheck support/download/bzr Shellcheck lib_shellscript.ConsecutiveEmptyLines support/download/cargo-post-process Shellcheck -support/download/cvs Shellcheck support/download/dl-wrapper Shellcheck support/download/file Shellcheck support/download/go-post-process Shellcheck
support/download/cvs +2 -1
@@ -40,12 +40,13 @@ shift $((OPTIND-1)) # Get rid of our options # 10 minutes should do the trick. _cvs() { if [ -z "${quiet}" ]; then - printf '%s ' timeout 10m ${CVS} "${@}"; printf '\n' + printf '%s ' timeout 10m "${CVS}" "${@}"; printf '\n' fi _plain_cvs "$@" } # Note: please keep command below aligned with what is printed above _plain_cvs() { + # shellcheck disable=SC2086 # We really want word splitting in CVS eval timeout 10m ${CVS} "${@}" }
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 8/9 support/scripts/apply-patches: use appropriate TAR
In reply to Yann E. MORIN--- package/Makefile.in | 2 +- support/scripts/apply-patches.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
package/Makefile.in +1 -1
@@ -231,7 +231,7 @@ endif INSTALL := $(shell which install || type -p install) UNZIP := $(shell which unzip || type -p unzip) -q -APPLY_PATCHES = PATH=$(HOST_DIR)/bin:$$PATH support/scripts/apply-patches.sh $(if $(QUIET),-s) +APPLY_PATCHES = TAR=$(TAR) PATH=$(HOST_DIR)/bin:$$PATH support/scripts/apply-patches.sh $(if $(QUIET),-s) HOST_CPPFLAGS = -I$(HOST_DIR)/include HOST_CFLAGS ?= -O2
support/scripts/apply-patches.sh +1 -1
@@ -146,7 +146,7 @@ function scan_patchdir { unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked" rm -rf "$unpackedarchivedir" 2> /dev/null mkdir "$unpackedarchivedir" - tar -C "$unpackedarchivedir" -xaf "${path}/$i" + $(TAR) -C "$unpackedarchivedir" -xaf "${path}/$i" scan_patchdir "$unpackedarchivedir" else apply_patch "$path" "$i"
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 5/9 support/download/helpers: use appropriate TAR
In reply to Yann E. MORIN--- support/download/helpers | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
support/download/helpers +2 -2
@@ -59,7 +59,7 @@ mk_tar_gz() { LC_ALL=C sort <"${tmp}.list" >"${tmp}.sorted" # Create POSIX tarballs, since that's the format the most reproducible - tar cf - --transform="s#^\./#${base_dir}/#S" \ + ${TAR} cf - --transform="s#^\./#${base_dir}/#S" \ --numeric-owner --owner=0 --group=0 --mtime="${date}" \ --format=posix --pax-option="${pax_options}" --mode='go=u,go-w' \ -T "${tmp}.sorted" >"${tmp}.tar"
@@ -78,7 +78,7 @@ post_process_unpack() { local one_file mkdir "${dest}" - tar -C "${dest}" --strip-components=1 -xzf "${tarball}" + ${TAR} -C "${dest}" --strip-components=1 -xzf "${tarball}" one_file="$(find "${dest}" -type f -print0 |LC_ALL=C sort -z |sed 's/\x0.*//')" touch -r "${one_file}" "${dest}.timestamp" }
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 9/9 package/sunxi-mali-utgard-driver: handle patching the Buildroot way
In reply to Yann E. MORIN--- .../0001-build.sh-do-not-apply-patches.patch | 39 +++++++++++++++++++ .../sunxi-mali-utgard-driver.mk | 3 +- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 package/sunxi-mali-utgard-driver/0001-build.sh-do-not-apply-patches.patch
package/sunxi-mali-utgard-driver/0001-build.sh-do-not-apply-patches.patch new file +39 -0
@@ -0,0 +1,39 @@ +From 079ed8aa57ba6629b992c3d0d01904d3e5170d3b Mon Sep 17 00:00:00 2001 +From: "Yann E. MORIN" <[email protected]> +Date: Wed, 5 Jun 2024 13:06:16 +0200 +Subject: [PATCH] build.sh: do not apply patches + +In Buildroot, we handle applying the patches in a generic way, with +appropriate tools (e.g. with a proper tar). + +Upstream: not applicable +Signed-off-by: Yann E. MORIN <[email protected]> +--- + build.sh | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/build.sh b/build.sh +index d1fedff..26efc53 100755 +--- a/build.sh ++++ b/build.sh +@@ -10,6 +10,8 @@ BUILD_OPTS="USING_UMP=0 + USING_DEVFREQ=1" + + apply_patches() { ++ return 0 # Patching handled by Buildroot ++ + pushd $2 + + quilt push -a +@@ -22,6 +24,8 @@ apply_patches() { + } + + unapply_patches() { ++ return 0 # Patching handled by Buildroot ++ + pushd $2 + + quilt pop -a +-- +2.45.1 +
package/sunxi-mali-utgard-driver/sunxi-mali-utgard-driver.mk +1 -2
@@ -16,8 +16,7 @@ SUNXI_MALI_UTGARD_DRIVER_MAKE_OPTS = \ define SUNXI_MALI_UTGARD_DRIVER_USE_APPLY_PATCHES ln -sf $(SUNXI_MALI_UTGARD_REV)/series $(@D)/patches - $(SED) 's|quilt push -a|$(TOPDIR)/support/scripts/apply-patches.sh . ../patches|' \ - $(@D)/build.sh + $(APPLY_PATCHES) $(@D)/$(SUNXI_MALI_UTGARD_REV) $(@D)/patches endef SUNXI_MALI_UTGARD_DRIVER_POST_PATCH_HOOKS += SUNXI_MALI_UTGARD_DRIVER_USE_APPLY_PATCHES
Signature · 6 lines
2.45.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [External] [PATCH 8/9] support/scripts/apply-patches: use appropriate TAR
In reply to Yann E. MORINHi Yann,
Quoted 36 lines
-----Original Message-----
From: buildroot <[email protected]> On Behalf Of Yann E. MORIN
Sent: Wednesday, June 5, 2024 9:18 AM
To: [email protected]
Cc: Yann E. MORIN <[email protected]>
Subject: [External] [Buildroot] [PATCH 8/9] support/scripts/apply-patches:
use appropriate TARSigned-off-by Yann E. MORIN <[email protected]>--- package/Makefile.in | 2 +- support/scripts/apply-patches.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)package/Makefile.in +1
-1@@ -231,7 +231,7 @@ endif INSTALL := $(shell which install || type -p install) UNZIP := $(shell which unzip || type -p unzip) -q -APPLY_PATCHES = PATH=$(HOST_DIR)/bin:$$PATH support/scripts/apply- patches.sh $(if $(QUIET),-s) +APPLY_PATCHES = TAR=$(TAR) PATH=$(HOST_DIR)/bin:$$PATH support/scripts/apply-patches.sh $(if $(QUIET),-s)
HOST_CPPFLAGS= -I$(HOST_DIR)/include
HOST_CFLAGS?= -O2support/scripts/apply- renamed from support/scripts/apply-patches.sh +0
-0
patches.sh
index6da83f6826..39a0c050d6100755
support/scripts/apply-patches.sh function scan_patchdir { · line 149
Quoted 5 lines
support/scripts/apply-patches.sh +1
-1@@ -146,7 +146,7 @@ function scan_patchdir { unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked" rm -rf "$unpackedarchivedir" 2> /dev/null mkdir "$unpackedarchivedir" - tar -C "$unpackedarchivedir" -xaf "${path}/$i" + $(TAR) -C "$unpackedarchivedir" -xaf "${path}/$i"
Shouldn't this be ${TAR} since it's a shell script?
Thanks,
Brandon Maier
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [External] [PATCH 8/9] support/scripts/apply-patches: use appropriate TAR
Brandon, All,
On 2024-06-05 15:22 +0000, Maier, Brandon L Collins spake thusly:
[--SNIP--]
Quoted 5 lines
Quoted 5 lines
support/scripts/apply- renamed from support/scripts/apply-patches.sh +0
-0
patches.sh
index6da83f6826..39a0c050d6100755support/scripts/apply-patches.sh +0
-0
Quoted 8 lines
support/scripts/apply-patches.sh function scan_patchdir { · line 149
Quoted 6 lines
support/scripts/apply-patches.sh +1
-1@@ -146,7 +146,7 @@ function scan_patchdir { unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked" rm -rf "$unpackedarchivedir" 2> /dev/null mkdir "$unpackedarchivedir" - tar -C "$unpackedarchivedir" -xaf "${path}/$i" + $(TAR) -C "$unpackedarchivedir" -xaf "${path}/$i"Shouldn't this be
${TAR}since it's a shell script?
Damned, one I missed... Thanks!
I tried to find a case where I could exercise that code path, but I could not find a package with uses a tarball as a patch...
I'll respin a bit later; thanks for your eagle eyes! :-)
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [External] [PATCH 8/9] support/scripts/apply-patches: use appropriate TAR
Brandon, All,
On 2024-06-05 17:32 +0200, Yann E. MORIN spake thusly:
Quoted 14 lines
On 2024-06-05 15:22 +0000, Maier, Brandon L Collins spake thusly:
[--SNIP--]Quoted 4 lines
Quoted 4 lines
support/scripts/apply- renamed from support/scripts/apply-patches.sh +0
-0
patches.sh
index6da83f6826..39a0c050d6100755
---a/support/scripts/apply-patches.shQuoted 8 lines
support/scripts/apply- function scan_patchdir { · line 149
Quoted 7 lines
+++
b/support/scripts/apply-patches.shsupport/scripts/apply- renamed from support/scripts/apply-patches.sh +1
-1@@ -146,7 +146,7 @@ function scan_patchdir { unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked" rm -rf "$unpackedarchivedir" 2> /dev/null mkdir "$unpackedarchivedir" - tar -C "$unpackedarchivedir" -xaf "${path}/$i" + $(TAR) -C "$unpackedarchivedir" -xaf "${path}/$i"Shouldn't this be
${TAR}since it's a shell script?
Quoted 3 lines
Damned, one I missed... Thanks!
I tried to find a case where I could exercise that code path, but I could not find a package with uses a tarball as a patch...
Obviously I did not look too far. I now can see;
- heirloom-mailx
- libid3tag
- liblockfile
- netcat-openbsd
- unzip
I'll re-run a test.
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot