Skip to contentSkip to conversation

Rename TAR_OPTIONS to BUILDROOT_TAR_OPTIONS to avoid conflict with GNU tar.

PATCH New Peter Korsgaard 1 participant 3 messages Jan 26, 2014 – Jan 27, 2014 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Rename TAR_OPTIONS to BUILDROOT_TAR_OPTIONS to avoid conflict with GNU tar.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Nix" == Nix <[email protected]> writes:

Hi,

Quoted 23 lines

GNU tar > 1.13.17 interprets TAR_OPTIONS as an environment variable containing options to be prepended to the set on the command line.

This causes considerable trouble here, where it is set to -xf by default, since -xf causes whatever argument follows to be interpreted as a filename, even if it is e.g. --strip-components=1. This tends to cause spurious "Multiple archive files require '-M' option" errors which are very hard to track down, since nothing is visibly wrong with the command, and repeating it outside of make works perfectly well.

Fix by avoiding this risky variable name.

---
 Makefile                                           | 2 +-
 package/cvs/cvs.mk                                 | 2 +-
 package/gcc/gcc.mk                                 | 2 +-
 package/lsof/lsof.mk                               | 4 ++--
 package/perl/perl.mk                               | 2 +-
 package/pkg-generic.mk                             | 2 +-
 toolchain/toolchain-external/toolchain-external.mk | 6 +++---
 7 files changed, 10 insertions(+), 10 deletions(-)
Quoted 6 lines

(Sent directly to the listed maintainer: I'm not subscribed to the buildroot list yet and it's awfully high volume...)

I can't really understand how buildroot works for anyone, given this bug. I'm sure it must, but, how? Is everyone using a tar <=1.13? Surely not, it's fourteen years old...

Hmm, I'm certainly not:

tar --version
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

But this should only be an issue if TAR_OPTIONS are exported to the environment, which it isn't:

git grep export | grep -c TAR_OPTIONS
0

Do you perhaps have a local patch which exports it?

Quoted 106 lines
Makefile +1 -1
index 9dfb1e0..c66a471 100644
@@ -299,7 +299,7 @@ KERNEL_ARCH:=$(shell echo "$(ARCH)" | sed -e "s/-.*//" \
 ZCAT:=$(call qstrip,$(BR2_ZCAT))
 BZCAT:=$(call qstrip,$(BR2_BZCAT))
 XZCAT:=$(call qstrip,$(BR2_XZCAT))
-TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf
+BUILDROOT_TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf
 
 # packages compiled for the host go here
 HOST_DIR:=$(call qstrip,$(BR2_HOST_DIR))
package/cvs/cvs.mk +1 -1
index d2a1033..92d44b9 100644
@@ -25,7 +25,7 @@ endif
 CVS_CONF_OPT = $(CVS_CONFIGURE_ARGS)
 
 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) $(BUILDROOT_TAR_OPTIONS) -
 	rm -f $(@D)/cvs-$(CVS_VERSION).tar.bz2
 endef
 
package/gcc/gcc.mk +1 -1
index 236297d..0a8679b 100644
@@ -70,7 +70,7 @@ define HOST_GCC_EXTRACT_CMDS
 		--exclude='libgo/*' \
 		--exclude='gcc/testsuite/*' \
 		--exclude='libstdc++-v3/testsuite/*' \
-		$(TAR_OPTIONS) -
+		$(BUILDROOT_TAR_OPTIONS) -
 	mkdir -p $(@D)/libstdc++-v3/testsuite/
 	echo "all:" > $(@D)/libstdc++-v3/testsuite/Makefile.in
 	echo "install:" >> $(@D)/libstdc++-v3/testsuite/Makefile.in
package/lsof/lsof.mk +2 -2
index f4b1b4c..d6c0ec2 100644
@@ -42,8 +42,8 @@ endif
 # The .tar.bz2 contains another .tar, which contains the source code.
 define LSOF_EXTRACT_CMDS
         $(call suitable-extractor,$(LSOF_SOURCE)) $(DL_DIR)/$(LSOF_SOURCE) | \
