bootstrap: use GNULIB_SRCDIR to reduce disk usage
authorEric Blake <eblake@redhat.com>
Mon, 22 Feb 2010 15:46:42 +0000 (08:46 -0700)
committerEric Blake <eblake@redhat.com>
Mon, 22 Feb 2010 23:01:02 +0000 (16:01 -0700)
This slightly changes the semantics of GNULIB_SRCDIR; previously,
it was a way to change the contents of .gitmodules to actually
point to a new location, which meant that running:
 GNULIB_SRCDIR=~/gnulib ./bootstrap
would result in a dirty tree.  The new semantics are nicer; the
submodule is cloned as normal, but the clone uses the original
$GNULIB_SRCDIR as an object reference to reduce download time
and disk space.

* build-aux/bootstrap (GNULIB_SRCDIR): If set, use as a reference,
rather than reconfiguring where the submodule points.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
build-aux/bootstrap

index efba1e7..916b311 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-02-22  Eric Blake  <eblake@redhat.com>
 
+       bootstrap: use GNULIB_SRCDIR to reduce disk usage
+       * build-aux/bootstrap (GNULIB_SRCDIR): If set, use as a reference,
+       rather than reconfiguring where the submodule points.
+
        gettimeofday: restore support for platforms that lack function
        * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Also compile
        replacement if function is missing.
index 0fb0ac5..1595d1b 100755 (executable)
@@ -43,7 +43,7 @@ Options:
                           sources reside.  Use this if you already
                           have gnulib sources on your machine, and
                           do not want to waste your bandwidth downloading
-                          them again.
+                          them again.  Defaults to \$GNULIB_SRCDIR.
  --copy                   Copy files instead of creating symbolic links.
  --force                  Attempt to bootstrap even if the sources seem
                           not to have been checked out.
@@ -421,15 +421,11 @@ case ${GNULIB_SRCDIR--} in
   GNULIB_SRCDIR=gnulib
   ;;
 *)
-  # Redirect the gnulib submodule to the directory on the command line
-  # if possible.
+  # Use GNULIB_SRCDIR as a reference.  Assumes git 1.6.4 or newer.
   if test -d "$GNULIB_SRCDIR"/.git && \
         git_modules_config submodule.gnulib.url >/dev/null; then
-    git submodule init
-    GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
-    git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
     echo "$0: getting gnulib files..."
-    git submodule update || exit $?
+    git submodule update --init --reference "$GNULIB_SRCDIR" gnulib || exit $?
     GNULIB_SRCDIR=gnulib
   fi
   ;;