From 39fb794ebc03087c3a36e7292cf72162e63d7aba Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 24 Sep 2018 17:34:22 +1000 Subject: [PATCH] Allow debootstrap to cleanup without a kernel Currently there's more-or-less an assumption that a kernel is installed, so module blacklists are simply echoed into the modprobe blacklist. This may not be the case with some ongoing container work. Although we don't need to blacklist modules for containers, it also doesn't hurt. Move the debootstrap element to the new modprobe element, and allow it to create the blacklist directory. Change-Id: I0f057caf473951df56a2af9633e3a5b53e0809b1 --- diskimage_builder/elements/debootstrap/element-deps | 2 ++ .../debootstrap/install.d/15-cleanup-debootstrap | 1 - .../modprobe/extra-data.d/50-modprobe-blacklist | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/diskimage_builder/elements/debootstrap/element-deps b/diskimage_builder/elements/debootstrap/element-deps index 0dd8a43b0..a65556089 100644 --- a/diskimage_builder/elements/debootstrap/element-deps +++ b/diskimage_builder/elements/debootstrap/element-deps @@ -1,2 +1,4 @@ dpkg +modprobe pkg-map + diff --git a/diskimage_builder/elements/debootstrap/install.d/15-cleanup-debootstrap b/diskimage_builder/elements/debootstrap/install.d/15-cleanup-debootstrap index 3059a05a0..507237524 100755 --- a/diskimage_builder/elements/debootstrap/install.d/15-cleanup-debootstrap +++ b/diskimage_builder/elements/debootstrap/install.d/15-cleanup-debootstrap @@ -22,4 +22,3 @@ set -eu set -o pipefail install -d -m 0755 -o root -g root /etc/sudoers.d -echo 'blacklist pcspkr' > /etc/modprobe.d/blacklist.conf diff --git a/diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist b/diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist index 9f8c7119f..f763d8b64 100755 --- a/diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist +++ b/diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist @@ -6,6 +6,17 @@ fi set -eu set -o pipefail +# This would only not be here if there was no kmod package installed, +# which can happen in some container situations. Obviously +# blacklisting a kernel module is not really useful; however allowing +# this to work can allow modules that do other things that *are* +# useful for a container to "just work" without a whole bunch of +# refactoring. +if [ ! -d /etc/modprobe.d ]; then + # ^ so we can see in the logs if we took this path ... + mkdir -p /etc/modprobe.d +fi + # copy all modprobe.d snippets to /etc/modprobe.d eval declare -A image_elements=($(get_image_element_array))