build: honor autogen.sh --no-git

Based on a report by Chandrashekar Shastri, at
https://bugzilla.redhat.com/show_bug.cgi?id=979360

On systems where git cannot access the outside world, a developer
can instead arrange to get a copy of gnulib at the right commit
via side channels (such as NFS share drives), set GNULIB_SRCDIR,
then use ./autogen.sh --no-git.  In this setup, we will now
avoid direct use of git.  Of course, this means no automatic
gnulib updates when libvirt.git updates its submodule, but it
is expected that any developer in such a situation is already
prepared to deal with the fallout.

* .gnulib: Update to latest, for bootstrap.
* bootstrap: Synchronize from gnulib.
* autogen.sh (no_git): Avoid git when requested.
* cfg.mk (_update_required): Skip automatic rerun of bootstrap if
we can't use git.
* docs/compiling.html.in: Document this setup.
* docs/hacking.html.in: Mention this.
* HACKING: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2013-07-03 14:43:11 -06:00
parent 040d3f7758
commit 1e503ee534
7 changed files with 59 additions and 14 deletions

@ -1 +1 @@
Subproject commit f40e61ea0c4940b027aade7dd48948aa93f133a4 Subproject commit b72ff2a45efde544c406804186d37a3254728571

View File

@ -36,7 +36,8 @@ developer is:
git checkout -t origin -b workbranch git checkout -t origin -b workbranch
Hack, committing any changes along the way Hack, committing any changes along the way
Then, when you want to post your patches: More hints on compiling can be found here <compiling.html>. When you want to
post your patches:
git pull --rebase git pull --rebase
(fix any conflicts) (fix any conflicts)

View File

