diff options
Diffstat (limited to 'mkinitfs')
| -rw-r--r-- | mkinitfs/APKBUILD | 43 | ||||
| -rw-r--r-- | mkinitfs/mkinitfs-mdadm_fix.patch | 40 | ||||
| -rw-r--r-- | mkinitfs/mkinitfs.post-install | 8 | ||||
| -rw-r--r-- | mkinitfs/mkinitfs.post-upgrade | 8 | ||||
| -rw-r--r-- | mkinitfs/mkinitfs.pre-upgrade | 13 | ||||
| -rw-r--r-- | mkinitfs/mkinitfs.trigger | 37 |
6 files changed, 149 insertions, 0 deletions
diff --git a/mkinitfs/APKBUILD b/mkinitfs/APKBUILD new file mode 100644 index 0000000..37131b0 --- /dev/null +++ b/mkinitfs/APKBUILD @@ -0,0 +1,43 @@ +# Maintainer: Natanael Copa <ncopa@alpinelinux.org> +pkgname=mkinitfs +pkgver=3.7.0 +# shellcheck disable=SC2034 # used for git versions, keep around for next time +_ver=${pkgver%_git*} +pkgrel=4 +pkgdesc="Tool to generate initramfs images for Alpine" +url="https://gitlab.alpinelinux.org/alpine/mkinitfs" +arch="all" +license="GPL-2.0-only" +# currently we do not ship any testsuite +options="!check" +makedepends_host="busybox kmod-dev util-linux-dev cryptsetup-dev linux-headers" +makedepends="$makedepends_host" +depends=" + apk-tools>=2.9.1 + busybox-binsh + busybox>=1.28.2-r1 + kmod + lddtree>=1.25 + mdev-conf + " +subpackages="$pkgname-doc" +install="$pkgname.pre-upgrade $pkgname.post-install $pkgname.post-upgrade" +triggers="$pkgname.trigger=/usr/share/kernel/*" +source="https://gitlab.alpinelinux.org/alpine/mkinitfs/-/archive/$pkgver/mkinitfs-$pkgver.tar.gz + mkinitfs-mdadm_fix.patch" + +provides="initramfs-generator" +provider_priority=900 # highest + +build() { + make VERSION=$pkgver-r$pkgrel +} + +package() { + make install DESTDIR="$pkgdir" +} + +sha512sums=" +72d31cf5554a3fd3eb48bff79a2c81694f208e0bb727a997f875fdf847b90d028973dbbf1c71d1a7174806de5aab5e21810d852c0ef5f04e46c96367b751d9f4 mkinitfs-3.7.0.tar.gz +09d1a33499ee268528860d872a3a3ade319659ccc0df03cda3e738ca23399e45c903ff8aebb8542de4881fa6930db03b4cc6748715cb5f32967c9c9db6f5111e mkinitfs-mdadm_fix.patch +" diff --git a/mkinitfs/mkinitfs-mdadm_fix.patch b/mkinitfs/mkinitfs-mdadm_fix.patch new file mode 100644 index 0000000..2981d7f --- /dev/null +++ b/mkinitfs/mkinitfs-mdadm_fix.patch @@ -0,0 +1,40 @@ +diff --git a/nlplug-findfs/nlplug-findfs.c b/nlplug-findfs/nlplug-findfs.c +index 1cb48d2..7b0b940 100644 +--- a/nlplug-findfs/nlplug-findfs.c ++++ b/nlplug-findfs/nlplug-findfs.c +@@ -479,9 +479,9 @@ static int load_kmod(const char *modalias, char *driver, size_t len) + return count; + } + +-static void start_mdadm(char *devnode) ++static void start_mdadm(char *devnode, const char *searchdev) + { +- char *mdadm_argv[] = { ++ char *root_mdadm_argv[] = { + MDADM_PATH, + "--incremental", + "--run", +@@ -489,6 +489,14 @@ static void start_mdadm(char *devnode) + devnode, + NULL + }; ++ char *nonroot_mdadm_argv[] = { ++ MDADM_PATH, ++ "--incremental", ++ "--quiet", ++ devnode, ++ NULL ++ }; ++ char **mdadm_argv = (strcmp(devnode, searchdev) == 0) ? root_mdadm_argv : nonroot_mdadm_argv; + if (use_mdadm) + spawn_command(&spawnmgr, mdadm_argv, 0); + } +@@ -1006,7 +1014,7 @@ static int searchdev(struct uevent *ev, const char *searchdev, int scanbootmedia + + if (!rc && type) { + if (strcmp("linux_raid_member", type) == 0) { +- start_mdadm(ev->devnode); ++ start_mdadm(ev->devnode, searchdev); + } else if (strcmp("LVM2_member", type) == 0) { + start_lvm2(ev->devnode); + } else if (strcmp("zfs_member", type) == 0) { diff --git a/mkinitfs/mkinitfs.post-install b/mkinitfs/mkinitfs.post-install new file mode 100644 index 0000000..a2a404b --- /dev/null +++ b/mkinitfs/mkinitfs.post-install @@ -0,0 +1,8 @@ +#!/bin/sh + +# safety. if nlplug-findfs is missing in the initramfs image we may end up +# with an unbootable system. + +if ! grep -q -w /sbin/nlplug-findfs /etc/mkinitfs/features.d/base.files; then + echo "/sbin/nlplug-findfs" >> /etc/mkinitfs/features.d/base.files +fi diff --git a/mkinitfs/mkinitfs.post-upgrade b/mkinitfs/mkinitfs.post-upgrade new file mode 100644 index 0000000..a2a404b --- /dev/null +++ b/mkinitfs/mkinitfs.post-upgrade @@ -0,0 +1,8 @@ +#!/bin/sh + +# safety. if nlplug-findfs is missing in the initramfs image we may end up +# with an unbootable system. + +if ! grep -q -w /sbin/nlplug-findfs /etc/mkinitfs/features.d/base.files; then + echo "/sbin/nlplug-findfs" >> /etc/mkinitfs/features.d/base.files +fi diff --git a/mkinitfs/mkinitfs.pre-upgrade b/mkinitfs/mkinitfs.pre-upgrade new file mode 100644 index 0000000..0ece527 --- /dev/null +++ b/mkinitfs/mkinitfs.pre-upgrade @@ -0,0 +1,13 @@ +#!/bin/sh + +mkdir -p /etc/mkinitfs/features.d +for i in files modules; do + for j in /etc/mkinitfs/$i.d/*; do + [ -e "$j" ] || continue + case "$j" in + *.apk-new) continue;; + esac + mv $j /etc/mkinitfs/features.d/${j##*/}.$i + done +done +exit 0 diff --git a/mkinitfs/mkinitfs.trigger b/mkinitfs/mkinitfs.trigger new file mode 100644 index 0000000..35b13c0 --- /dev/null +++ b/mkinitfs/mkinitfs.trigger @@ -0,0 +1,37 @@ +#!/bin/sh + +CONFIG='/etc/mkinitfs/mkinitfs.conf' +if [ -f "$CONFIG" ]; then + case "$(. "$CONFIG" >/dev/null; printf %s "$disable_trigger")" in + yes | YES | true | TRUE | 1) exit 0;; + esac +fi + +for i in "$@"; do + # get last element in path + flavor=${i##*/} + if ! [ -f "$i"/kernel.release ]; then + # kernel was uninstalled + rm -f $( readlink -f /boot/initramfs-$flavor ) \ + /boot/initramfs-$flavor /boot/vmlinuz-$flavor \ + /boot/$flavor /boot/$flavor.gz /$flavor /$flavor.gz + continue + fi + abi_release=$(cat "$i"/kernel.release) + initfs=initramfs-$flavor + mkinitfs -o /boot/$initfs $abi_release || { + echo " mkinitfs failed!" >2 + echo " your system may not be bootable" >2 + exit 1 + } +done + +# extlinux will use path relative partition, so if /boot is on a +# separate partition we want /boot/<kernel> resolve to /<kernel> +if ! [ -e /boot/boot ]; then + ln -sf . /boot/boot 2>/dev/null # silence error in case of FAT +fi + +# sync only the filesystem on /boot as that is where we are writing the initfs. +sync -f /boot +exit 0 |
