summaryrefslogtreecommitdiffstats
path: root/builder/build-initramfs.sh
diff options
context:
space:
mode:
authorJonathan Bauer2017-03-07 11:14:32 +0100
committerJonathan Bauer2017-03-07 11:14:32 +0100
commit9b61577c3ceb809c2473d4757590a01054466eaf (patch)
tree2bbbd2dc0a7e79f8509b53bef2f1aba939900489 /builder/build-initramfs.sh
parentYannick Bilger's WLAN boot prototype (diff)
downloadsystemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.tar.gz
systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.tar.xz
systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.zip
moved all dracut modules to modules.d/ + support
Diffstat (limited to 'builder/build-initramfs.sh')
-rwxr-xr-xbuilder/build-initramfs.sh64
1 files changed, 39 insertions, 25 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh
index dcab3b1d..0c01c888 100755
--- a/builder/build-initramfs.sh
+++ b/builder/build-initramfs.sh
@@ -24,9 +24,9 @@
## region ensure presence of needed dependencies
set -o errexit
-_needed_location="$(dirname "${BASH_SOURCE[0]}")/dnbd3-rootfs"
+_needed_location="$(dirname "${BASH_SOURCE[0]}")/modules.d"
if ! [[ -d "$_needed_location" ]]; then
- echo "The dnbd3 dracut plugin isn't available, loading it."
+ echo "The dracut modules aren't available, loading them."
if ! hash git; then
echo "Needed dependency \"git\" isn't available. Please install \"git\" or provide the repositories data structure in \"$(dirname "${BASH_SOURCE[0]}")\"."
fi
@@ -41,19 +41,29 @@ if ! [[ -d "$_needed_location" ]]; then
branch="$(git config --file "$toplevel/.gitmodules" "submodule.$name.branch")"
git clone --depth 1 --branch "$branch"
'
- git submodule update --remote
+ git submodule update # --remote <- this seems like a bad idea
popd
- for mod in dnbd3-rootfs conf-tgz dns ib-conf bootnet-conf; do
- cp --recursive \
- "${_temporary_repository_location}/builder/${mod}" \
- "$(dirname $_needed_location)/${mod}"
- done
+ # finally copy all dracut modules under modules.d/
+ _nullglob_backup="$(shopt -p nullglob || true)"
+ shopt -u nullglob
+ ## HACK the directory structure until its git'ed
+ #_temporary_modules_directory="$(mktemp --directory)"
+ #cp --recursive \
+ # "${_temporary_repository_location}/builder/"*/ \
+ # "${_temporary_modules_directory}/"
+ ## re-set old nullglob option
+ #${_nullglob_backup}
+ #mv "${_temporary_modules_directory}" "${_temporary_repository_location}/builder/modules.d/"
+ # END HACK
+ cp --recursive \
+ "${_temporary_repository_location}/builder/modules.d/" \
+ "$(dirname $_needed_location)"
rm --recursive --force "$_temporary_repository_location"
fi
set +o errexit
## endregion
# shellcheck source=./dnbd3-rootfs/scripts/rebash/core.sh
-source "$(dirname "${BASH_SOURCE[0]}")/dnbd3-rootfs/scripts/rebash/core.sh"
+source "$(dirname "${BASH_SOURCE[0]}")/modules.d/dnbd3-rootfs/scripts/rebash/core.sh"
core.import exceptions
core.import logging
core.import utils
@@ -435,7 +445,7 @@ cleanup() {
`cleanup`
'
local plugin_path
- plugin_path="$(dirname "${BASH_SOURCE[0]}")/dnbd3-rootfs/"
+ plugin_path="$(dirname "${BASH_SOURCE[0]}")/modules.d/dnbd3-rootfs/"
# shellcheck disable=SC1090
source "${plugin_path}module-setup.sh"
# shellcheck disable=SC2034
@@ -552,23 +562,26 @@ main() {
logging.info "Dracut isn't available yet loading it."
initialize_dracut
fi
-
- declare -A _dracut_modules=( [dnbd3]='../../dnbd3-rootfs' [conf]='../../conf-tgz' [dns]='../../dns' [ib]='../../ib-conf' [bootnet]='../../bootnet-conf')
- for mod in dnbd3 conf dns ib bootnet; do
- _dracut_modules_source="${_dracut_modules[$mod]}"
- _dracut_modules_target="$(dirname "${BASH_SOURCE[0]}")/dracut/modules.d/90$(basename "${_dracut_modules[$mod]}")"
- if [[ ! -L "$_dracut_modules_target" || "$(readlink \
- "$_dracut_modules_target")" != "$_dracut_modules_source" ]]
+
+ for _dracut_module in "$(dirname "${BASH_SOURCE[0]}")/modules.d/"*; do
+ [ -d "${_dracut_module}" ] || continue
+ _dracut_module="$(basename $_dracut_module)"
+ # shouldn't we use absolute paths here?
+ _dracut_module_relative_path="../../modules.d/${_dracut_module}"
+ _dracut_module_target="$(dirname "${BASH_SOURCE[0]}")/dracut/modules.d/90${_dracut_module}"
+ if [[ ! -L "$_dracut_module_target" || "$(readlink \
+ "$_dracut_module_target")" != "$_dracut_module_relative_path" ]]
then
logging.info \
- "Link ${mod} plugin into dracut modules folder ($_dracut_modules_source -> $_dracut_modules_target)."
- if ! ln --symbolic --force "$_dracut_modules_source" \
- "$_dracut_modules_target" 2>/dev/null; then
+ "Link ${_dracut_module} plugin into dracut modules folder ($_dracut_module_relative_path -> $_dracut_module_target)."
+ if ! ln --symbolic --force "$_dracut_module_relative_path" \
+ "$_dracut_module_target"; then
logging.warn \
- "Linking \"$_dracut_modules_source\" to \"$_dracut_modules_target\" failed. We will copy them. So we have to recopy it every time to ensure that recompiled things take effect."
+ "Linking \"$_dracut_module_relative_path\" to \"$_dracut_module_target\" failed." \
+ " We will copy them. So we have to recopy it every time to ensure that recompiled things take effect."
cp --recursive --force --no-target-directory \
- "$(dirname "${BASH_SOURCE[0]}")/$(basename "$_dracut_modules_source")" \
- "$_dracut_modules_target"
+ "$(dirname "${BASH_SOURCE[0]}")/modules.d/$_dracut_module" \
+ "$_dracut_module_target"
fi
fi
done
@@ -578,7 +591,8 @@ main() {
if [ "$verbose" == 'yes' ]; then
_loglevel='--verbose'
fi
- _modules='dnbd3-rootfs conf-tgz dns ib-conf bootnet-conf'
+ _modules='dnbd3-rootfs conf-tgz'
+ logging.info "Default modules: ${_modules}"
if [ "$debug" == 'yes' ]; then
_loglevel="$_loglevel --stdlog 4"
_modules="$_modules i18n terminfo"
@@ -588,7 +602,7 @@ main() {
fi
if [[ "$full_cleanup" == 'yes' ]]; then
logging.info 'Removing all modules.'
- rm "$(dirname "${BASH_SOURCE[0]}")/dnbd3-rootfs" \
+ rm "$(dirname "${BASH_SOURCE[0]}")/modules.d" \
"$(dirname "${BASH_SOURCE[0]}")/dracut" --recursive --force
elif [[ "$cleanup" == 'yes' ]]; then
logging.info 'Removing distribution specific files.'