summaryrefslogtreecommitdiffstats
path: root/main/mkinitfs/delay-umount-apkovl.patch
blob: 983008b3fb65ba5d66ca95741db306f36d40b684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
diff --git a/initramfs-init.in b/initramfs-init.in
index f64ef26..8f01c8f 100755
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -244,8 +244,8 @@ resolve_dev() {
 	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 @@ remount_alpine_mnt() {
 		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 @@ if [ -f "$ovl" ]; then
 	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 @@ else
 	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 @@ rc_add modloop sysinit
 # 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,11 +532,23 @@ else
 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