#!/bin/sh # TODO: check samizdat source to see what it copies [ "$1" = prereqs ] && { echo; exit; } 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 "$@"; } . /usr/share/initramfs-tools/hook-functions PATH=/usr/local/lib/samizdat-rhizome/initrd:/usr/local/bin:$PATH . samizdat-paths.sh repo_execs=$(echo "${samizdat_initrd_files_dir}"/*) path_execs=' mountpoint openvt rsync gpg2 pinentry-curses truncate dmsetup dmstats cryptsetup mkfs.btrfs btrfs fsck.hfsplus wait_for_files samizdat-pinentry dynmenu samizdat-password-agent samizdat-gpg-agent parted fallocate strace btrfstune sfdisk ' graft_paths=" /bin/OpenVT=/bin/openvt /bin/LoSetup=/sbin/losetup /patchroot/patchroot.sh=${samizdat_initrd_files_dir}/patchroot.sh /patchroot/sources.list=/etc/apt/sources.list /patchroot/initrd-dependencies.txt=${samizdat_initrd_files_dir}/initrd-dependencies.txt /lib/samizdat/vol_id.txt=${samizdat_initrd_files_dir}/vol_id.txt " absolute_path_copies='/lib/terminfo/l/linux /usr/bin/gpg-agent' modules='loop dm-snapshot dm-crypt btrfs hfs hfsplus' modules_dirs='kernel/drivers/net/ethernet kernel/fs/nls kernel/crypto' for f in $repo_execs; 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