diff -Nru finalrd-3~ubuntu18.04.0/debian/changelog finalrd-6~ubuntu18.04.1/debian/changelog --- finalrd-3~ubuntu18.04.0/debian/changelog 2019-05-23 12:54:36.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/debian/changelog 2020-09-10 14:54:08.000000000 +0000 @@ -1,8 +1,30 @@ -finalrd (3~ubuntu18.04.0) bionic; urgency=medium +finalrd (6~ubuntu18.04.1) bionic; urgency=medium - * Backport finalrd to bionic. LP: #1830211 + * No-change backport to bionic (LP: #1895160) - -- Dimitri John Ledkov Thu, 23 May 2019 13:54:36 +0100 + -- Dimitri John Ledkov Thu, 10 Sep 2020 15:54:08 +0100 + +finalrd (6) groovy; urgency=medium + + * xenial compat - ensure directories exist before using them + * Change packaging to be compatible with debhelper 9 + * Update code name to 6 + + -- Dimitri John Ledkov Fri, 28 Aug 2020 17:02:09 +0100 + +finalrd (5) focal; urgency=medium + + * Introduce hookless mode + * Update initrd-release file to Five Man Alive + + -- Dimitri John Ledkov Wed, 18 Dec 2019 13:42:32 +0000 + +finalrd (4) eoan; urgency=medium + + * Set and export `verbose' variable for initramfs-tools, otherwise, + finalrd fails to create shutdown initrd, resulting in shutdown hangs. + + -- Dimitri John Ledkov Mon, 30 Sep 2019 18:43:22 +0100 finalrd (3) cosmic; urgency=medium diff -Nru finalrd-3~ubuntu18.04.0/debian/compat finalrd-6~ubuntu18.04.1/debian/compat --- finalrd-3~ubuntu18.04.0/debian/compat 2018-06-21 09:50:00.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/debian/compat 2020-08-28 15:57:34.000000000 +0000 @@ -1 +1 @@ -11 +9 diff -Nru finalrd-3~ubuntu18.04.0/debian/control finalrd-6~ubuntu18.04.1/debian/control --- finalrd-3~ubuntu18.04.0/debian/control 2018-08-03 14:07:01.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/debian/control 2020-08-28 15:57:34.000000000 +0000 @@ -2,7 +2,7 @@ Section: utils Priority: optional Maintainer: Dimitri John Ledkov -Build-Depends: debhelper (>= 11) +Build-Depends: debhelper (>= 9), dh-systemd Standards-Version: 4.1.2 Homepage: https://launchpad.net/finalrd Vcs-Git: https://git.launchpad.net/finalrd @@ -10,10 +10,12 @@ Package: finalrd Architecture: all -Depends: initramfs-tools-core, ${misc:Depends} +Depends: ${misc:Depends} +Recommends: initramfs-tools-core Description: final runtime directory for shutdown Generates a systemd compatible shutdown runtime directory. This - enables to execute scripts and binaries to clean up shutdown. Sample - hooks and shutdown scripts are provided to unmount filesystems, - dissamble dm, cleanly shutdown mdadm raid arrays, and perform iscsi - logout. Approximate tmpfs RAM requirement is 14MB on shutdown. + enables to execute scripts and binaries to clean up shutdown. + . + Also supports hookless operation, to simply facilitate clean shutdowns. + . + Approximate tmpfs RAM requirement is 14MB on shutdown. diff -Nru finalrd-3~ubuntu18.04.0/debian/rules finalrd-6~ubuntu18.04.1/debian/rules --- finalrd-3~ubuntu18.04.0/debian/rules 2018-06-21 09:50:00.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/debian/rules 2020-08-28 16:02:09.000000000 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/make -f %: - dh $@ + dh $@ --with systemd -override_dh_installsystemd: - dh_installsystemd --no-stop-on-upgrade --no-restart-after-upgrade +override_dh_systemd_start: + dh_systemd_start --no-restart-on-upgrade diff -Nru finalrd-3~ubuntu18.04.0/finalrd.pod finalrd-6~ubuntu18.04.1/finalrd.pod --- finalrd-3~ubuntu18.04.0/finalrd.pod 2018-06-21 09:53:18.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/finalrd.pod 2020-08-28 15:57:34.000000000 +0000 @@ -34,6 +34,16 @@ B. This would execute B generator late in the shutdown cycle, just in time for pivot. +=head1 HOOKLESS OPERATION + +If initramfs-tools is not available, and thus copy_exec is not +available, hooks will not be executed or copied into the shutdown +directory. However, shutdown dir will still be created to ensure init +has somewhere to pivot, and attempt a cleaner shutdown without holding +up the root filesystem. + +For example, Ubuntu Core is such system. + =head1 HOOKS INTERFACE DESCRIPTION I<*.finalrd> hooks can be shipped in I, I, I. These diff -Nru finalrd-3~ubuntu18.04.0/finalrd-ratelimit.conf finalrd-6~ubuntu18.04.1/finalrd-ratelimit.conf --- finalrd-3~ubuntu18.04.0/finalrd-ratelimit.conf 1970-01-01 00:00:00.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/finalrd-ratelimit.conf 2020-08-28 15:57:34.000000000 +0000 @@ -0,0 +1,2 @@ +[Journal] +RateLimitIntervalSec=0 diff -Nru finalrd-3~ubuntu18.04.0/finalrd-rebootspeed.sh finalrd-6~ubuntu18.04.1/finalrd-rebootspeed.sh --- finalrd-3~ubuntu18.04.0/finalrd-rebootspeed.sh 1970-01-01 00:00:00.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/finalrd-rebootspeed.sh 2020-08-28 15:57:34.000000000 +0000 @@ -0,0 +1,41 @@ +#!/bin/sh + +reboot_id=-1 +json=no + +while [ $# -gt 0 ] +do + key="$1" + case $key in + -b|--boot) + reboot_id="$2" + shift + shift + ;; + --json) + json=yes + shift + esac +done + +newboot_id=$((reboot_id+1)) + +reboot_start=$(journalctl -q -b $reboot_id -o short-unix --no-pager -u systemd-logind SHUTDOWN=reboot | sed 's/ .*//') +if [ -z "$reboot_start" ] ; then + printf "No reboot marker was found, please reboot using:\n sudo dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Reboot boolean:false\n" >&2 + exit 1 +fi + +journal_end=$(journalctl -q -b $reboot_id -o short-unix --no-pager -u systemd-journald -r -n 1 | sed 's/ .*//') +boot_start=$(journalctl -q -b $newboot_id -o short-unix -k | head -n 1 | sed 's/ .*//') + + +tx_time=$(echo $journal_end - $reboot_start | bc) +void_time=$(echo $boot_start - $journal_end | bc) +reboot_time=$(echo $boot_start - $reboot_start | bc) + +if [ "$json" = "yes" ]; then + echo "{\"tx_time\": $tx_time, \"void_time\": $void_time, \"reboot_time\": $reboot_time}" +else + echo reboot $reboot_time = transaction $tx_time + void $void_time +fi diff -Nru finalrd-3~ubuntu18.04.0/finalrd.sh finalrd-6~ubuntu18.04.1/finalrd.sh --- finalrd-3~ubuntu18.04.0/finalrd.sh 2018-08-03 14:06:21.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/finalrd.sh 2020-08-28 15:57:34.000000000 +0000 @@ -7,6 +7,8 @@ export DESTDIR=/run/initramfs # for /usr/lib/dracut/dracut-install export DESTROOTDIR=$DESTDIR +# initramfs-tools now requires this to be set +export verbose=n # something already created shutdown initramfs # same check is done by e.g. dracut-shutdown @@ -19,31 +21,42 @@ # options mount -o remount,exec /run -# base dirs -mkdir -p $DESTDIR $DESTDIR/etc -for d in bin sbin lib lib64; do - mkdir -p $DESTDIR/usr/$d - ln -s usr/$d $DESTDIR/$d -done - -# required for in_initrd() systemd detection, part of shutdown -# spec/requirements this is equivalent to /etc/os-release -cat > $DESTDIR/etc/initrd-release <> /run/finalrd-libs.conf + if [ -L $lib ] + then + target=$(realpath -e $lib) + echo "C $DESTDIR$target - - - - $target" >> /run/finalrd-libs.conf + echo "L $DESTDIR$lib - - - - $(readlink $lib)" >> /run/finalrd-libs.conf + else + echo "C $DESTDIR$lib - - - - $lib" >> /run/finalrd-libs.conf + fi + done +done +systemd-tmpfiles --create /usr/lib/finalrd/finalrd-static.conf /run/finalrd-libs.conf + +### HOOKS SUPPORT ### +# Without initramfs-tools, hooks are not supported +[ -e /usr/share/initramfs-tools/hook-functions ] || exit 0 . /usr/share/initramfs-tools/hook-functions -copy_exec /lib/systemd/systemd-shutdown /shutdown -copy_exec /bin/sh for d in /usr/share/finalrd /etc/finalrd /run/finalrd do @@ -54,6 +67,4 @@ fi done -# copy ld configs, and rebuild cache -cp -Lr /etc/ld.so.conf* $DESTDIR/etc/ ldconfig -r $DESTDIR diff -Nru finalrd-3~ubuntu18.04.0/finalrd-static.conf finalrd-6~ubuntu18.04.1/finalrd-static.conf --- finalrd-3~ubuntu18.04.0/finalrd-static.conf 1970-01-01 00:00:00.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/finalrd-static.conf 2020-08-28 16:00:06.000000000 +0000 @@ -0,0 +1,17 @@ +d /run/initramfs/usr/bin +d /run/initramfs/usr/sbin +d /run/initramfs/usr/lib +d /run/initramfs/usr/lib64 +d /run/initramfs/etc +d /run/initramfs/usr/lib/systemd/system-shutdown +L /run/initramfs/bin - - - - usr/bin +L /run/initramfs/sbin - - - - usr/sbin +L /run/initramfs/lib - - - - usr/lib +L /run/initramfs/lib64 - - - - usr/lib64 +f /run/initramfs/etc/initrd-release - - - - NAME="FinalRD"\nVERSION="6"\nID=finalrd\nPRETTY_NAME="Final Runtime Directory Six - Half a dozen"\nVERSION_ID="6"\nVERSION_CODENAME=halfadozen\n +C /run/initramfs/shutdown - - - - /lib/systemd/systemd-shutdown +C /run/initramfs/usr/bin/dash - - - - /bin/dash +L /run/initramfs/usr/bin/sh - - - - dash +C /run/initramfs/etc/ld.so.conf - - - - /etc/ld.so.conf +C /run/initramfs/etc/ld.so.cache - - - - /etc/ld.so.cache +C /run/initramfs/etc/ld.so.conf.d - - - - /etc/ld.so.conf.d diff -Nru finalrd-3~ubuntu18.04.0/Makefile finalrd-6~ubuntu18.04.1/Makefile --- finalrd-3~ubuntu18.04.0/Makefile 2018-08-03 14:07:17.000000000 +0000 +++ finalrd-6~ubuntu18.04.1/Makefile 2020-08-28 15:57:34.000000000 +0000 @@ -3,11 +3,17 @@ check: dash -n *.sh +install-ratelimit: + mkdir -p $(DESTDIR)/usr/lib/systemd/journald.conf.d + cp finalrd-ratelimit.conf $(DESTDIR)/usr/lib/systemd/journald.conf.d/ + install: mkdir -p $(DESTDIR)/lib/systemd/system mkdir -p $(DESTDIR)/usr/share/finalrd mkdir -p $(DESTDIR)/usr/share/man/man1/ mkdir -p $(DESTDIR)/usr/bin/ + mkdir -p $(DESTDIR)/usr/lib/finalrd/ + cp finalrd-static.conf $(DESTDIR)/usr/lib/finalrd/ cp finalrd.sh $(DESTDIR)/usr/bin/finalrd cp *.service $(DESTDIR)/lib/systemd/system/ pod2man -u -c finalrd -r 'finalrd 2' -d '' finalrd.pod | gzip -9 > $(DESTDIR)/usr/share/man/man1/finalrd.1.gz