summaryrefslogtreecommitdiff
path: root/initramfs-tools/hooks/samizdat
blob: fb424e69080de13c1c56e718c06fe32ed52143d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
[ "$1" = prereqs ] && { echo; exit; }
. /usr/share/initramfs-tools/hook-functions

OUR_BINPATH=/usr/local/lib/samizdat/initrd/bin

# This insanity is necessary for initramfs-tools.
# TODO: File bug against initramfs-tools.
PATH=$OUR_BINPATH:$PATH

die() { printf 'Error: generating initramfs: %s\n' "$*" >&2; exit 1; }

CopyExec() { copy_exec "$@" || die "failed to copy_exec $*"; }
CopyExecE() { [ "$2" ] || die "cannot find binary to copy: $1"; shift; CopyExec "$@"; }

path_execs='
    mountpoint openvt rsync truncate dmsetup
    dmstats cryptsetup mkfs.btrfs btrfs fsck.hfsplus wait_for_files
    dynmenu parted fallocate strace btrfstune sfdisk
'

graft_paths="
    /bin/OpenVT=/bin/openvt
    /bin/LoSetup=/sbin/losetup
    /patchroot/patchroot.sh=${OUR_BINPATH}/patchroot.sh
"

absolute_path_copies='/lib/terminfo/l/linux'

modules='loop dm-snapshot dm-crypt btrfs hfs hfsplus'
modules_dirs='kernel/drivers/net/ethernet kernel/fs/nls kernel/crypto'

for f in "${OUR_BINPATH}"/*; do CopyExec "$f" /bin; done
for c in $path_execs; do
    s=$(which $c)
    CopyExecE "$c" "$s" /bin;
done
for f in $absolute_path_copies; do CopyExec "$f" "$f"; done
for m in $modules; do force_load "$m" || die "command failed: force_load $m"; done
for dir in $modules_dirs; do copy_modules_dir "$dir" || die "command failed: copy_modules_dir $dir"; done

for e in $graft_paths; do
    case "$e" in
        *=*) CopyExecE "graft_path $e" "${e#*=}" "${e%%=*}" ;;
        *) die "(BUG) invalid graft_path: $e" ;;
    esac
done

exit 0