[Libguestfs] [PATCH] supermin: If disabled, don't compile in supermin code or check for supermin.

Richard W.M. Jones rjones at redhat.com
Mon Nov 8 12:49:57 UTC 2010


On Sun, Nov 07, 2010 at 07:12:42PM +0000, Richard W.M. Jones wrote:
> It works, but this warning message is definitely a bug:
> 
>   sh: febootstrap-supermin-helper: command not found

Attached is a patch which fixes this issue.

I tested this by compiling with and without supermin, and it works
(ie. compiles and runs simple tests) in both cases.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-------------- next part --------------
>From 4e656a61d40ff51e63aa06d857c40c14ff31ddb9 Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones at redhat.com>
Date: Mon, 8 Nov 2010 12:46:31 +0000
Subject: [PATCH] supermin: If disabled, don't compile in supermin code or check for supermin.

If supermin is disabled at compile time and the user just wants to
use the ordinary appliance, there is no need to compile in all
the supermin code, and in particular there is no need to check
for the supermin appliance (which involves running
febootstrap-supermin-helper that probably doesn't exist).

This fixes a warning message observed under Debian w/o supermin:

  sh: febootstrap-supermin-helper: command not found
---
 configure.ac    |    2 +-
 src/appliance.c |   16 +++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index c42a855..b42429e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -404,7 +404,7 @@ dnl enabling this option.
 AC_ARG_ENABLE([supermin],
         [AS_HELP_STRING([--enable-supermin],
           [enable supermin appliance (see README) @<:@default=no@:>@])],
-        [],
+        [AC_DEFINE([ENABLE_SUPERMIN],[1],[Supermin appliance enabled.])],
         [enable_supermin=no])
 AM_CONDITIONAL([SUPERMIN],[test "x$enable_supermin" = "xyes"])
 
diff --git a/src/appliance.c b/src/appliance.c
index 7dc42c1..26f5261 100644
--- a/src/appliance.c
+++ b/src/appliance.c
@@ -47,12 +47,14 @@ static const char *initrd_name = "initramfs." host_cpu ".img";
 static int find_path (guestfs_h *g, int (*pred) (guestfs_h *g, const char *pelem, void *data), void *data, char **pelem);
 static int dir_contains_file (const char *dir, const char *file);
 static int dir_contains_files (const char *dir, ...);
-static int contains_supermin_appliance (guestfs_h *g, const char *path, void *data);
 static int contains_ordinary_appliance (guestfs_h *g, const char *path, void *data);
+#if ENABLE_SUPERMIN
+static int contains_supermin_appliance (guestfs_h *g, const char *path, void *data);
 static char *calculate_supermin_checksum (guestfs_h *g, const char *supermin_path);
 static int check_for_cached_appliance (guestfs_h *g, const char *supermin_path, const char *checksum, char **kernel, char **initrd, char **appliance);
 static int build_supermin_appliance (guestfs_h *g, const char *supermin_path, const char *checksum, char **kernel, char **initrd, char **appliance);
 static int run_supermin_helper (guestfs_h *g, const char *supermin_path, const char *cachedir, size_t cdlen);
+#endif
 
 /* Locate or build the appliance.
  *
@@ -88,6 +90,7 @@ guestfs___build_appliance (guestfs_h *g,
 {
   int r;
 
+#if ENABLE_SUPERMIN
   /* Step (1). */
   char *supermin_path;
   r = find_path (g, contains_supermin_appliance, NULL, &supermin_path);
@@ -116,6 +119,7 @@ guestfs___build_appliance (guestfs_h *g,
     }
     free (supermin_path);
   }
+#endif
 
   /* Step (5). */
   char *path;
@@ -141,15 +145,16 @@ guestfs___build_appliance (guestfs_h *g,
 }
 
 static int
-contains_supermin_appliance (guestfs_h *g, const char *path, void *data)
+contains_ordinary_appliance (guestfs_h *g, const char *path, void *data)
 {
-  return dir_contains_files (path, "supermin.d", "kmod.whitelist", NULL);
+  return dir_contains_files (path, kernel_name, initrd_name, NULL);
 }
 
+#if ENABLE_SUPERMIN
 static int
-contains_ordinary_appliance (guestfs_h *g, const char *path, void *data)
+contains_supermin_appliance (guestfs_h *g, const char *path, void *data)
 {
-  return dir_contains_files (path, kernel_name, initrd_name, NULL);
+  return dir_contains_files (path, "supermin.d", "kmod.whitelist", NULL);
 }
 
 /* supermin_path is a path which is known to contain a supermin
@@ -531,6 +536,7 @@ run_supermin_helper (guestfs_h *g, const char *supermin_path,
   perror ("execvp");
   _exit (EXIT_FAILURE);
 }
+#endif
 
 /* Search elements of g->path, returning the first path element which
  * matches the predicate function 'pred'.
-- 
1.7.3.2



More information about the Libguestfs mailing list