m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make gnulib a git submodule


From: Eric Blake
Subject: make gnulib a git submodule
Date: Mon, 16 Mar 2009 11:13:17 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

After recent success in bison and coreutils in using gnulib as a
submodule, I've decided to do the same for m4.  This patch is currently
available at
$ git fetch git://repo.or.cz/m4/ericb.git branch-1.4

but if no one has any complaints, I will go ahead and merge it into all
three branches next week.  It has the advantage that future m4 releases
now record exactly which gnulib version was in effect at the time.

This patch tries to make submodule usage as handy as possible, by making
./bootstrap do all the work of initializing the module.  Unfortunately, it
probably makes CVS checkouts of m4 harder (does anyone still try to do
that?), as you will have to manually do a CVS checkout into the expected
gnulib subdirectory.  Meanwhile, the GNULIB_SRCDIR environment variable
can make the process MUCH faster (hmm, maybe I should file an upstream
enhancement request to the git folks that 'git submodule update --init'
would benefit from adding a --reference parameter).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm+iK0ACgkQ84KuGfSFAYCg/wCgtYCJp0Q9wucqvwlwPOUDxhHy
NWYAoK9cRbOmHJdlMoGxQ0dytKY68Ryv
=SOg3
-----END PGP SIGNATURE-----
>From ff30f1cf31416dba9cd70feb199e45a67f582242 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 16 Mar 2009 10:38:55 -0600
Subject: [PATCH] Make gnulib a git submodule.

* .gitmodules: New file.
* gnulib: Record which version of gnulib has been tested.
* bootstrap: Aid in submodule usage.
* cfg.mk (gnulib_dir): Alter default location of gnulib.
* HACKING: Mention how to use submodule.

Signed-off-by: Eric Blake <address@hidden>
---
 .gitmodules |    3 ++
 ChangeLog   |    9 ++++++
 HACKING     |   57 ++++++++++++++++++++++++++++++++---------
 bootstrap   |   81 +++++++++++++++++++++++++++++------------------------------
 cfg.mk      |    2 +-
 gnulib      |    1 +
 6 files changed, 98 insertions(+), 55 deletions(-)
 create mode 100644 .gitmodules
 create mode 160000 gnulib

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..acb2669
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "gnulib"]
+       path = gnulib
+       url = git://git.sv.gnu.org/gnulib.git
diff --git a/ChangeLog b/ChangeLog
index cf9aa91..05d62c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-03-16  Eric Blake  <address@hidden>
+
+       Make gnulib a git submodule.
+       * .gitmodules: New file.
+       * gnulib: Record which version of gnulib has been tested.
+       * bootstrap: Aid in submodule usage.
+       * cfg.mk (gnulib_dir): Alter default location of gnulib.
+       * HACKING: Mention how to use submodule.
+
 2009-03-12  Eric Blake  <address@hidden>

        Fix awk script portability.
