summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2019-03-13 08:14:07 +0000
committerintrigeri <intrigeri@boum.org>2019-03-13 09:02:26 +0000
commitf9fb29dc7162bb4526e39293be7befe3a310d15b (patch)
tree8fd76ebf669dbff4d071fe3ac1473e43fb7ed72b
parent0dbc3c2a805d7d7f8c44efcd0124b90ff8c9e08a (diff)
Sanity check the size of the initramfs (refs: #16452)
This will help us detect if any of this happens: - config/chroot_local-hooks/99-initramfs-compress is broken - live-build does not generate the initramfs after config/chroot_local-hooks/99-initramfs-compress has applied our preferred configuration - Some unrelated change makes the initramfs substantially larger, as an unintended side-effect. As of Tails 3.12.1, our current initramfs is 30M large so a 35M limit should give us just enough safety margin.
-rwxr-xr-xconfig/binary_local-hooks/05-check_initramfs-size25
1 files changed, 25 insertions, 0 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