Debian Codegraph @

debian/tests/remote-unlocking.d/initramfs-hook

raw
1 #!/bin/sh
2
3 # Copyright 2021 Guilhem Moulin <[email protected]>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in all
13 # copies or substantial portions of the Software.
14
15 PREREQ=""
16
17 prereqs() {
18 echo "$PREREQ"
19 }
20
21 case "$1" in
22 prereqs)
23 prereqs
24 exit 0
25 ;;
26 esac
27
28 . /usr/share/initramfs-tools/hook-functions
29 set -eu
30
31 copy_exec /sbin/sfdisk
32
33 # we'd like to run before busybox to ship GNU tar and mke2fs(8) from
34 # e2fsprogs instead, but we can't express reverse dependencies and
35 # copy_exe() is a no-op when the target exists, so we remove any
36 # pre-existing binaries from $DESTDIR before calling copy_exec() again
37 for exe in /bin/tar /sbin/mke2fs; do
38 rm -f -- "$DESTDIR$exe" "$DESTDIR/usr$exe"
39 copy_exec "$exe"
40 done
41
42 # copy the key file used to format and unlock the root FS so we can call
43 # `cryptsetup luksFormat` and `cryptsetup luksOpen` from the initrd
44 install -Dm0600 -- "$AUTOPKGTEST_TMP/rootfs.key" "$DESTDIR/cryptroot/rootfs.key"
45
46 exit 0