home: hub: mkinitfs

Download patch

ref: e23f578b4300fe24f22a43ef8f6fd856aba56a92
parent: 0a85b3309e856b318cc9cdd2391dfbcd465a7ea4
author: Natanael Copa <ncopa@alpinelinux.org>
date: Fri Aug 26 16:07:15 CDT 2011

init: delay unmounting apkovl media til after packages are installed

We might need the apk cache on config media

--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -244,8 +244,8 @@
 	esac
 }
 
-# remount ALPINE_MNT according given fstab
-remount_alpine_mnt() {
+# relocate ALPINE_MNT according given fstab
+relocate_alpine_mnt() {
 	local fstab="$1"
 	local mnt=$(find_mnt $ALPINE_DEV $fstab)
 	if [ "$ALPINE_MNT" != "$mnt" ]; then
@@ -253,10 +253,6 @@
 		mount -o move $ALPINE_MNT $mnt
 		ALPINE_MNT=$mnt
 	fi
-	# respect users mount options in fstab
-	if [ -n "$MNTOPTS" ]; then
-		mount -o remount,$MNTOPTS "$ALPINE_MNT"
-	fi
 }
 
 # gotta start from somewhere :)
@@ -458,7 +454,6 @@
 	eend $? $errstr || ovlfiles=
 	# hack, incase /root/.ssh was included in apkovl
 	[ -d "$sysroot/root" ] && chmod 700 "$sysroot/root"
-	umount $ovl_unmount 2>/dev/null &
 	pkgs="$pkgs $(sed 's/\#.*//' $sysroot/etc/lbu/packages.list 2>/dev/null)"
 	rm -f "$sysroot"/etc/lbu/packages.list
 	pkgs="$pkgs $(cat $sysroot/var/lib/apk/world $sysroot/etc/apk/world 2>/dev/null)"
@@ -480,12 +475,19 @@
 	rc_add savecache shutdown
 fi
 
-# let user override tmpfs size in fstab in apkovl
 if [ -f $sysroot/etc/fstab ]; then
+	has_fstab=1
+
+	# let user override tmpfs size in fstab in apkovl
 	mountopts=$(awk '$2 == "/" && $3 == "tmpfs" { print $4 }' $sysroot/etc/fstab)
 	if [ -n "$mountopts" ]; then
 		mount -o remount,$mountopts $sysroot
 	fi
+
+	# move the ALPINE_MNT if ALPINE_DEV is specified in users fstab
+	# this is so a generated /etc/apk/repositories will use correct
+	# mount dir
+	relocate_alpine_mnt "$sysroot"/etc/fstab
 fi
 
 # in case we upgrade we might need those:
@@ -496,13 +498,6 @@
 # hack so we get openrc
 pkgs="$pkgs alpine-base"
 
-# move the ALPINE_MNT if ALPINE_DEV is specified in users fstab
-# this is so a generated /etc/apk/repositories will use correct mount dir
-if [ -f "$sysroot"/etc/fstab ]; then
-	has_fstab=1
-	remount_alpine_mnt "$sysroot"/etc/fstab
-fi
-
 # copy keys so apk finds them. apk looks for stuff relative --root
 mkdir -p $sysroot/etc/apk/keys/
 cp -a /etc/apk/keys $sysroot/etc/apk
@@ -537,10 +532,22 @@
 fi
 eend $?
 
+# unmount ovl mount if needed
+if [ -n "$ovl_unmount" ]; then
+	umount $ovl_unmount 2>/dev/null
+fi
+
 # remount ALPINE_MNT according default fstab from package
 if [ -z "$has_fstab" ] && [ -f "$sysroot"/etc/fstab ]; then
-	remount_alpine_mnt "$sysroot"/etc/fstab
+	relocate_alpine_mnt "$sysroot"/etc/fstab
 fi
+
+# respect mount options in fstab for ALPINE_MNT (e.g if user wants rw)
+opts=$(awk "\$2 == \"$ALPINE_MNT\" {print \$4}" $sysroot/etc/fstab)
+if [ -n "$opts" ]; then
+	mount -o remount,$opts "$ALPINE_MNT"
+fi
+
 
 # fix inittab if alternative console
 setup_inittab_console $CONSOLE