diff options
author | Daniel Dickinson <crazycshore@gmail.com> | 2010-12-03 20:01:23 +0000 |
---|---|---|
committer | Daniel Dickinson <crazycshore@gmail.com> | 2010-12-03 20:01:23 +0000 |
commit | 68124370ac82720273db30b5706c227e60c1fa4d (patch) | |
tree | 890bb5ac1a4f6b94c1f75f243cbfee0354699f0d /package | |
parent | 581378f5cb6ff8c0321f80f0750d9a7a09dfd63b (diff) | |
download | upstream-68124370ac82720273db30b5706c227e60c1fa4d.tar.gz upstream-68124370ac82720273db30b5706c227e60c1fa4d.tar.bz2 upstream-68124370ac82720273db30b5706c227e60c1fa4d.zip |
block-extroot: Added md5sum to extroot and underlying root filesystem. This is used to ensure that the extroot is not mounted as the rootfs after a sysupgrade *until the user deals with the extroot).
SVN-Revision: 24230
Diffstat (limited to 'package')
-rw-r--r-- | package/block-extroot/Makefile | 1 | ||||
-rw-r--r-- | package/block-extroot/files/50_determine_usb_root | 1 | ||||
-rw-r--r-- | package/block-extroot/files/55_determine_extroot_sysupgrade | 55 |
3 files changed, 57 insertions, 0 deletions
diff --git a/package/block-extroot/Makefile b/package/block-extroot/Makefile index f1e093bcc3..05d5e18a1a 100644 --- a/package/block-extroot/Makefile +++ b/package/block-extroot/Makefile @@ -53,6 +53,7 @@ define Package/block-extroot/install $(INSTALL_DATA) ./files/extmount.sh $(1)/lib/functions/ $(INSTALL_DIR) $(1)/lib/preinit $(INSTALL_DATA) ./files/50_determine_usb_root $(1)/lib/preinit/ + $(INSTALL_DATA) ./files/55_determine_extroot_sysupgrade $(1)/lib/preinit/ $(INSTALL_DATA) ./files/60_pivot_usb_root $(1)/lib/preinit/ $(INSTALL_DIR) $(1)/lib/preinit echo "extroot_settle_time=\"$(CONFIG_EXTROOT_SETTLETIME)\"" >$(1)/lib/preinit/00_extroot.conf diff --git a/package/block-extroot/files/50_determine_usb_root b/package/block-extroot/files/50_determine_usb_root index b899203e5d..e87855c2a7 100644 --- a/package/block-extroot/files/50_determine_usb_root +++ b/package/block-extroot/files/50_determine_usb_root @@ -18,6 +18,7 @@ determine_external_root() { if [ "$jffs" = "/tmp/overlay" ] && [ -r "/tmp/overlay/etc/config/fstab" ]; then UCI_CONFIG_DIR="/tmp/overlay/etc/config" ER_IS_SQUASHFS=true + ER_OVERLAY_PREFIX="/tmp/overlay" fi # For squashfs on firstboot root_device will be tmpfs for the ramoverlay, diff --git a/package/block-extroot/files/55_determine_extroot_sysupgrade b/package/block-extroot/files/55_determine_extroot_sysupgrade new file mode 100644 index 0000000000..21af8b0180 --- /dev/null +++ b/package/block-extroot/files/55_determine_extroot_sysupgrade @@ -0,0 +1,55 @@ +#!/bin/sh +# Copyright (C) 2010 Daniel Dickinson +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + + +check_set_md5sum() { + local er_md5sum_file + er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum" + + local er_extroot_md5sum + if [ -f $md5sum_file ]; then + er_extroot_md5sum="$(cat $er_md5sum_file)" + fi + + local er_extroot_overlay_md5sum + if [ -f "/overlay/etc/extroot.md5sum" ]; then + er_extroot_overlay_md5sum="$(cat /overlay/.extroot.md5sum)" + fi + + if [ -z "$er_extroot_overlay_md5sum" ]; then + cat $er_md5sum_file >/overlay/.extroot.md5sum + elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then + pi_extroot_mount_success="false" + mkdir -p /tmp/overlay-disabled + mount --move /overlay /tmp/overlay-disabled + fi +} + +set_jffs_md5sum() { + # We do this anytime block-extroot exists, even on the first boot with + # no extroot defined. + + local er_md5sum_file + er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum" + + local er_extroot_md5sum + if [ -f $er_md5sum_file ]; then + er_extroot_md5sum="$(cat $er_md5sum_file)" + fi + if [ -z "$er_extroot_md5sum" ]; then + dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file + fi +} + +determine_extroot_sysupgrade() { + check_skip || set_jffs_md5sum + + check_skip || [ "$pi_extroot_mount_success" != "true" ] || { + check_set_md5sum + } +} + +boot_hook_add preinit_mount_root determine_extroot_sysupgrade + |