diff --git a/HACKING b/HACKING
index eade193..934d41e 100644
--- a/HACKING
+++ b/HACKING
@@ -48,16 +48,6 @@ and is not part of a release distribution.
   - LZMA Utils 4.32 or later (from <http://tukaani.org/lzma/>)
   - Texinfo 4.8 or later
   - Any prerequisites of the above (such as perl, tex)
-  - A git checkout of gnulib.  A read-only copy of gnulib can be
-    obtained by:
-      git clone git://git.sv.gnu.org/gnulib.git
-    or
-      cvs -d:pserver:address@hidden:/srv/git/gnulib.git \
-        co -d gnulib HEAD
-
-  If you are a member of the savannah group for gnulib, a read-write
-  copy can be obtained by:
-    git clone <savannah-user>@git.sv.gnu.org:/srv/git/gnulib.git

   Note that none of these bootstrapping dependencies should be required
   by a distributed release.
@@ -69,8 +59,42 @@ and is not part of a release distribution.
   install:
   - Libsigsegv 2.6 or later

-* Either add the gnulib directory to your PATH, or run
-    GNULIB_TOOL=path/to/gnulib/gnulib-tool ./bootstrap
+* M4 includes gnulib as a git submodule.  By default, the bootstrap
+  script will attempt to run
+    git submodule update --init
+  to grab a gnulib clone from the official read-only location of
+    git://git.sv.gnu.org/gnulib.git
+
+  However, this can be network and disk intensive.  If you already have
+  another gnulib clone on your disk, you can use the environment
+  variable GNULIB_SRCDIR to point to the previous checkout to speed up
+  the process.  Additionally, both the bootstrap script and gnulib-tool
+  require a shell that supports functions, so you can set the
+  environment variable CONFIG_SHELL to choose a better shell on systems
+  (like Solaris) where /bin/sh is lacking.  Thus, you may find it
+  convenient to run:
+    GNULIB_SRCDIR=path/to/gnulib CONFIG_SHELL=path/to/sh \
+      path/to/sh ./bootstrap
+
+  A read-only copy of gnulib can be obtained by:
+      git clone git://git.sv.gnu.org/gnulib.git
+    or
+      cvs -d:pserver:address@hidden:/srv/git/gnulib.git \
+        co -d gnulib HEAD
+
+  Using a CVS checkout might work, but it is relatively untested,
+  particularly now that we use a git submodule for gnulib.
+
+  If you are a member of the savannah group for gnulib, a read-write
+  copy can be obtained by:
+    git clone <savannah-user>@git.sv.gnu.org:/srv/git/gnulib.git
+
+  If you are behind a firewall that blocks the git protocol, you may
+  find it useful to do:
+    git config --global url.http://git.sv.gnu.org/r/.insteadof \
+      git://git.sv.gnu.org/
+  to force git to transparently rewrite all savannah git references to
+  instead use http.

 * When it is time for a release, it is a good idea to bootstrap with
   official releases of the autotools, rather than git builds, to reduce
@@ -202,6 +226,13 @@ yyyy-mm-dd  Name of Author  <address@hidden>  (tiny change)

 * Make sure your locale is sane, e.g. by exporting LC_ALL=C.

+* Make sure you are happy with the particular gnulib version recorded as
+  the gnulib submodule.  If necessary to update to the latest, run:
+    cd gnulib
+    git pull
+    cd ..
+    git commit -m 'Update gnulib submodule to latest.' gnulib
+
 * Update the version number in NEWS and ChangeLog, and mention in README
   whether the release is stable.  See
   http://www.gnu.org/software/libtool/contribute.html for details of the
@@ -209,7 +240,7 @@ yyyy-mm-dd  Name of Author  <address@hidden>  (tiny change)
   intra-release versions carry more information thanks to
   git-version-gen).

-* Run ./bootstrap.
+* Run ./bootstrap, perhaps with environment variables set.

 * Run ./configure (a VPATH build should work, but is less tested).

diff --git a/bootstrap b/bootstrap
index 1c558a7..b9898e1 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh

-# bootstrap (GNU M4) version 2009-02-26
+# bootstrap (GNU M4) version 2009-03-16
 # Written by Gary V. Vaughan  <address@hidden>

 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software
@@ -29,7 +29,7 @@

 # You can also set the following variables to help $progname
 # locate the right tools:
-#   AUTORECONF, GNULIB_SRCDIR, GNULIB_TOOL, M4, RM, SED
+#   AUTORECONF, CONFIG_SHELL, GNULIB_SRCDIR, M4, RM, SED

 # This script bootstraps a git or CVS checkout of GNU M4 by correctly
 # calling out to parts of the GNU Build Platform.  Currently this
@@ -39,7 +39,7 @@
 # Report bugs to <address@hidden>

 : ${AUTORECONF=autoreconf}
-: ${GNULIB_TOOL=gnulib-tool}
+: ${CONFIG_SHELL=/bin/sh}
 : ${RM='rm -f'}
 : ${SED=sed}

@@ -250,43 +250,42 @@ if test -d .git && (git --version) >/dev/null 2>/dev/null 
; then
   fi
 fi

-## ---------------------------- ##
-## Find the gnulib module tree. ##
-## ---------------------------- ##
+## ------------------------------ ##
+## Update the gnulib module tree. ##
+## ------------------------------ ##

