Skip to content

Commit 284530a

Browse files
committed
scripts: initramfs: add skip option, but still download firmware files
1 parent 7fbd319 commit 284530a

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

rootfs-install/files/initramfs/rpi-post-update-hook

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,36 @@ BOOT_MOUNTPOINT=/tmp/rpi-boot-img
1919
# read config vars
2020
source /etc/initramfs/rpi-vars.sh
2121

22+
RPI_CONFIG=$(cat "$RPI_CONFIG_FILE")
23+
RPI_CONFIG_RAW=$(cat "$RPI_CONFIG_RAW_FILE")
24+
RPI_CMDLINE=$(cat "$RPI_CMDLINE_FILE" | head -1)
25+
[[ -z "$RPI_CONFIG_EXTRA" ]] || RPI_CONFIG+="
26+
$RPI_CONFIG_EXTRA"
27+
[[ -z "$RPI_CMDLINE_EXTRA" ]] || RPI_CMDLINE+=" $RPI_CMDLINE_EXTRA"
28+
29+
INTERPOLATE_VARS=(
30+
"ROOTFS_PARTITION=LABEL=$IMAGE_ROOTFS_PART_NAME"
31+
)
32+
33+
function download_firmware_files() {
34+
for file in "${RPI_FIRMWARE_FILES[@]}"; do
35+
if [[ "$file" == "/"* ]]; then
36+
# absolute path, copy it
37+
cp -f "$file" "$1/$(basename "$file")"
38+
else
39+
# download the latest rpi firmware files (debian repo is outdated)
40+
wget "https://github.com/raspberrypi/firmware/raw/master/boot/$file" \
41+
-O "$1/$file"
42+
fi
43+
done
44+
}
45+
46+
if [[ -n "$RPI_SKIP_IMAGE_GEN" ]]; then
47+
# save config.txt to /boot
48+
interpolate_vars "$RPI_CONFIG" "${INTERPOLATE_VARS[@]}" > "/boot/config.txt"
49+
exit 0
50+
fi
51+
2252
echo "Running RPI ramdisk generator for version $version..."
2353

2454
dd if=/dev/zero bs=1M count=$BOOT_IMG_SIZE of="$BOOT_IMG"
@@ -38,27 +68,8 @@ mount /dev/loop8 "$BOOT_MOUNTPOINT"
3868

3969
install "/boot/vmlinuz-$version" "$BOOT_MOUNTPOINT/kernel8.img"
4070
install "/boot/initrd.img-$version" "$BOOT_MOUNTPOINT/initrd.img"
41-
for file in "${RPI_FIRMWARE_FILES[@]}"; do
42-
if [[ "$file" == "/"* ]]; then
43-
# absolute path, copy it
44-
cp -f "$file" "$BOOT_MOUNTPOINT/$(basename "$file")"
45-
else
46-
# download the latest rpi firmware files (debian repo is outdated)
47-
wget "https://github.com/raspberrypi/firmware/raw/master/boot/$file" \
48-
-O "$BOOT_MOUNTPOINT/$file"
49-
fi
50-
done
51-
52-
RPI_CONFIG=$(cat "$RPI_CONFIG_FILE")
53-
RPI_CONFIG_RAW=$(cat "$RPI_CONFIG_RAW_FILE")
54-
RPI_CMDLINE=$(cat "$RPI_CMDLINE_FILE" | head -1)
55-
[[ -z "$RPI_CONFIG_EXTRA" ]] || RPI_CONFIG+="
56-
$RPI_CONFIG_EXTRA"
57-
[[ -z "$RPI_CMDLINE_EXTRA" ]] || RPI_CMDLINE+=" $RPI_CMDLINE_EXTRA"
71+
download_firmware_files "$BOOT_MOUNTPOINT/"
5872

59-
INTERPOLATE_VARS=(
60-
"ROOTFS_PARTITION=LABEL=$IMAGE_ROOTFS_PART_NAME"
61-
)
6273
interpolate_vars "$RPI_CONFIG" "${INTERPOLATE_VARS[@]}" > "$BOOT_MOUNTPOINT/config.txt"
6374
interpolate_vars "$RPI_CONFIG_RAW" "${INTERPOLATE_VARS[@]}" > "/boot/config-raw.txt"
6475
interpolate_vars "$RPI_CMDLINE" "${INTERPOLATE_VARS[@]}" > "$BOOT_MOUNTPOINT/cmdline.txt"

rootfs-install/scripts/50-boot-files.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ $([[ -z "$IMAGE_ROOTFS_PART_NAME" ]] || declare -p IMAGE_ROOTFS_PART_NAME)
4040
$([[ -z "$RPI_FIRMWARE_FILES" ]] || declare -p RPI_FIRMWARE_FILES)
4141
$([[ -z "$RPI_BOOT_EXTRA_FILES" ]] || declare -p RPI_BOOT_EXTRA_FILES)
4242
$([[ -z "$RPI_CONFIG_EXTRA" ]] || declare -p RPI_CONFIG_EXTRA)
43+
$([[ -z "$RPI_SKIP_IMAGE_GEN" ]] || declare -p RPI_SKIP_IMAGE_GEN)
4344
EOF
4445

4546
# debs to install

0 commit comments

Comments
 (0)