-                $(TAR) -O $(TAR_OPTIONS) - lsof_$(LSOF_VERSION)/lsof_$(LSOF_VERSION)_src.tar | \
-        $(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(LSOF_DIR) $(TAR_OPTIONS) -
+                $(TAR) -O $(BUILDROOT_TAR_OPTIONS) - lsof_$(LSOF_VERSION)/lsof_$(LSOF_VERSION)_src.tar | \
+        $(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(LSOF_DIR) $(BUILDROOT_TAR_OPTIONS) -
 endef
 
 define LSOF_CONFIGURE_CMDS
package/perl/perl.mk +1 -1
index ec94e4f..a6770f2 100644
@@ -31,7 +31,7 @@ PERL_POST_DOWNLOAD_HOOKS += PERL_CROSS_DOWNLOAD
 
 define PERL_CROSS_EXTRACT
 	$(call suitable-extractor,$(PERL_CROSS_SOURCE)) $(DL_DIR)/$(PERL_CROSS_SOURCE) | \
-	$(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(@D) $(TAR_OPTIONS) -
+	$(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $(@D) $(BUILDROOT_TAR_OPTIONS) -
 endef
 PERL_POST_EXTRACT_HOOKS += PERL_CROSS_EXTRACT
 
package/pkg-generic.mk +1 -1
index 1b99c2a..794b2e2 100644
@@ -377,7 +377,7 @@ $(2)_TARGET_DIRCLEAN =		$$($(2)_DIR)/.stamp_dircleaned
 # default extract command
 $(2)_EXTRACT_CMDS ?= \
 	$$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $(DL_DIR)/$$($(2)_SOURCE) | \
-	$(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $$($(2)_DIR) $(TAR_OPTIONS) -)
+	$(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $$($(2)_DIR) $(BUILDROOT_TAR_OPTIONS) -)
 
 # post-steps hooks
 $(2)_POST_DOWNLOAD_HOOKS        ?=
toolchain/toolchain-external/toolchain-external.mk +3 -3
index a7bfafc..616bec5 100644
@@ -377,16 +377,16 @@ ifeq ($(BR2_TOOLCHAIN_EXTERNAL_BLACKFIN_UCLINUX_2012R1)$(BR2_TOOLCHAIN_EXTERNAL_
 define TOOLCHAIN_EXTERNAL_EXTRACT_CMDS
 	mkdir -p $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)
 	$(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) | \
-		$(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(TAR_OPTIONS) -
+		$(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(BUILDROOT_TAR_OPTIONS) -
 	$(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_EXTRA_DOWNLOADS) | \
-		$(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(TAR_OPTIONS) -
+		$(TAR) $(TAR_STRIP_COMPONENTS)=3 --hard-dereference -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(BUILDROOT_TAR_OPTIONS) -
 endef
 else ifneq ($(TOOLCHAIN_EXTERNAL_SOURCE),)
 # Normal handling of toolchain tarball extraction.
 define TOOLCHAIN_EXTERNAL_EXTRACT_CMDS
 	mkdir -p $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)
 	$(call suitable-extractor,$(TOOLCHAIN_EXTERNAL_SOURCE)) $(DL_DIR)/$(TOOLCHAIN_EXTERNAL_SOURCE) | \
-		$(TAR) $(TAR_STRIP_COMPONENTS)=1 --exclude='usr/lib/locale/*' -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(TAR_OPTIONS) -
+		$(TAR) $(TAR_STRIP_COMPONENTS)=1 --exclude='usr/lib/locale/*' -C $(TOOLCHAIN_EXTERNAL_INSTALL_DIR) $(BUILDROOT_TAR_OPTIONS) -
 	$(TOOLCHAIN_EXTERNAL_FIXUP_CMDS)
 endef
 endif
Signature · 1 line
1.8.5.2.169.ge058798
Signature · 1 line
Bye, Peter Korsgaard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 1/1 Rename TAR_OPTIONS to BUILDROOT_TAR_OPTIONS to avoid conflict with GNU tar.

Quoted 19 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Nix" == Nix <[email protected]> writes:

On 26 Jan 2014, Peter Korsgaard verbalised:

Quoted 7 lines

But this should only be an issue if TAR_OPTIONS are exported to the environment, which it isn't:

git grep export | grep -c TAR_OPTIONS
0

Do you perhaps have a local patch which exports it?

Ah, that explains it! I have TAR_OPTIONS set (to --wildcard) in my /etc/environment, which means it lands in make's environment and causes make to update the environment variable when the local makefile variable of the same name is set. Since this export is actually recommended in tar's NEWS and near the top of appendix A in the tar info docs, I suspect a good few 'old hands' used to the old wildcarding GNU tar behaviour might have it set.

Quoted 4 lines

So an alternative (much smaller) patch is to keep the variable name the same, but explicitly unexport it, to keep the local environment from torpedoing things like this. (Presumably we never want the local buildroot TAR_OPTIONS to propagate into the environment like this.)

Indeed, and likewise we don't want a user's custom TAR_OPTIONS to affect the behaviour of Buildroot, so we should just unexport it like we do for E.G. GREP_OPTIONS.

Care to send a patch doing that? Thanks.

Signature · 1 line
Bye, Peter Korsgaard 

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

PATCH 1/1 Unexport TAR_OPTIONS.

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Nix" == Nix <[email protected]> writes:

GNU tar > 1.13.17 interprets TAR_OPTIONS as an environment variable containing options to be prepended to the set on the command line.

Quoted 7 lines

Since we use the same variable, if the user's environment already contains TAR_OPTIONS, our use of the same variable name modifies the environment and causes untars to misbehave when TAR_OPTIONS causes a -xf to be prepended to the tar command line, likely converting a subsequent flag into a spurious filename.

Committed, thanks.

Quoted 10 lines
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Quoted 5 lines

Indeed, and likewise we don't want a user's custom TAR_OPTIONS to affect the behaviour of Buildroot, so we should just unexport it like we do for E.G. GREP_OPTIONS.

Care to send a patch doing that? Thanks.

Quoted 7 lines

Instant patch. (I wish the problems I'm having with a 32-bit fakeroot trying to run 64-bit stuff from the host and freezing with horrible communication-related errors were so easy to solve... I might just revamp the three-year-old buildroot fork I'm working from so it's not relying on a 32-bit external codesourcery toolchain and build the damn toolchain myself. That seems likely to be easier than debugging *anything* to do with never-to-be-sufficiently-cursed fakeroot.)

Yes please - We've added quite some features and fixed bugs during the last 3 years!

Quoted 14 lines
Makefile +1 -0
index 9dfb1e0..067458b 100644
@@ -261,6 +261,7 @@ unexport CPP
 unexport CFLAGS
 unexport CXXFLAGS
 unexport GREP_OPTIONS
+unexport TAR_OPTIONS
 unexport CONFIG_SITE
 unexport QMAKESPEC
 unexport TERMINFO
Signature · 1 line
1.8.5.2.169.ge058798
Signature · 1 line
Bye, Peter Korsgaard