]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
build: Fix build failure in VPATH builds outside of the source tree.
authorBruno Haible <bruno@clisp.org>
Wed, 7 Jan 2026 21:00:50 +0000 (22:00 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 7 Jan 2026 21:00:50 +0000 (22:00 +0100)
* build-aux/jar-cf: Unset CDPATH. Run 'git log' from $top_srcdir, not from the
current directory.

build-aux/jar-cf

index bffd52141b2fc742b95aff54509839a5e222c57d..7e5139e7633e2c5d247bdcd9005c39fc26b4849d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Creating a Java archive (.jar).
 
-# Copyright (C) 2024 Free Software Foundation, Inc.
+# Copyright (C) 2024-2026 Free Software Foundation, Inc.
 #
 # This file is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published
@@ -40,7 +40,7 @@ Send patches and bug reports to <bug-gettext@gnu.org>."
 func_version ()
 {
   echo "jar-cf (GNU gettext)"
-  echo "Copyright (C) 2024 Free Software Foundation, Inc.
+  echo "Copyright (C) 2026 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <https://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."
@@ -94,13 +94,16 @@ top_srcdir="$2"
 shift
 shift
 
+# Unset CDPATH.  Otherwise, output from 'cd dir' can surprise callers.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
 if $jar_program --help 2>&1 | grep '\--date=' >/dev/null; then
   # The JAR_PROGRAM supports the --date option. Its effect is to set the given
   # date as time stamp on all the ELEMENTs and also the META-INF/MANIFEST.MF.
   # Use it, for reproducibility (cf. <https://reproducible-builds.org/>).
   if test -d "$top_srcdir/.git"; then
     # We are in a git checkout. Use the date of the latest commit.
-    date=`git log -n 1 --date=iso --format=fuller | sed -n -e 's/^CommitDate: //p' | sed -e 's/ /T/' -e 's/ \(...\)\(..\)$/\1:\2/'`
+    date=`cd "$top_srcdir" && git log -n 1 --date=iso --format=fuller | sed -n -e 's/^CommitDate: //p' | sed -e 's/ /T/' -e 's/ \(...\)\(..\)$/\1:\2/'`
   else
     # We are building from a tarball.
     # Use the date of the first entry of the ChangeLog file.