Skip to content

Commit

Permalink
pi image updates (#1)
Browse files Browse the repository at this point in the history
* refactor(export-image): ensure loop device partition nodes are created

* refactor(stage0): only disable initramfs updates if update-initramfs.conf exists

* refactor(stage0): check whether foreign architecture is needed

* refactor(stage0): prevent kernel packages from creating useless symlinks

* refactor(stage1): remove cmdline.txt and config.txt symlinks

* refactor(stage2): rc.local drop-in no longer required, since Debian ships its own version

* refactor(export-image): make sure initramfs is created
  • Loading branch information
steveiliop56 authored Feb 5, 2024
1 parent 9bd0d5a commit 83a7a74
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion export-image/05-finalise/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ INFO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.info"
sed -i 's/^update_initramfs=.*/update_initramfs=all/' "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf"

on_chroot << EOF
update-initramfs -u
update-initramfs -k all -c
if [ -x /etc/init.d/fake-hwclock ]; then
/etc/init.d/fake-hwclock stop
fi
Expand Down
1 change: 1 addition & 0 deletions export-image/prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ if [ "${NO_PRERUN_QCOW2}" = "0" ]; then
fi
done

ensure_loopdev_partitions "$LOOP_DEV"
BOOT_DEV="${LOOP_DEV}p1"
ROOT_DEV="${LOOP_DEV}p2"

Expand Down
14 changes: 14 additions & 0 deletions scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,17 @@ ensure_next_loopdev() {
[[ -b "$loopdev" ]] || mknod "$loopdev" b 7 "$loopmaj"
}
export -f ensure_next_loopdev

ensure_loopdev_partitions() {
local line
local partition
local majmin
lsblk -r -n -o "NAME,MAJ:MIN" "$1" | grep -v "^${1#/dev/} " | while read -r line; do
partition="${line%% *}"
majmin="${line#* }"
if [ ! -b "/dev/$partition" ]; then
mknod "/dev/$partition" b "${majmin%:*}" "${majmin#*:}"
fi
done
}
export -f ensure_loopdev_partitions
13 changes: 9 additions & 4 deletions stage0/00-configure-apt/00-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ fi

cat files/raspberrypi.gpg.key | gpg --dearmor > "${STAGE_WORK_DIR}/raspberrypi-archive-stable.gpg"
install -m 644 "${STAGE_WORK_DIR}/raspberrypi-archive-stable.gpg" "${ROOTFS_DIR}/etc/apt/trusted.gpg.d/"
on_chroot << EOF
dpkg --add-architecture armhf
apt-get update
apt-get dist-upgrade -y
on_chroot <<- \EOF
ARCH="$(dpkg --print-architecture)"
if [ "$ARCH" = "armhf" ]; then
dpkg --add-architecture arm64
elif [ "$ARCH" = "arm64" ]; then
dpkg --add-architecture armhf
fi
apt-get update
apt-get dist-upgrade -y
EOF
9 changes: 8 additions & 1 deletion stage0/02-firmware/02-run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/bin/bash -e

sed -i 's/^update_initramfs=.*/update_initramfs=no/' "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf"
if [ -f "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf" ]; then
sed -i 's/^update_initramfs=.*/update_initramfs=no/' "${ROOTFS_DIR}/etc/initramfs-tools/update-initramfs.conf"
fi

if [ ! -f "${ROOTFS_DIR}/etc/kernel-img.conf" ]; then
echo "do_symlinks=0" > "${ROOTFS_DIR}/etc/kernel-img.conf"
fi
rm -f "${ROOTFS_DIR}/"{vmlinuz,initrd.img}*
11 changes: 4 additions & 7 deletions stage1/00-boot-files/00-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ if ! [ -L "${ROOTFS_DIR}/boot/overlays" ]; then
fi

install -m 644 files/cmdline.txt "${ROOTFS_DIR}/boot/firmware/"
if ! [ -L "${ROOTFS_DIR}/boot/cmdline.txt" ]; then
ln -s firmware/cmdline.txt "${ROOTFS_DIR}/boot/cmdline.txt"
fi

install -m 644 files/config.txt "${ROOTFS_DIR}/boot/firmware/"
if ! [ -L "${ROOTFS_DIR}/boot/config.txt" ]; then
ln -s firmware/config.txt "${ROOTFS_DIR}/boot/config.txt"
fi

for file in cmdline.txt config.txt; do
printf "DO NOT EDIT THIS FILE\n\nThe file you are looking for has moved to %s\n" "/boot/firmware/${file}" > "${ROOTFS_DIR}/boot/${file}"
done
3 changes: 0 additions & 3 deletions stage2/01-sys-tweaks/01-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

install -m 755 files/resize2fs_once "${ROOTFS_DIR}/etc/init.d/"

install -d "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d"
install -m 644 files/ttyoutput.conf "${ROOTFS_DIR}/etc/systemd/system/rc-local.service.d/"

install -m 644 files/50raspi "${ROOTFS_DIR}/etc/apt/apt.conf.d/"

install -m 644 files/console-setup "${ROOTFS_DIR}/etc/default/"
Expand Down
2 changes: 0 additions & 2 deletions stage2/01-sys-tweaks/files/ttyoutput.conf

This file was deleted.

0 comments on commit 83a7a74

Please sign in to comment.