maint: Replace "build-aux/gnu-fetch" with 'fetch' maintainer rule

Fetching third-party files inside a make rule is convenient and less
error prone since 'make' has access to '$srcdir'.

* build-aux/gnu-fetch: Delete.
* maint.mk (WGET, git_sv_host, sv_git_am, sv_git_gl)
(fetchfiles): New macros.
(fetch): New target.
* HACKING <Updating auxilary scripts>: Update instructions.
This commit is contained in:
Mathieu Lirzin 2018-03-25 22:55:01 +02:00
commit e66f0dcdd6
No known key found for this signature in database
GPG key ID: 0ADEE10094604D37
3 changed files with 44 additions and 98 deletions

View file

@ -55,7 +55,7 @@ follows.
* Updating auxilary scripts * Updating auxilary scripts
Fetch new versions of the files that are maintained in other GNU Fetch new versions of the files that are maintained in other GNU
repositories by running "cd build-aux; ./gnu-fetch". In case any file in the repositories by running "make fetch". In case any file in the
Mcron repository has been updated, commit and re-run the testsuite. Mcron repository has been updated, commit and re-run the testsuite.
* Code coverage * Code coverage

View file

@ -1,97 +0,0 @@
#!/bin/sh
# Fetch files maintained in other GNU repositories.
scriptversion=2018-03-24.21; # UTC
# Copyright © 2018 Mathieu Lirzin <mthl@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -e
WGET=wget
# Git repositories on Savannah.
git_sv_host='git.savannah.gnu.org'
# Some repositories we sync files from.
sv_git_am="https://${git_sv_host}/gitweb/?p=automake.git;a=blob_plain;hb=HEAD;f="
sv_git_gl="https://${git_sv_host}/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f="
# Files that we fetch and which we compare against.
# Note that the 'lib/COPYING' file must still be synced by hand.
FETCHFILES="
${sv_git_am}contrib/test-driver.scm
${sv_git_gl}build-aux/gitlog-to-changelog
${sv_git_gl}build-aux/do-release-commit-and-tag
${sv_git_gl}build-aux/gnu-web-doc-update
${sv_git_gl}build-aux/gnupload
"
usage="Usage: $0
fetch files maintained in other GNU repositories
"
while test -n "$1"
do
case $1 in
-*)
case $1 in
--help)
echo "$usage"
exit $?
;;
--version)
echo "gnu-fetch $scriptversion"
exit $?
;;
--)
shift
break
;;
-*)
echo "$0: Unknown option '$1', try '$0 --help'" 1>&2
exit 1
;;
esac
;;
esac
shift
done
rm -rf Fetchdir
mkdir Fetchdir
for url in ${FETCHFILES}
do
file=`printf '%s\n' "$url" | sed 's|^.*/||; s|^.*=||'`
"$WGET" -nv "$url" -O "Fetchdir/$file" || exit 1
if cmp "Fetchdir/$file" "$file" >/dev/null; then
: Nothing to do
else
echo "$0: updating file $file"
cp "Fetchdir/$file" "$file" || exit 1
fi
done
rm -rf Fetchdir
exit 0
# Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View file

@ -18,3 +18,46 @@
# Rebuild Makefile.in if this file is modifed. # Rebuild Makefile.in if this file is modifed.
Makefile.in: maint.mk Makefile.in: maint.mk
## -------------------- ##
## Third-party files. ##
## ---------------------##
WGET = wget
# Git repositories on Savannah.
git_sv_host = git.savannah.gnu.org
# Some repositories we sync files from.
sv_git_am = 'https://$(git_sv_host)/gitweb/?p=automake.git;a=blob_plain;hb=HEAD;f='
sv_git_gl = 'https://$(git_sv_host)/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
# Files that we fetch and which we compare against.
# Note that the 'lib/COPYING' file must still be synced by hand.
fetchfiles = \
$(sv_git_am)contrib/test-driver.scm \
$(sv_git_gl)build-aux/do-release-commit-and-tag \
$(sv_git_gl)build-aux/gitlog-to-changelog \
${sv_git_gl}build-aux/gnu-web-doc-update \
$(sv_git_gl)build-aux/gnupload
# Fetch the latest versions of few scripts and files we care about.
# A retrieval failure or a copying failure usually mean serious problems,
# so we'll just bail out if 'wget' or 'cp' fail.
fetch:
$(AM_V_at)rm -rf Fetchdir
$(AM_V_at)mkdir Fetchdir
$(AM_V_GEN)set -e; \
if $(AM_V_P); then wget_opts=; else wget_opts=-nv; fi; \
for url in $(fetchfiles); do \
file=`printf '%s\n' "$$url" | sed 's|^.*/||; s|^.*=||'`; \
$(WGET) $$wget_opts "$$url" -O Fetchdir/$$file || exit 1; \
if cmp Fetchdir/$$file $(srcdir)/build-aux/$$file >/dev/null; then \
: Nothing to do; \
else \
echo "$@: updating file $$file"; \
cp Fetchdir/$$file $(srcdir)/build-aux/$$file || exit 1; \
fi; \
done
$(AM_V_at)rm -rf Fetchdir
.PHONY: fetch