Skip to content

Commit b51ed91

Browse files
Replaced hardcoded kernel version with dynamically determined one.
Thanks to stuartf for his awesome sed statement to get the installed kernel version and hence the initramfs version. This fixes issue #68.
1 parent 7b78f6f commit b51ed91

File tree

1 file changed

+22
-17
lines changed
  • scripts/etc/init.d

1 file changed

+22
-17
lines changed

scripts/etc/init.d/rcS

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/busybox sh
22

3-
KERNEL_VERSION=3.10-3-rpi
4-
53
# default options, can be overriden in installer-config.txt
64
preset=server
75
packages=
@@ -496,21 +494,6 @@ echo ""
496494
# there is no hw clock on rpi
497495
echo "HWCLOCKACCESS=no" >> /rootfs/etc/default/hwclock || fail
498496

499-
echo "Configuring bootloader to start the installed system..."
500-
mv /rootfs/boot/config.txt /rootfs/boot/config-reinstall.txt
501-
502-
if [ -f /rootfs/vmlinuz ] ; then
503-
# use latest kernel with initramfs in first boot
504-
echo -n "Install new kernel and initramfs... "
505-
cp /rootfs/vmlinuz /rootfs/boot/kernel.img
506-
echo "OK"
507-
echo "initramfs initrd.img-${KERNEL_VERSION}" > /rootfs/boot/config.txt
508-
else
509-
echo -n "Copying installer kernel to installed system... "
510-
# use install kernel in first boot
511-
cp /rootfs/boot/kernel_install.img /rootfs/boot/kernel.img || fail
512-
echo "OK"
513-
fi
514497

515498
# remove cdebootstrap-helper-rc.d which prevents rc.d scripts from running
516499
echo -n "Removing cdebootstrap-helper-rc.d... "
@@ -540,6 +523,28 @@ fi
540523
# add reasonable default modules, works only after kernel is properly installed
541524
echo "snd-bcm2835" >> /rootfs/etc/modules
542525

526+
echo "Configuring bootloader to start the installed system..."
527+
mv /rootfs/boot/config.txt /rootfs/boot/config-reinstall.txt
528+
529+
# find kernel/initramfs version
530+
KERNEL_VERSION=$(sed -n -e '/^Package: linux-image-rpi-rpfv$/,/Package: /{s/^Depends: .*linux-image-\(.*-rpi\).*$/\1/p}' /rootfs/var/lib/dpkg/status)
531+
echo "Kernel version: '${KERNEL_VERSION}'"
532+
533+
if [ -f /rootfs/vmlinuz ] ; then
534+
# use latest kernel with initramfs in first boot
535+
echo -n "Copying new kernel to installed system... "
536+
cp /rootfs/vmlinuz /rootfs/boot/kernel.img
537+
echo "OK"
538+
echo -n "Specify new initramfs in config.txt... "
539+
echo "initramfs initrd.img-${KERNEL_VERSION}" > /rootfs/boot/config.txt
540+
echo "OK"
541+
else
542+
echo -n "Copying installer kernel to installed system... "
543+
# use install kernel in first boot
544+
cp /rootfs/boot/kernel_install.img /rootfs/boot/kernel.img || fail
545+
echo "OK"
546+
fi
547+
543548
# default cmdline.txt
544549
echo -n "Creating default cmdline.txt... "
545550
echo "$cmdline root=$rootpartition rootfstype=$rootfstype rootwait" > /rootfs/boot/cmdline.txt

0 commit comments

Comments
 (0)