From f3160a5b6cd3895fd92dcd8deac3f5521168c595 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 20 Jul 2011 21:58:17 +0200 Subject: [PATCH] "eject" is optional now refined shutdown procedure --- ...ec-remove-noreplace-for-01-dist.conf.patch | 22 ++ 0002-add-TEST-15-BTRFSRAID.patch | 192 ++++++++++++++++++ 0003-dracut.logrotate-remove-yearly.patch | 21 ++ ...create-logfile-with-0600-permissions.patch | 32 +++ ...squash-live-optionally-install-eject.patch | 22 ++ 0006-enable-shutdown-module-by-default.patch | 35 ++++ ...shutdown.sh-put-shutdown-in-function.patch | 31 +++ ...shutdown.sh-put-shutdown-in-function.patch | 30 +++ ...10-RAID-extend-test-case-to-shutdown.patch | 99 +++++++++ ...est-init-turn-off-debug-for-shutdown.patch | 21 ++ 0011-shutdown-fixed-check_shutdown-loop.patch | 98 +++++++++ 0012-dracut-lib.sh-fixed-getargs.patch | 73 +++++++ ...ut-lib.sh-fix-previous-getargs-patch.patch | 24 +++ ...t-init-add-comment-for-rd.break-shut.patch | 23 +++ dracut.spec | 36 +++- 15 files changed, 757 insertions(+), 2 deletions(-) create mode 100644 0001-dracut.spec-remove-noreplace-for-01-dist.conf.patch create mode 100644 0002-add-TEST-15-BTRFSRAID.patch create mode 100644 0003-dracut.logrotate-remove-yearly.patch create mode 100644 0004-dracut-logger-create-logfile-with-0600-permissions.patch create mode 100644 0005-90dmsquash-live-optionally-install-eject.patch create mode 100644 0006-enable-shutdown-module-by-default.patch create mode 100644 0007-90dm-dm-shutdown.sh-put-shutdown-in-function.patch create mode 100644 0008-90mdraid-md-shutdown.sh-put-shutdown-in-function.patch create mode 100644 0009-TEST-10-RAID-extend-test-case-to-shutdown.patch create mode 100644 0010-TEST-10-RAID-test-init-turn-off-debug-for-shutdown.patch create mode 100644 0011-shutdown-fixed-check_shutdown-loop.patch create mode 100644 0012-dracut-lib.sh-fixed-getargs.patch create mode 100644 0013-99base-dracut-lib.sh-fix-previous-getargs-patch.patch create mode 100644 0014-TEST-10-RAID-test-init-add-comment-for-rd.break-shut.patch diff --git a/0001-dracut.spec-remove-noreplace-for-01-dist.conf.patch b/0001-dracut.spec-remove-noreplace-for-01-dist.conf.patch new file mode 100644 index 0000000..f01132a --- /dev/null +++ b/0001-dracut.spec-remove-noreplace-for-01-dist.conf.patch @@ -0,0 +1,22 @@ +From 8e702c3d0facbe4f6381068b74efb56bdc0c1653 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 12:39:58 +0200 +Subject: [PATCH] dracut.spec: remove noreplace for 01-dist.conf + +--- + dracut.spec | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/dracut.spec b/dracut.spec +index 26263d8..30741cd 100644 +--- a/dracut.spec ++++ b/dracut.spec +@@ -215,7 +215,7 @@ rm -rf $RPM_BUILD_ROOT + %{_datadir}/dracut/dracut-logger + %config(noreplace) /etc/dracut.conf + %if 0%{?fedora} || 0%{?suse_version} +-%config(noreplace) /etc/dracut.conf.d/01-dist.conf ++%config /etc/dracut.conf.d/01-dist.conf + %endif + %dir /etc/dracut.conf.d + %{_mandir}/man8/dracut.8* diff --git a/0002-add-TEST-15-BTRFSRAID.patch b/0002-add-TEST-15-BTRFSRAID.patch new file mode 100644 index 0000000..2f0768a --- /dev/null +++ b/0002-add-TEST-15-BTRFSRAID.patch @@ -0,0 +1,192 @@ +From 54703a719f49b3c4aafb60d49b265e2cde9bb16f Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 14:10:30 +0200 +Subject: [PATCH] add TEST-15-BTRFSRAID + +--- + test/TEST-15-BTRFSRAID/99-idesymlinks.rules | 8 +++ + test/TEST-15-BTRFSRAID/Makefile | 10 +++ + test/TEST-15-BTRFSRAID/create-root.sh | 22 +++++++ + test/TEST-15-BTRFSRAID/hard-off.sh | 3 + + test/TEST-15-BTRFSRAID/test-init | 11 ++++ + test/TEST-15-BTRFSRAID/test.sh | 82 +++++++++++++++++++++++++++ + 6 files changed, 136 insertions(+), 0 deletions(-) + create mode 100644 test/TEST-15-BTRFSRAID/99-idesymlinks.rules + create mode 100644 test/TEST-15-BTRFSRAID/Makefile + create mode 100755 test/TEST-15-BTRFSRAID/create-root.sh + create mode 100755 test/TEST-15-BTRFSRAID/hard-off.sh + create mode 100755 test/TEST-15-BTRFSRAID/test-init + create mode 100755 test/TEST-15-BTRFSRAID/test.sh + +diff --git a/test/TEST-15-BTRFSRAID/99-idesymlinks.rules b/test/TEST-15-BTRFSRAID/99-idesymlinks.rules +new file mode 100644 +index 0000000..d557790 +--- /dev/null ++++ b/test/TEST-15-BTRFSRAID/99-idesymlinks.rules +@@ -0,0 +1,8 @@ ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd" ++ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}" +diff --git a/test/TEST-15-BTRFSRAID/Makefile b/test/TEST-15-BTRFSRAID/Makefile +new file mode 100644 +index 0000000..bc0ddb6 +--- /dev/null ++++ b/test/TEST-15-BTRFSRAID/Makefile +@@ -0,0 +1,10 @@ ++all: ++ @make -s --no-print-directory -C ../.. all ++ @basedir=../.. testdir=../ ./test.sh --all ++setup: ++ @make --no-print-directory -C ../.. all ++ @basedir=../.. testdir=../ ./test.sh --setup ++clean: ++ @basedir=../.. testdir=../ ./test.sh --clean ++run: ++ @basedir=../.. testdir=../ ./test.sh --run +diff --git a/test/TEST-15-BTRFSRAID/create-root.sh b/test/TEST-15-BTRFSRAID/create-root.sh +new file mode 100755 +index 0000000..60dd319 +--- /dev/null ++++ b/test/TEST-15-BTRFSRAID/create-root.sh +@@ -0,0 +1,22 @@ ++#!/bin/sh ++# don't let udev and this script step on eachother's toes ++for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do ++ > "/etc/udev/rules.d/$x" ++done ++udevadm control --reload-rules ++# save a partition at the beginning for future flagging purposes ++sfdisk -C 524288 -H 2 -S 32 -L /dev/sda </dev/sda1 ++poweroff -f +diff --git a/test/TEST-15-BTRFSRAID/hard-off.sh b/test/TEST-15-BTRFSRAID/hard-off.sh +new file mode 100755 +index 0000000..12c3d5a +--- /dev/null ++++ b/test/TEST-15-BTRFSRAID/hard-off.sh +@@ -0,0 +1,3 @@ ++#!/bin/sh ++getarg rd.shell || poweroff -f ++getarg failme && poweroff -f +diff --git a/test/TEST-15-BTRFSRAID/test-init b/test/TEST-15-BTRFSRAID/test-init +new file mode 100755 +index 0000000..8f7cdf3 +--- /dev/null ++++ b/test/TEST-15-BTRFSRAID/test-init +@@ -0,0 +1,11 @@ ++#!/bin/sh ++export PATH=/sbin:/bin:/usr/sbin:/usr/bin ++exec >/dev/console 2>&1 ++echo "dracut-root-block-success" >/dev/sda1 ++export TERM=linux ++export PS1='initramfs-test:\w\$ ' ++[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab ++stty sane ++echo "made it to the rootfs! Powering down." ++mount -n -o remount,ro / ++poweroff -f +diff --git a/test/TEST-15-BTRFSRAID/test.sh b/test/TEST-15-BTRFSRAID/test.sh +new file mode 100755 +index 0000000..96ecd2e +--- /dev/null ++++ b/test/TEST-15-BTRFSRAID/test.sh +@@ -0,0 +1,82 @@ ++#!/bin/bash ++TEST_DESCRIPTION="root filesystem on multiple device btrfs" ++ ++KVERSION=${KVERSION-$(uname -r)} ++ ++# Uncomment this to debug failures ++#DEBUGFAIL="rd.shell" ++DISKIMAGE=/var/tmp/TEST-15-BTRFSRAID-root.img ++test_run() { ++ $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic \ ++ -net none -kernel /boot/vmlinuz-$KVERSION \ ++ -append "root=LABEL=root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \ ++ -initrd initramfs.testing ++ grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1 ++} ++ ++test_setup() { ++ # Create the blank file to use as a root filesystem ++ dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024 ++ ++ kernel=$KVERSION ++ # Create what will eventually be our root filesystem onto an overlay ++ ( ++ initdir=overlay/source ++ . $basedir/dracut-functions ++ dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \ ++ /lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient ++ inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" ++ inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" ++ dracut_install grep ++ inst ./test-init /sbin/init ++ find_binary plymouth >/dev/null && dracut_install plymouth ++ (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) ++ cp -a /etc/ld.so.conf* $initdir/etc ++ sudo ldconfig -r "$initdir" ++ ) ++ ++ # second, install the files needed to make the root filesystem ++ ( ++ initdir=overlay ++ . $basedir/dracut-functions ++ dracut_install sfdisk mkfs.btrfs poweroff cp umount ++ inst_hook initqueue 01 ./create-root.sh ++ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ++ ) ++ ++ # create an initramfs that will create the target root filesystem. ++ # We do it this way so that we do not risk trashing the host mdraid ++ # devices, volume groups, encrypted partitions, etc. ++ $basedir/dracut -l -i overlay / \ ++ -m "dash btrfs udev-rules base rootfs-block kernel-modules" \ ++ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \ ++ --nomdadmconf \ ++ -f initramfs.makeroot $KVERSION || return 1 ++ rm -rf overlay ++ # Invoke KVM and/or QEMU to actually create the target filesystem. ++ $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic -net none \ ++ -kernel "/boot/vmlinuz-$kernel" \ ++ -append "root=LABEL=root rw quiet console=ttyS0,115200n81 selinux=0" \ ++ -initrd initramfs.makeroot || return 1 ++ grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1 ++ ( ++ initdir=overlay ++ . $basedir/dracut-functions ++ dracut_install poweroff shutdown ++ inst_hook emergency 000 ./hard-off.sh ++ inst ./cryptroot-ask /sbin/cryptroot-ask ++ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules ++ ) ++ sudo $basedir/dracut -l -i overlay / \ ++ -o "plymouth network" \ ++ -a "debug" \ ++ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \ ++ -f initramfs.testing $KVERSION || return 1 ++} ++ ++test_cleanup() { ++ rm -fr overlay mnt ++ rm -f $DISKIMAGE initramfs.makeroot initramfs.testing ++} ++ ++. $testdir/test-functions diff --git a/0003-dracut.logrotate-remove-yearly.patch b/0003-dracut.logrotate-remove-yearly.patch new file mode 100644 index 0000000..940af79 --- /dev/null +++ b/0003-dracut.logrotate-remove-yearly.patch @@ -0,0 +1,21 @@ +From 8a29368bf1077757d160535e381c6f6de32a95fb Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 17:21:02 +0200 +Subject: [PATCH] dracut.logrotate: remove "yearly" + +logrotate would only rotate yearly with it +--- + dracut.logrotate | 1 - + 1 files changed, 0 insertions(+), 1 deletions(-) + +diff --git a/dracut.logrotate b/dracut.logrotate +index e7d4f0a..76bdd80 100644 +--- a/dracut.logrotate ++++ b/dracut.logrotate +@@ -2,6 +2,5 @@ + missingok + notifempty + size 30k +- yearly + create 0600 root root + } diff --git a/0004-dracut-logger-create-logfile-with-0600-permissions.patch b/0004-dracut-logger-create-logfile-with-0600-permissions.patch new file mode 100644 index 0000000..41df5c5 --- /dev/null +++ b/0004-dracut-logger-create-logfile-with-0600-permissions.patch @@ -0,0 +1,32 @@ +From e45ffb5d1fddf751f50bc268846d81659120be62 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 17:24:33 +0200 +Subject: [PATCH] dracut-logger: create logfile with 0600 permissions + +--- + dracut-logger | 4 ++++ + 1 files changed, 4 insertions(+), 0 deletions(-) + +diff --git a/dracut-logger b/dracut-logger +index 3bcce83..a5a3ee9 100755 +--- a/dracut-logger ++++ b/dracut-logger +@@ -106,6 +106,7 @@ __DRACUT_LOGGER__=1 + # @warning Function sets global variables @var maxloglvl and @syslogfacility. + # See file doc comment for details. + dlog_init() { ++ local __oldumask + # Skip initialization if it's already done. + [ -n "$maxloglvl" ] && return 0 + +@@ -118,7 +119,10 @@ dlog_init() { + if [ -z "$fileloglvl" ]; then + [ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0 + elif [ $fileloglvl -gt 0 ]; then ++ __oldumask=$(umask) ++ umask 0377 + ! [ -e "$logfile" ] && >"$logfile" ++ umask $__oldumask + if [ -w "$logfile" -a -f "$logfile" ]; then + # Mark new run in the log file + echo >>"$logfile" diff --git a/0005-90dmsquash-live-optionally-install-eject.patch b/0005-90dmsquash-live-optionally-install-eject.patch new file mode 100644 index 0000000..96636b7 --- /dev/null +++ b/0005-90dmsquash-live-optionally-install-eject.patch @@ -0,0 +1,22 @@ +From 34b22d6049e416c12f75e53bfc8a142024751d0e Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 17:49:29 +0200 +Subject: [PATCH] 90dmsquash-live: optionally install eject + +--- + modules.d/90dmsquash-live/module-setup.sh | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh +index e1a8996..8ed633f 100755 +--- a/modules.d/90dmsquash-live/module-setup.sh ++++ b/modules.d/90dmsquash-live/module-setup.sh +@@ -27,7 +27,7 @@ install() { + inst losetup + inst grep + +- dracut_install eject ++ dracut_install -o eject + + inst blockdev + type -P checkisomd5 >/dev/null && inst checkisomd5 diff --git a/0006-enable-shutdown-module-by-default.patch b/0006-enable-shutdown-module-by-default.patch new file mode 100644 index 0000000..cc1784e --- /dev/null +++ b/0006-enable-shutdown-module-by-default.patch @@ -0,0 +1,35 @@ +From 2560da6be28e244ddf5c84ab3ada69c1dfacc796 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 19:04:54 +0200 +Subject: [PATCH] enable shutdown module by default + +--- + dracut.conf.d/fedora.conf.example | 2 +- + modules.d/99shutdown/module-setup.sh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/dracut.conf.d/fedora.conf.example b/dracut.conf.d/fedora.conf.example +index 8ca67d4..eddbf0f 100644 +--- a/dracut.conf.d/fedora.conf.example ++++ b/dracut.conf.d/fedora.conf.example +@@ -2,6 +2,6 @@ + + # i18n + i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP" +-add_dracutmodules+=" rpmversion shutdown " ++add_dracutmodules+=" rpmversion " + stdloglvl=3 + prefix=/run/initramfs +diff --git a/modules.d/99shutdown/module-setup.sh b/modules.d/99shutdown/module-setup.sh +index c4d2bb5..ae402ef 100755 +--- a/modules.d/99shutdown/module-setup.sh ++++ b/modules.d/99shutdown/module-setup.sh +@@ -3,7 +3,7 @@ + # ex: ts=8 sw=4 sts=4 et filetype=sh + + check() { +- return 255 ++ return 0 + } + + depends() { diff --git a/0007-90dm-dm-shutdown.sh-put-shutdown-in-function.patch b/0007-90dm-dm-shutdown.sh-put-shutdown-in-function.patch new file mode 100644 index 0000000..1193bda --- /dev/null +++ b/0007-90dm-dm-shutdown.sh-put-shutdown-in-function.patch @@ -0,0 +1,31 @@ +From 4456861f7edc8861a32bdd8ca3d3e49f602837e8 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 19:06:08 +0200 +Subject: [PATCH] 90dm/dm-shutdown.sh: put shutdown in function + +--- + modules.d/90dm/dm-shutdown.sh | 17 +++++++++++++++-- + 1 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/modules.d/90dm/dm-shutdown.sh b/modules.d/90dm/dm-shutdown.sh +index 026eb26..3e668f8 100644 +--- a/modules.d/90dm/dm-shutdown.sh ++++ b/modules.d/90dm/dm-shutdown.sh +@@ -1,2 +1,15 @@ +-echo "Disassembling device-mapper devices" +-dmsetup -v remove_all ++#!/bin/sh ++# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- ++# ex: ts=8 sw=4 sts=4 et filetype=sh ++_do_dm_shutdown() { ++ local ret ++ info "Disassembling device-mapper devices" ++ dmsetup -v remove_all ++ ret=$? ++#info "dmsetup ls --tree" ++#dmsetup ls --tree 2>&1 | vinfo ++ return $ret ++} ++ ++_do_dm_shutdown ++ diff --git a/0008-90mdraid-md-shutdown.sh-put-shutdown-in-function.patch b/0008-90mdraid-md-shutdown.sh-put-shutdown-in-function.patch new file mode 100644 index 0000000..cf046c2 --- /dev/null +++ b/0008-90mdraid-md-shutdown.sh-put-shutdown-in-function.patch @@ -0,0 +1,30 @@ +From 8e448cadf9fe979ac951b3ca6b5d3a5eecc150c2 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 19:06:26 +0200 +Subject: [PATCH] 90mdraid/md-shutdown.sh: put shutdown in function + +--- + modules.d/90mdraid/md-shutdown.sh | 16 ++++++++++++++-- + 1 files changed, 14 insertions(+), 2 deletions(-) + +diff --git a/modules.d/90mdraid/md-shutdown.sh b/modules.d/90mdraid/md-shutdown.sh +index f07f621..aa89bf6 100644 +--- a/modules.d/90mdraid/md-shutdown.sh ++++ b/modules.d/90mdraid/md-shutdown.sh +@@ -1,2 +1,14 @@ +-echo "Disassembling mdraid devices." +-mdadm -v --stop --scan ++#!/bin/sh ++# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- ++# ex: ts=8 sw=4 sts=4 et filetype=sh ++_do_md_shutdown() { ++ local ret ++ info "Disassembling mdraid devices." ++ mdadm -v --stop --scan ++ ret=$? ++#info "cat /proc/mdstat" ++# cat /proc/mdstat | vinfo ++ return $ret ++} ++ ++_do_md_shutdown diff --git a/0009-TEST-10-RAID-extend-test-case-to-shutdown.patch b/0009-TEST-10-RAID-extend-test-case-to-shutdown.patch new file mode 100644 index 0000000..20937be --- /dev/null +++ b/0009-TEST-10-RAID-extend-test-case-to-shutdown.patch @@ -0,0 +1,99 @@ +From ceaf49d735b2395897253ae05f6a3b55e09eb252 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 19:08:25 +0200 +Subject: [PATCH] TEST-10-RAID: extend test case to shutdown + +--- + test/TEST-10-RAID/test-init | 13 +++++++++++-- + test/TEST-10-RAID/test.sh | 17 +++++++++-------- + 2 files changed, 20 insertions(+), 10 deletions(-) + +diff --git a/test/TEST-10-RAID/test-init b/test/TEST-10-RAID/test-init +index 8f7cdf3..029084a 100755 +--- a/test/TEST-10-RAID/test-init ++++ b/test/TEST-10-RAID/test-init +@@ -1,11 +1,20 @@ + #!/bin/sh + export PATH=/sbin:/bin:/usr/sbin:/usr/bin ++strstr() { [ "${1#*$2*}" != "$1" ]; } ++CMDLINE=$(while read line; do echo $line;done < /proc/cmdline) ++plymouth --quit + exec >/dev/console 2>&1 + echo "dracut-root-block-success" >/dev/sda1 + export TERM=linux + export PS1='initramfs-test:\w\$ ' +-[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab ++[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab ++[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab + stty sane +-echo "made it to the rootfs! Powering down." ++echo "made it to the rootfs!" ++strstr "$CMDLINE" "rd.shell" && sh -i ++echo "Powering down." + mount -n -o remount,ro / ++if [ -e /lib/systemd/systemd-shutdown ]; then ++ exec /lib/systemd/systemd-shutdown poweroff ++fi + poweroff -f +diff --git a/test/TEST-10-RAID/test.sh b/test/TEST-10-RAID/test.sh +index 0b3fc0c..fe95437 100755 +--- a/test/TEST-10-RAID/test.sh ++++ b/test/TEST-10-RAID/test.sh +@@ -5,18 +5,18 @@ KVERSION=${KVERSION-$(uname -r)} + + # Uncomment this to debug failures + #DEBUGFAIL="rd.shell" +- ++DISKIMAGE=/var/tmp/TEST-10-RAID-root.img + test_run() { +- $testdir/run-qemu -hda root.ext2 -m 256M -nographic \ ++ $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic \ + -net none -kernel /boot/vmlinuz-$KVERSION \ + -append "root=/dev/dracut/root rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \ + -initrd initramfs.testing +- grep -m 1 -q dracut-root-block-success root.ext2 || return 1 ++ grep -m 1 -q dracut-root-block-success $DISKIMAGE || return 1 + } + + test_setup() { + # Create the blank file to use as a root filesystem +- dd if=/dev/zero of=root.ext2 bs=1M count=40 ++ dd if=/dev/null of=$DISKIMAGE bs=1M seek=40 + + kernel=$KVERSION + # Create what will eventually be our root filesystem onto an overlay +@@ -28,9 +28,10 @@ test_setup() { + inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script" + inst "$basedir/modules.d/40network/ifup" "/sbin/ifup" + dracut_install grep ++ dracut_install /lib/systemd/systemd-shutdown + inst ./test-init /sbin/init + find_binary plymouth >/dev/null && dracut_install plymouth +- (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp ) ++ (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp run) + cp -a /etc/ld.so.conf* $initdir/etc + sudo ldconfig -r "$initdir" + ) +@@ -54,11 +55,11 @@ test_setup() { + -f initramfs.makeroot $KVERSION || return 1 + rm -rf overlay + # Invoke KVM and/or QEMU to actually create the target filesystem. +- $testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \ ++ $testdir/run-qemu -hda $DISKIMAGE -m 256M -nographic -net none \ + -kernel "/boot/vmlinuz-$kernel" \ + -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \ + -initrd initramfs.makeroot || return 1 +- grep -m 1 -q dracut-root-block-created root.ext2 || return 1 ++ grep -m 1 -q dracut-root-block-created $DISKIMAGE || return 1 + ( + initdir=overlay + . $basedir/dracut-functions +@@ -76,7 +77,7 @@ test_setup() { + + test_cleanup() { + rm -fr overlay mnt +- rm -f root.ext2 initramfs.makeroot initramfs.testing ++ rm -f $DISKIMAGE initramfs.makeroot initramfs.testing + } + + . $testdir/test-functions diff --git a/0010-TEST-10-RAID-test-init-turn-off-debug-for-shutdown.patch b/0010-TEST-10-RAID-test-init-turn-off-debug-for-shutdown.patch new file mode 100644 index 0000000..76f00a9 --- /dev/null +++ b/0010-TEST-10-RAID-test-init-turn-off-debug-for-shutdown.patch @@ -0,0 +1,21 @@ +From 00d89f51701a89543c67715beedc70b903244f08 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 21:10:58 +0200 +Subject: [PATCH] TEST-10-RAID/test-init: turn off debug for shutdown + +--- + test/TEST-10-RAID/test-init | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/test/TEST-10-RAID/test-init b/test/TEST-10-RAID/test-init +index 029084a..4c8c9e1 100755 +--- a/test/TEST-10-RAID/test-init ++++ b/test/TEST-10-RAID/test-init +@@ -14,6 +14,7 @@ echo "made it to the rootfs!" + strstr "$CMDLINE" "rd.shell" && sh -i + echo "Powering down." + mount -n -o remount,ro / ++echo " rd.debug=0 " > /run/initramfs/etc/cmdline + if [ -e /lib/systemd/systemd-shutdown ]; then + exec /lib/systemd/systemd-shutdown poweroff + fi diff --git a/0011-shutdown-fixed-check_shutdown-loop.patch b/0011-shutdown-fixed-check_shutdown-loop.patch new file mode 100644 index 0000000..c723f0d --- /dev/null +++ b/0011-shutdown-fixed-check_shutdown-loop.patch @@ -0,0 +1,98 @@ +From f47e0234987e7e6cfb2439e90658cb5c3b8bdef8 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 21:11:36 +0200 +Subject: [PATCH] shutdown: fixed check_shutdown loop + +--- + modules.d/90dm/dm-shutdown.sh | 11 ++++++----- + modules.d/90mdraid/md-shutdown.sh | 9 ++++++--- + modules.d/99shutdown/shutdown | 24 ++++++++++++++---------- + 3 files changed, 26 insertions(+), 18 deletions(-) + +diff --git a/modules.d/90dm/dm-shutdown.sh b/modules.d/90dm/dm-shutdown.sh +index 3e668f8..80d80d0 100644 +--- a/modules.d/90dm/dm-shutdown.sh ++++ b/modules.d/90dm/dm-shutdown.sh +@@ -3,13 +3,14 @@ + # ex: ts=8 sw=4 sts=4 et filetype=sh + _do_dm_shutdown() { + local ret ++ local final=$1 + info "Disassembling device-mapper devices" + dmsetup -v remove_all + ret=$? +-#info "dmsetup ls --tree" +-#dmsetup ls --tree 2>&1 | vinfo ++ if [ "x$final" != "x" ]; then ++ info "dmsetup ls --tree" ++ dmsetup ls --tree 2>&1 | vinfo ++ fi + return $ret + } +- +-_do_dm_shutdown +- ++_do_dm_shutdown $1 +diff --git a/modules.d/90mdraid/md-shutdown.sh b/modules.d/90mdraid/md-shutdown.sh +index aa89bf6..bc36166 100644 +--- a/modules.d/90mdraid/md-shutdown.sh ++++ b/modules.d/90mdraid/md-shutdown.sh +@@ -3,12 +3,15 @@ + # ex: ts=8 sw=4 sts=4 et filetype=sh + _do_md_shutdown() { + local ret ++ local final=$1 + info "Disassembling mdraid devices." + mdadm -v --stop --scan + ret=$? +-#info "cat /proc/mdstat" +-# cat /proc/mdstat | vinfo ++ if [ "x$final" != "x" ]; then ++ info "cat /proc/mdstat" ++ cat /proc/mdstat | vinfo ++ fi + return $ret + } + +-_do_md_shutdown ++_do_md_shutdown $1 +diff --git a/modules.d/99shutdown/shutdown b/modules.d/99shutdown/shutdown +index bff29b9..a31a95d 100755 +--- a/modules.d/99shutdown/shutdown ++++ b/modules.d/99shutdown/shutdown +@@ -64,21 +64,25 @@ while [ $_cnt -le 40 ]; do + done + [ $_cnt -ge 40 ] && umount_a + +-check_finished() { +- local f +- for f in $hookdir/shutdown/*.sh; do +- [ -e "$f" ] || continue +- ( . "$f" ) || return 1 ++_check_shutdown() { ++ local __f ++ local __s=1 ++ for __f in $hookdir/shutdown/*.sh; do ++ [ -e "$__f" ] || continue ++ ( . "$__f" $1 ) ++ if [ $? -eq 0 ]; then ++ rm -f $__f ++ __s=0 ++ fi + done +- return 0 ++ return $__s + } + + _cnt=0 +-while [ $_cnt -le 40 ]; do +- check_finished 2>/dev/null && break +- _cnt=$(($_cnt+1)) ++while _check_shutdown; do ++: + done +-[ $_cnt -ge 40 ] && check_finished ++_check_shutdown final + + getarg 'rd.break=shutdown' && emergency_shell -n cmdline "Break before shutdown" + [ "$1" = "reboot" ] && reboot -f -d -n --no-wall diff --git a/0012-dracut-lib.sh-fixed-getargs.patch b/0012-dracut-lib.sh-fixed-getargs.patch new file mode 100644 index 0000000..7f9cfc2 --- /dev/null +++ b/0012-dracut-lib.sh-fixed-getargs.patch @@ -0,0 +1,73 @@ +From 9e7f4955895c1064e3bdd03f5f781efc9b98d5d6 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 21:12:17 +0200 +Subject: [PATCH] dracut-lib.sh: fixed getargs() + +if $1 has a "=", we want the exact match +if cmdline argument has no "=", we assume "=1" +--- + modules.d/99base/dracut-lib.sh | 31 ++++++++++++++++++++++++------- + 1 files changed, 24 insertions(+), 7 deletions(-) + +diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh +index 10025bd..c2202f1 100755 +--- a/modules.d/99base/dracut-lib.sh ++++ b/modules.d/99base/dracut-lib.sh +@@ -45,19 +45,36 @@ _getcmdline() { + } + + _dogetarg() { +- local _o _val ++ local _o _val _doecho + unset _val + unset _o ++ unset _doecho + _getcmdline + + for _o in $CMDLINE; do +- if [ "$_o" = "$1" ]; then +- return 0; ++ if [ "${_o%%=*}" = "${1%=}" ]; then ++ if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then ++ # if $1 has a "=", we want the exact match ++ if [ "$_o" = "$1" ]; then ++ _val="1"; ++ unset _doecho ++ fi ++ continue ++ fi ++ ++ if [ "${_o#*=}" = "$_o" ]; then ++ # if cmdline argument has no "=", we assume "=1" ++ _val="1"; ++ unset _doecho ++ continue ++ fi ++ ++ _val=${_o#*=}; ++ _doecho=1 + fi +- [ "${_o%%=*}" = "${1%=}" ] && _val=${_o#*=}; + done + if [ -n "$_val" ]; then +- echo $_val; ++ [ "x$_doecho" != "x" ] && echo $_val; + return 0; + fi + return 1; +@@ -67,13 +84,13 @@ getarg() { + set +x + while [ $# -gt 0 ]; do + case $1 in +- -y) if _dogetarg $2; then ++ -y) if _dogetarg $2 >/dev/null; then + echo 1 + [ "$RD_DEBUG" = "yes" ] && set -x + return 0 + fi + shift 2;; +- -n) if _dogetarg $2; then ++ -n) if _dogetarg $2 >/dev/null; then + echo 0; + [ "$RD_DEBUG" = "yes" ] && set -x + return 1 diff --git a/0013-99base-dracut-lib.sh-fix-previous-getargs-patch.patch b/0013-99base-dracut-lib.sh-fix-previous-getargs-patch.patch new file mode 100644 index 0000000..487ec9b --- /dev/null +++ b/0013-99base-dracut-lib.sh-fix-previous-getargs-patch.patch @@ -0,0 +1,24 @@ +From b1b678427e0a158487a2a3ef5a1be39f891a1cc3 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 21:38:07 +0200 +Subject: [PATCH] 99base/dracut-lib.sh: fix previous getargs patch + +patch 9e7f4955895c1064e3bdd03f5f781efc9b98d5d6 ignored +"getargs key=value" +--- + modules.d/99base/dracut-lib.sh | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh +index c2202f1..6807b53 100755 +--- a/modules.d/99base/dracut-lib.sh ++++ b/modules.d/99base/dracut-lib.sh +@@ -52,7 +52,7 @@ _dogetarg() { + _getcmdline + + for _o in $CMDLINE; do +- if [ "${_o%%=*}" = "${1%=}" ]; then ++ if [ "${_o%%=*}" = "${1%%=*}" ]; then + if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then + # if $1 has a "=", we want the exact match + if [ "$_o" = "$1" ]; then diff --git a/0014-TEST-10-RAID-test-init-add-comment-for-rd.break-shut.patch b/0014-TEST-10-RAID-test-init-add-comment-for-rd.break-shut.patch new file mode 100644 index 0000000..ddf8f97 --- /dev/null +++ b/0014-TEST-10-RAID-test-init-add-comment-for-rd.break-shut.patch @@ -0,0 +1,23 @@ +From 8570b544e96d150263c639b9411270488a95ad2b Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Wed, 20 Jul 2011 21:40:50 +0200 +Subject: [PATCH] TEST-10-RAID/test-init: add comment for rd.break=shutdown + +--- + test/TEST-10-RAID/test-init | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/test/TEST-10-RAID/test-init b/test/TEST-10-RAID/test-init +index 4c8c9e1..02c0d1d 100755 +--- a/test/TEST-10-RAID/test-init ++++ b/test/TEST-10-RAID/test-init +@@ -14,7 +14,8 @@ echo "made it to the rootfs!" + strstr "$CMDLINE" "rd.shell" && sh -i + echo "Powering down." + mount -n -o remount,ro / +-echo " rd.debug=0 " > /run/initramfs/etc/cmdline ++#echo " rd.break=shutdown " >> /run/initramfs/etc/cmdline ++echo " rd.debug=0 " >> /run/initramfs/etc/cmdline + if [ -e /lib/systemd/systemd-shutdown ]; then + exec /lib/systemd/systemd-shutdown poweroff + fi diff --git a/dracut.spec b/dracut.spec index 7a11602..4638b23 100644 --- a/dracut.spec +++ b/dracut.spec @@ -8,7 +8,7 @@ Name: dracut Version: 011 -Release: 1 +Release: 15.git20110720 Summary: Initramfs generator using udev %if 0%{?fedora} @@ -22,6 +22,20 @@ URL: https://dracut.wiki.kernel.org/ # Source can be generated by # http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2 +Patch1: 0001-dracut.spec-remove-noreplace-for-01-dist.conf.patch +Patch2: 0002-add-TEST-15-BTRFSRAID.patch +Patch3: 0003-dracut.logrotate-remove-yearly.patch +Patch4: 0004-dracut-logger-create-logfile-with-0600-permissions.patch +Patch5: 0005-90dmsquash-live-optionally-install-eject.patch +Patch6: 0006-enable-shutdown-module-by-default.patch +Patch7: 0007-90dm-dm-shutdown.sh-put-shutdown-in-function.patch +Patch8: 0008-90mdraid-md-shutdown.sh-put-shutdown-in-function.patch +Patch9: 0009-TEST-10-RAID-extend-test-case-to-shutdown.patch +Patch10: 0010-TEST-10-RAID-test-init-turn-off-debug-for-shutdown.patch +Patch11: 0011-shutdown-fixed-check_shutdown-loop.patch +Patch12: 0012-dracut-lib.sh-fixed-getargs.patch +Patch13: 0013-99base-dracut-lib.sh-fix-previous-getargs-patch.patch +Patch14: 0014-TEST-10-RAID-test-init-add-comment-for-rd.break-shut.patch BuildArch: noarch @@ -156,6 +170,20 @@ This package contains tools to assemble the local initrd and host configuration. %prep %setup -q -n %{name}-%{version} +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 %build @@ -217,7 +245,7 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/dracut/dracut-logger %config(noreplace) /etc/dracut.conf %if 0%{?fedora} || 0%{?suse_version} -%config(noreplace) /etc/dracut.conf.d/01-dist.conf +%config /etc/dracut.conf.d/01-dist.conf %endif %dir /etc/dracut.conf.d %{_mandir}/man8/dracut.8* @@ -290,6 +318,10 @@ rm -rf $RPM_BUILD_ROOT %dir /var/lib/dracut/overlay %changelog +* Wed Jul 20 2011 Harald Hoyer 011-15.git20110720 +- "eject" is optional now +- refined shutdown procedure + * Mon Jul 18 2011 Harald Hoyer 011-1 - version 011