Package: debirf
Version: 0.37
Severity: minor

I'vve been looking for this issue for several days: our debirf-based
system generally works well (and debirf is a great tool!). However I get
one specific system kept failing to boot.

When I break in the first-stage loader, I see that rootfs.cxz has the
right size but an incorrect md5sum (compared to the one in nest/ , and
compared to the one extracted from the initrd.cgz file on the USB device
I boot from).

Eventually my workaround was to replace the compressor from xz to gzip
(See attached patch). I did verify that the issue is not the amount of
memory in the system, as the same image boots fine in KVM with slightly
less memory.

-- System Information:
Debian Release: 9.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: armhf

Kernel: Linux 4.9.0-6-amd64 (SMP w/4 CPU cores)
Locale: LANG=he_IL.UTF-8, LC_CTYPE=he_IL.UTF-8 (charmap=UTF-8), 
LANGUAGE=he_IL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages debirf depends on:
ii  apt          1.4.8
ii  cpio         2.11+dfsg-6
ii  debootstrap  1.0.89
ii  fakechroot   2.19-3
ii  fakeroot     1.21-3.1
ii  klibc-utils  2.0.4-9
ii  xz-utils     5.2.2-1.2+b1

Versions of packages debirf recommends:
ii  grub-common  2.02~beta3-5
ii  lsb-release  9.20161125
ii  xorriso      1.4.6-1+b1

Versions of packages debirf suggests:
ii  syslinux-common  3:6.03+dfsg-14.1+deb9u1

-- no debconf information
>From 44c422ffd9df729d90b59c41a8f335c25913b593 Mon Sep 17 00:00:00 2001
From: Tzafrir Cohen <tzafrir.co...@xorcom.com>
Date: Tue, 10 Apr 2018 16:07:43 +0300
Subject: [PATCH] debirf: support gzip for nested rootfs

Add configuration variable DEBIRF_COMPRESS, defaults to "xz".
May also be set to "gzip". This is the compressor to use for
the nested rootfs.

For the sake of simplicity, the name of that file remains rootfs.cxz
regardless.

Gzip-compressed images are noticably larger (roughly 150% in my case).
However we had a case of an odd corruption of the xz image when the
compressor was xz (on one specific system, with an Atom D525 based Intel
board).
---
 debirf | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/debirf b/debirf
index 1e20c5c..9133a28 100755
--- a/debirf
+++ b/debirf
@@ -39,6 +39,8 @@ STAGE_ROOT=${STAGE_ROOT:-true}
 STAGE_MODULES=${STAGE_MODULES:-true}
 STAGE_INITRD=${STAGE_INITRD:-true}
 
+DEBIRF_COMPRESS=${DEBIRF_COMPRESS:xz}
+
 # warn if running as root
 ROOT_WARNING=true
 
@@ -48,6 +50,7 @@ export 
DEVICE_ARCHIVE=${DEVICE_ARCHIVE:-/usr/share/debirf/devices.tar.gz}
 # default package include/excludes
 DEBIRF_DEFAULT_PACKAGES=${DEBIRF_DEFAULT_PACKAGES:-/usr/share/debirf/packages}
 
+
 ###############################################################
 ### FUNCTIONS
 
@@ -159,7 +162,7 @@ pack_rootfs() {
 
     # abort with a failure if our attempts to build the rootfs fail:
     set -o pipefail
-    fakeroot_if_needed bash -c ". $DEBIRF_COMMON && 
FAKECHROOT_EXCLUDE_PATH=/does-not-exist debirf_exec sh -c 'find * | grep -v -e 
^run/ | cpio --create -H newc'" | xz -9 > "$1"
+    fakeroot_if_needed bash -c ". $DEBIRF_COMMON && 
FAKECHROOT_EXCLUDE_PATH=/does-not-exist debirf_exec sh -c 'find * | grep -v -e 
^run/ | cpio --create -H newc'" | ${DEBIRF_COMPRESS} -9 > "$1"
 }
 export -f pack_rootfs
 
@@ -215,7 +218,7 @@ if (grep -q break=preunpack /proc/cmdline); then
 fi
 cd /newroot
 echo unpacking rootfs...
-unxz - < /rootfs.cxz | cpio -i
+$DEBIRF_UNCOMRESS - < /rootfs.cxz | cpio -i
 if (grep -q break=bottom /proc/cmdline); then
   echo "honoring break=bottom kernel arg"
   /bin/sh
@@ -317,6 +320,11 @@ setup_environment() {
     # set fakechroot save file
     DEBIRF_FAKEROOT_STATE="$DEBIRF_BUILDD/.fakeroot-state.${DEBIRF_LABEL}"
 
+    DEBIRF_UNCOMRESS="unxz"
+    if [ "${DEBIRF_COMPRESS}" = "gzip" ]; then
+        DEBIRF_UNCOMRESS="gunzip"
+    fi
+
     # set the debirf distro variables based on host distro
     set_distro
 
-- 
2.11.0

Reply via email to