build: Fix build failure in VPATH builds outside of the source tree.

* build-aux/jar-cf: Unset CDPATH. Run 'git log' from $top_srcdir, not from the
current directory.
This commit is contained in:
Bruno Haible 2026-01-07 22:00:50 +01:00
parent 7d6d59eb6a
commit 9740ab9ef6

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Creating a Java archive (.jar). # 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 # This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published # 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 () func_version ()
{ {
echo "jar-cf (GNU gettext)" 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> 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. This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law." There is NO WARRANTY, to the extent permitted by law."
@ -94,13 +94,16 @@ top_srcdir="$2"
shift shift
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 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 # 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. # date as time stamp on all the ELEMENTs and also the META-INF/MANIFEST.MF.
# Use it, for reproducibility (cf. <https://reproducible-builds.org/>). # Use it, for reproducibility (cf. <https://reproducible-builds.org/>).
if test -d "$top_srcdir/.git"; then if test -d "$top_srcdir/.git"; then
# We are in a git checkout. Use the date of the latest commit. # 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 else
# We are building from a tarball. # We are building from a tarball.
# Use the date of the first entry of the ChangeLog file. # Use the date of the first entry of the ChangeLog file.