bug-gnulib
[Top][All Lists]
Advanced

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

Re: bootstrap and git submodules


From: Bruno Haible
Subject: Re: bootstrap and git submodules
Date: Sun, 14 Mar 2010 14:54:02 +0100
User-agent: KMail/1.9.9

Hi Jim and Eric,

Thanks for your explanations how 'bootstrap' is to be used with git. But
I still don't find the current state reasonable, because:

  * There are five use cases of the 'bootstrap' script:
      1) A normal user who wants to check out coreutils with the version
         of gnulib with which it was tested. Does not want to be bothered
         with versions, what gnulib is in the first place, etc.
      2) Like 1), but the user knows what gnulib is and has a copy of it
         on his disk.
      3) An expert user who wants to check out the latest gnulib,
         regardless what it contains. He is prepared to report errors.
      4) Like 2), and he has a copy of gnulib on his disk.
      5) An expert user who wants to use his modified version of gnulib.

    Most users are in case 1), therefore this has to be the default.

    The option --gnulib-srcdir was for use case 5 in the past, IIRC. Now it
    is for use case 2, says Jim. So, the cases 3, 4, 5 are not made easy
    by 'bootstrap'.

  * I was in case 5, you are telling me to use git commands - and not the
    most simple ones - in order to combine source with source. This means,
    the git submodule support is getting in the way. It is like if I wanted
    to do "make" after having modified a source code file, I would be required
    to do "cvs admin" or some such.

So, I think 'bootstrap' needs 3 command line options:
  - One option for choosing use case 3. I propose --gnulib-newest.
  - One option for choosing use cases 2 or 4, from 1 or 3. I propose to call
    it --gnulib-repodir.
  - One option for choosing use case 5. The name --gnulib-srcdir seems to be
    the right one for this. (As it was before 2008.)

Here is a proposed patch. Tested in all five cases.


2010-03-14  Bruno Haible  <address@hidden>

        bootstrap: Support more use cases.
        * build-aux/bootstrap: New options --gnulib-repodir, --gnulib-newest.
        If --gnulib-srcdir is specified, use it directly. Otherwise rely on the
        options --gnulib-repodir and --gnulib-newest.
        (usage): Rename --gnulib-srcdir to --gnulib-repodir. Document new
        options --gnulib-newest, --gnulib-srcdir.

*** build-aux/bootstrap.orig    Sun Mar 14 14:46:43 2010
--- build-aux/bootstrap Sun Mar 14 14:38:11 2010
***************
*** 49,63 ****
  Bootstrap this package from the checked-out sources.
  
  Options:
!  --gnulib-srcdir=DIRNAME  Specify the local directory where gnulib
!                           sources reside.  Use this if you already
!                           have gnulib sources on your machine, and
!                           do not want to waste your bandwidth downloading
!                           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.
!  --skip-po                Do not download po files.
  
  If the file $0.conf exists in the same directory as this script, its
  contents are read as shell variables to configure the bootstrap.
--- 49,75 ----
  Bootstrap this package from the checked-out sources.
  
  Options:
!   --gnulib-repodir=DIRNAME  Specify the local directory with a recent gnulib
!                             checkout.  Use this if you already have gnulib
!                             sources on your machine, and do not want to waste
!                             your bandwidth downloading them again.
!                             Defaults to \$GNULIB_REPODIR.
!   --gnulib-newest           Specify to use the newest available gnulib 
revision
!                             instead of the one that this package was tested
!                             with.  Use this if you expect to have some bug
!                             fixed through the newer gnulib version, and are
!                             prepared to analyze or report problems, should 
they
!                             occur.
!   --gnulib-srcdir=DIRNAME   Specify the local directory where gnulib sources
!                             reside.  The options --gnulib-repodir and
!                             --gnulib-newest are ignored in this case.  Use 
this
!                             if you want to test against a specific gnulib
!                             revision, possibly with commits or uncommitted
!                             changes of yours.
!   --copy                    Copy files instead of creating symbolic links.
!   --force                   Attempt to bootstrap even if the sources seem not
!                             to have been checked out.
!   --skip-po                 Do not download po files.
  
  If the file $0.conf exists in the same directory as this script, its
  contents are read as shell variables to configure the bootstrap.
***************
*** 226,231 ****
--- 238,247 ----
    --help)
      usage
      exit;;
+   --gnulib-repodir=*)
+     GNULIB_REPODIR=`expr "X$option" : 'X--gnulib-repodir=\(.*\)'`;;
+   --gnulib-newest)
+     gnulib_newest=true;;
    --gnulib-srcdir=*)
      GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
    --skip-po)
***************
*** 397,466 ****
    fi
  fi
  
  
! cleanup_gnulib() {
!   status=$?
!   rm -fr "$gnulib_path"
!   exit $status
! }
! 
! git_modules_config () {
!   test -f .gitmodules && git config --file .gitmodules "$@"
! }
! 
! gnulib_path=`git_modules_config submodule.gnulib.path`
  
! # Get gnulib files.
  
