* bootstrap: Update from gnulib

This commit is contained in:
Tim Rühsen
2024-11-10 11:30:53 +01:00
parent 27c8c96350
commit 44472c59b8

272
bootstrap
View File

@ -3,7 +3,7 @@
# Bootstrap this package from checked-out sources. # Bootstrap this package from checked-out sources.
scriptversion=2023-12-10.18; # UTC scriptversion=2024-07-04.10; # UTC
# Copyright (C) 2003-2024 Free Software Foundation, Inc. # Copyright (C) 2003-2024 Free Software Foundation, Inc.
# #
@ -37,7 +37,7 @@ medir=`dirname "$me"`
# A library of shell functions for autopull.sh, autogen.sh, and bootstrap. # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
scriptlibversion=2023-12-10.18; # UTC scriptlibversion=2024-07-21.12; # UTC
# Copyright (C) 2003-2024 Free Software Foundation, Inc. # Copyright (C) 2003-2024 Free Software Foundation, Inc.
# #
@ -478,10 +478,9 @@ find_tool ()
# --------------------- Preparing GNULIB_SRCDIR for use. --------------------- # --------------------- Preparing GNULIB_SRCDIR for use. ---------------------
# This is part of autopull.sh, but bootstrap needs it too, for self-upgrading. # This is part of autopull.sh, but bootstrap needs it too, for self-upgrading.
# cleanup_gnulib fails, removing the directory $gnulib_path first.
cleanup_gnulib() { cleanup_gnulib() {
status=$? status=$?
# XXX It's a bad idea to erase the submodule directory if it contains local
# modifications.
rm -fr "$gnulib_path" rm -fr "$gnulib_path"
exit $status exit $status
} }
@ -499,54 +498,61 @@ prepare_GNULIB_SRCDIR ()
test -f "$GNULIB_SRCDIR/gnulib-tool" \ test -f "$GNULIB_SRCDIR/gnulib-tool" \
|| die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \ || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \
"but does not contain gnulib-tool" "but does not contain gnulib-tool"
elif $use_git; then if test -n "$GNULIB_REVISION" && $use_git; then
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it is
# branch name that can be fetched from origin. It fails, however,
# if the GNULIB_REVISION is a commit hash that only exists in
# origin. In this case, we need a 'git fetch' and then retry
# 'git checkout "$GNULIB_REVISION"'.
(cd "$GNULIB_SRCDIR" \
&& { git checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git fetch origin && git checkout "$GNULIB_REVISION"; }
}
) || exit $?
fi
else
if ! $use_git; then
die "Error: --no-git is specified," \
"but neither --gnulib-srcdir nor \$GNULIB_SRCDIR is specified"
fi
if git submodule -h | grep -- --reference > /dev/null; then
:
else
die "git version is too old, git >= 1.6.4 is required"
fi
gnulib_path=$(git_modules_config submodule.gnulib.path) gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib if test -n "$gnulib_path"; then
# A submodule 'gnulib' is configured.
# Get gnulib files. Populate $gnulib_path, possibly updating a # Get gnulib files. Populate $gnulib_path, updating the submodule.
# submodule, for use in the rest of the script. if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git; then
# Use GNULIB_REFDIR as a reference.
if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git \ echo "$0: getting gnulib files..."
&& git_modules_config submodule.gnulib.url >/dev/null; then git submodule update --init --reference "$GNULIB_REFDIR" "$gnulib_path"\
# Use GNULIB_REFDIR as a reference. || exit $?
echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then
# Prefer the one-liner available in git 1.6.4 or newer.
git submodule update --init --reference "$GNULIB_REFDIR" \
"$gnulib_path" || exit $?
else else
# This fallback allows at least git 1.5.5. # GNULIB_REFDIR is not set or not usable. Ignore it.
if test -f "$gnulib_path"/gnulib-tool; then if git_modules_config submodule.gnulib.url >/dev/null; then
# Since file already exists, assume submodule init already complete. echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $? git submodule update -- "$gnulib_path" || exit $?
else else
# Older git can't clone into an empty directory. die "Error: submodule 'gnulib' has no configured url"
rmdir "$gnulib_path" 2>/dev/null
git clone --reference "$GNULIB_REFDIR" \
"$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
&& git submodule init -- "$gnulib_path" \
&& git submodule update -- "$gnulib_path" \
|| exit $?
fi fi
fi fi
else else
# GNULIB_REFDIR is not set or not usable. Ignore it. gnulib_path='gnulib'
if git_modules_config submodule.gnulib.url >/dev/null; then if test ! -d "$gnulib_path"; then
# The subdirectory 'gnulib' does not yet exist. Clone into it.
echo "$0: getting gnulib files..." echo "$0: getting gnulib files..."
git submodule init -- "$gnulib_path" || exit $?
git submodule update -- "$gnulib_path" || exit $?
elif [ ! -d "$gnulib_path" ]; then
echo "$0: getting gnulib files..."
trap cleanup_gnulib HUP INT PIPE TERM trap cleanup_gnulib HUP INT PIPE TERM
gnulib_url=${GNULIB_URL:-$default_gnulib_url}
shallow= shallow=
if test -z "$GNULIB_REVISION"; then if test -z "$GNULIB_REVISION"; then
if git clone -h 2>&1 | grep -- --depth > /dev/null; then if git clone -h 2>&1 | grep -- --depth > /dev/null; then
shallow='--depth 2' shallow='--depth 2'
fi fi
git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \ git clone $shallow "$gnulib_url" "$gnulib_path" \
|| cleanup_gnulib || cleanup_gnulib
else else
if git fetch -h 2>&1 | grep -- --depth > /dev/null; then if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
@ -562,30 +568,43 @@ prepare_GNULIB_SRCDIR ()
# is without fetching all commits. So fall back to fetching all # is without fetching all commits. So fall back to fetching all
# commits. # commits.
git -C "$gnulib_path" init git -C "$gnulib_path" init
git -C "$gnulib_path" remote add origin \ git -C "$gnulib_path" remote add origin "$gnulib_url"
${GNULIB_URL:-$default_gnulib_url}
git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
|| git -C "$gnulib_path" fetch origin \ || git -C "$gnulib_path" fetch origin \
|| cleanup_gnulib || cleanup_gnulib
git -C "$gnulib_path" reset --hard FETCH_HEAD git -C "$gnulib_path" reset --hard FETCH_HEAD
(cd "$gnulib_path" && git checkout "$GNULIB_REVISION") \
|| cleanup_gnulib
fi fi
trap - HUP INT PIPE TERM trap - HUP INT PIPE TERM
else
# The subdirectory 'gnulib' already exists.
if test -n "$GNULIB_REVISION"; then
if test -d "$gnulib_path/.git"; then
# The 'git checkout "$GNULIB_REVISION"' command succeeds if the
# GNULIB_REVISION is a commit hash that exists locally, or if it is
# branch name that can be fetched from origin. It fails, however,
# if the GNULIB_REVISION is a commit hash that only exists in
# origin. In this case, we need a 'git fetch' and then retry
# 'git checkout "$GNULIB_REVISION"'.
(cd "$gnulib_path" \
&& { git checkout "$GNULIB_REVISION" 2>/dev/null \
|| { git fetch origin && git checkout "$GNULIB_REVISION"; }
}
) || exit $?
else
die "Error: GNULIB_REVISION is specified in bootstrap.conf," \
"but '$gnulib_path' contains no git history"
fi
fi
fi fi
fi fi
GNULIB_SRCDIR=$gnulib_path # Verify that $gnulib_path contains a gnulib checkout.
# Verify that the submodule contains a gnulib checkout.
test -f "$gnulib_path/gnulib-tool" \ test -f "$gnulib_path/gnulib-tool" \
|| die "Error: $gnulib_path is supposed to contain a gnulib checkout," \ || die "Error: '$gnulib_path' is supposed to contain a gnulib checkout," \
"but does not contain gnulib-tool" "but does not contain gnulib-tool"
GNULIB_SRCDIR=$gnulib_path
fi fi
# XXX Should this be done if $use_git is false?
if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
&& ! git_modules_config submodule.gnulib.url >/dev/null; then
(cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
fi
# $GNULIB_SRCDIR now points to the version of gnulib to use, and # $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here. # we no longer need to use git or $gnulib_path below here.
} }
@ -647,7 +666,8 @@ fi
autopull_usage() { autopull_usage() {
cat <<EOF cat <<EOF
Usage: $me [OPTION]... Usage: $me [OPTION]...
Bootstrap this package from the checked-out sources. Bootstrap this package from the checked-out sources, phase 1:
Pull files from the network.
Optional environment variables: Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib GNULIB_SRCDIR Specifies the local directory where gnulib
@ -664,18 +684,19 @@ Optional environment variables:
which is Gnulib's upstream repository. which is Gnulib's upstream repository.
Options: Options:
--bootstrap-sync if this bootstrap script is not identical to
--bootstrap-sync If this bootstrap script is not identical to
the version in the local gnulib sources, the version in the local gnulib sources,
update this script, and then restart it with update this script, and then restart it with
/bin/sh or the shell \$CONFIG_SHELL /bin/sh or the shell \$CONFIG_SHELL.
--no-bootstrap-sync do not check whether bootstrap is out of sync --no-bootstrap-sync Do not check whether bootstrap is out of sync.
--force attempt to bootstrap even if the sources seem
not to have been checked out --force Attempt to bootstrap even if the sources seem
--no-git do not use git to update gnulib. Requires that not to have been checked out.
\$GNULIB_SRCDIR or the --gnulib-srcdir option --no-git Do not use git to update gnulib. Requires that
points to a gnulib repository with the correct \$GNULIB_SRCDIR points to a gnulib repository
revision with the correct revision.
--skip-po do not download po files --skip-po Do not download *.po files.
EOF EOF
bootstrap_print_option_usage_hook bootstrap_print_option_usage_hook
cat <<EOF cat <<EOF
@ -687,17 +708,16 @@ are honored.
Gnulib sources can be fetched in various ways: Gnulib sources can be fetched in various ways:
* If the environment variable GNULIB_SRCDIR is set (either as an * If the environment variable GNULIB_SRCDIR is set, then sources are
environment variable or via the --gnulib-srcdir option), then sources fetched from that local directory. If it is a git repository and the
are fetched from that local directory. If it is a git repository and configuration variable GNULIB_REVISION is set in bootstrap.conf, then
the configuration variable GNULIB_REVISION is set in bootstrap.conf, that revision is checked out.
then that revision is checked out.
* Otherwise, if this package is in a git repository with a 'gnulib' * Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated submodule configured, then that submodule is initialized and updated
and sources are fetched from there. If GNULIB_REFDIR is set (either and sources are fetched from there. If the environment variable
as an environment variable or via the --gnulib-refdir option) and is GNULIB_REFDIR is set and is a git repository, then it is used as a
a git repository, then it is used as a reference. reference.
* Otherwise, if the 'gnulib' directory does not exist, Gnulib sources * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
are cloned into that directory using git from \$GNULIB_URL, defaulting are cloned into that directory using git from \$GNULIB_URL, defaulting
@ -890,7 +910,8 @@ update_po_files() {
autogen_usage() { autogen_usage() {
cat <<EOF cat <<EOF
Usage: $me [OPTION]... Usage: $me [OPTION]...
Bootstrap this package from the checked-out sources. Bootstrap this package from the checked-out sources, phase 2:
Generate files from local files (no network access).
Optional environment variables: Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib GNULIB_SRCDIR Specifies the local directory where gnulib
@ -899,9 +920,9 @@ Optional environment variables:
you want to use these sources. you want to use these sources.
Options: Options:
--copy copy files instead of creating symbolic links --copy Copy files instead of creating symbolic links.
--force attempt to bootstrap even if the sources seem --force Attempt to bootstrap even if the sources seem
not to have been checked out not to have been checked out.
EOF EOF
bootstrap_print_option_usage_hook bootstrap_print_option_usage_hook
cat <<EOF cat <<EOF
@ -1234,6 +1255,20 @@ autogen()
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \ $gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed" || die "gnulib-tool failed"
if test $with_gettext = yes && test ! -f $m4_base/gettext.m4; then
# The gnulib-tool invocation has removed $m4_base/gettext.m4, that the
# AUTOPOINT invocation had installed. This can occur when the gnulib
# module 'gettext' was previously present but is now not present any more.
# Repeat the AUTOPOINT invocation and the gnulib-tool invocation.
echo "$0: $AUTOPOINT --force"
$AUTOPOINT --force || return
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
|| die "gnulib-tool failed"
fi
for file in $gnulib_files; do for file in $gnulib_files; do
symlink_to_dir "$GNULIB_SRCDIR" $file \ symlink_to_dir "$GNULIB_SRCDIR" $file \
|| die "failed to symlink $file" || die "failed to symlink $file"
@ -1331,7 +1366,7 @@ autogen()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Local Variables: # Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptlibversion=" # time-stamp-start: "scriptlibversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0" # time-stamp-time-zone: "UTC0"
@ -1347,44 +1382,55 @@ Optional environment variables:
GNULIB_SRCDIR Specifies the local directory where gnulib GNULIB_SRCDIR Specifies the local directory where gnulib
sources reside. Use this if you already sources reside. Use this if you already
have gnulib sources on your machine, and have gnulib sources on your machine, and
do not want to waste your bandwidth downloading you want to use these sources.
them again. GNULIB_REFDIR Specifies the local directory where a gnulib
GNULIB_URL URL of the gnulib repository. The default is
$default_gnulib_url,
which is Gnulib's upstream repository.
Options:
--pull Do phase 1: pull files from network
--gen Do phase 2: generate from local files.
(The default is to do both phases.)
--gnulib-srcdir=DIRNAME specify the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
you want to use these sources. Defaults
to \$GNULIB_SRCDIR
--gnulib-refdir=DIRNAME specify the local directory where a gnulib
repository (with a .git subdirectory) resides. repository (with a .git subdirectory) resides.
Use this if you already have gnulib sources Use this if you already have gnulib sources
and history on your machine, and do not want and history on your machine, and do not want
to waste your bandwidth downloading them again. to waste your bandwidth downloading them again.
Defaults to \$GNULIB_REFDIR Only used for phase 1 (--pull).
GNULIB_URL URL of the gnulib repository. The default is
$default_gnulib_url,
which is Gnulib's upstream repository.
Only used for phase 1 (--pull).
--bootstrap-sync if this bootstrap script is not identical to Options:
--pull Do phase 1: Pull files from the network.
--gen Do phase 2: Generate files from local files
(no network access).
(The default is to do both phases.)
--gnulib-srcdir=DIRNAME Specifies the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
you want to use these sources. Defaults
to \$GNULIB_SRCDIR.
--gnulib-refdir=DIRNAME Specifies the local directory where a gnulib
repository (with a .git subdirectory) resides.
Use this if you already have gnulib sources
and history on your machine, and do not want
to waste your bandwidth downloading them again.
Defaults to \$GNULIB_REFDIR.
Only used for phase 1 (--pull).
--bootstrap-sync If this bootstrap script is not identical to
the version in the local gnulib sources, the version in the local gnulib sources,
update this script, and then restart it with update this script, and then restart it with
/bin/sh or the shell \$CONFIG_SHELL /bin/sh or the shell \$CONFIG_SHELL.
--no-bootstrap-sync do not check whether bootstrap is out of sync --no-bootstrap-sync Do not check whether bootstrap is out of sync.
--copy copy files instead of creating symbolic links --copy Copy files instead of creating symbolic links.
--force attempt to bootstrap even if the sources seem Only used for phase 2 (--gen).
not to have been checked out --force Attempt to bootstrap even if the sources seem
--no-git do not use git to update gnulib. Requires that not to have been checked out.
--no-git Do not use git to update gnulib. Requires that
\$GNULIB_SRCDIR or the --gnulib-srcdir option \$GNULIB_SRCDIR or the --gnulib-srcdir option
points to a gnulib repository with the correct points to a gnulib repository with the correct
revision revision.
--skip-po do not download po files Only used for phase 1 (--pull).
--skip-po Do not download *.po files.
Only used for phase 1 (--pull).
EOF EOF
bootstrap_print_option_usage_hook bootstrap_print_option_usage_hook
cat <<EOF cat <<EOF
@ -1396,11 +1442,11 @@ are honored.
Gnulib sources can be fetched in various ways: Gnulib sources can be fetched in various ways:
* If the environment variable GNULIB_SRCDIR is set (either as an * If GNULIB_SRCDIR is set (either as an environment variable or via the
environment variable or via the --gnulib-srcdir option), then sources --gnulib-srcdir option), then sources are fetched from that local
are fetched from that local directory. If it is a git repository and directory. If it is a git repository and the configuration variable
the configuration variable GNULIB_REVISION is set in bootstrap.conf, GNULIB_REVISION is set in bootstrap.conf, then that revision is
then that revision is checked out. checked out.
* Otherwise, if this package is in a git repository with a 'gnulib' * Otherwise, if this package is in a git repository with a 'gnulib'
submodule configured, then that submodule is initialized and updated submodule configured, then that submodule is initialized and updated
@ -1521,16 +1567,16 @@ if $pull && { $use_git || test -z "$SKIP_PO"; }; then
fi fi
if $gen; then if $gen; then
autogen \ autogen \
`if $copy; then echo ' --copy'; fi` \ `if $copy; then echo ' --copy'; fi` \
`if test -z "$checkout_only_file"; then echo ' --force'; fi` \ `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
|| die "could not generate auxiliary files" || die "could not generate auxiliary files"
fi fi
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Local Variables: # Local Variables:
# eval: (add-hook 'before-save-hook 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0" # time-stamp-time-zone: "UTC0"