]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fetch gnulib files from gitweb.
authorZack Weinberg <zackw@panix.com>
Thu, 3 Sep 2020 15:40:50 +0000 (11:40 -0400)
committerZack Weinberg <zackw@panix.com>
Thu, 3 Sep 2020 15:40:50 +0000 (11:40 -0400)
‘make fetch’ pulls the files maintained by Automake from gitweb, so we
always get the HEAD revision at the time of the operation.  The files
maintained by Gnulib, on the other hand, are just copied from whatever
local gnulib checkout you happen to have on your hard drive at the
time, which might not have been updated recently and might not even be
checked out from gnulib trunk.

This patch makes us use the same logic for Gnulib that we do for
Automake.  It also pulls all of the code out of cfg.mk to a separate
shell script.  The lists of files to update from each repository are
also moved to that file.

 * build-aux/fetch.sh: New script.  Lists of files to fetch from
   Gnulib and Automake are now kept here.
 * cfg.mk (fetch): Run fetch.sh, it does all the work.
   (gnulib-update, autom4te-update, WGETFLAGS, automake_gitweb)
   (autom4te_files, move_if_change): Delete.

build-aux/fetch.sh [new file with mode: 0755]
cfg.mk

diff --git a/build-aux/fetch.sh b/build-aux/fetch.sh
new file mode 100755 (executable)
index 0000000..bbb7d40
--- /dev/null
@@ -0,0 +1,77 @@
+#! /bin/sh
+
+: "${WGET=wget}"
+: "${PERL=perl}"
+
+gitweb_base="https://git.savannah.gnu.org/gitweb/?p="
+gitweb_op=";a=blob_plain;hb=HEAD;f="
+
+gnulib_gitweb="${gitweb_base}gnulib.git${gitweb_op}"
+automake_gitweb="${gitweb_base}automake.git${gitweb_op}"
+
+# This list should be in alphabetical order, *except* that this script
+# uses move-if-change itself, so that one should be first.
+gnulib_files="
+       build-aux/move-if-change
+       build-aux/announce-gen
+       build-aux/config.guess
+       build-aux/config.sub
+       build-aux/gendocs.sh
+       build-aux/git-version-gen
+       build-aux/gitlog-to-changelog
+       build-aux/gnupload
+       build-aux/install-sh
+       build-aux/mdate-sh
+       build-aux/texinfo.tex
+       build-aux/update-copyright
+       build-aux/useless-if-before-free
+       build-aux/vc-list-files
+       doc/fdl.texi
+       doc/gendocs_template
+       doc/gnu-oids.texi
+       doc/make-stds.texi
+       doc/standards.texi
+       m4/autobuild.m4
+       top/GNUmakefile
+       top/maint.mk
+"
+
+automake_files="
+        lib/Automake/Channels.pm
+        lib/Automake/FileUtils.pm
+        lib/Automake/Getopt.pm
+        lib/Automake/XFile.pm
+"
+
+srcdir="$1"
+shift
+
+move_if_change="${srcdir}/build-aux/move-if-change"
+
+scratch="$(mktemp -p . -d fetch.XXXXXXXXX)"
+trap "rm -rf '$scratch'" 0
+
+run () {
+    printf '+ %s\n' "$*"
+    "$@" || exit 1
+}
+
+for file in $gnulib_files; do
+    fbase="${file##*/}"
+    destdir="${file%/*}"
+    if [ "$destdir" = top ]; then
+        dest="${srcdir}/${fbase}"
+    else
+        dest="${srcdir}/${file}"
+    fi
+    run "$WGET" -nv -O "${scratch}/${fbase}" "${gnulib_gitweb}${file}"
+    run "$move_if_change" "${scratch}/${fbase}" "$dest"
+done
+
+for file in $automake_files; do
+    fbase="${file##*/}"
+    dest="${srcdir}/lib/Autom4te/${fbase}"
+    run "$WGET" -nv -O "${scratch}/${fbase}" "${automake_gitweb}${file}"
+    run "$PERL" -pi -e 's/Automake::/Autom4te::/g' "${scratch}/${fbase}"
+    run "$move_if_change" "${scratch}/${fbase}" "$dest"
+done
diff --git a/cfg.mk b/cfg.mk
index b9401f1134afaec67e11a379871487245fb9d9e3..e6dc499695c2f727e5075f07bfa03a0ff9ea8e38 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -46,62 +46,14 @@ To: $(announcement_mail-$(RELEASE_TYPE))                            \
 CC: $(announcement_Cc_)                                                        \
 Mail-Followup-To: autoconf@gnu.org
 
-# Update files from gnulib.
-.PHONY: fetch gnulib-update autom4te-update
-fetch: gnulib-update autom4te-update
-
-gnulib-update:
-       cp $(gnulib_dir)/build-aux/announce-gen $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/config.guess $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/config.sub $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/gendocs.sh $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/git-version-gen $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/gitlog-to-changelog $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/gnupload $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/install-sh $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/mdate-sh $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/move-if-change $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/texinfo.tex $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/update-copyright $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/useless-if-before-free $(srcdir)/build-aux
-       cp $(gnulib_dir)/build-aux/vc-list-files $(srcdir)/build-aux
-       cp $(gnulib_dir)/doc/fdl.texi $(srcdir)/doc
-       cp $(gnulib_dir)/doc/gendocs_template $(srcdir)/doc
-       cp $(gnulib_dir)/doc/gnu-oids.texi $(srcdir)/doc
-       cp $(gnulib_dir)/doc/make-stds.texi $(srcdir)/doc
-       cp $(gnulib_dir)/doc/standards.texi $(srcdir)/doc
-       cp $(gnulib_dir)/m4/autobuild.m4 $(srcdir)/m4
-       cp $(gnulib_dir)/top/GNUmakefile $(srcdir)
-       cp $(gnulib_dir)/top/maint.mk $(srcdir)
+# Update files maintained in gnulib and autom4te.
+.PHONY: fetch
 
 WGET = wget
-WGETFLAGS = -C off
-
-## Fetch the latest versions of files we care about.
-automake_gitweb = \
-  https://git.savannah.gnu.org/gitweb/?p=automake.git;a=blob_plain;hb=HEAD;
-autom4te_files = \
-  Autom4te/Channels.pm \
-  Autom4te/FileUtils.pm \
-  Autom4te/Getopt.pm \
-  Autom4te/XFile.pm
-
-move_if_change = '$(abs_srcdir)'/build-aux/move-if-change
-
-autom4te-update:
-       rm -fr Fetchdir > /dev/null 2>&1
-       mkdir -p Fetchdir/Autom4te
-       for file in $(autom4te_files); do \
-         infile=`echo $$file | sed 's/Autom4te/Automake/g'`; \
-         $(WGET) $(WGET_FLAGS) \
-           "$(automake_gitweb)f=lib/$$infile" \
-           -O "Fetchdir/$$file" || exit; \
-       done
-       perl -pi -e 's/Automake::/Autom4te::/g' Fetchdir/Autom4te/*.pm
-       for file in $(autom4te_files); do \
-         $(move_if_change) Fetchdir/$$file $(srcdir)/lib/$$file || exit; \
-       done
-       rm -fr Fetchdir > /dev/null 2>&1
+
+fetch:
+       WGET="$(WGET)" PERL="$(PERL)" \
+           $(SHELL) $(srcdir)/build-aux/fetch.sh "$(abs_top_srcdir)"
 
 # Tests not to run.
 local-checks-to-skip ?= \