Skip to content

Commit 11b61bd

Browse files
committed
Add Raspberry Pi image generation support
1 parent 88db6d6 commit 11b61bd

2 files changed

Lines changed: 162 additions & 41 deletions

File tree

chroot-script

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ bash -n /etc/debootstrap/variables
3535
[ -r /proc/1 ] || mount -t proc none /proc
3636
[ -r /sys/kernel ] || mount -t sysfs none /sys
3737

38+
if [ -n "$RPIFIRM" ]; then
39+
mkdir --parents /boot/firmware
40+
mount "$RPIFIRM" /boot/firmware
41+
fi
42+
3843
# variable checks {{{
3944

4045
# use aptitude only if it's available
@@ -336,6 +341,9 @@ kernel() {
336341
if expr "$COMPONENTS" : '.*non-free' >/dev/null ; then
337342
KERNELPACKAGES="$KERNELPACKAGES firmware-linux"
338343
fi
344+
if [ -n "$RPI" ] ; then
345+
KERNELPACKAGES="$KERNELPACKAGES raspi-firmware"
346+
fi
339347
# shellcheck disable=SC2086
340348
DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL $KERNELPACKAGES
341349
else
@@ -344,6 +352,19 @@ kernel() {
344352
}
345353
# }}}
346354

355+
# fix kernel command line for Raspberry Pi {{{
356+
rpi_cmdline() {
357+
if [ -z "$RPI" ]; then
358+
return 0
359+
fi
360+
361+
local cmdline
362+
cmdline="$(cat /boot/firmware/cmdline.txt)"
363+
cmdline="$(sed "s/root=[^ ]*/root=UUID=${TARGET_UUID}/" <<< "$cmdline")"
364+
echo "$cmdline" > /boot/firmware/cmdline.txt
365+
}
366+
# }}}
367+
347368
# reconfigure packages {{{
348369
reconfigure() {
349370
if [ -n "$RECONFIGURE" ] ; then
@@ -484,6 +505,11 @@ if [ -n "$EFI" ] ; then
484505
echo "UUID=$UUID_EFI /boot/efi vfat umask=0077 0 1" >> /etc/fstab
485506
fi
486507

508+
if [ -n "$RPIFIRM" ] ; then
509+
UUID_RPIFIRM="$(blkid -o value -s UUID "$RPIFIRM")"
510+
echo "UUID=$UUID_RPIFIRM /boot/firmware vfat umask=0077 0 1" >> /etc/fstab
511+
fi
512+
487513
cat >> /etc/fstab << EOF
488514
proc /proc proc defaults 0 0
489515
/dev/cdrom /mnt/cdrom0 iso9660 ro,user,noauto 0 0
@@ -823,6 +849,8 @@ finalize() {
823849

824850
umount /sys >/dev/null 2>/dev/null || true
825851
umount /proc >/dev/null 2>/dev/null || true
852+
853+
umount /boot/firmware >/dev/null 2>/dev/null || true
826854
}
827855
# }}}
828856

@@ -847,7 +875,7 @@ trap signal_handler HUP INT QUIT TERM
847875
kernel packages extrapackages reconfigure hosts \
848876
default_locales timezone fstab install_fs_tools hostname \
849877
initrd grub_install passwords \
850-
custom_scripts upgrade_system remove_apt_cache services \
878+
custom_scripts upgrade_system rpi_cmdline remove_apt_cache services \
851879
remove_chrootmirror; do
852880
if stage "$i" ; then
853881
"$i"

0 commit comments

Comments
 (0)