From 31383970c72cd96e9b69c7e4a9e5a92bf9f72529 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Thu, 21 Jun 2018 16:10:53 +0200 Subject: [PATCH] Add new modprobe element This element will replace modprobe-blacklist element. It wil still have the blacklist functionality, but it also adds the feature of passing a complete file with settings to the modprobe.d directory. Adding this functionality, that will allow elements that depends on this module, to just copy the specified files to the final directory. Change-Id: I9a44f7d11520b8b1e604956d3c1db2fc7e2bf457 --- .../elements/modprobe-blacklist/README.rst | 4 ++++ .../elements/modprobe/README.rst | 21 +++++++++++++++++++ .../extra-data.d/50-modprobe-blacklist | 20 ++++++++++++++++++ .../modprobe/install.d/80-modprobe-blacklist | 13 ++++++++++++ ...add-modprobe-element-8e3b0287ebb11920.yaml | 10 +++++++++ 5 files changed, 68 insertions(+) create mode 100644 diskimage_builder/elements/modprobe/README.rst create mode 100755 diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist create mode 100755 diskimage_builder/elements/modprobe/install.d/80-modprobe-blacklist create mode 100644 releasenotes/notes/add-modprobe-element-8e3b0287ebb11920.yaml diff --git a/diskimage_builder/elements/modprobe-blacklist/README.rst b/diskimage_builder/elements/modprobe-blacklist/README.rst index b506dd94c..6716de720 100644 --- a/diskimage_builder/elements/modprobe-blacklist/README.rst +++ b/diskimage_builder/elements/modprobe-blacklist/README.rst @@ -10,3 +10,7 @@ to a list of string separated by spaces. Example: export DIB_MODPROBE_BLACKLIST="igb" + +.. note:: + This element has been deprecated and replaced by the modprobe element, that + covers 100% the modprobe-blacklist functionality. diff --git a/diskimage_builder/elements/modprobe/README.rst b/diskimage_builder/elements/modprobe/README.rst new file mode 100644 index 000000000..876fdcb51 --- /dev/null +++ b/diskimage_builder/elements/modprobe/README.rst @@ -0,0 +1,21 @@ +======== +modprobe +======== + +Allows to configure specific modprobe options on the image. + +It contains the following functionalities: + +1. Ability to blacklist specific modules using modprobe.d/blacklist.conf. + In order to use set DIB_MODPROBE_BLACKLIST to the name of your + module. To disable multiple modules you can set DIB_MODPROBE_BLACKLIST + to a list of string separated by spaces. + + Example: + + export DIB_MODPROBE_BLACKLIST="igb" + +2. Ability to copy specific files into /etc/modprobe.d directory, so it + allows to configure settings with freedom. To achieve that, the files + to be copied needs to be placed inside an specific modprobe.d directory + of the element. diff --git a/diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist b/diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist new file mode 100755 index 000000000..9f8c7119f --- /dev/null +++ b/diskimage_builder/elements/modprobe/extra-data.d/50-modprobe-blacklist @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +# copy all modprobe.d snippets to /etc/modprobe.d + +eval declare -A image_elements=($(get_image_element_array)) + +for i in "${!image_elements[@]}"; do + element=$i + element_dir=${image_elements[$i]} + + if [ -d "${element_dir}/modprobe.d/" ]; then + sudo cp ${element_dir}/modprobe.d/*.conf $TMP_MOUNT_PATH/etc/modprobe.d/ + fi +done diff --git a/diskimage_builder/elements/modprobe/install.d/80-modprobe-blacklist b/diskimage_builder/elements/modprobe/install.d/80-modprobe-blacklist new file mode 100755 index 000000000..6493726f8 --- /dev/null +++ b/diskimage_builder/elements/modprobe/install.d/80-modprobe-blacklist @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +MODULES_LIST=${DIB_MODPROBE_BLACKLIST:?"Please set DIB_MODPROBE_BLACKLIST."} + +for mod_name in $MODULES_LIST; do + echo "blacklist $mod_name" >> /etc/modprobe.d/blacklist.conf +done diff --git a/releasenotes/notes/add-modprobe-element-8e3b0287ebb11920.yaml b/releasenotes/notes/add-modprobe-element-8e3b0287ebb11920.yaml new file mode 100644 index 000000000..63c4d0340 --- /dev/null +++ b/releasenotes/notes/add-modprobe-element-8e3b0287ebb11920.yaml @@ -0,0 +1,10 @@ +--- +features: + - Add new modprobe element. This element will replace + modprobe-blacklist element. It wil still have the + blacklist functionality, but it also adds the feature + of passing a complete file with settings to the + modprobe.d directory. Adding this functionality, that + will allow elements that depends on this module, to + just copy the specified files to the final directory. +