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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/bin/sh
#
# Copyright 2022 Helmut Grohne <helmut@subdivi.de>
# SPDX-License-Identifier: MIT
#
# This is a mmdebstrap customize hook that installs a kernel image. The name
# of the kernel image depends on the architecture, derivative and release.
set -eu
TARGET="$1"
if dpkg-query --root="$TARGET" --showformat='${db:Status-Status}\n' --show 'linux-image-*' 2>/dev/null | grep -q '^installed$'; then
exit 0
fi
ARCHITECTURES=$(xargs < "$TARGET/var/lib/dpkg/arch")
KERNEL_ARCH="${ARCHITECTURES%% *}"
case "$KERNEL_ARCH" in
armel)
KERNEL_ARCH=rpi
case "$ARCHITECTURES " in
*" arm64 "*) KERNEL_ARCH=arm64:arm64 ;;
*" armhf "*) KERNEL_ARCH=armmp:armhf ;;
esac
;;
armhf)
KERNEL_ARCH=armmp
case "$ARCHITECTURES " in
*" arm64 "*) KERNEL_ARCH=arm64:arm64 ;;
esac
;;
hppa)
KERNEL_ARCH=parisc
;;
i386)
KERNEL_ARCH=686-pae
case "$ARCHITECTURES " in
*" amd64 "*) KERNEL_ARCH=amd64:amd64 ;;
esac
;;
mips64el)
KERNEL_ARCH=5kc-malta
;;
mipsel)
KERNEL_ARCH=4kc-malta
case "$ARCHITECTURES " in
*" mips64el "*) KERNEL_ARCH=5kc-malta:mips64el
esac
;;
ppc64)
KERNEL_ARCH=powerpc64
;;
ppc64el)
KERNEL_ARCH=powerpc64le
;;
esac
export APT_CONFIG="$MMDEBSTRAP_APT_CONFIG"
if test "${MMDEBSTRAP_MODE:-}" = chrootless; then
set -- \
-oDPkg::Options::=--force-not-root \
-oDPkg::Options::=--force-script-chrootless \
-oDPkg::Options::=--root="$TARGET" \
-oDPkg::Options::=--log="$TARGET/var/log/dpkg.log"
else
set -- -oDPkg::Chroot-Directory="$TARGET"
fi
# On some derivatives such as Ubuntu, linux image does not depend on an initramfs.
apt-get --yes satisfy "$@" "linux-image-cloud-$KERNEL_ARCH | linux-image-$KERNEL_ARCH | linux-image-generic" "initramfs-tools | linux-initramfs-tool"
|