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