From 3a7dc7aa73ac07bc079feea374a51f47fd586bc0 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 31 Mar 2013 20:35:05 +0200 Subject: [PATCH] Don't ever try to overwrite /usr/bin/git Previously, version.sh got the path to git as its first and only argument. Since the previous commit, this is not the path to src/version.cpp and the second argument is the path to git. However, let's assume someone does "git pull && make". They still have the old Makefile laying around, which will pass the path to git as the first argument to version.sh. Thus, this will overwrite /usr/bin/git with some generated source code. Whoops. Thanks to KindOne for reporting this problem! Signed-off-by: Uli Schlachter --- Makefile.in | 4 ++-- version.sh | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index 7dd0fd19..02ed37b9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -103,10 +103,10 @@ src/%.o: src/%.cpp Makefile # If git-describe differs from .version_extra, add a phony target to dependencies, forcing version.o to be recompiled # znc-0.200-430-g80acaa7 -> -DVERSION_EXTRA="\"-git-430-80acaa7\"" -src/version.cpp: Makefile version.sh $(shell if [ x`cat .version_extra 2> /dev/null` != x`$(srcdir)/version.sh '' $(GIT) 2> /dev/null` ]; then echo version_extra_recompile; fi) +src/version.cpp: Makefile version.sh $(shell if [ x`cat .version_extra 2> /dev/null` != x`$(srcdir)/version.sh $(GIT) 2> /dev/null` ]; then echo version_extra_recompile; fi) @mkdir -p .depend src $(E) Building source file version.cpp... - $(Q)$(srcdir)/version.sh "$@" "$(GIT)" > .version_extra 2> /dev/null + $(Q)WRITE_OUTPUT=yes $(srcdir)/version.sh "$(GIT)" > .version_extra 2> /dev/null install: znc $(LIBZNC) test -d $(DESTDIR)$(bindir) || $(INSTALL) -d $(DESTDIR)$(bindir) diff --git a/version.sh b/version.sh index 3a5e4e16..33aa95a5 100755 --- a/version.sh +++ b/version.sh @@ -3,11 +3,8 @@ # Get the path to the source directory GIT_DIR=`dirname $0` -# Our first argument should be the file that we write to -OUTPUT="$1" - -# Our second argument should be the path to git -GIT="$2" +# Our argument should be the path to git +GIT="$1" if [ "x$GIT" = "x" ] then EXTRA="" @@ -30,10 +27,10 @@ else fi # Generate output file, if any -if [ "x$OUTPUT" != "x" ] +if [ "x$WRITE_OUTPUT" = "xyes" ] then - echo '#include ' > $OUTPUT - echo "const char* ZNC_VERSION_EXTRA = \"$EXTRA\";" >> $OUTPUT + echo '#include ' > src/version.cpp + echo "const char* ZNC_VERSION_EXTRA = \"$EXTRA\";" >> src/version.cpp fi echo "$EXTRA"