use gnulib, and begin to pass its "make syntax-check" tests
by Jim Meyering
Here's a patch series to make libguestfs use gnulib via a git submodule.
The first thing I did was to look at the failures from "make syntax-check"
and fix the config.h-related ones below. The others are now
temporarily disabled via a variable in cfg.mk.
I fixed the config-h problems and moved those change sets to precede
the test-adding one, so that bisection still works, even if you use
the new "syntax-check" rule as your metric.
As I fix others, I'll remove the rule name from the disabled-tests list.
>From 3d13b4e3062a3b06d9ed3acadb4cb55fb41a05c8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 3 Aug 2009 06:58:16 -0400
Subject: [PATCH 1/4] build: add -I option to get config.h.
* ocaml/Makefile.am (AM_CPPFLAGS): Define.
(guestfs_c.o, guestfs_c_actions.o): Use it.
---
ocaml/Makefile.am | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 12522f2..1aa0cb6 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -28,6 +28,9 @@ SUBDIRS = examples
CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so
CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
+AM_CPPFLAGS = -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \
+ -I$(top_srcdir)/src -I$(top_builddir)/src
+
if HAVE_OCAML
noinst_DATA = mlguestfs.cma mlguestfs.cmxa META
@@ -39,10 +42,10 @@ mlguestfs.cmxa: guestfs_c.o guestfs_c_actions.o guestfs.cmx
$(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs
guestfs_c.o: guestfs_c.c
- $(CC) $(CFLAGS) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml -I$(top_srcdir)/src -I$(top_builddir)/src -fPIC -Wall -c $<
+ $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
guestfs_c_actions.o: guestfs_c_actions.c
- $(CC) $(CFLAGS) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml -I$(top_srcdir)/src -I$(top_builddir)/src -fPIC -Wall -c $<
+ $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $<
TESTS_ENVIRONMENT = \
LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
--
1.6.3.3
>From 48ff4073b5317da2076de4633779965eb1bda726 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 3 Aug 2009 05:33:35 -0400
Subject: [PATCH 2/4] always include <config.h>
* ocaml/guestfs_c.c: Include <config.h>.
* examples/to-xml.c: Likewise.
* examples/hello.c: Likewise.
---
capitests/test-command.c | 1 +
examples/hello.c | 1 +
examples/to-xml.c | 1 +
ocaml/guestfs_c.c | 1 +
4 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/capitests/test-command.c b/capitests/test-command.c
index 1e29ee9..d451ebe 100644
--- a/capitests/test-command.c
+++ b/capitests/test-command.c
@@ -20,6 +20,7 @@
* guestfs_command and guestfs_command_lines functions.
*/
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/examples/hello.c b/examples/hello.c
index a4cc43d..a8649f3 100644
--- a/examples/hello.c
+++ b/examples/hello.c
@@ -4,6 +4,7 @@
* hello guest.img /dev/VolGroup00/LogVol00
*/
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/examples/to-xml.c b/examples/to-xml.c
index d6422e0..5b75244 100644
--- a/examples/to-xml.c
+++ b/examples/to-xml.c
@@ -7,6 +7,7 @@
* to-xml guest.img [guest.img ...]
*/
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/ocaml/guestfs_c.c b/ocaml/guestfs_c.c
index 43a85b8..f983696 100644
--- a/ocaml/guestfs_c.c
+++ b/ocaml/guestfs_c.c
@@ -16,6 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
--
1.6.3.3
>From e0c33625431f7533ed5ae928032353017ebd27fa Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 3 Aug 2009 05:18:10 -0400
Subject: [PATCH 3/4] maint: use a git submodule for gnulib
* .gitmodules: New file, to track gnulib.
* .gnulib: Submodule directory.
* Makefile.am (EXTRA_DIST): Don't list config.rpath or
gitlog-to-changelog.
* autogen.sh: Adapt to use the new submodule.
* cfg.mk: New file.
(SUBDIRS): Add gnulib/lib and gnulib/tests.
(dist-hook): Reflect new location of getlog-to-changelog.
* configure.ac: Set build-aux/ as AUX_DIR.
Invoke gl_EARLY and gl_INIT.
(AC_CONFIG_FILES): Add gnulib/lib/Makefile and gnulib/tests/Makefile.
---
.gitignore | 5 +
.gitmodules | 3 +
.gnulib | 1 +
Makefile.am | 8 +-
autogen.sh | 11 +
bootstrap | 82 ++++++++
cfg.mk | 240 ++++++++++++++++++++++
config.rpath | 548 ---------------------------------------------------
configure.ac | 6 +
gitlog-to-changelog | 175 ----------------
mkinstalldirs | 111 -----------
11 files changed, 351 insertions(+), 839 deletions(-)
create mode 100644 .gitmodules
create mode 160000 .gnulib
create mode 100755 bootstrap
create mode 100644 cfg.mk
delete mode 100755 config.rpath
delete mode 100755 gitlog-to-changelog
delete mode 100755 mkinstalldirs
diff --git a/.gitignore b/.gitignore
index a3b365f..147e1cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -179,3 +179,8 @@ test-tool/libguestfs-test-tool.1
test-tool/libguestfs-test-tool
test-tool/libguestfs-test-tool-helper
v2v/virt-v2v.1
+/GNUmakefile
+/maint.mk
+/build-aux
+/gnulib
+.git-module-status
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..7acb1ea
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "gnulib"]
+ path = .gnulib
+ url = git://git.sv.gnu.org/gnulib.git
diff --git a/.gnulib b/.gnulib
new file mode 160000
index 0000000..7560950
--- /dev/null
+++ b/.gnulib
@@ -0,0 +1 @@
+Subproject commit 7560950d6efd9e209b8d7188e1a95ceb53035889
diff --git a/Makefile.am b/Makefile.am
index 3cba8bc..e5ca43c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,8 +17,8 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = src daemon appliance fish po examples images \
- capitests regressions test-tool
+SUBDIRS = gnulib/lib src daemon appliance fish po examples images \
+ gnulib/tests capitests regressions test-tool
if HAVE_OCAML
SUBDIRS += ocaml
@@ -52,13 +52,11 @@ SUBDIRS += cat
endif
EXTRA_DIST = \
- config.rpath \
guestfs.pod guestfs-actions.pod guestfs-structs.pod \
guestfish.pod guestfish-actions.pod \
html/pod.css \
HACKING TODO \
libguestfs.pc libguestfs.pc.in \
- gitlog-to-changelog \
recipes/LICENSE \
recipes/README \
recipes/*.html \
@@ -153,7 +151,7 @@ website: $(HTMLFILES) $(TEXTFILES)
# Generate the ChangeLog automatically from the gitlog.
dist-hook:
- ./gitlog-to-changelog > ChangeLog
+ $(top_srcdir)/build-aux/gitlog-to-changelog > ChangeLog
cp ChangeLog $(distdir)/ChangeLog
# Update the list of translatable files in po/POTFILES.in.
diff --git a/autogen.sh b/autogen.sh
index ba4612c..5179623 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -21,6 +21,17 @@
set -e
set -v
+# Ensure that whenever we pull in a gnulib update or otherwise change to a
+# different version (i.e., when switching branches), we also rerun ./bootstrap.
+curr_status=.git-module-status
+t=$(git submodule status)
+if test "$t" = "$(cat $curr_status 2>/dev/null)"; then
+ : # good, it's up to date
+else
+ echo running bootstrap...
+ ./bootstrap && echo "$t" > $curr_status
+fi
+
mkdir -p daemon/m4
autoreconf -i
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..73a5e04
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+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.
+
+If the file bootstrap.conf exists in the current working directory, its
+contents are read as shell variables to configure the bootstrap.
+
+Running without arguments will suffice in most cases.
+"
+}
+
+for option
+do
+ case $option in
+ --help)
+ usage
+ exit;;
+ --gnulib-srcdir=*)
+ GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
+ *)
+ echo >&2 "$0: $option: unknown option"
+ exit 1;;
+ esac
+done
+
+# Get gnulib files.
+
+case ${GNULIB_SRCDIR--} in
+-)
+ echo "$0: getting gnulib files..."
+ git submodule init || exit $?
+ git submodule update || exit $?
+ GNULIB_SRCDIR=.gnulib
+ ;;
+*)
+ # Redirect the gnulib submodule to the directory on the command line
+ # if possible.
+ if test -d "$GNULIB_SRCDIR"/.git && \
+ git config --file .gitmodules submodule.gnulib.url >/dev/null; then
+ git submodule init
+ GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
+ git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
+ echo "$0: getting gnulib files..."
+ git submodule update || exit $?
+ GNULIB_SRCDIR=.gnulib
+ else
+ echo >&2 "$0: invalid gnulib srcdir: $GNULIB_SRCDIR"
+ exit 1
+ fi
+ ;;
+esac
+
+gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
+<$gnulib_tool || exit
+
+modules='
+gitlog-to-changelog
+gnu-make
+gnumakefile
+maintainer-makefile
+manywarnings
+warnings
+vc-list-files
+'
+
+$gnulib_tool \
+ --avoid=dummy \
+ --with-tests \
+ --m4-base=gnulib/m4 \
+ --source-base=gnulib/lib \
+ --tests-base=gnulib/tests \
+ --import $modules
diff --git a/cfg.mk b/cfg.mk
new file mode 100644
index 0000000..9363d41
--- /dev/null
+++ b/cfg.mk
@@ -0,0 +1,240 @@
+# Customize Makefile.maint. -*- makefile -*-
+# Copyright (C) 2003-2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Use alpha.gnu.org for alpha and beta releases.
+# Use ftp.gnu.org for major releases.
+gnu_ftp_host-alpha = alpha.gnu.org
+gnu_ftp_host-beta = alpha.gnu.org
+gnu_ftp_host-major = ftp.gnu.org
+gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
+
+url_dir_list = \
+ ftp://$(gnu_rel_host)/gnu/coreutils
+
+# Tests not to run as part of "make distcheck".
+local-checks-to-skip = \
+ sc_po_check \
+ changelog-check \
+ check-AUTHORS \
+ makefile-check \
+ makefile_path_separator_check \
+ patch-check \
+ sc_GPL_version \
+ sc_always_defined_macros \
+ sc_cast_of_alloca_return_value \
+ sc_dd_max_sym_length \
+ sc_error_exit_success \
+ sc_file_system \
+ sc_immutable_NEWS \
+ sc_makefile_path_separator_check \
+ sc_obsolete_symbols \
+ sc_prohibit_S_IS_definition \
+ sc_prohibit_atoi_atof \
+ sc_prohibit_jm_in_m4 \
+ sc_prohibit_quote_without_use \
+ sc_prohibit_quotearg_without_use \
+ sc_prohibit_stat_st_blocks \
+ sc_prohibit_strcmp_and_strncmp \
+ sc_prohibit_strcmp \
+ sc_root_tests \
+ sc_space_tab \
+ sc_sun_os_names \
+ sc_system_h_headers \
+ sc_tight_scope \
+ sc_two_space_separator_in_usage \
+ sc_error_message_uppercase \
+ sc_program_name \
+ sc_require_test_exit_idiom \
+ sc_makefile_check \
+ sc_useless_cpp_parens
+
+# Avoid uses of write(2). Either switch to streams (fwrite), or use
+# the safewrite wrapper.
+sc_avoid_write:
+ @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
+ grep '\<write *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$') && \
+ { echo "$(ME): the above files use write;" \
+ " consider using the safewrite wrapper instead" \
+ 1>&2; exit 1; } || :; \
+ else :; \
+ fi
+
+# Use STREQ rather than comparing strcmp == 0, or != 0.
+# Similarly, use STREQLEN or STRPREFIX rather than strncmp.
+sc_prohibit_strcmp_and_strncmp:
+ @grep -nE '! *strn?cmp *\(|\<strn?cmp *\([^)]+\) *==' \
+ $$($(VC_LIST_EXCEPT)) \
+ | grep -vE ':# *define STREQ(LEN)?\(' && \
+ { echo '$(ME): use STREQ(LEN) in place of the above uses of strcmp(strncmp)' \
+ 1>&2; exit 1; } || :
+
+# Use virAsprintf rather than a'sprintf since *strp is undefined on error.
+sc_prohibit_asprintf:
+ @re='\<[a]sprintf\>' \
+ msg='use virAsprintf, not a'sprintf \
+ $(_prohibit_regexp)
+
+# Prohibit the inclusion of <ctype.h>.
+sc_prohibit_ctype_h:
+ @grep -E '^# *include *<ctype\.h>' $$($(VC_LIST_EXCEPT)) && \
+ { echo "$(ME): don't use ctype.h; instead, use c-ctype.h" \
+ 1>&2; exit 1; } || :
+
+# Ensure that no C source file uses TABs for indentation.
+# Also match *.h.in files, to get libvirt.h.in.
+# Exclude files in gnulib, since they're imported.
+sc_TAB_in_indentation:
+ @grep -lE '^ * ' /dev/null \
+ $$($(VC_LIST_EXCEPT) \
+ | grep -E '\.[ch](\.in)?$$' \
+ | grep -v '^gnulib/') && \
+ { echo '$(ME): found TAB(s) used for indentation in C sources;'\
+ 'use spaces' 1>&2; exit 1; } || :
+
+ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
+|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
+
+sc_avoid_ctype_macros:
+ @grep -E '\b($(ctype_re)) *\(' /dev/null \
+ $$($(VC_LIST_EXCEPT)) && \
+ { echo "$(ME): don't use ctype macros (use c-ctype.h)" \
+ 1>&2; exit 1; } || :
+
+sc_prohibit_virBufferAdd_with_string_literal:
+ @re='\<virBufferAdd *\([^,]+, *"[^"]' \
+ msg='use virBufferAddLit, not virBufferAdd, with a string literal' \
+ $(_prohibit_regexp)
+
+# Not only do they fail to deal well with ipv6, but the gethostby*
+# functions are also not thread-safe.
+sc_prohibit_gethostby:
+ @re='\<gethostby(addr|name2?) *\(' \
+ msg='use getaddrinfo, not gethostby*' \
+ $(_prohibit_regexp)
+
+# Many of the function names below came from this filter:
+# git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
+# |sed 's/.*\.c- *//'|perl -pe 's/ ?\(.*//'|sort -u \
+# |grep -vE '^(qsort|if|close|assert|fputc|free|N_|vir.*GetName|.*Unlock|virNodeListDevices|virHashRemoveEntry|freeaddrinfo|.*[fF]ree|xdrmem_create|xmlXPathFreeObject|virUUIDFormat|openvzSetProgramSentinal|polkit_action_unref)$'
+
+msg_gen_function =
+msg_gen_function += DEBUG0
+msg_gen_function += DISABLE_fprintf
+msg_gen_function += ERROR
+msg_gen_function += ERROR0
+msg_gen_function += REMOTE_DEBUG
+msg_gen_function += ReportError
+msg_gen_function += VIR_FREE
+msg_gen_function += VIR_INFO
+msg_gen_function += VIR_USE_CPU
+msg_gen_function += errorf
+msg_gen_function += lxcError
+msg_gen_function += networkLog
+msg_gen_function += networkReportError
+msg_gen_function += oneError
+msg_gen_function += openvzError
+msg_gen_function += openvzLog
+msg_gen_function += qemudDispatchClientFailure
+msg_gen_function += qemudLog
+msg_gen_function += qemudReportError
+msg_gen_function += regerror
+msg_gen_function += remoteDispatchFormatError
+msg_gen_function += umlLog
+msg_gen_function += umlReportError
+msg_gen_function += virConfError
+msg_gen_function += virDomainReportError
+msg_gen_function += virSecurityReportError
+msg_gen_function += virHashError
+msg_gen_function += virLibConnError
+msg_gen_function += virLibDomainError
+msg_gen_function += virLog
+msg_gen_function += virNetworkReportError
+msg_gen_function += virNodeDeviceReportError
+msg_gen_function += virProxyError
+msg_gen_function += virRaiseError
+msg_gen_function += virReportErrorHelper
+msg_gen_function += virReportSystemError
+msg_gen_function += virSexprError
+msg_gen_function += virStorageLog
+msg_gen_function += virStorageReportError
+msg_gen_function += virXMLError
+msg_gen_function += virXenInotifyError
+msg_gen_function += virXenStoreError
+msg_gen_function += virXendError
+msg_gen_function += vshCloseLogFile
+msg_gen_function += xenUnifiedError
+msg_gen_function += xenXMError
+
+# Uncomment the following and run "make syntax-check" to see diagnostics
+# that are not yet marked for translation, but that need to be rewritten
+# so that they are translatable.
+# msg_gen_function += error
+# msg_gen_function += fprintf
+# msg_gen_function += testError
+# msg_gen_function += virXenError
+# msg_gen_function += vshPrint
+# msg_gen_function += vshError
+
+func_or := $(shell printf '$(msg_gen_function)'|tr -s '[[:space:]]' '|')
+func_re := ($(func_or))
+
+# Look for diagnostics that aren't marked for translation.
+# This won't find any for which error's format string is on a separate line.
+# The sed filters eliminate false-positives like these:
+# _("...: "
+# "%s", _("no storage vol w..."
+sc_libvirt_unmarked_diagnostics:
+ @grep -nE \
+ '\<$(func_re) \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
+ | grep -v '_''(' && \
+ { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
+ exit 1; } || :
+ @{ grep -nE '\<$(func_re) *\(.*;$$' $$($(VC_LIST_EXCEPT)); \
+ grep -A1 -nE '\<$(func_re) *\(.*,$$' $$($(VC_LIST_EXCEPT)); } \
+ | sed 's/_("[^"][^"]*"//;s/[ ]"%s"//' \
+ | grep '[ ]"' && \
+ { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
+ exit 1; } || :
+
+# Disallow trailing blank lines.
+sc_prohibit_trailing_blank_lines:
+ @$(VC_LIST_EXCEPT) | xargs perl -ln -0777 -e \
+ '/\n\n+$$/ and print $$ARGV' > $@-t
+ @found=0; test -s $@-t && { found=1; cat $@-t 1>&2; \
+ echo '$(ME): found trailing blank line(s)' 1>&2; }; \
+ rm -f $@-t; \
+ test $$found = 0
+
+# We don't use this feature of maint.mk.
+prev_version_file = /dev/null
+
+ifeq (0,$(MAKELEVEL))
+ _curr_status = .git-module-status
+ # The sed filter accommodates those who check out on a commit from which
+ # no tag is reachable. In that case, git submodule status prints a "-"
+ # in column 1 and does not print a "git describe"-style string after the
+ # submodule name. Contrast these:
+ # -b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib
+ # b653eda3ac4864de205419d9f41eec267cb89eeb .gnulib (v0.0-2286-gb653eda)
+ _submodule_hash = sed 's/.//;s/ .*//'
+ _update_required := $(shell \
+ actual=$$(git submodule status | $(_submodule_hash)); \
+ stamp="$$($(_submodule_hash) $(_curr_status) 2>/dev/null)"; \
+ test "$$stamp" = "$$actual"; echo $$?)
+ ifeq (1,$(_update_required))
+ $(error gnulib update required; run ./autogen.sh first)
+ endif
+endif
diff --git a/config.rpath b/config.rpath
deleted file mode 100755
index 4db13e5..0000000
--- a/config.rpath
+++ /dev/null
@@ -1,548 +0,0 @@
-#! /bin/sh
-# Output a system dependent set of variables, describing how to set the
-# run time search path of shared libraries in an executable.
-#
-# Copyright 1996-2003 Free Software Foundation, Inc.
-# Taken from GNU libtool, 2001
-# Originally by Gordon Matzigkeit <gord(a)gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-#
-# The first argument passed to this file is the canonical host specification,
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
-# should be set by the caller.
-#
-# The set of defined variables is at the end of this script.
-
-# Known limitations:
-# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
-# than 256 bytes, otherwise the compiler driver will dump core. The only
-# known workaround is to choose shorter directory names for the build
-# directory and/or the installation directory.
-
-# All known linkers require a `.a' archive for static linking (except M$VC,
-# which needs '.lib').
-libext=a
-shrext=.so
-
-host="$1"
-host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
-
-wl=
-if test "$GCC" = yes; then
- wl='-Wl,'
-else
- case "$host_os" in
- aix*)
- wl='-Wl,'
- ;;
- mingw* | pw32* | os2*)
- ;;
- hpux9* | hpux10* | hpux11*)
- wl='-Wl,'
- ;;
- irix5* | irix6* | nonstopux*)
- wl='-Wl,'
- ;;
- newsos6)
- ;;
- linux*)
- case $CC in
- icc|ecc)
- wl='-Wl,'
- ;;
- ccc)
- wl='-Wl,'
- ;;
- esac
- ;;
- osf3* | osf4* | osf5*)
- wl='-Wl,'
- ;;
- sco3.2v5*)
- ;;
- solaris*)
- wl='-Wl,'
- ;;
- sunos4*)
- wl='-Qoption ld '
- ;;
- sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
- wl='-Wl,'
- ;;
- sysv4*MP*)
- ;;
- uts4*)
- ;;
- esac
-fi
-
-# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
-
-hardcode_libdir_flag_spec=
-hardcode_libdir_separator=
-hardcode_direct=no
-hardcode_minus_L=no
-
-case "$host_os" in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
-esac
-
-ld_shlibs=yes
-if test "$with_gnu_ld" = yes; then
- case "$host_os" in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs=no
- fi
- ;;
- amigaos*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- # Samuel A. Falvo II <kc5tja(a)dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can use
- # them.
- ld_shlibs=no
- ;;
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- :
- else
- ld_shlibs=no
- fi
- ;;
- cygwin* | mingw* | pw32*)
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec='-L$libdir'
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- :
- else
- ld_shlibs=no
- fi
- ;;
- netbsd*)
- ;;
- solaris* | sysv5*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs=no
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- :
- else
- ld_shlibs=no
- fi
- ;;
- sunos4*)
- hardcode_direct=yes
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- :
- else
- ld_shlibs=no
- fi
- ;;
- esac
- if test "$ld_shlibs" = yes; then
- # Unlike libtool, we use -rpath here, not --rpath, since the documented
- # option of GNU ld is called -rpath, not --rpath.
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- fi
-else
- case "$host_os" in
- aix3*)
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L=yes
- if test "$GCC" = yes; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct=unsupported
- fi
- ;;
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- else
- aix_use_runtimelinking=no
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- esac
- fi
- hardcode_direct=yes
- hardcode_libdir_separator=':'
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct=yes
- else
- # We have old collect2
- hardcode_direct=unsupported
- hardcode_minus_L=yes
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_libdir_separator=
- fi
- esac
- fi
- # Begin _LT_AC_SYS_LIBPATH_AIX.
- echo 'int main () { return 0; }' > conftest.c
- ${CC} ${LDFLAGS} conftest.c -o conftest
- aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
- if test -z "$aix_libpath"; then
- aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
- fi
- if test -z "$aix_libpath"; then
- aix_libpath="/usr/lib:/lib"
- fi
- rm -f conftest.c conftest
- # End _LT_AC_SYS_LIBPATH_AIX.
- if test "$aix_use_runtimelinking" = yes; then
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
- else
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- fi
- fi
- ;;
- amigaos*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs=no
- ;;
- bsdi4*)
- ;;
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec=' '
- libext=lib
- ;;
- darwin* | rhapsody*)
- if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
- hardcode_direct=no
- fi
- ;;
- dgux*)
- hardcode_libdir_flag_spec='-L$libdir'
- ;;
- freebsd1*)
- ld_shlibs=no
- ;;
- freebsd2.2*)
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- ;;
- freebsd2*)
- hardcode_direct=yes
- hardcode_minus_L=yes
- ;;
- freebsd*)
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- ;;
- hpux9*)
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_direct=yes
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- ;;
- hpux10* | hpux11*)
- if test "$with_gnu_ld" = no; then
- case "$host_cpu" in
- hppa*64*)
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_direct=no
- ;;
- ia64*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_direct=no
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- ;;
- *)
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_direct=yes
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- ;;
- esac
- fi
- ;;
- irix5* | irix6* | nonstopux*)
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- ;;
- netbsd*)
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- ;;
- newsos6)
- hardcode_direct=yes
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- ;;
- openbsd*)
- hardcode_direct=yes
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- else
- case "$host_os" in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- hardcode_libdir_flag_spec='-R$libdir'
- ;;
- *)
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
- os2*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- ;;
- osf3*)
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- ;;
- osf4* | osf5*)
- if test "$GCC" = yes; then
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- else
- # Both cc and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec='-rpath $libdir'
- fi
- hardcode_libdir_separator=:
- ;;
- sco3.2v5*)
- ;;
- solaris*)
- hardcode_libdir_flag_spec='-R$libdir'
- ;;
- sunos4*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_direct=yes
- hardcode_minus_L=yes
- ;;
- sysv4)
- case $host_vendor in
- sni)
- hardcode_direct=yes # is this really true???
- ;;
- siemens)
- hardcode_direct=no
- ;;
- motorola)
- hardcode_direct=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- ;;
- sysv4.3*)
- ;;
- sysv4*MP*)
- if test -d /usr/nec; then
- ld_shlibs=yes
- fi
- ;;
- sysv4.2uw2*)
- hardcode_direct=yes
- hardcode_minus_L=no
- ;;
- sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
- ;;
- sysv5*)
- hardcode_libdir_flag_spec=
- ;;
- uts4*)
- hardcode_libdir_flag_spec='-L$libdir'
- ;;
- *)
- ld_shlibs=no
- ;;
- esac
-fi
-
-# Check dynamic linker characteristics
-# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
-libname_spec='lib$name'
-case "$host_os" in
- aix3*)
- ;;
- aix4* | aix5*)
- ;;
- amigaos*)
- ;;
- beos*)
- ;;
- bsdi4*)
- ;;
- cygwin* | mingw* | pw32*)
- shrext=.dll
- ;;
- darwin* | rhapsody*)
- shrext=.dylib
- ;;
- dgux*)
- ;;
- freebsd1*)
- ;;
- freebsd*)
- ;;
- gnu*)
- ;;
- hpux9* | hpux10* | hpux11*)
- case "$host_cpu" in
- ia64*)
- shrext=.so
- ;;
- hppa*64*)
- shrext=.sl
- ;;
- *)
- shrext=.sl
- ;;
- esac
- ;;
- irix5* | irix6* | nonstopux*)
- case "$host_os" in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
- *) libsuff= shlibsuff= ;;
- esac
- ;;
- esac
- ;;
- linux*oldld* | linux*aout* | linux*coff*)
- ;;
- linux*)
- ;;
- netbsd*)
- ;;
- newsos6)
- ;;
- nto-qnx)
- ;;
- openbsd*)
- ;;
- os2*)
- libname_spec='$name'
- shrext=.dll
- ;;
- osf3* | osf4* | osf5*)
- ;;
- sco3.2v5*)
- ;;
- solaris*)
- ;;
- sunos4*)
- ;;
- sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
- ;;
- sysv4*MP*)
- ;;
- uts4*)
- ;;
-esac
-
-sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
-escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
-shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
-escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
-
-sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
-
-# How to pass a linker flag through the compiler.
-wl="$escaped_wl"
-
-# Static library suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally "so").
-shlibext="$shlibext"
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator="$hardcode_libdir_separator"
-
-# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct="$hardcode_direct"
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L="$hardcode_minus_L"
-
-EOF
diff --git a/configure.ac b/configure.ac
index ece7da7..df466fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ m4_define([libguestfs_release], [65])
m4_define([libguestfs_extra], [])
AC_INIT([libguestfs],libguestfs_major.libguestfs_minor.libguestfs_release[]libguestfs_extra)
+AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_MACRO_DIR([m4])
@@ -40,6 +41,9 @@ AC_PROG_CC_STDC
AC_PROG_INSTALL
AC_PROG_CPP
+gl_EARLY
+gl_INIT
+
AC_C_PROTOTYPES
test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
@@ -594,6 +598,8 @@ AC_CONFIG_FILES([Makefile
inspector/Makefile
v2v/Makefile
libguestfs.pc
+ gnulib/lib/Makefile
+ gnulib/tests/Makefile
ocaml/META perl/Makefile.PL])
AC_OUTPUT
diff --git a/gitlog-to-changelog b/gitlog-to-changelog
deleted file mode 100755
index 0a94b9e..0000000
--- a/gitlog-to-changelog
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/usr/bin/perl
-# Convert git log output to ChangeLog format.
-
-my $VERSION = '2008-12-21 12:07'; # UTC
-# The definition above must lie within the first 8 lines in order
-# for the Emacs time-stamp write hook (at end) to update it.
-# If you change this file with Emacs, please let the write hook
-# do its job. Otherwise, update this string manually.
-
-# Copyright (C) 2008 Free Software Foundation, Inc.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Written by Jim Meyering
-
-use strict;
-use warnings;
-use Getopt::Long;
-use POSIX qw(strftime);
-
-(my $ME = $0) =~ s|.*/||;
-
-# use File::Coda; # http://meyering.net/code/Coda/
-END {
- defined fileno STDOUT or return;
- close STDOUT and return;
- warn "$ME: failed to close standard output: $!\n";
- $? ||= 1;
-}
-
-sub usage ($)
-{
- my ($exit_code) = @_;
- my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
- if ($exit_code != 0)
- {
- print $STREAM "Try `$ME --help' for more information.\n";
- }
- else
- {
- print $STREAM <<EOF;
-Usage: $ME [OPTIONS] [ARGS]
-
-Convert git log output to ChangeLog format. If present, any ARGS
-are passed to "git log". To avoid ARGS being parsed as options to
-$ME, they may be preceded by '--'.
-
-OPTIONS:
-
- --since=DATE convert only the logs since DATE;
- the default is to convert all log entries.
-
- --help display this help and exit
- --version output version information and exit
-
-EXAMPLE:
-
- $ME --since=2008-01-01 > ChangeLog
- $ME -- -n 5 foo > last-5-commits-to-branch-foo
-
-EOF
- }
- exit $exit_code;
-}
-
-# If the string $S is a well-behaved file name, simply return it.
-# If it contains white space, quotes, etc., quote it, and return the new string.
-sub shell_quote($)
-{
- my ($s) = @_;
- if ($s =~ m![^\w+/.,-]!)
- {
- # Convert each single quote to '\''
- $s =~ s/\'/\'\\\'\'/g;
- # Then single quote the string.
- $s = "'$s'";
- }
- return $s;
-}
-
-sub quoted_cmd(@)
-{
- return join (' ', map {shell_quote $_} @_);
-}
-
-{
- my $since_date = '1970-01-01 UTC';
- GetOptions
- (
- help => sub { usage 0 },
- version => sub { print "$ME version $VERSION\n"; exit },
- 'since=s' => \$since_date,
- ) or usage 1;
-
- my @cmd = (qw (git log --log-size), "--since=$since_date",
- '--pretty=format:%ct %an <%ae>%n%n%s%n%b%n', @ARGV);
- open PIPE, '-|', @cmd
- or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"
- . "(Is your Git too old? Version 1.5.1 or later is required.)\n");
-
- my $prev_date_line = '';
- while (1)
- {
- defined (my $in = <PIPE>)
- or last;
- $in =~ /^log size (\d+)$/
- or die "$ME:$.: Invalid line (expected log size):\n$in";
- my $log_nbytes = $1;
-
- my $log;
- my $n_read = read PIPE, $log, $log_nbytes;
- $n_read == $log_nbytes
- or die "$ME:$.: unexpected EOF\n";
-
- my @line = split "\n", $log;
- my $author_line = shift @line;
- defined $author_line
- or die "$ME:$.: unexpected EOF\n";
- $author_line =~ /^(\d+) (.*>)$/
- or die "$ME:$.: Invalid line "
- . "(expected date/author/email):\n$author_line\n";
-
- my $date_line = sprintf "%s $2\n", strftime ("%F", localtime ($1));
- # If this line would be the same as the previous date/name/email
- # line, then arrange not to print it.
- if ($date_line ne $prev_date_line)
- {
- $prev_date_line eq ''
- or print "\n";
- print $date_line;
- }
- $prev_date_line = $date_line;
-
- # Omit "Signed-off-by..." lines.
- @line = grep !/^Signed-off-by: .*>$/, @line;
-
- # Remove leading and trailing blank lines.
- while ($line[0] =~ /^\s*$/) { shift @line; }
- while ($line[$#line] =~ /^\s*$/) { pop @line; }
-
- # Prefix each non-empty line with a TAB.
- @line = map { length $_ ? "\t$_" : '' } @line;
-
- print "\n", join ("\n", @line), "\n";
-
- defined ($in = <PIPE>)
- or last;
- $in ne "\n"
- and die "$ME:$.: unexpected line:\n$in";
- }
-
- close PIPE
- or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n";
- # FIXME-someday: include $PROCESS_STATUS in the diagnostic
-}
-
-# Local Variables:
-# indent-tabs-mode: nil
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "my $VERSION = '"
-# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "'; # UTC"
-# End:
diff --git a/mkinstalldirs b/mkinstalldirs
deleted file mode 100755
index d2d5f21..0000000
--- a/mkinstalldirs
+++ /dev/null
@@ -1,111 +0,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman(a)prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
-
-errstatus=0
-dirmode=""
-
-usage="\
-Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
-
-# process command line arguments
-while test $# -gt 0 ; do
- case $1 in
- -h | --help | --h*) # -h for help
- echo "$usage" 1>&2
- exit 0
- ;;
- -m) # -m PERM arg
- shift
- test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
- dirmode=$1
- shift
- ;;
- --) # stop option processing
- shift
- break
- ;;
- -*) # unknown option
- echo "$usage" 1>&2
- exit 1
- ;;
- *) # first non-opt arg
- break
- ;;
- esac
-done
-
-for file
-do
- if test -d "$file"; then
- shift
- else
- break
- fi
-done
-
-case $# in
- 0) exit 0 ;;
-esac
-
-case $dirmode in
- '')
- if mkdir -p -- . 2>/dev/null; then
- echo "mkdir -p -- $*"
- exec mkdir -p -- "$@"
- fi
- ;;
- *)
- if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
- echo "mkdir -m $dirmode -p -- $*"
- exec mkdir -m "$dirmode" -p -- "$@"
- fi
- ;;
-esac
-
-for file
-do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
-
- pathcomp=
- for d
- do
- pathcomp="$pathcomp$d"
- case $pathcomp in
- -*) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp"
-
- mkdir "$pathcomp" || lasterr=$?
-
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- else
- if test ! -z "$dirmode"; then
- echo "chmod $dirmode $pathcomp"
- lasterr=""
- chmod "$dirmode" "$pathcomp" || lasterr=$?
-
- if test ! -z "$lasterr"; then
- errstatus=$lasterr
- fi
- fi
- fi
- fi
-
- pathcomp="$pathcomp/"
- done
-done
-
-exit $errstatus
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# End:
-# mkinstalldirs ends here
--
1.6.3.3
>From e832bcedb02699e7327d9f85d12461ae8f78c788 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 3 Aug 2009 05:53:26 -0400
Subject: [PATCH 4/4] build: temporarily disable failing "syntax-check" rules
* cfg.mk (disable_temporarily): Define.
---
cfg.mk | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 9363d41..61a4db1 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -59,8 +59,22 @@ local-checks-to-skip = \
sc_program_name \
sc_require_test_exit_idiom \
sc_makefile_check \
+ $(disable_temporarily) \
sc_useless_cpp_parens
+disable_temporarily = \
+ sc_makefile_TAB_only_indentation \
+ sc_unmarked_diagnostics \
+ sc_TAB_in_indentation \
+ sc_prohibit_ctype_h \
+ sc_prohibit_asprintf \
+ sc_m4_quote_check \
+ sc_prohibit_trailing_blank_lines \
+ sc_avoid_ctype_macros \
+ sc_const_long_option \
+ sc_avoid_write \
+ sc_trailing_blank
+
# Avoid uses of write(2). Either switch to streams (fwrite), or use
# the safewrite wrapper.
sc_avoid_write:
--
1.6.3.3
15 years, 1 month
[PATCH] guestfs: don't fault upon failed vasprintf
by Jim Meyering
>From 774e791d2617b318223317aa004e495b9d274d97 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Mon, 3 Aug 2009 08:43:54 -0400
Subject: [PATCH] guestfs: don't fault upon failed vasprintf
* src/guestfs.c (guestfs_perrorf): Handle failed vasprintf.
---
src/guestfs.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/guestfs.c b/src/guestfs.c
index 63e24f0..802c1d2 100644
--- a/src/guestfs.c
+++ b/src/guestfs.c
@@ -443,9 +443,11 @@ guestfs_perrorf (guestfs_h *g, const char *fs, ...)
int err = errno;
va_start (args, fs);
- vasprintf (&msg, fs, args);
+ int err = vasprintf (&msg, fs, args);
va_end (args);
+ if (err < 0) return;
+
#ifndef _GNU_SOURCE
char buf[256];
strerror_r (err, buf, sizeof buf);
--
1.6.3.3
15 years, 1 month
[REPOST] Use grub entries to find Linux kernels
by Matthew Booth
This is a repost of the patch I sent on Friday. I know it was already ACK'd, but
I've changed a fair bit in addition to adding the requested POD. Specifically:
I discovered that augeas's grub lens wasn't returning cmdline the way I
expected. This is fixed.
The kernel package, if known, is output as a property of the kernel.
The XML output of virt-inspector is updated with all the new output.
15 years, 1 month
[PATCH] Use grub entries to find Linux kernels
by Matthew Booth
This change adds grub parsing to Lib.pm. It adds the following structure to $os:
{boot}
->{configs}
->[0]
->{title} = "Fedora (2.6.29.6-213.fc11.i686.PAE)"
->{kernel} = \kernel
->{cmdline} = "ro root=/dev/mapper/vg_mbooth-lv_root rhgb"
->{initrd} = \initrd
->{default} = 0
The kernel and initrd entries are just references to their top level entries
under kernels and initrd_modules respectively.
It also changes the way Linux kernels and initrd are discovered. Instead of
searching /lib/modules and /boot for files with matching names, kernels and
initrds are scanned as they are discovered in grub.conf.
---
perl/lib/Sys/Guestfs/Lib.pm | 278 +++++++++++++++++++++++++++++--------------
1 files changed, 189 insertions(+), 89 deletions(-)
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index bbc583f..20e29ff 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -1343,7 +1343,6 @@ sub inspect_in_detail
_check_for_kernels ($g, $os);
if ($os->{os} eq "linux") {
_find_modprobe_aliases ($g, $os);
- _check_for_initrd ($g, $os);
}
}
@@ -1392,48 +1391,170 @@ sub _check_for_applications
sub _check_for_kernels
{
- local $_;
- my $g = shift;
- my $os = shift;
+ my ($g, $os) = @_;
- my @kernels;
+ if ($os->{os} eq "linux") {
+ # Iterate over entries in grub.conf, populating $os->{boot}
+ # For every kernel we find, inspect it and add to $os->{kernels}
+
+ my @boot_configs;
+
+ # We want
+ # $os->{boot}
+ # ->{configs}
+ # ->[0]
+ # ->{title} = "Fedora (2.6.29.6-213.fc11.i686.PAE)"
+ # ->{kernel} = \kernel
+ # ->{cmdline} = "ro root=/dev/mapper/vg_mbooth-lv_root rhgb"
+ # ->{initrd} = \initrd
+ # ->{default} = \config
+ # Initialise augeas
+ $g->aug_init("/", 16);
+
+ my @configs = ();
+ # Get all configurations from grub
+ foreach my $bootable
+ ($g->aug_match("/files/etc/grub.conf/title"))
+ {
+ my %config = ();
+ $config{title} = $g->aug_get($bootable);
+
+ my $grub_kernel;
+ eval {
+ $grub_kernel = $g->aug_get("$bootable/kernel");
+ };
+ if($@) {
+ warn __x("Grub entry {title} has no kernel",
+ title => $config{title});
+ }
- my $osn = $os->{os};
- if ($osn eq "linux") {
- # Installed kernels will have a corresponding /lib/modules/<version>
- # directory, which is the easiest way to find out what kernels
- # are installed, and what modules are available.
- foreach ($g->ls ("/lib/modules")) {
- if ($g->is_dir ("/lib/modules/$_")) {
- my %kernel;
- $kernel{version} = $_;
-
- # List modules.
- my @modules;
- my $any_module;
- my $prefix = "/lib/modules/$_";
- foreach ($g->find ($prefix)) {
- if (m,/([^/]+)\.ko$, || m,([^/]+)\.o$,) {
- $any_module = "$prefix$_" unless defined $any_module;
- push @modules, $1;
- }
- }
+ # Check we've got a kernel entry
+ if(defined($grub_kernel)) {
+ # Parse a kernel path and optional kernel command line
+ if($grub_kernel =~ /^\s*(\S+)(?:\s+(.*))?$/) {
+ my $kernel_path = $1;
+ $config{cmdline} = $2 if defined($2);
+
+ my $kernel = _inspect_linux_kernel($g, $os, "/boot$1");
+
+ # Check the kernel was recognised
+ if(defined($kernel)) {
+ $config{kernel} = $kernel;
+
+ # Look for an initrd entry
+ my $initrd;
+ eval {
+ $initrd = $g->aug_get("$bootable/initrd");
+ };
+
+ unless($@) {
+ $config{initrd} =
+ _inspect_initrd($g, $os, "/boot$initrd",
+ $kernel->{version});
+ } else {
+ warn __x("Grub entry {title} does not specify an ".
+ "initrd", title => $config{title});
+ }
+ }
+ }
+ else {
+ warn __x("Unexpected grub kernel line: {grub_kernel}",
+ grub_kernel => $grub_kernel);
+ next;
+ }
+ }
- $kernel{modules} = \@modules;
+ push(@configs, \%config);
+ }
- # Determine kernel architecture by looking at the arch
- # of any kernel module.
- $kernel{arch} = file_architecture ($g, $any_module);
- push @kernels, \%kernel;
- }
- }
+ # Create the top level boot entry
+ my %boot;
+ $boot{configs} = \@configs;
- } elsif ($osn eq "windows") {
+ # Add the default configuration
+ eval {
+ $boot{default} = $g->aug_get("/files/etc/grub.conf/default");
+ };
+ if($@) {
+ warn __"No grub default specified";
+ }
+
+ $os->{boot} = \%boot;
+ }
+
+ elsif ($os->{os} eq "windows") {
# XXX
}
+}
+
+sub _inspect_linux_kernel
+{
+ my ($g, $os, $path) = @_;
+
+ my %kernel = ();
+
+ $kernel{path} = $path;
+
+ # Try to get the kernel version by running file against it
+ my $version;
+ my $filedesc = $g->file($path);
+ if($filedesc =~ /^$path: Linux kernel .*\bversion\s+(\S+)\b/) {
+ $version = $1;
+ }
+
+ # Sometimes file can't work out the kernel version, for example because it's
+ # a Xen PV kernel. In this case try to guess the version from the filename
+ else {
+ if($path =~ m{/boot/vmlinuz-(.*)}) {
+ $version = $1;
+
+ # Check /lib/modules/$version exists
+ if(!$g->is_dir("/lib/modules/$version")) {
+ warn __x("Didn't find modules directory {modules} for kernel ".
+ "{path}", modules => "/lib/modules/$version",
+ path => $path);
+
+ # Give up
+ return undef;
+ }
+ } else {
+ warn __x("Couldn't guess kernel version number from path for ".
+ "kernel {path}", path => $path);
+
+ # Give up
+ return undef;
+ }
+ }
+
+ $kernel{version} = $version;
+
+ # List modules.
+ my @modules;
+ my $any_module;
+ my $prefix = "/lib/modules/$version";
+ foreach my $module ($g->find ($prefix)) {
+ if ($module =~ m{/([^/]+)\.(?:ko|o)$}) {
+ $any_module = "$prefix$module" unless defined $any_module;
+ push @modules, $1;
+ }
+ }
+
+ $kernel{modules} = \@modules;
+
+ # Determine kernel architecture by looking at the arch
+ # of any kernel module.
+ $kernel{arch} = file_architecture ($g, $any_module);
+
+ # Put this kernel on the top level kernel list
+ my $kernels = $os->{kernels};
+ if(!defined($kernels)) {
+ $kernels = [];
+ $os->{kernels} = $kernels;
+ }
+ push(@$kernels, \%kernel);
- $os->{kernels} = \@kernels;
+ return \%kernel;
}
# Find all modprobe aliases. Specifically, this looks in the following
@@ -1450,28 +1571,14 @@ sub _find_modprobe_aliases
my $os = shift;
# Initialise augeas
- my $success = 0;
- $success = $g->aug_init("/", 16);
-
- # Register /etc/modules.conf and /etc/conf.modules to the Modprobe lens
- my @results;
- @results = $g->aug_match("/augeas/load/Modprobe/incl");
-
- # Calculate the next index of /augeas/load/Modprobe/incl
- my $i = 1;
- foreach ( @results ) {
- next unless m{/augeas/load/Modprobe/incl\[(\d*)]};
- $i = $1 + 1 if ($1 == $i);
- }
+ $g->aug_init("/", 16);
- $success = $g->aug_set("/augeas/load/Modprobe/incl[$i]",
- "/etc/modules.conf");
- $i++;
- $success = $g->aug_set("/augeas/load/Modprobe/incl[$i]",
- "/etc/conf.modules");
+ # Register additional paths to the Modprobe lens
+ $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/modules.conf");
+ $g->aug_set("/augeas/load/Modprobe/incl[last()+1]", "/etc/conf.modules");
# Make augeas reload
- $success = $g->aug_load();
+ $g->aug_load();
my %modprobe_aliases;
@@ -1479,9 +1586,7 @@ sub _find_modprobe_aliases
/files/etc/modules.conf/alias
/files/etc/modprobe.conf/alias
/files/etc/modprobe.d/*/alias) {
- @results = $g->aug_match($pattern);
-
- for my $path ( @results ) {
+ for my $path ( $g->aug_match($pattern) ) {
$path =~ m{^/files(.*)/alias(?:\[\d*\])?$}
or die __x("{path} doesn't match augeas pattern",
path => $path);
@@ -1505,45 +1610,40 @@ sub _find_modprobe_aliases
$os->{modprobe_aliases} = \%modprobe_aliases;
}
-# Get a listing of device drivers in any initrd corresponding to a
-# kernel. This is an indication of what can possibly be booted.
-
-sub _check_for_initrd
+# Get a listing of device drivers from an initrd
+sub _inspect_initrd
{
- local $_;
- my $g = shift;
- my $os = shift;
+ my ($g, $os, $path, $version) = @_;
+
+ my @modules;
+
+ # Disregard old-style compressed ext2 files and only work with real
+ # compressed cpio files, since cpio takes ages to (fail to) process anything
+ # else.
+ if ($g->file ($path) =~ /cpio/) {
+ eval {
+ @modules = $g->initrd_list ($path);
+ };
+ unless ($@) {
+ @modules = grep { m{([^/]+)\.(?:ko|o)$} } @modules;
+ } else {
+ warn __x("{filename}: could not read initrd format",
+ filename => "$path");
+ }
+ }
- my %initrd_modules;
-
- foreach my $initrd ($g->ls ("/boot")) {
- if ($initrd =~ m/^initrd-(.*)\.img$/ && $g->is_file ("/boot/$initrd")) {
- my $version = $1;
- my @modules;
-
- # Disregard old-style compressed ext2 files and only
- # work with real compressed cpio files, since cpio
- # takes ages to (fail to) process anything else.
- if ($g->file ("/boot/$initrd") =~ /cpio/) {
- eval {
- @modules = $g->initrd_list ("/boot/$initrd");
- };
- unless ($@) {
- @modules = grep { m,([^/]+)\.ko$, || m,([^/]+)\.o$, }
- @modules;
- $initrd_modules{$version} = \@modules
- } else {
- warn __x("{filename}: could not read initrd format",
- filename => "/boot/$initrd");
- }
- }
- }
+ # Add to the top level initrd_modules entry
+ my $initrd_modules = $os->{initrd_modules};
+ if(!defined($initrd_modules)) {
+ $initrd_modules = {};
+ $os->{initrd_modules} = $initrd_modules;
}
+
+ $initrd_modules->{$version} = \@modules;
- $os->{initrd_modules} = \%initrd_modules;
+ return \@modules;
}
-
1;
=head1 COPYRIGHT
--
1.6.2.5
15 years, 1 month