! case ${GNULIB_SRCDIR--} in
! -)
!   if git_modules_config submodule.gnulib.url >/dev/null; then
!     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 1 2 13 15
  
!     git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
!     git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
!       cleanup_gnulib
  
-     trap - 1 2 13 15
-   fi
-   GNULIB_SRCDIR=$gnulib_path
-   ;;
- *)
-   # Use GNULIB_SRCDIR as a reference.
-   if test -d "$GNULIB_SRCDIR"/.git && \
-         git_modules_config submodule.gnulib.url >/dev/null; then
-     echo "$0: getting gnulib files..."
-     if git submodule --help|grep reference > /dev/null; then
-       # Prefer the one-liner available in git 1.6.4 or newer.
-       git submodule update --init --reference "$GNULIB_SRCDIR" \
-         "$gnulib_path" || exit $?
-     else
-       # This fallback allows at least git 1.5.5.
-       if test -f "$gnulib_path"/gnulib-tool; then
-         # Since file already exists, assume submodule init already complete.
-         git submodule update "$gnulib_path" || exit $?
-       else
-         # Older git can't clone into an empty directory.
-         rmdir "$gnulib_path" 2>/dev/null
-         git clone --reference "$GNULIB_SRCDIR" \
-           "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
-           && git submodule init "$gnulib_path" \
-           && git submodule update "$gnulib_path" \
-           || exit $?
-       fi
      fi
      GNULIB_SRCDIR=$gnulib_path
    fi
-   ;;
- esac
  
  gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  <$gnulib_tool || exit
  
--- 413,507 ----
    fi
  fi
  
+ # Locate or check out the gnulib sources.
+ if test -n "$GNULIB_SRCDIR"; then
+   # The user wants to use his specified gnulib sources.
+   :
+ else
+   # Get the gnulib files.
+ 
+   # Packages are supposed to have a .gitmodules file that contains something
+   # like this:
+   #   [submodule "gnulib"]
+   #           path = gnulib
+   #           url = git://git.sv.gnu.org/gnulib.git
+   git_modules_config () {
+     test -f .gitmodules && git config --file .gitmodules "$@"
+   }
  
!   # The location within this package of the checked out gnulib sources.
!   gnulib_path=`git_modules_config submodule.gnulib.path`
  
!   if test -n "$GNULIB_REPODIR"; then
!     # The user has a gnulib checkout in $GNULIB_REPODIR.
  
!     # Use GNULIB_REPODIR as a reference.
!     if test -d "$GNULIB_REPODIR"/.git && \
!           git_modules_config submodule.gnulib.url >/dev/null; then
!       echo "$0: getting gnulib files..."
!       if git submodule --help|grep reference > /dev/null; then
!         # Prefer the one-liner available in git 1.6.4 or newer.
!         git submodule update --init --reference "$GNULIB_REPODIR" \
!           "$gnulib_path" || exit $?
!       else
!         # This fallback allows at least git 1.5.5.
!         if test -f "$gnulib_path"/gnulib-tool; then
!           # Since file already exists, assume submodule init already complete.
!           git submodule update "$gnulib_path" || exit $?
!         else
!           # Older git can't clone into an empty directory.
!           rmdir "$gnulib_path" 2>/dev/null
!           git clone --reference "$GNULIB_REPODIR" \
!             "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
!             && git submodule init "$gnulib_path" \
!             && git submodule update "$gnulib_path" \
!             || exit $?
!         fi
!       fi
!       GNULIB_SRCDIR=$gnulib_path
!     fi
  
!   else
!     # The user does not have a gnulib checkout.
!     # Check it out, over the network.
  
!     if git_modules_config submodule.gnulib.url >/dev/null; then
!       echo "$0: getting gnulib files..."
!       git submodule init "$gnulib_path" || exit $?
!       git submodule update "$gnulib_path" || exit $?
! 
!     elif test ! -d "$gnulib_path"; then
!       echo "$0: getting gnulib files..."
! 
!       cleanup_gnulib() {
!         status=$?
!         rm -fr "$gnulib_path"
!         exit $status
!       }
! 
!       trap cleanup_gnulib 1 2 13 15
! 
!       git clone --help|grep depth > /dev/null && shallow='--depth 2' || 
shallow=
!       git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
!         cleanup_gnulib
  
!       trap - 1 2 13 15
  
      fi
      GNULIB_SRCDIR=$gnulib_path
    fi
  
+   if test -n "$GNULIB_SRCDIR" && test -n "$gnulib_newest"; then
+     # The user wants to use the newest gnulib commit.
+     # Pull the newest public changes into $gnulib_path.
+     # This requires network access.
+     # This has no effect on the index and checked out files in 
$GNULIB_REPODIR.
+     echo "$0: getting gnulib files update..."
+     (cd "$gnulib_path" && git pull origin master)
+   fi
+ fi
+ 
+ # Verify that GNULIB_SRCDIR contains the gnulib-tool program.
  gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  <$gnulib_tool || exit
  




reply via email to

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