summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/mkinitfs/APKBUILD4
-rw-r--r--main/mkinitfs/mount-move.patch115
2 files changed, 118 insertions, 1 deletions
diff --git a/main/mkinitfs/APKBUILD b/main/mkinitfs/APKBUILD
index 00974e2a7..dd2c59a0f 100644
--- a/main/mkinitfs/APKBUILD
+++ b/main/mkinitfs/APKBUILD
@@ -1,13 +1,14 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mkinitfs
pkgver=2.3.4
-pkgrel=2
+pkgrel=3
pkgdesc="Tool to generate initramfs images for Alpine"
url=http://git.alpinelinux.org/cgit/mkinitfs
depends="busybox apk-tools>=2.0"
triggers="$pkgname.trigger=/usr/share/kernel/*"
source="http://git.alpinelinux.org/cgit/$pkgname.git/snapshot/$pkgname-$pkgver.tar.bz2
0001-init-fix-progressbar-when-not-quiet.patch
+ mount-move.patch
eglibc.patch
"
arch="noarch"
@@ -45,4 +46,5 @@ package() {
}
md5sums="abec6dced89e137dc60542c1e5f938ac mkinitfs-2.3.4.tar.bz2
4ea4389d5dff0a69d6792420574d2f1f 0001-init-fix-progressbar-when-not-quiet.patch
+049392dd315240d2c7d892ef67072e03 mount-move.patch
e59c2f7de496fe430b07e32fd812ebe0 eglibc.patch"
diff --git a/main/mkinitfs/mount-move.patch b/main/mkinitfs/mount-move.patch
new file mode 100644
index 000000000..493166324
--- /dev/null
+++ b/main/mkinitfs/mount-move.patch
@@ -0,0 +1,115 @@
+diff --git a/initramfs-init.in b/initramfs-init.in
+index 2ff2585..f64ef26 100755
+--- a/initramfs-init.in
++++ b/initramfs-init.in
+@@ -104,10 +104,32 @@ unpack_apkovl() {
+ }
+
+ # find mount dir for given device in an fstab
++# returns global MNTOPTS
+ find_mnt() {
+- local dev="$1"
+- local fsfile="$2"
+- awk "\$1 == \"$dev\" {print \$2}\"" "$fsfile" 2>/dev/null
++ local search_dev="$1" fstab="$2"
++ MNTOPTS=
++ [ -r "$fstab" ] || return 1
++ local dev mnt fs chk
++ case "$search_dev" in
++ UUID=*|LABEL=*|/dev/*);;
++ *) search_dev=/dev/$search_dev;;
++ esac
++ local search_real_dev=$(resolve_dev $search_dev)
++ while read dev mnt fs MNTOPTS chk; do
++ local real_dev=$(resolve_dev $dev)
++ local i j
++ for i in "$search_dev" "$search_real_dev"; do
++ [ -z "$i" ] && continue
++ for j in "$dev" "$real_dev"; do
++ [ -z "$j" ] && continue
++ if [ "$i" = "$j" ]; then
++ echo "$mnt"
++ return
++ fi
++ done
++ done
++ done < $fstab
++ MNTOPTS=
+ }
+
+ # Wait for usb to settle
+@@ -214,6 +236,29 @@ start_lvm() {
+ lvm vgchange --ignorelockingfailure -a y >/dev/null 2>&1
+ }
+
++# resolve an uuid or symlink to the real device
++resolve_dev() {
++ case "$1" in
++ UUID=*|LABEL=*) findfs "$1";;
++ *) readlink -f "$1";;
++ esac
++}
++
++# remount ALPINE_MNT according given fstab
++remount_alpine_mnt() {
++ local fstab="$1"
++ local mnt=$(find_mnt $ALPINE_DEV $fstab)
++ if [ "$ALPINE_MNT" != "$mnt" ]; then
++ mkdir -p "$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 :)
+ echo "Alpine Init $VERSION"
+
+@@ -270,7 +315,7 @@ if [ -n "$KOPT_ovl_dev" ] ; then
+ fi
+
+ case "$ALPINE_DEV" in
+- UUID=*) ;;
++ UUID=*|LABEL=*) ;;
+ *) ALPINE_DEV=/dev/$ALPINE_DEV ;;
+ esac
+
+@@ -453,20 +498,9 @@ 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
+-new_mnt=$(find_mnt $ALPINE_DEV $sysroot/etc/fstab)
+-if [ -n "$new_mnt" ] && [ "$new_mnt" != "$ALPINE_MNT" ]; then
+- mkdir -p $new_mnt
+- mount -o move $ALPINE_MNT $new_mnt
+- ALPINE_MNT="$new_mnt"
+-fi
+-
+-# let user set ALPINE_MNT as readonly in fstab
+-if [ -f $sysroot/etc/fstab ]; then
+- mountopts=$(awk "\$2 == \"$ALPINE_MNT\" { print \$4 }" \
+- $sysroot/etc/fstab)
+- if [ -n "$mountopts" ]; then
+- mount -o remount,$mountopts $ALPINE_MNT
+- fi
++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
+@@ -503,6 +537,11 @@ else
+ fi
+ eend $?
+
++# remount ALPINE_MNT according default fstab from package
++if [ -z "$has_fstab" ] && [ -f "$sysroot"/etc/fstab ]; then
++ remount_alpine_mnt "$sysroot"/etc/fstab
++fi
++
+ # fix inittab if alternative console
+ setup_inittab_console $CONSOLE
+