diff options
Diffstat (limited to 'share/customize-kernel.sh')
-rwxr-xr-x | share/customize-kernel.sh | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/share/customize-kernel.sh b/share/customize-kernel.sh index d216eaa..0a252a4 100755 --- a/share/customize-kernel.sh +++ b/share/customize-kernel.sh @@ -8,14 +8,52 @@ set -eu +if [ "${MMDEBSTRAP_VERBOSITY:-1}" -ge 3 ]; then + set -x +fi + TARGET="$1" +ARCHITECTURES=$(xargs < "$TARGET/var/lib/dpkg/arch") + +affected_by_1079443() { + case "${ARCHITECTURES%% *}" in + armel|armhf) + ;; + *) + return 1 + ;; + esac + test "${1:-}" = --maybe && return 0 + test -d "$TARGET/etc/initramfs-tools/hooks" || return 1 + dpkg-query --root="$TARGET" --showformat='${db:Status-Status}\n' --show dracut-install 2>/dev/null | grep -q '^installed$' +} +work_around_1079443() { + # FTS or its usage in dracut-install is broken on some 32bit architectures. + echo "Warning: working around #1079443" + cat >"$TARGET/etc/initramfs-tools/hooks/work_around_1079443" <<'EOF' +#!/bin/sh + +test "${1-}" = prereqs && exit 0 + +. /usr/share/initramfs-tools/hook-functions + +# work around #1079443 +manual_add_modules virtio_blk +EOF + chmod +x "$TARGET/etc/initramfs-tools/hooks/work_around_1079443" + if test "${1:-}" = --update && test -x "$TARGET/usr/bin/update-initramfs"; then + chroot "$TARGET/update-initramfs -u" + fi +} + if dpkg-query --root="$TARGET" --showformat='${db:Status-Status}\n' --show 'linux-image-*' 2>/dev/null | grep -q '^installed$'; then + if affected_by_1079443; then + work_around_1079443 --update + fi exit 0 fi -ARCHITECTURES=$(xargs < "$TARGET/var/lib/dpkg/arch") - KERNEL_ARCH="${ARCHITECTURES%% *}" case "$KERNEL_ARCH" in armel) @@ -70,4 +108,15 @@ else 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" +KERNEL_SATISFY="linux-image-cloud-$KERNEL_ARCH | linux-image-$KERNEL_ARCH | linux-image-generic" +INITRD_SATISFY="initramfs-tools | linux-initramfs-tool" + +if affected_by_1079443 --maybe; then + apt-get --yes satisfy "$@" "$INITRD_SATISFY" + if affected_by_1079443; then + work_around_1079443 + fi + apt-get --yes satisfy "$@" "$KERNEL_SATISFY" +else + apt-get --yes satisfy "$@" "$KERNEL_SATISFY" "$INITRD_SATISFY" +fi |