[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#533903: initramfs-tools: support different compression tools in mkinitramfs



Hello Maximilian,

this version uses /etc/initramfs-tools/initramfs.conf to determine
the compression method, checks kernel and userspace support with
fallback to gzip. Since LZO didnt work for me at all with 2.6.33 
I left that out for now.

unified diff against git attached

regards
Bert Schulze
diff -rup a/conf/initramfs.conf b/conf/initramfs.conf
--- a/conf/initramfs.conf	2010-02-28 19:05:48.000000000 +0100
+++ b/conf/initramfs.conf	2010-02-28 19:14:53.000000000 +0100
@@ -36,6 +36,12 @@ BUSYBOX=y
 KEYMAP=n
 
 #
+# COMPRESS: [ gzip | bzip2 | lzma ]
+#
+
+COMPRESS=gzip
+
+#
 # NFS Section of the config.
 #
 
diff -rup a/initramfs.conf.5 b/initramfs.conf.5
--- a/initramfs.conf.5	2010-02-28 19:05:48.000000000 +0100
+++ b/initramfs.conf.5	2010-02-28 19:18:40.000000000 +0100
@@ -48,6 +48,13 @@ The keymap will anyway be loaded by the
 that might need input will normally set this variable automatically, so there
 should normally be no need to set this.
 
+.TP
+\fB COMPRESS
+Specifies the compression method used for the initramfs image.
+.B mkinitramfs
+will default to gzip if the kernel lacks support (CONFIG_RD) or the
+corresponding userspace utility is not present.
+
 .SH NFS VARIABLES
 .TP
 \fB BOOT
diff -rup a/mkinitramfs b/mkinitramfs
--- a/mkinitramfs	2010-02-28 19:05:48.000000000 +0100
+++ b/mkinitramfs	2010-02-28 19:04:08.000000000 +0100
@@ -123,6 +123,20 @@ case "${version}" in
 	;;
 esac
 
+# Check userspace and kernel support for compressed initramfs images
+compress=${COMPRESS}
+if [ -z "`which ${COMPRESS}`" ]; then
+	compress=gzip
+	[ "${verbose}" = y ] && \
+		echo "Userspace does not support ${COMPRESS}, defaulting to gzip"
+fi
+
+if ! `grep -q -i config_rd_${COMPRESS}=y /boot/config-${version}` ; then
+	compress=gzip
+	[ "${verbose}" = y ] && \
+		echo "Kernel does not support ${COMPRESS}, defaulting to gzip"
+fi
+
 if [ -d "${outfile}" ]; then
 	echo "${outfile} is a directory"
 	exit 1
@@ -265,7 +279,7 @@ eval `
         find . 4>&-; echo "ec1=$?;" >&4
     } | {
         cpio --quiet --dereference -o -H newc 4>&-; echo "ec2=$?;" >&4
-    } | gzip >"${outfile}"
+    } | ${compress} >"${outfile}"
     echo "ec3=$?;" >&4
 `
 if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi
diff -rup a/mkinitramfs.8 b/mkinitramfs.8
--- a/mkinitramfs.8	2010-02-28 19:05:48.000000000 +0100
+++ b/mkinitramfs.8	2010-02-28 19:07:54.000000000 +0100
@@ -27,7 +27,7 @@ mkinitramfs \- low-level tool for genera
 The
 .B mkinitramfs
 script generates an initramfs image.
-The initramfs is a gzipped cpio archive. The archive can be used on a
+The initramfs is a compressed cpio archive. The archive can be used on a
 different box of the same arch with the corresponding Linux kernel.
 .B mkinitramfs
 is meant for advanced usage. On your local box

Reply to: