mirror of
https://git.proxmox.com/git/proxmox-backup-restore-image
synced 2025-05-30 00:13:30 +00:00
build initramfs: add options for pre-caching dependencies and allow using them
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
d7de479f9a
commit
f773602bd3
@ -9,44 +9,72 @@ INIT="../../init-shim-rs/target/x86_64-unknown-linux-gnu/release/init-shim-rs"
|
|||||||
echo "Using build dir: $BUILDDIR"
|
echo "Using build dir: $BUILDDIR"
|
||||||
rm -rf "$BUILDDIR"
|
rm -rf "$BUILDDIR"
|
||||||
mkdir -p "$BUILDDIR"
|
mkdir -p "$BUILDDIR"
|
||||||
|
if [ -d pkgs ]; then
|
||||||
|
echo "copying package cache into build-dir"
|
||||||
|
cp -a pkgs "$BUILDDIR/pkgs"
|
||||||
|
NO_DOWNLOAD="1"
|
||||||
|
fi
|
||||||
cd "$BUILDDIR"
|
cd "$BUILDDIR"
|
||||||
mkdir "$ROOT"
|
mkdir "$ROOT"
|
||||||
|
|
||||||
# adds necessary packages to initramfs build root folder
|
# adds necessary packages to initramfs build root folder
|
||||||
add_pkgs() {
|
add_pkgs() {
|
||||||
DEPS=""
|
if [ -z "$NO_DOWNLOAD" ]; then
|
||||||
for pkg in $1; do
|
DEPS=""
|
||||||
LOCAL_DEPS=$(apt-rdepends -f Depends -s Depends "$pkg" | grep -v '^ ')
|
for pkg in $1; do
|
||||||
DEPS="$DEPS $LOCAL_DEPS"
|
printf " getting reverse dependencies for '%s'" "$pkg"
|
||||||
done
|
LOCAL_DEPS=$(apt-rdepends -f Depends -s Depends "$pkg" | grep -v '^ ')
|
||||||
# debconf and gcc are unnecessary, libboost-regex doesn't install on bullseye
|
TO_DOWNLOAD=""
|
||||||
DEPS=$(echo "$DEPS" |\
|
for deb in $LOCAL_DEPS; do
|
||||||
sed -E 's/debconf(-2\.0)?//' |\
|
[ ! -e "pkgs/$deb" ] && TO_DOWNLOAD="$TO_DOWNLOAD $deb"
|
||||||
sed -E 's/libboost-regex//' |\
|
done
|
||||||
sed -E 's/gcc-.{1,2}-base//')
|
[ -n "$TO_DOWNLOAD" ] && DEPS="$DEPS $TO_DOWNLOAD"
|
||||||
apt-get download $DEPS
|
done
|
||||||
for deb in ./*.deb; do
|
# debconf and gcc are unnecessary, libboost-regex doesn't install on bullseye
|
||||||
dpkg-deb -x "$deb" "$ROOT"
|
DEPS=$(echo "$DEPS" |\
|
||||||
done
|
sed -E 's/debconf(-2\.0)?//g' |\
|
||||||
rm ./*.deb
|
sed -E 's/libboost-regex//g' |\
|
||||||
|
sed -E 's/gcc-.{1,2}-base//g')
|
||||||
|
|
||||||
|
if [ ! -d pkgs ]; then
|
||||||
|
mkdir pkgs
|
||||||
|
fi
|
||||||
|
if [ -n "$DEPS" ]; then
|
||||||
|
(cd pkgs; apt-get download $DEPS)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -z "$DOWNLOAD_ONLY" ]; then
|
||||||
|
for deb in pkgs/*.deb; do
|
||||||
|
dpkg-deb -x "$deb" "$ROOT"
|
||||||
|
done
|
||||||
|
if [ -z "$NO_DOWNLOAD" ]; then
|
||||||
|
rm -rf pkgs/
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
make_cpio() {
|
make_cpio() {
|
||||||
|
echo "creating CPIO archive '$1'"
|
||||||
fakeroot -- sh -c "
|
fakeroot -- sh -c "
|
||||||
cd '$ROOT';
|
cd '$ROOT';
|
||||||
find . -print0 | cpio --null -oV --format=newc -F ../$1
|
find . -print0 | cpio --null -oV --format=newc -F ../$1
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
cp $INIT "$ROOT/init"
|
if [ -z "$DOWNLOAD_ONLY" ]; then
|
||||||
chmod a+x "$ROOT/init" # just to be sure
|
echo "copying init"
|
||||||
|
cp $INIT "$ROOT/init"
|
||||||
|
chmod a+x "$ROOT/init" # just to be sure
|
||||||
|
|
||||||
# tell daemon it's running in the correct environment
|
# tell daemon it's running in the correct environment
|
||||||
touch "$ROOT/restore-vm-marker"
|
touch "$ROOT/restore-vm-marker"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "getting base dependencies"
|
||||||
|
|
||||||
add_pkgs "
|
add_pkgs "
|
||||||
libstdc++6:amd64 \
|
libstdc++6:amd64 \
|
||||||
libssl1.1:amd64 \
|
libssl3:amd64 \
|
||||||
libacl1:amd64 \
|
libacl1:amd64 \
|
||||||
libblkid1:amd64 \
|
libblkid1:amd64 \
|
||||||
libuuid1:amd64 \
|
libuuid1:amd64 \
|
||||||
@ -59,19 +87,26 @@ add_pkgs "
|
|||||||
thin-provisioning-tools:amd64 \
|
thin-provisioning-tools:amd64 \
|
||||||
"
|
"
|
||||||
|
|
||||||
# install custom ZFS tools (built without libudev)
|
if [ -z "$DOWNLOAD_ONLY" ]; then
|
||||||
mkdir -p "$ROOT/sbin"
|
|
||||||
cp -a ../zfstools/sbin/* "$ROOT/sbin/"
|
|
||||||
cp -a ../zfstools/etc/* "$ROOT/etc/"
|
|
||||||
cp -a ../zfstools/lib/* "$ROOT/lib/"
|
|
||||||
cp -a ../zfstools/usr/* "$ROOT/usr/"
|
|
||||||
|
|
||||||
rm -rf ${ROOT:?}/usr/share # contains only docs and debian stuff
|
echo "install ZFS tool"
|
||||||
rm -rf ${ROOT:?}/usr/local/include # header files
|
# install custom ZFS tools (built without libudev)
|
||||||
rm -rf ${ROOT:?}/usr/local/share # mostly ZFS tests
|
mkdir -p "$ROOT/sbin"
|
||||||
rm -f ${ROOT:?}/lib/x86_64-linux-gnu/*.a # static libraries
|
cp -a ../zfstools/sbin/* "$ROOT/sbin/"
|
||||||
|
cp -a ../zfstools/etc/* "$ROOT/etc/"
|
||||||
|
cp -a ../zfstools/lib/* "$ROOT/lib/"
|
||||||
|
cp -a ../zfstools/usr/* "$ROOT/usr/"
|
||||||
|
|
||||||
make_cpio "initramfs.img"
|
echo "cleanup unused data from base dependencies"
|
||||||
|
rm -rf ${ROOT:?}/usr/share # contains only docs and debian stuff
|
||||||
|
rm -rf ${ROOT:?}/usr/local/include # header files
|
||||||
|
rm -rf ${ROOT:?}/usr/local/share # mostly ZFS tests
|
||||||
|
rm -f ${ROOT:?}/lib/x86_64-linux-gnu/*.a # static libraries
|
||||||
|
|
||||||
|
make_cpio "initramfs.img"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "getting extra/debug dependencies"
|
||||||
|
|
||||||
# add debug helpers for debug initramfs, packages from above are included too
|
# add debug helpers for debug initramfs, packages from above are included too
|
||||||
add_pkgs "
|
add_pkgs "
|
||||||
@ -80,5 +115,8 @@ add_pkgs "
|
|||||||
gdb:amd64 \
|
gdb:amd64 \
|
||||||
strace:amd64 \
|
strace:amd64 \
|
||||||
"
|
"
|
||||||
# leave /usr/share here, it contains necessary stuff for gdb
|
|
||||||
make_cpio "initramfs-debug.img"
|
if [ -z "$DOWNLOAD_ONLY" ]; then
|
||||||
|
# leave /usr/share here, it contains necessary stuff for gdb
|
||||||
|
make_cpio "initramfs-debug.img"
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user