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

Bug#549681: bug#549681: mkvmlinuz: use xz to compress vmlinuz-boxed initrd



> some OpenFirmware implementations, such as the one in the PegasosII,
> have a 12 MB size limit on kernel images, and no initrd loading
> capability. The latter is worked around by merging the initrd into the
> image with the "mkvmlinuz" tool, however the generated images are
> unbootable if they exceed 12 MB.

The attached patch brings vmlinuz from about 13MB to about 9.5MB, which
is well under the 12MB limit. Downside is that xz compressing is
noticeably slower than currently used gzip, but decompressing speed
difference is not noticeable.

I've tested it on Pegasos II machine, it boots really fast. Updated
mkvmlinuz package is waiting on mentors.debian.net for a willing sponsor
for upload.

Milan
Index: mkvmlinuz
===================================================================
--- mkvmlinuz	(revision 19233)
+++ mkvmlinuz	(working copy)
@@ -133,11 +133,6 @@
 # if no release was specified, extract it from the kernel image name
 if test -z "$release"; then
     release=$(echo $kernel | sed s/.*vmlinux-//)
-    if echo $release | grep -q '2\.[46]\.[0-9]*'; then
-	:
-    else
-	release=""
-    fi
 fi
 
 if dpkg --compare-versions $release ge 2.6.16 && test "$arch" != "prep" ; then
@@ -158,6 +153,12 @@
   post_2_6_19=
 fi
 
+if dpkg --compare-versions $release ge 2.6.38 && test "$arch" != "prep" ; then
+  post_2_6_38=Yes
+else
+  post_2_6_38=
+fi
+
 test -z "$verbose" || echo === Release version seems to be $release.
 
 # if no object file directory was specified, try to find one
@@ -206,6 +207,11 @@
 test -z "$verbose" || echo === Doing build in $work.
 
 # utilities
+if test "$post_2_6_38"; then
+  XZ="xz --check=crc32 -8"
+else
+  XZ=false
+fi
 if test "$post_2_6_16"; then
   ADDNOTE=$objdir/addnote # must be present in mkvmlinuz fallback tools
   if test \! -f "$ADDNOTE"; then
@@ -291,22 +297,35 @@
 
 # create the compressed initrd image file
 if test -n "$initrd"; then
-    test -z "$verbose" || echo === Creating compressed initrd image initrd.gz...
+    test -z "$verbose" || echo === Creating compressed initrd image
     if test -z "$compressed"; then
-        # Detect if the file was already compressed by gzip.
-    	if test "`od -A n -c -N 2 $initrd`" = " 037 213"; then 
-	    compressed="Yes"
+	if test "`xxd -p -l2 $initrd`" = "1f8b"; then
+	    test -z "$verbose" || echo === $initrd is already gzip compressed
+	    do_cmd cp -p $initrd $work/initrd.gz
+	    if test -n "$post_2_6_38" && test "$arch" != "prep"; then
+	      test -z "$verbose" || echo === recompressing to xz
+	      zcat $initrd | $XZ - > $work/initrd.xz
+	    fi
+	elif test "`xxd -p -l6 $initrd`" = "fd377a585a00"; then 
+	    test -z "$verbose" || echo === $initrd is already xz compressed
+	    do_cmd cp -p $initrd $work/initrd.xz
 	else
+	    test -z "$verbose" || echo === assuming $initrd was not compressed
 	    compressed="No"
 	fi
     fi
     case "$compressed" in
     	Yes)
 	    do_cmd cp -p $initrd $work/initrd.gz
+	    do_cmd ln -s $work/initrd.gz $work/initrd.xz
 	    ;;
     	No)
 	    do_cmd cp -p $initrd $work/initrd
-	    do_cmd $GZIP $work/initrd
+	    if test -n "$post_2_6_38" && test "$arch" != "prep"; then
+	      do_cmd $XZ $work/initrd
+	    else
+	      do_cmd $GZIP $work/initrd
+	    fi
 	    ;;
     esac
 fi
@@ -317,7 +336,11 @@
   WRAPPER=$objdir/wrapper
   vmlinuz=$work/vmlinuz.$arch
   if test -n "$initrd"; then
-    INITRD="-i $work/initrd.gz"
+    if test "$post_2_6_38"; then
+      INITRD="-i $work/initrd.xz"
+    else
+      INITRD="-i $work/initrd.gz"
+    fi
   fi
   $WRAPPER -c -o $vmlinuz -p $arch $INITRD -D $objdir -W $work $kernel
 else 

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: