diff options
Diffstat (limited to 'sys-boot/myinitramfs/files/gen.sh')
-rwxr-xr-x | sys-boot/myinitramfs/files/gen.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/sys-boot/myinitramfs/files/gen.sh b/sys-boot/myinitramfs/files/gen.sh new file mode 100755 index 0000000..3341d93 --- /dev/null +++ b/sys-boot/myinitramfs/files/gen.sh @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +OUT="$(readlink -f "$1")" +shift + +cd "$(dirname "$(readlink -f "$0")")" + +INIT="./init.plain" + +while [ $# -gt 0 ]; do + case "$1" in + encrypted) + INIT="./init.enc" + ;; + esac + shift +done + +LIST="$(mktemp)" + +# Base list +cp baselist "$LIST" +# Init script +echo "file /init $INIT 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 <exelist + +# Print current list +cat "$LIST" + +# Buld initramfs +CPIO="$(mktemp)" +gen_init_cpio "$LIST" > "$CPIO" +gzip "$CPIO" +mv "$CPIO.gz" "$OUT" + +# Cleaup +rm "$LIST" |