summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorHelmut Grohne <helmutg@debian.org>2023-01-18 05:18:04 +0000
committerHelmut Grohne <helmutg@debian.org>2023-01-18 05:18:04 +0000
commita2c90e0223d9a79fecfe226256a32fd08ace9d7b (patch)
tree29e5a4989c084820571277f26fdcf06cd5326c3a /share
parent8961c87b6b1289d50e7e53cbca497f5ee9ed7b3c (diff)
parentd6c10bd8bd690434672873dcc7d9314d986c7e3e (diff)
downloaddebvm-a2c90e0223d9a79fecfe226256a32fd08ace9d7b.tar.gz
Merge branch 'one-kernel' into 'main'
debvm-create: install only one kernel image See merge request helmutg/debvm!27
Diffstat (limited to 'share')
-rwxr-xr-xshare/customize-kernel.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/share/customize-kernel.sh b/share/customize-kernel.sh
new file mode 100755
index 0000000..c7122c2
--- /dev/null
+++ b/share/customize-kernel.sh
@@ -0,0 +1,56 @@
+#!/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
+
+ARCHITECTURE=$(cat "$TARGET/var/lib/dpkg/arch")
+
+KERNEL_ARCH="$ARCHITECTURE"
+case "$ARCHITECTURE" in
+ armhf)
+ KERNEL_ARCH=armmp
+ ;;
+ hppa)
+ KERNEL_ARCH=parisc
+ ;;
+ i386)
+ KERNEL_ARCH=686-pae
+ ;;
+ mips64el)
+ KERNEL_ARCH=5kc-malta
+ ;;
+ mipsel)
+ KERNEL_ARCH=4kc-malta
+ ;;
+ 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
+
+apt-get --yes satisfy "$@" "linux-image-cloud-$KERNEL_ARCH | linux-image-$KERNEL_ARCH | linux-image-generic" "initramfs-tools | linux-initramfs-tool"