]>
Commit | Line | Data |
---|---|---|
3b259e7a SR |
1 | #!/bin/sh |
2 | ||
3 | set -e | |
4 | ||
5 | ROOT="root" | |
6 | BUILDDIR="build/initramfs" | |
7 | INIT="../../init-shim-rs/target/release/init-shim-rs" | |
8 | ||
3b259e7a SR |
9 | echo "Using build dir: $BUILDDIR" |
10 | rm -rf "$BUILDDIR" | |
11 | mkdir -p "$BUILDDIR" | |
12 | cd "$BUILDDIR" | |
13 | mkdir "$ROOT" | |
14 | ||
2a1ef81f SR |
15 | # adds necessary packages to initramfs build root folder |
16 | add_pkgs() { | |
17 | DEPS="" | |
18 | for pkg in $1; do | |
19 | LOCAL_DEPS=$(apt-rdepends -f Depends -s Depends "$pkg" | grep -v '^ ') | |
20 | DEPS="$DEPS $LOCAL_DEPS" | |
21 | done | |
22 | # debconf and gcc are unnecessary | |
23 | DEPS=$(echo "$DEPS" |\ | |
24 | sed -E 's/debconf(-2\.0)?//' |\ | |
25 | sed -E 's/gcc-.{1,2}-base//') | |
26 | apt-get download $DEPS | |
27 | for deb in ./*.deb; do | |
28 | dpkg-deb -x "$deb" "$ROOT" | |
29 | done | |
3b259e7a | 30 | rm ./*.deb |
2a1ef81f | 31 | } |
3b259e7a | 32 | |
2a1ef81f SR |
33 | make_cpio() { |
34 | fakeroot -- sh -c " | |
35 | cd '$ROOT'; | |
36 | find . -print0 | cpio --null -oV --format=newc -F ../$1 | |
37 | " | |
38 | } | |
3b259e7a SR |
39 | |
40 | cp $INIT "$ROOT/init" | |
41 | chmod a+x "$ROOT/init" # just to be sure | |
42 | ||
43 | # tell daemon it's running in the correct environment | |
44 | touch "$ROOT/restore-vm-marker" | |
45 | ||
2a1ef81f SR |
46 | add_pkgs " |
47 | libstdc++6:amd64 \ | |
48 | libssl1.1:amd64 \ | |
49 | libacl1:amd64 \ | |
50 | " | |
51 | rm -rf ${ROOT:?}/usr/share # contains only docs and debian stuff | |
52 | make_cpio "initramfs.img" | |
53 | ||
54 | # add debug helpers for debug initramfs, packages from above are included too | |
55 | add_pkgs " | |
56 | util-linux:amd64 \ | |
57 | busybox-static:amd64 \ | |
58 | gdb:amd64 \ | |
3b259e7a | 59 | " |
2a1ef81f SR |
60 | # leave /usr/share here, it contains necessary stuff for gdb |
61 | make_cpio "initramfs-debug.img" |