#!/bin/sh set -e OUT="$(readlink -f "$1")" shift cd "$(dirname "$(readlink -f "$0")")" LIST="$(mktemp)" add_exec() { P="$(which "$1")" echo "# $EXE" >> "$LIST" echo "file $P $P 755 0 0" >> "$LIST" ldd "$P" | awk '{ print $3 }' | sed -n '/^[^ ]\+$/p' | while read -r LIB; do echo "file $LIB $LIB 755 0 0" >> "$LIST" done } # Base list cp baselist "$LIST" # Init script echo "file /init ./init.enc 755 0 0" >> "$LIST" echo >> "$LIST" # Executables required when USE_DMI if [ -n "$USE_DMI" ]; then echo "file /sbin/initramfs_password ./initramfs_password 755 0 0" >> "$LIST" add_exec dmidecode fi # Executables while read -r EXE; do add_exec "$EXE" done "$CPIO" gzip "$CPIO" mv "$CPIO.gz" "$OUT" # Cleaup rm "$LIST"