diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2015-11-25 19:29:34 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2015-11-25 19:40:22 +0000 |
commit | 96479804b2876dff118035e49ebf35ff43fbaa85 (patch) | |
tree | 0f5881d2cccbe0a94d085796606528bfb2fd349b /main | |
parent | 4e6d75d2eaada36f90eebd88ddc34d30eabb4f93 (diff) | |
download | aports-96479804b2876dff118035e49ebf35ff43fbaa85.tar.bz2 aports-96479804b2876dff118035e49ebf35ff43fbaa85.tar.xz |
main/mkinitfs: fix mount relocation
Diffstat (limited to 'main')
-rw-r--r-- | main/mkinitfs/APKBUILD | 8 | ||||
-rw-r--r-- | main/mkinitfs/git.patch | 103 |
2 files changed, 79 insertions, 32 deletions
diff --git a/main/mkinitfs/APKBUILD b/main/mkinitfs/APKBUILD index 36c069a784..f70c0ede97 100644 --- a/main/mkinitfs/APKBUILD +++ b/main/mkinitfs/APKBUILD @@ -2,7 +2,7 @@ pkgname=mkinitfs pkgver=2.8.0_git20151025 _ver=${pkgver%_git*} -pkgrel=0 +pkgrel=1 pkgdesc="Tool to generate initramfs images for Alpine" url="http://git.alpinelinux.org/cgit/mkinitfs" makedepends="kmod-dev util-linux-dev cryptsetup-dev linux-headers" @@ -37,8 +37,8 @@ package() { make install DESTDIR="$pkgdir" || return 1 } md5sums="1a321336d97b22257349ddd36884ec34 mkinitfs-2.8.0.tar.xz -141a0411c74ac7533162b8a4007e2004 git.patch" +56af089f7c606e13cb65a3cf32d4bfb8 git.patch" sha256sums="5ffe4c5ec9e0ff4581e5b24301fd30d0964120d6b30ee78ea79f31ff48eeab73 mkinitfs-2.8.0.tar.xz -525507c490490fd622b4f8760d212f2552570bebcdb974641d3aff65181854e5 git.patch" +a3e823b10669cf7ef62bed3e7e4f662d157484a4f7449bea5b95cf9afefc1a15 git.patch" sha512sums="c103003f95c7d7d94daa41d0a81b210a0208c93d77203978554fb127a21e2f143b56990865fc53e2c5c732ef663603b297da63d31f915b1e3a3e0f3818aa8f2e mkinitfs-2.8.0.tar.xz -bdd182ef4fcd82c99f658e53c9c406bb7ad16ad6c19d3a11397699ed57c52d3e05e9d927807e02fd8980b5948fc5c37d184303a6d22b075e6b23aa5b8567af11 git.patch" +a5d15f34954c27c7b4ae5a2e9dab16b33b8360c29e9083d9a43947241a4e606d7acfe244f01b6e29c6977e81194e579e511f38aba963b732bd5e86c555ced15d git.patch" diff --git a/main/mkinitfs/git.patch b/main/mkinitfs/git.patch index a1ba95cbe0..14842a85e9 100644 --- a/main/mkinitfs/git.patch +++ b/main/mkinitfs/git.patch @@ -239,7 +239,7 @@ index fa74c10..b0e6c22 100644 kernel/drivers/virtio +kernel/drivers/net/virtio_net* diff --git a/initramfs-init.in b/initramfs-init.in -index 934fe92..0834175 100755 +index 934fe92..cdf50b9 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -7,7 +7,7 @@ sysroot=/sysroot @@ -290,7 +290,49 @@ index 934fe92..0834175 100755 apk add --quiet --initdb --repositories-file /tmp/repositories openssl\ || return 1 -@@ -136,66 +111,12 @@ find_mnt() { +@@ -110,92 +85,35 @@ unpack_apkovl() { + # find mount dir for given device in an fstab + # returns global MNTOPTS + find_mnt() { +- local search_dev="$1" fstab="$2" +- MNTOPTS= +- [ -r "$fstab" ] || return 1 +- local dev mnt fs chk ++ local search_dev="$1" ++ local fstab="$2" + case "$search_dev" in +- UUID=*|LABEL=*|/dev/*);; +- *) search_dev=/dev/$search_dev;; ++ UUID*|LABEL*) search_dev=$(findfs "$search_dev");; + esac +- local search_real_dev=$(resolve_dev $search_dev) ++ MNTOPTS= ++ [ -r "$fstab" ] || return 1 ++ local search_maj_min=$(stat -L -c '%t,%T' $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 ++ case "$dev" in ++ UUID*|LABEL*) dev=$(findfs "$dev");; ++ esac ++ if [ -b "$dev" ]; then ++ local maj_min=$(stat -L -c '%t,%T' $dev) ++ if [ "$maj_min" = "$search_maj_min" ]; then ++ echo "$mnt" ++ return ++ fi ++ fi + done < $fstab MNTOPTS= } @@ -357,7 +399,7 @@ index 934fe92..0834175 100755 setup_inittab_console(){ while [ $# -gt 0 ]; do local tty=${1%,*} -@@ -225,44 +146,6 @@ setup_inittab_console(){ +@@ -225,44 +143,6 @@ setup_inittab_console(){ done } @@ -402,7 +444,7 @@ index 934fe92..0834175 100755 # determine the default interface to use if ip=dhcp is set # uses the first "eth" interface. ip_choose_if() { -@@ -332,10 +215,6 @@ configure_ip() { +@@ -332,10 +212,6 @@ configure_ip() { ip_set "$device" "$client_ip" "$netmask" "$gw_ip" eend $? fi @@ -413,7 +455,7 @@ index 934fe92..0834175 100755 } # resolve an uuid or symlink to the real device -@@ -346,37 +225,23 @@ resolve_dev() { +@@ -346,37 +222,27 @@ resolve_dev() { esac } @@ -422,16 +464,21 @@ index 934fe92..0834175 100755 - local fstab="$1" - local mnt=$(find_mnt $ALPINE_DEV $fstab) - if [ -n "$mnt" ] && [ "$ALPINE_MNT" != "$mnt" ]; then +- mkdir -p "$mnt" +- mount -o move $ALPINE_MNT $mnt +- ALPINE_MNT=$mnt +# relocate mountpoint according given fstab +relocate_mount() { -+ local dir="${1%%/}" ++ local dir="${1}" + local fstab="$2" -+ local mnt=$(find_mnt $dir $fstab) -+ if [ -n "$mnt" ] && [ "$dir" != "$mnt" ]; then - mkdir -p "$mnt" -- mount -o move $ALPINE_MNT $mnt -- ALPINE_MNT=$mnt -+ mount -o move "$dir" "$mnt" ++ local dev=$(df -P "$dir" | tail -1 | awk '{print $1}') ++ local mnt=$(find_mnt $dev $fstab) ++ if [ -n "$mnt" ]; then ++ local oldmnt=$(awk -v d=$dev '$1==d {print $2}' /proc/mounts) ++ if [ "$oldmnt" != "$mnt" ]; then ++ mkdir -p "$mnt" ++ mount -o move "$oldmnt" "$mnt" ++ fi fi } @@ -459,7 +506,7 @@ index 934fe92..0834175 100755 | sed 's:/.boot_repository$::' fi } -@@ -438,63 +303,14 @@ if [ "$KOPT_dma" = no ]; then +@@ -438,63 +304,14 @@ if [ "$KOPT_dma" = no ]; then modprobe libata dma=0 fi @@ -524,7 +571,7 @@ index 934fe92..0834175 100755 # optional blacklist for i in ${KOPT_blacklist/,/ }; do -@@ -502,12 +318,8 @@ for i in ${KOPT_blacklist/,/ }; do +@@ -502,12 +319,8 @@ for i in ${KOPT_blacklist/,/ }; do done # setup /dev @@ -537,7 +584,7 @@ index 934fe92..0834175 100755 [ -d /dev/pts ] || mkdir -m 755 /dev/pts [ -c /dev/ptmx ] || mknod -m 666 /dev/ptmx c 5 2 # make sure /dev/null is setup correctly -@@ -516,7 +328,6 @@ RC=$? +@@ -516,7 +329,6 @@ RC=$? mount -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts [ -d /dev/shm ] || mkdir /dev/shm mount -t tmpfs -o nodev,nosuid,noexec shm /dev/shm @@ -545,7 +592,7 @@ index 934fe92..0834175 100755 # load available drivers to get access to modloop media ebegin "Loading boot drivers" -@@ -528,34 +339,36 @@ if [ -f /etc/modules ] ; then +@@ -528,34 +340,36 @@ if [ -f /etc/modules ] ; then modprobe -q $module $args done fi @@ -595,7 +642,7 @@ index 934fe92..0834175 100755 fi eend $? -@@ -571,35 +384,11 @@ if [ -n "$KOPT_root" ]; then +@@ -571,35 +385,11 @@ if [ -n "$KOPT_root" ]; then exec /bin/busybox sh fi @@ -634,7 +681,7 @@ index 934fe92..0834175 100755 eend $? # early console? -@@ -620,27 +409,24 @@ fi +@@ -620,27 +410,24 @@ fi mount -t tmpfs -o $rootflags tmpfs $sysroot @@ -674,7 +721,7 @@ index 934fe92..0834175 100755 ;; esac -@@ -660,26 +446,16 @@ if [ -f "$ovl" ]; then +@@ -660,26 +447,16 @@ if [ -f "$ovl" ]; then eend $? $errstr || ovlfiles= # hack, incase /root/.ssh was included in apkovl [ -d "$sysroot/root" ] && chmod 700 "$sysroot/root" @@ -705,7 +752,7 @@ index 934fe92..0834175 100755 rc_add hwclock boot rc_add modules boot -@@ -695,17 +471,24 @@ if [ -f "$sysroot/etc/.default_boot_services" -o ! -f "$ovl" ]; then +@@ -695,17 +472,24 @@ if [ -f "$sysroot/etc/.default_boot_services" -o ! -f "$ovl" ]; then rm -f "$sysroot/etc/.default_boot_services" fi @@ -736,7 +783,7 @@ index 934fe92..0834175 100755 eend 0 else KOPT_splash="no" -@@ -723,13 +506,13 @@ if [ -f $sysroot/etc/fstab ]; then +@@ -723,13 +507,13 @@ if [ -f $sysroot/etc/fstab ]; then # 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 @@ -748,15 +795,15 @@ index 934fe92..0834175 100755 -rc_add modloop sysinit + if [ -e /tmp/repositores ]; then -+ cut -d/ -f1-3 < /tmp/repositories | while read dir; do ++ while read dir; do + relocate_mount "$dir" "$sysroot"/etc/fstab -+ done ++ done < /tmp/repositories + fi +fi # hack so we get openrc pkgs="$pkgs alpine-base" -@@ -776,11 +559,16 @@ if [ "$KOPT_keep_apk_new" != yes ]; then +@@ -776,11 +560,16 @@ if [ "$KOPT_keep_apk_new" != yes ]; then apkflags="$apkflags --clean-protected" [ -n "$ovlfiles" ] && apkflags="$apkflags --overlay-from-stdin" fi @@ -773,7 +820,7 @@ index 934fe92..0834175 100755 eend $? # unmount ovl mount if needed -@@ -788,9 +576,11 @@ if [ -n "$ovl_unmount" ]; then +@@ -788,9 +577,11 @@ if [ -n "$ovl_unmount" ]; then umount $ovl_unmount 2>/dev/null fi @@ -782,13 +829,13 @@ index 934fe92..0834175 100755 - relocate_alpine_mnt "$sysroot"/etc/fstab +# remount according default fstab from package +if [ -z "$has_fstab" ] && [ -f "$sysroot"/etc/fstab ] && [ -f /tmp/repositories ]; then -+ cut -d/ -f1-3 < /tmp/repositories | while read dir; do ++ while read dir; do + relocate_mount "$dir" "$sysroot"/etc/fstab -+ done ++ done < /tmp/repositories fi # generate repositories if none exists. this needs to be done after relocation -@@ -810,10 +600,10 @@ fi +@@ -810,10 +601,10 @@ fi setup_inittab_console $CONSOLE # copy alpine release info |