summaryrefslogtreecommitdiffstats
path: root/config/binary_local-hooks/05-check_initramfs-size
blob: bc51b2d9c4db66775d1a26737638a80a2cde3b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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=$((32 * 1024 * 1024)) # in bytes
ACTUAL_SIZE=$(stat --format='%s' "$INITRAMFS")
if [ "$ACTUAL_SIZE" -ge "$MAX_SIZE" ]; then
   echo "E: initramfs is larger ($ACTUAL_SIZE bytes) than the maximum allowed ($MAX_SIZE)" >&2
   exit 1
fi