-if test -n "$GNULIB_SRCDIR" && test -d "$GNULIB_SRCDIR" ; then
-  gnulibdir=$GNULIB_SRCDIR
+if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
+  if test -f gnulib/gnulib-tool ; then
+    func_echo "updating gnulib submodule"
+    git submodule update \
+      || func_fatal_error "Unable to update gnulib"
+  else
+    # A fresh checkout creates an empty subdirectory gnulib.  However,
+    # older git didn't know how to clone into an empty subdir.  If the
+    # user provided GNULIB_SRCDIR, then make the initial clone refer
+    # to the existing checkout, to save network traffic.
+    func_echo "importing gnulib submodule"
+    if test -d "$GNULIB_SRCDIR" ; then
+      rmdir gnulib 2>/dev/null
+      git clone --reference "$GNULIB_SRCDIR" git://git.sv.gnu.org/gnulib.git \
+        && git submodule init && git submodule update \
+        || func_fatal_error "Unable to update gnulib"
+    else
+      git submodule update --init \
+        || func_fatal_error "Unable to update gnulib"
+    fi
+  fi
 else
-  case $GNULIB_TOOL in
-    /*  )  gnulibdir=$GNULIB_TOOL ;;           # absolute
-    */* )  gnulibdir=`pwd`/$GNULIB_TOOL ;;     # relative
-    *   )  gnulibdir=`which "$GNULIB_TOOL"` ;; # PATH search
-  esac
-
-  # Follow symlinks
-  while test -h "$gnulibdir"; do
-
-    # Resolve symbolic link.
-    sedexpr1='s, -> ,#%%#,'
-    sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
-    linkval=`ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
-    test -n "$linkval" || break
-
-    case "$linkval" in
-       /* ) gnulibdir="$linkval" ;;
-       * )  gnulibdir=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
-    esac
-
-  done
-  gnulibdir=`echo "$gnulibdir" | $SED "$dirname"`
+  func_echo "git not detected.  If needed, update gnulib subdirectory manually"
 fi

 ## ---------------------- ##
 ## Import Gnulib modules. ##
 ## ---------------------- ##

-func_echo "running: $GNULIB_TOOL --update"
-$GNULIB_TOOL --update || func_fatal_error "gnulib-tool failed"
+func_echo "running: $CONFIG_SHELL gnulib/gnulib-tool --update"
+$CONFIG_SHELL gnulib/gnulib-tool --update \
+  || func_fatal_error "gnulib-tool failed"

 ## ----------- ##
 ## Autoreconf. ##
@@ -299,15 +298,15 @@ $AUTORECONF --force --verbose --install || 
func_fatal_error "autoreconf failed"
 ## Gnulib is more up-to-date than automake. ##
 ## ---------------------------------------- ##

-func_update "$gnulibdir"/build-aux/config.guess build-aux/config.guess
-func_update "$gnulibdir"/build-aux/config.sub build-aux/config.sub
-func_update "$gnulibdir"/build-aux/depcomp build-aux/depcomp
-func_update "$gnulibdir"/build-aux/install-sh build-aux/install-sh
-func_update "$gnulibdir"/build-aux/mdate-sh build-aux/mdate-sh
-func_update "$gnulibdir"/build-aux/missing build-aux/missing
-func_update "$gnulibdir"/build-aux/texinfo.tex build-aux/texinfo.tex
-func_update "$gnulibdir"/doc/COPYINGv3 COPYING
-func_update "$gnulibdir"/doc/INSTALL INSTALL
+func_update gnulib/build-aux/config.guess build-aux/config.guess
+func_update gnulib/build-aux/config.sub build-aux/config.sub
+func_update gnulib/build-aux/depcomp build-aux/depcomp
+func_update gnulib/build-aux/install-sh build-aux/install-sh
+func_update gnulib/build-aux/mdate-sh build-aux/mdate-sh
+func_update gnulib/build-aux/missing build-aux/missing
+func_update gnulib/build-aux/texinfo.tex build-aux/texinfo.tex
+func_update gnulib/doc/COPYINGv3 COPYING
+func_update gnulib/doc/INSTALL INSTALL

 exit 0

diff --git a/cfg.mk b/cfg.mk
index ff05a1e..3dda9f6 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -38,4 +38,4 @@ local-checks-to-skip = changelog-check

 # The local directory containing the checked-out copy of gnulib used in this
 # release.  Used solely to get gnulib's SHA1 for the "announcement" target.
-gnulib_dir = $(srcdir)/../gnulib
+gnulib_dir = $(srcdir)/gnulib
diff --git a/gnulib b/gnulib
new file mode 160000
index 0000000..01c0837
--- /dev/null
+++ b/gnulib
@@ -0,0 +1 @@
+Subproject commit 01c0837c339245a704e692cbb492d3238eab54fe
-- 
1.6.1.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]