[Libguestfs] [PATCH 2/3] appliance: add a "rescue" appliance for virt-rescue

Pino Toscano ptoscano at redhat.com
Thu Oct 2 15:36:24 UTC 2014


Add a new appliance flavour for virt-rescue, so it can have extra
packages.

Currently it provides no extra packages.
---
 appliance/Makefile.am           | 21 ++++++++++++++++++++-
 appliance/packagelist-rescue.in | 16 ++++++++++++++++
 rescue/rescue.c                 |  4 ++++
 3 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 appliance/packagelist-rescue.in

diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index 7b30bbe..4e19708 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -32,6 +32,7 @@ EXTRA_DIST = \
 
 fsdir = $(libdir)/guestfs
 superminfsdir = $(libdir)/guestfs/supermin.d
+superminrescuefsdir = $(libdir)/guestfs/supermin-rescue.d
 
 fs_DATA =
 superminfs_DATA = \
@@ -42,6 +43,8 @@ superminfs_DATA = \
 	supermin.d/init.tar.gz \
 	supermin.d/packages \
 	supermin.d/udev-rules.tar.gz
+superminrescuefs_DATA = \
+	supermin-rescue.d/packages
 
 supermin.d/base.tar.gz supermin.d/packages: stamp-supermin
 stamp-supermin: make.sh packagelist
@@ -55,6 +58,14 @@ stamp-supermin: make.sh packagelist
 	  supermin.d/udev-rules.tar.gz
 	touch $@
 
+supermin-rescue.d/packages: stamp-supermin-rescue
+stamp-supermin-rescue: stamp-supermin make.sh packagelist-rescue
+	rm -f $@ supermin-rescue.d/packages
+	mkdir -p supermin-rescue.d
+	cat packagelist-rescue | awk '{for (i=1; i<=NF; i++) print $i}' \
+	  | sort > supermin-rescue.d/packages
+	touch $@
+
 # This used to be a configure-generated file.  However config.status
 # always touches the destination file, which means the appliance got
 # rebuilt too often.
@@ -76,6 +87,12 @@ packagelist: packagelist.in Makefile
 	cmp -s $@ $@-t || mv $@-t $@
 	rm -f $@-t
 
+packagelist-rescue: packagelist-rescue.in Makefile
+	m4 $(PACKAGELIST_CPP_FLAGS) $< | \
+	grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t
+	cmp -s $@ $@-t || mv $@-t $@
+	rm -f $@-t
+
 supermin.d/daemon.tar.gz: ../daemon/guestfsd guestfsd.suppressions guestfs_lvm_conf.aug guestfs_shadow.aug
 	rm -f $@ $@-t
 	rm -rf tmp-d
@@ -151,4 +168,6 @@ CLEANFILES = \
 
 DISTCLEANFILES = \
 	stamp-supermin \
-	supermin.d/*
+	stamp-supermin-rescue \
+	supermin.d/* \
+	supermin-rescue.d/*
diff --git a/appliance/packagelist-rescue.in b/appliance/packagelist-rescue.in
new file mode 100644
index 0000000..aec0201
--- /dev/null
+++ b/appliance/packagelist-rescue.in
@@ -0,0 +1,16 @@
+dnl This is the list of distro packages which are
+dnl installed on the appliance.
+dnl
+dnl This file is processed by m4 with one of the
+dnl following symbols defined (depending on the distro):
+dnl
+dnl   REDHAT=1     For Fedora, RHEL, EPEL and workalikes.
+dnl   DEBIAN=1     For Debian.
+dnl   UBUNTU=1     For Ubuntu.
+dnl   ARCHLINUX=1  For Archlinux.
+dnl   SUSE=1       For OpenSUSE.
+dnl   FRUGALWARE=1 For Frugalware.
+dnl   MAGEIA=1     For Mageia.
+
+dnl Basically the same with a few minor tweaks.
+ifelse(UBUNTU,1,`define(`DEBIAN',1)')
diff --git a/rescue/rescue.c b/rescue/rescue.c
index 00187a4..79c7d9a 100644
--- a/rescue/rescue.c
+++ b/rescue/rescue.c
@@ -323,6 +323,10 @@ main (int argc, char *argv[])
     }
   }
 
+  /* Use the "rescue" appliance flavour. */
+  if (guestfs_set_flavour (g, "rescue") == -1)
+    exit (EXIT_FAILURE);
+
   /* Set other features. */
   if (memsize > 0)
     if (guestfs_set_memsize (g, memsize) == -1)
-- 
1.9.3




More information about the Libguestfs mailing list