From 803cf67dabfe32516f2ed08ba76dc9de7f9311cb Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Tue, 4 Sep 2007 11:35:32 +0200 Subject: update-initramfs: Don't check for ro /boot inside of a chroot. debian-live may as well be build on a host with ro /boot --- update-initramfs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'update-initramfs') diff --git a/update-initramfs b/update-initramfs index 774da61..a257f1c 100755 --- a/update-initramfs +++ b/update-initramfs @@ -33,6 +33,19 @@ EOF exit 1 } +# chroot check +chrooted() +{ + # borrowed from udev's postinst + if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then + # the devicenumber/inode pair of / is the same as that of + # /sbin/init's root, so we're *not* in a chroot and hence + # return false. + return 1 + fi + return 0 +} + mild_panic() { if [ -n "${1}" ]; then @@ -86,7 +99,7 @@ backup_booted_initramfs() # first time run thus no backup [ ! -r "${initramfs_bak}" ] && return 0 - # chroot + # chroot with no /proc [ ! -r /proc/uptime ] && rm -f "${initramfs_bak}" && return 0 # no kept backup wanted @@ -248,7 +261,11 @@ delete_sha1() # ro /boot is not modified ro_boot_check() { - [ -r /proc/mounts ] || return 0 + # check irrelevant inside of a chroot + if [ ! -r /proc/mounts ] || chrooted; then + return 0 + fi + boot_opts=$(awk '/boot/{if (match($4, /ro/) && $2 == "/boot") print "ro"}' /proc/mounts) if [ -n "${boot_opts}" ]; then -- cgit v1.2.3