3 # Enable xtrace with timestamp
4 export PS4
='$(date "+%H:%M:%S.%3N") '
9 prereqs
() { echo "$PREREQS"; }
20 option
="$(tr ' ' '\n' < /proc/cmdline | grep '^early_patch\b')"
22 [ -n "$option" ] ||
exit 0
29 for mod
in fscache
9pnet
9pnet_virtio
9p
; do
30 modprobe
-vvv -d /root
/ $mod
33 mkdir
-p "$MOUNTPOINT"
34 mount
-t 9p src
"$MOUNTPOINT"
35 "${MOUNTPOINT}/hook" /root
37 # early_patch=umount will umount the filesystem immediately after running the hook
38 # this is needed to have early_patch in the test suite.
39 # In fact, qemu cannot do snapshots while this is mounted
40 if echo "$option" |
grep -qw umount
; then
46 # Make plymouth write the log to /root/var/log/boot.log
47 /bin
/plymouth update-root-fs
--new-root-dir=/root
--read-write
48 # Stop plymouth, so that the user can see the shell
49 /bin
/plymouth quit || true
51 # Disable xtrace to make the following output more readable
53 echo -e >&2 "\nThe early_patch hook failed. Spawning a shell to allow debugging..."
54 echo >&2 "The log is in /root/var/log/boot.log"
55 echo >&2 "Press Ctrl-D to continue booting."
57 # Call panic from /usr/share/initramfs-tools/scripts/functions to
58 # spawn a shell. Note that panic does not work if set -e is active.
63 # This is necessary to have `set -e` work in the `run` function, see
64 # https://stackoverflow.com/a/11092989/2804197
68 if [ "$ret" -ne 0 ]; then