From 8faf140777b9d8138563f4b4a3e2229cb5639472 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Thu, 18 Sep 2014 18:38:30 +0400 Subject: [PATCH] kernel, stage2: rearranged initrd hooks stage2 has been thinking it's synonymous with propagator and used to usurp kernel's belongings either; carefully tear scripts apart so that kernel feature makes sure initrd gets generated, and stage2 (which is still all about propagator) cares for its bits. --- doc/assumptions.txt | 2 +- .../stage1/scripts.d/10-initrd-base | 6 ----- .../stage1/scripts.d/80-make-initrd} | 26 ++++++++++--------- .../stage1/scripts.d/11-initrd-propagator | 7 +++++ .../stage2/stage1/scripts.d/81-make-initfs | 13 ++++++++++ 5 files changed, 35 insertions(+), 19 deletions(-) rename features.in/{stage2 => kernel}/stage1/scripts.d/10-initrd-base (65%) rename features.in/{stage2/stage1/scripts.d/80-make-initfs => kernel/stage1/scripts.d/80-make-initrd} (53%) create mode 100755 features.in/stage2/stage1/scripts.d/11-initrd-propagator create mode 100755 features.in/stage2/stage1/scripts.d/81-make-initfs diff --git a/doc/assumptions.txt b/doc/assumptions.txt index 4fb76a63..39bbbcb9 100644 --- a/doc/assumptions.txt +++ b/doc/assumptions.txt @@ -27,7 +27,7 @@ ALT Linux 6.0+ и GNU make 3.81+ (на которых и разрабатыва E: Couldn't find package -* features.in/stage2/stage1/scripts.d/02-kdefault +* features.in/kernel/stage1/scripts.d/80-make-initrd * features.in/stage2/stage1/scripts.d/03-test-kernel * sub.in/stage1/Makefile ** ожидают, что в stage1 попадёт строго одно ядро сообразно diff --git a/features.in/stage2/stage1/scripts.d/10-initrd-base b/features.in/kernel/stage1/scripts.d/10-initrd-base similarity index 65% rename from features.in/stage2/stage1/scripts.d/10-initrd-base rename to features.in/kernel/stage1/scripts.d/10-initrd-base index 21fafd17..287e2119 100755 --- a/features.in/stage2/stage1/scripts.d/10-initrd-base +++ b/features.in/kernel/stage1/scripts.d/10-initrd-base @@ -1,6 +1,5 @@ #!/bin/sh # prepare base make-initrd configuration for stage1 -# see also http://www.altlinux.org/Make-initrd-propagator MAKE_INITRD_VER="`make-initrd -V \ | sed -rn 's/^make-initrd version ([0-9.]+)/\1/p'`" @@ -10,8 +9,3 @@ if [ "`rpmvercmp "$MAKE_INITRD_VER" "0.8.1"`" != "-1" ]; then else sed -i 's/AUTODETECT/#&/' /etc/initrd.mk # see also #28578 fi - -echo 'FEATURES += propagator' >> /etc/initrd.mk - -# FIXME: #29705 workaround -echo 'MODULES_PRELOAD += ahci' >> /etc/initrd.mk diff --git a/features.in/stage2/stage1/scripts.d/80-make-initfs b/features.in/kernel/stage1/scripts.d/80-make-initrd similarity index 53% rename from features.in/stage2/stage1/scripts.d/80-make-initfs rename to features.in/kernel/stage1/scripts.d/80-make-initrd index b24968b3..1c935c57 100755 --- a/features.in/stage2/stage1/scripts.d/80-make-initfs +++ b/features.in/kernel/stage1/scripts.d/80-make-initrd @@ -1,7 +1,7 @@ #!/bin/sh -efux # NB: /etc/initrd.mk carefully prepared by earlier scripts -verbose() { [ -z "$GLOBAL_VERBOSE" ] || echo "** 80-make-initfs: $@" >&2; } +fatal() { echo "** error: $@" >&1; exit 1; } kver="$(rpm -qa 'kernel-image*' \ --qf '%{installtime} %{version}-%{name}-%{release}\n' \ @@ -10,6 +10,9 @@ kver="$(rpm -qa 'kernel-image*' \ | cut -f 2 -d ' ' \ | sed 's/kernel-image-//')" +[ -n "$kver" ] || + fatal "no kernel version identified" + MAKE_INITRD_OPTS="--no-checks -k $kver" MAKE_INITRD_VER="`make-initrd -V \ | sed -rn 's/^make-initrd version ([0-9.]+)/\1/p'`" @@ -19,17 +22,16 @@ if [ "`rpmvercmp "$MAKE_INITRD_VER" "0.7.8"`" != "-1" ]; then MAKE_INITRD_OPTS="$MAKE_INITRD_OPTS --no-depmod" fi -[ -z "$GLOBAL_VERBOSE" ] || MAKE_INITRD_OPTS="$MAKE_INITRD_OPTS -v" +[ -z "$GLOBAL_VERBOSE" ] || + MAKE_INITRD_OPTS="$MAKE_INITRD_OPTS -v" -if make-initrd $MAKE_INITRD_OPTS; then - pdir="$(getconf LIBDIR)/propagator" - mkdir -p "$pdir" - gzip < /boot/initrd-$kver.img > "$pdir"/initfs -else - verbose "make-initrd failed" - exit 1 -fi +make-initrd $MAKE_INITRD_OPTS || + fatal "make-initrd failed" + +[ -h /boot/vmlinuz ] || + ln -s vmlinuz-$kver /boot/vmlinuz + +[ -h /boot/initrd.img ] || + ln -s initrd-$kver.img /boot/initrd.img -[ -h /boot/vmlinuz ] || ln -s vmlinuz-$kver /boot/vmlinuz -[ -h /boot/initrd.img ] || ln -s initrd-$kver.img /boot/initrd.img : diff --git a/features.in/stage2/stage1/scripts.d/11-initrd-propagator b/features.in/stage2/stage1/scripts.d/11-initrd-propagator new file mode 100755 index 00000000..5022d30f --- /dev/null +++ b/features.in/stage2/stage1/scripts.d/11-initrd-propagator @@ -0,0 +1,7 @@ +#!/bin/sh +# see also http://www.altlinux.org/Make-initrd-propagator + +echo 'FEATURES += propagator' >> /etc/initrd.mk + +# FIXME: #29705 workaround +echo 'MODULES_PRELOAD += ahci' >> /etc/initrd.mk diff --git a/features.in/stage2/stage1/scripts.d/81-make-initfs b/features.in/stage2/stage1/scripts.d/81-make-initfs new file mode 100755 index 00000000..18e825e0 --- /dev/null +++ b/features.in/stage2/stage1/scripts.d/81-make-initfs @@ -0,0 +1,13 @@ +#!/bin/sh -efu +# NB: initrd.mk carefully built by an earlier script + +verbose() { [ -z "$GLOBAL_VERBOSE" ] || echo "** 81-make-initfs: $@" >&2; } + +if [ -h /boot/initrd.img ]; then + pdir="$(getconf LIBDIR)/propagator" + mkdir -p "$pdir" + gzip < /boot/initrd.img > "$pdir"/initfs +else + verbose "/boot/initrd.img missing" + exit 1 +fi