Lin Ma
2018-Apr-10 07:42 UTC
[Libguestfs] [PATCH 0/5] Some improvements in bootstrap, m4 and configure.ac
Lin Ma (5): configure: error out if using libvirt backend and no header files configure: output the default backend in summary configure: try pcre-config if pcre pkg-config file not found configure: output clearer message when missing libmagic configure: support using local gnulib src directory as $GNULIB_SRCDIR bootstrap | 78 +++++++++++++++++++++++++++++++++++++++++++++---- configure.ac | 1 + m4/guestfs-libraries.m4 | 21 ++++++++++--- 3 files changed, 91 insertions(+), 9 deletions(-) -- 2.15.1
Lin Ma
2018-Apr-10 07:42 UTC
[Libguestfs] [PATCH 1/5] configure: error out if using libvirt backend and no header files
It should error out instead of warning if users provide the option '--with-default-backend=libvirt' and no libvirt devel package installed. Signed-off-by: Lin Ma <lma@suse.com> --- m4/guestfs-libraries.m4 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/m4/guestfs-libraries.m4 b/m4/guestfs-libraries.m4 index 6d5f3e3c1..88d4f1cde 100644 --- a/m4/guestfs-libraries.m4 +++ b/m4/guestfs-libraries.m4 @@ -269,8 +269,13 @@ AS_IF([test "$with_libvirt" != "no"],[ AC_SUBST([LIBVIRT_CFLAGS]) AC_SUBST([LIBVIRT_LIBS]) AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.]) - ], - [AC_MSG_WARN([libvirt not found, some core features will be disabled])]) + ],[ + if test "$DEFAULT_BACKEND" = "libvirt"; then + AC_MSG_ERROR([Please install the libvirt devel package]) + else + AC_MSG_WARN([libvirt not found, some core features will be disabled]) + fi + ]) ]) AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"]) -- 2.15.1
Lin Ma
2018-Apr-10 07:42 UTC
[Libguestfs] [PATCH 2/5] configure: output the default backend in summary
Signed-off-by: Lin Ma <lma@suse.com> --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 898dda019..c1abf6a12 100644 --- a/configure.ac +++ b/configure.ac @@ -373,6 +373,7 @@ echo "Appliance ........................... $ENABLE_APPLIANCE" echo "QEMU ................................ $QEMU" echo "guestfish and C-based virt tools .... yes" echo "FUSE filesystem ..................... $enable_fuse" +echo "Default backend ..................... $DEFAULT_BACKEND" AS_ECHO_N(["GNU gettext for i18n ................ "]) if test "x$HAVE_GNU_GETTEXT_TRUE" = "x"; then echo "yes"; else echo "no"; fi AS_ECHO_N(["virt-p2v ............................ "]) -- 2.15.1
Lin Ma
2018-Apr-10 07:42 UTC
[Libguestfs] [PATCH 3/5] configure: try pcre-config if pcre pkg-config file not found
Signed-off-by: Lin Ma <lma@suse.com> --- m4/guestfs-libraries.m4 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/m4/guestfs-libraries.m4 b/m4/guestfs-libraries.m4 index 88d4f1cde..647bea9ec 100644 --- a/m4/guestfs-libraries.m4 +++ b/m4/guestfs-libraries.m4 @@ -238,7 +238,14 @@ AC_ARG_ENABLE([packet-dump],[ []) dnl Check for PCRE (required) -PKG_CHECK_MODULES([PCRE], [libpcre]) +PKG_CHECK_MODULES([PCRE], [libpcre], [], [ + AC_CHECK_PROGS([PCRE_CONFIG], [pcre-config pcre2-config], [no]) + AS_IF([test "x$PCRE_CONFIG" = "xno"], [ + AC_MSG_ERROR([Please install the pcre devel package]) + ]) + PCRE_CFLAGS=`$PCRE_CONFIG --cflags` + PCRE_LIBS=`$PCRE_CONFIG --libs` +]) dnl Check for Augeas >= 1.0.0 (required). PKG_CHECK_MODULES([AUGEAS],[augeas >= 1.0.0]) -- 2.15.1
Lin Ma
2018-Apr-10 07:42 UTC
[Libguestfs] [PATCH 4/5] configure: output clearer message when missing libmagic
Some of users probably don't know which packages they exactly need to install while they experienced the error message: libmagic (part of the "file" command) is required. So add corresponding package information into error message. Signed-off-by: Lin Ma <lma@suse.com> --- m4/guestfs-libraries.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/m4/guestfs-libraries.m4 b/m4/guestfs-libraries.m4 index 647bea9ec..17cf556d9 100644 --- a/m4/guestfs-libraries.m4 +++ b/m4/guestfs-libraries.m4 @@ -263,7 +263,8 @@ AC_CHECK_LIB([magic],[magic_file],[ ], []) ],[]) AS_IF([test -z "$MAGIC_LIBS"], - [AC_MSG_ERROR([libmagic (part of the "file" command) is required])]) + [AC_MSG_ERROR([libmagic (part of the "file" command) is required. + Please install the file devel package])]) dnl libvirt (highly recommended) AC_ARG_WITH([libvirt],[ -- 2.15.1
Lin Ma
2018-Apr-10 07:42 UTC
[Libguestfs] [PATCH 5/5] configure: support using local gnulib src directory as $GNULIB_SRCDIR
Don't clone online gnulib repo if the environment variable $GNULIB_SRCDIR is available, and add an option '--gnulib-srcdir' for bootstrap to specify a local source directory. (borrowed some code which wrote by Jim Meyering and Eric Blake in libvirt) Signed-off-by: Lin Ma <lma@suse.com> --- bootstrap | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/bootstrap b/bootstrap index bb665c6a8..aaf038d98 100755 --- a/bootstrap +++ b/bootstrap @@ -4,6 +4,13 @@ usage() { echo >&2 "\ Usage: $0 [OPTION]... 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 " } @@ -13,18 +20,79 @@ do --help) usage exit;; + --gnulib-srcdir=*) + GNULIB_SRCDIR=${option#--gnulib-srcdir=};; *) echo >&2 "$0: $option: unknown option" exit 1;; esac done -# Get gnulib files. +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) +test -z "$gnulib_path" && gnulib_path=gnulib + +# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a +# submodule, for use in the rest of the script. + +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 + + shallow+ git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2' + git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" || + cleanup_gnulib -echo "$0: getting gnulib files..." -git submodule init || exit $? -git submodule update || exit $? -GNULIB_SRCDIR=.gnulib + trap - 1 2 13 15 + fi + GNULIB_SRCDIR=$gnulib_path + ;; +*) + # Use GNULIB_SRCDIR directly or 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 -h|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 # Autoreconf runs aclocal before libtoolize, which causes spurious # warnings if the initial aclocal is confused by the libtoolized -- 2.15.1
Richard W.M. Jones
2018-Apr-10 08:06 UTC
Re: [Libguestfs] [PATCH 0/5] Some improvements in bootstrap, m4 and configure.ac
On Tue, Apr 10, 2018 at 03:42:51PM +0800, Lin Ma wrote:> Lin Ma (5): > configure: error out if using libvirt backend and no header files > configure: output the default backend in summary > configure: try pcre-config if pcre pkg-config file not found > configure: output clearer message when missing libmagic > configure: support using local gnulib src directory as $GNULIB_SRCDIR > > bootstrap | 78 +++++++++++++++++++++++++++++++++++++++++++++---- > configure.ac | 1 + > m4/guestfs-libraries.m4 | 21 ++++++++++--- > 3 files changed, 91 insertions(+), 9 deletions(-)It all looks good to me at a first glance. I'm going to try these out. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v