Installation failure caused by CDPATH environment variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This week I've installed Git on two different machines and one of them mysteriously failed making the "install" target in the "templates/Makefile". Specifically, the problem was occuring here:

        (cd blt && $(TAR) cf - .) | \
        (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)

And the error message was:

tar: This does not look like a tar archive
tar: Skipping to next header
tar: Error exit delayed from previous errors

Upon investigation, I discovered that the cause was that on the failing machine, the CDPATH environment variable was set and included "." (the current directory). This meant that upon executing:

        (cd blt && $(TAR) cf - .)

The data from tar was getting prepended with garbage because "cd blt" was echoing the path to the directory.

The workaround is to "unset CDPATH" or change the value of CDPATH so that it doesn't include the "." (although the latter is not very feasible because without "." at the front of CDPATH changing into a directory relative to the current directory can be quite painful).

What do you think about altering the templates/Makefile to make it more robust against this kind of environment?

Here's a possible patch:

From 057630bdcfeee63b90468d1a69153171b15780c0 Mon Sep 17 00:00:00 2001
From: Wincent Colaiuta <win@xxxxxxxxxxx>
Date: Wed, 11 Jul 2007 18:43:59 +0200

[PATCH] Proof Makefile against possible problems with CDPATH environment

If the CDPATH environment variable is set and contains a period
Bash may echo the current directory name while performing a cd,
and when this extra output is piped to tar as part of template
installation it can cause tar to abort with an error. This patch
avoids this problem by invoking cd as a separate step prior to
invoking tar.

Signed-off-by: Wincent Colaiuta <win@xxxxxxxxxxx>
---
 templates/Makefile |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/templates/Makefile b/templates/Makefile
index aaa39d3..3457ccb 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -46,5 +46,6 @@ clean:

 install: all
        $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'
-       (cd blt && $(TAR) cf - .) | \
+       cd blt && $(TAR) cf - . | \
        (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)
+       cd -
--
1.5.2.3


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux