summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2019-03-15 13:20:13 +0000
committerintrigeri <intrigeri@boum.org>2019-03-15 13:20:13 +0000
commit87b44edbe8f9b49e28658bf6c37980267c2db076 (patch)
treeea985e03222d10d89ddc6dc906ac4642840b4d11
parentb7a86ad32a5861a41eddab64e0c32db628cfa585 (diff)
parentf9fb29dc7162bb4526e39293be7befe3a310d15b (diff)
Merge branch 'bugfix/16452-remove-useless-extra-initramfs-update' into stable (Fix-committed: #16452)
-rwxr-xr-xconfig/binary_local-hooks/05-check_initramfs-size25
-rwxr-xr-xconfig/chroot_local-hooks/99-initramfs-compress12
2 files changed, 30 insertions, 7 deletions
diff --git a/config/binary_local-hooks/05-check_initramfs-size b/config/binary_local-hooks/05-check_initramfs-size
new file mode 100755
index 0000000..a5466e9
--- /dev/null
+++ b/config/binary_local-hooks/05-check_initramfs-size
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+set -e
+
+# Including common functions
+. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'checking the size of the initramfs')"
+HELP=""
+USAGE="${PROGRAM}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/binary
+Set_defaults
+
+Echo_message "checking the size of the initramfs"
+
+INITRAMFS=$(readlink --canonicalize binary/live/initrd.img)
+MAX_SIZE=$((35 * 1024 * 1024)) # in bytes
+ACTUAL_SIZE=$(stat --format='%s' "$INITRAMFS")
+if [ "$ACTUAL_SIZE" -gt "$MAX_SIZE" ]; then
+ echo "E: initramfs is larger ($ACTUAL_SIZE bytes) than the maximum allowed ($MAX_SIZE)" >&2
+ exit 1
+fi
diff --git a/config/chroot_local-hooks/99-initramfs-compress b/config/chroot_local-hooks/99-initramfs-compress
index c7f9885..ee97430 100755
--- a/config/chroot_local-hooks/99-initramfs-compress
+++ b/config/chroot_local-hooks/99-initramfs-compress
@@ -10,16 +10,14 @@ echo "Configuring compression of the initramfs"
ensure_hook_dependency_is_installed initramfs-tools xz-utils fatresize
# Compress the initramfs using a more size-wise efficient algorithm.
+# We do this late in the build process because compressing with XZ
+# takes much longer than compressing with the default algorithm
+# and earlier stages of the build generate the initramfs quite a few times.
+# live-build will regenerate it later on anyway, which will apply
+# the settings we configure here.
OPTS_FILE='/etc/initramfs-tools/initramfs.conf'
[ -f "${OPTS_FILE}" ] || exit 11
sed -i'' 's,^COMPRESS=.*,COMPRESS=xz,' "${OPTS_FILE}"
-
-# Force an initramfs update to apply our new compression settings.
-# We're relying on the fact that 1 XZ compression takes less time than
-# 6 * (XZ compression time - default compression time), so that making
-# faster the 6 initramfs updates that we currently go through during
-# the build is worth updating the initramfs a 7th time.
-update-initramfs -u