@ -49,6 +49,10 @@ fi
# we rerun bootstrap to pull in those diffs. # we rerun bootstrap to pull in those diffs.
bootstrap_hash() bootstrap_hash()
{ {
if test "$no_git"; then
echo no-git
return
fi
git submodule status | sed 's/^[ +-]//;s/ .*//' git submodule status | sed 's/^[ +-]//;s/ .*//'
git hash-object bootstrap.conf git hash-object bootstrap.conf
git ls-tree -d HEAD gnulib/local | awk '{print $3}' git ls-tree -d HEAD gnulib/local | awk '{print $3}'
@ -62,7 +66,9 @@ bootstrap_hash()
# Only run bootstrap from a git checkout, never from a tarball. # Only run bootstrap from a git checkout, never from a tarball.
if test -d .git; then if test -d .git; then
curr_status=.git-module-status t= curr_status=.git-module-status t=
if test -d .gnulib; then if test "$no_git"; then
t=no-git
elif test -d .gnulib; then
t=$(bootstrap_hash; git diff .gnulib) t=$(bootstrap_hash; git diff .gnulib)
fi fi
case $t:${CLEAN_SUBMODULE+set} in case $t:${CLEAN_SUBMODULE+set} in
@ -78,7 +84,7 @@ if test -d .git; then
# good, it's up to date, all we need is autoreconf # good, it's up to date, all we need is autoreconf
autoreconf -if autoreconf -if
else else
if test ${CLEAN_SUBMODULE+set}; then if test -z "$no_git" && test ${CLEAN_SUBMODULE+set}; then
echo cleaning up submodules... echo cleaning up submodules...
git submodule foreach 'git clean -dfqx && git reset --hard' git submodule foreach 'git clean -dfqx && git reset --hard'
fi fi

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Print a version string. # Print a version string.
scriptversion=2013-05-08.20; # UTC scriptversion=2013-07-03.20; # UTC
# Bootstrap this package from checked-out sources. # Bootstrap this package from checked-out sources.
@ -551,7 +551,7 @@ fi
echo "$0: Bootstrapping from checked-out $package sources..." echo "$0: Bootstrapping from checked-out $package sources..."
# See if we can use gnulib's git-merge-changelog merge driver. # See if we can use gnulib's git-merge-changelog merge driver.
if test -d .git && (git --version) >/dev/null 2>/dev/null ; then if $use_git && test -d .git && (git --version) >/dev/null 2>/dev/null ; then
if git config merge.merge-changelog.driver >/dev/null ; then if git config merge.merge-changelog.driver >/dev/null ; then
: :
elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
@ -574,13 +574,17 @@ git_modules_config () {
test -f .gitmodules && git config --file .gitmodules "$@" test -f .gitmodules && git config --file .gitmodules "$@"
} }
gnulib_path=$(git_modules_config submodule.gnulib.path) if $use_git; then
test -z "$gnulib_path" && gnulib_path=gnulib gnulib_path=$(git_modules_config submodule.gnulib.path)
test -z "$gnulib_path" && gnulib_path=gnulib
fi
# Get gnulib files. # Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a
# submodule, for use in the rest of the script.
case ${GNULIB_SRCDIR--} in case ${GNULIB_SRCDIR--} in
-) -)
# Note that $use_git is necessarily true in this case.
if git_modules_config submodule.gnulib.url >/dev/null; then if git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..." echo "$0: getting gnulib files..."
git submodule init || exit $? git submodule init || exit $?
@ -601,8 +605,8 @@ case ${GNULIB_SRCDIR--} in
GNULIB_SRCDIR=$gnulib_path GNULIB_SRCDIR=$gnulib_path
;; ;;
*) *)
# Use GNULIB_SRCDIR as a reference. # Use GNULIB_SRCDIR directly or as a reference.
if test -d "$GNULIB_SRCDIR"/.git && \ if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
git_modules_config submodule.gnulib.url >/dev/null; then git_modules_config submodule.gnulib.url >/dev/null; then
echo "$0: getting gnulib files..." echo "$0: getting gnulib files..."
if git submodule -h|grep -- --reference > /dev/null; then if git submodule -h|grep -- --reference > /dev/null; then
@ -628,6 +632,9 @@ case ${GNULIB_SRCDIR--} in
;; ;;
esac esac
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
# we no longer need to use git or $gnulib_path below here.
if $bootstrap_sync; then if $bootstrap_sync; then
cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || { cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
echo "$0: updating bootstrap and restarting..." echo "$0: updating bootstrap and restarting..."

1
cfg.mk
View File

@ -828,6 +828,7 @@ ifeq (0,$(MAKELEVEL))
test -d .git || { echo 0; exit; }; \ test -d .git || { echo 0; exit; }; \
test -f po/Makevars || { echo 1; exit; }; \ test -f po/Makevars || { echo 1; exit; }; \
test -f AUTHORS || { echo 1; exit; }; \ test -f AUTHORS || { echo 1; exit; }; \
test "no-git" = "$$(cat $(_curr_status))" && { echo 0; exit; }; \
actual=$$(git submodule status | $(_submodule_hash); \ actual=$$(git submodule status | $(_submodule_hash); \
git hash-object bootstrap.conf; \ git hash-object bootstrap.conf; \
git ls-tree -d HEAD gnulib/local | awk '{print $$3}'; \ git ls-tree -d HEAD gnulib/local | awk '{print $$3}'; \

View File

@ -65,8 +65,36 @@
checkout it is necessary to generate the configure script and Makefile.in checkout it is necessary to generate the configure script and Makefile.in
templates using the <code>autogen.sh</code> command. By default when templates using the <code>autogen.sh</code> command. By default when
the <code>configure</code> script is run from within a GIT checkout, it the <code>configure</code> script is run from within a GIT checkout, it
will turn on -Werror for builds. This can be disabled with --disable-werror, will turn on -Werror for builds. This can be disabled with
but this is not recommended. To build &amp; install libvirt to your home --disable-werror, but this is not recommended.
</p>
<p>
Libvirt takes advantage of
the <a href="http://www.gnu.org/software/gnulib/">gnulib</a>
project to provide portability to a number of platforms. This
is normally done dynamically via a git submodule in
the <code>.gnulib</code> subdirectory, which is auto-updated as
needed when you do incremental builds. Setting the environment
variable <code>GNULIB_SRCDIR</code> to a local directory
containing a git checkout of gnulib will let you reduce local
disk space requirements and network download time, regardless of
which actual commit you have in that reference directory.
</p>
<p>
However, if you are developing on a platform where git is not
available, or are behind a firewall that does not allow for git
to easily obtain the gnulib submodule, it is possible to instead
use a static mode of operation where you are then responsible
for updating the git submodule yourself. In this mode, you must
track the exact gnulib commit needed by libvirt (usually not the
latest gnulib.git) via alternative means, such as a shared NFS
drive or manual download, and run this any time libvirt.git
updates the commit stored in the .gnulib submodule:</p>
<pre>
$ GNULIB_SRCDIR=/path/to/gnulib ./autogen.sh --no-git
</pre>
<p>To build &amp; install libvirt to your home
directory the following commands can be run: directory the following commands can be run:
</p> </p>

View File

@ -35,7 +35,9 @@
git checkout -t origin -b workbranch git checkout -t origin -b workbranch
Hack, committing any changes along the way Hack, committing any changes along the way
</pre> </pre>
<p>Then, when you want to post your patches:</p> <p>More hints on compiling can be
found <a href="compiling.html">here</a>. When you want to
post your patches:</p>
<pre> <pre>
git pull --rebase git pull --rebase
(fix any conflicts) (fix any conflicts)