From f9a0c0ba0ddbdd351199f52eccf9b183556d3ed4 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 28 Aug 2013 22:35:42 +0100
Subject: [PATCH] appliance: Use gzip-compressed cpio files if supermin-helper
supports it.
supermin-helper >= 4.1.4 has new support for compressed cpio files
(not hostfiles). Detect if this is supported, and use it.
(cherry picked from commit ca4b4089689c0c908ee56a8021d65a79d39d803e)
---
appliance/Makefile.am | 23 +++++++++++++++++------
configure.ac | 15 +++++++++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index 54d3379..a9cc9fe 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -35,14 +35,18 @@ superminfs_DATA = \
supermin.d/init.img \
supermin.d/udev-rules.img
+if SUPERMIN_HELPER_COMPRESSED_CPIO
+GZ = .gz
+endif
+
if ENABLE_DAEMON
superminfs_DATA += \
- supermin.d/daemon.img
+ supermin.d/daemon.img$(GZ)
endif
if ENABLE_APPLIANCE
superminfs_DATA += \
- supermin.d/base.img \
+ supermin.d/base.img$(GZ) \
supermin.d/hostfiles
endif
@@ -73,20 +77,27 @@ excludelist: excludelist.in Makefile
cmp -s $@ $@-t || mv $@-t $@
rm -f $@-t
-supermin.d/base.img supermin.d/hostfiles: stamp-supermin
+supermin.d/base.img$(GZ) supermin.d/hostfiles: stamp-supermin
stamp-supermin: make.sh packagelist excludelist
- rm -f $@ supermin.d/base.img supermin.d/hostfiles
+ rm -f $@ supermin.d/base.img$(GZ) supermin.d/hostfiles
./make.sh
+if SUPERMIN_HELPER_COMPRESSED_CPIO
+ gzip -9 supermin.d/base.img
+endif
touch $@
-supermin.d/daemon.img: ../daemon/guestfsd guestfsd.suppressions
- rm -f $@ $@-t
+supermin.d/daemon.img$(GZ): ../daemon/guestfsd guestfsd.suppressions
+ rm -f $@ $@-t $@-tt
rm -rf tmp-d
mkdir -p tmp-d$(DAEMON_SUPERMIN_DIR) tmp-d/etc
ln ../daemon/guestfsd tmp-d$(DAEMON_SUPERMIN_DIR)/guestfsd
ln $(srcdir)/guestfsd.suppressions tmp-d/etc/guestfsd.suppressions
( cd tmp-d && find | cpio --quiet -o -H newc ) > $@-t
rm -r tmp-d
+if SUPERMIN_HELPER_COMPRESSED_CPIO
+ gzip -9 -c $@-t > $@-tt
+ mv $@-tt $@-t
+endif
mv $@-t $@
supermin.d/init.img: init
diff --git a/configure.ac b/configure.ac
index 75232e8..3e8a274 100644
--- a/configure.ac
+++ b/configure.ac
@@ -445,6 +445,21 @@ AC_CHECK_PROGS([SUPERMIN],
AC_CHECK_PROGS([SUPERMIN_HELPER],
[supermin-helper febootstrap-supermin-helper],[no])
+dnl supermin >= 4.1.4 supports compressed cpio images.
+AC_MSG_CHECKING([for supermin-helper version])
+supermin_helper_version=`$SUPERMIN_HELPER --version | awk '{print $2}'`
+AC_MSG_RESULT([$supermin_helper_version])
+AC_MSG_CHECKING([if supermin-helper supports compressed cpio images])
+supermin_helper_version_int=`echo "$supermin_helper_version" | awk -F. '{print $1 * 1000000 + $2 * 1000 + $3}'`
+if test $supermin_helper_version_int -ge 4001004; then
+ supermin_helper_compressed_cpio=yes
+else
+ supermin_helper_compressed_cpio=yes
+fi
+AC_MSG_RESULT([$supermin_helper_compressed_cpio])
+AM_CONDITIONAL([SUPERMIN_HELPER_COMPRESSED_CPIO],
+ [test "x$supermin_helper_compressed_cpio" = "xyes"])
+
dnl Pass supermin --packager-config option.
dnl
dnl Note that in febootstrap >= 3.21 / supermin >= 4.1.0, this option
--
1.8.3.1