]> git.proxmox.com Git - proxmox-backup-restore-image.git/blame - src/build_initramfs.sh
add debug initramfs as seperate package
[proxmox-backup-restore-image.git] / src / build_initramfs.sh
CommitLineData
3b259e7a
SR
1#!/bin/sh
2
3set -e
4
5ROOT="root"
6BUILDDIR="build/initramfs"
7INIT="../../init-shim-rs/target/release/init-shim-rs"
8
3b259e7a
SR
9echo "Using build dir: $BUILDDIR"
10rm -rf "$BUILDDIR"
11mkdir -p "$BUILDDIR"
12cd "$BUILDDIR"
13mkdir "$ROOT"
14
2a1ef81f
SR
15# adds necessary packages to initramfs build root folder
16add_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
33make_cpio() {
34 fakeroot -- sh -c "
35 cd '$ROOT';
36 find . -print0 | cpio --null -oV --format=newc -F ../$1
37 "
38}
3b259e7a
SR
39
40cp $INIT "$ROOT/init"
41chmod a+x "$ROOT/init" # just to be sure
42
43# tell daemon it's running in the correct environment
44touch "$ROOT/restore-vm-marker"
45
2a1ef81f
SR
46add_pkgs "
47 libstdc++6:amd64 \
48 libssl1.1:amd64 \
49 libacl1:amd64 \
50"
51rm -rf ${ROOT:?}/usr/share # contains only docs and debian stuff
52make_cpio "initramfs.img"
53
54# add debug helpers for debug initramfs, packages from above are included too
55add_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
61make_cpio "initramfs-debug.img"