summaryrefslogtreecommitdiff
path: root/sys-boot/myinitramfs/files/gen.sh
blob: b633731d52efed61dd2a1a9c16211e071e8bb15d (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
#!/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 <exelist

# Print current list
cat "$LIST"

# Buld initramfs
CPIO="$(mktemp)"
gen_init_cpio "$LIST" > "$CPIO"
gzip "$CPIO"
mv "$CPIO.gz" "$OUT"

# Cleaup
rm "$LIST"