summaryrefslogtreecommitdiffstats
path: root/builder
diff options
context:
space:
mode:
Diffstat (limited to 'builder')
-rwxr-xr-xbuilder/build-initramfs.sh49
1 files changed, 19 insertions, 30 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh
index 0c01c888..6b17cd32 100755
--- a/builder/build-initramfs.sh
+++ b/builder/build-initramfs.sh
@@ -21,14 +21,14 @@
# Note that you only get very necessary output until you provide "--verbose" as
# commandline options.
-
+declare -rg _root_dir="$(dirname "${BASH_SOURCE[0]}")"
## region ensure presence of needed dependencies
set -o errexit
-_needed_location="$(dirname "${BASH_SOURCE[0]}")/modules.d"
+_needed_location="${_root_dir}/modules.d"
if ! [[ -d "$_needed_location" ]]; then
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]}")\"."
+ echo "Needed dependency \"git\" isn't available. Please install \"git\" or provide the repositories data structure in \"${_root_dir}\"."
fi
_temporary_repository_location="$(mktemp --directory)"
git clone --depth 1 --no-single-branch \
@@ -44,17 +44,6 @@ if ! [[ -d "$_needed_location" ]]; then
git submodule update # --remote <- this seems like a bad idea
popd
# 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)"
@@ -63,7 +52,7 @@ fi
set +o errexit
## endregion
# shellcheck source=./dnbd3-rootfs/scripts/rebash/core.sh
-source "$(dirname "${BASH_SOURCE[0]}")/modules.d/dnbd3-rootfs/scripts/rebash/core.sh"
+source "${_root_dir}/modules.d/dnbd3-rootfs/scripts/rebash/core.sh"
core.import exceptions
core.import logging
core.import utils
@@ -411,14 +400,14 @@ initialize_dracut() {
`initialize_dracut`
'
- if [[ ! -f "$(dirname "${BASH_SOURCE[0]}")/dracut/install/dracut-install" ]]
+ if [[ ! -f "${_root_dir}/dracut/install/dracut-install" ]]
then
- mkdir --parents "$(dirname "${BASH_SOURCE[0]}")/dracut"
+ mkdir --parents "${_root_dir}/dracut"
logging.info 'Download and extract dracut.'
curl --location "$dracut_resource_url" | tar --extract --gzip \
- --directory "$(dirname "${BASH_SOURCE[0]}")/dracut" \
+ --directory "${_root_dir}/dracut" \
--strip-components 1
- pushd "$(dirname "${BASH_SOURCE[0]}")/dracut"
+ pushd "${_root_dir}/dracut"
# NOTE: On virtualbox shared folder symlinks are not allowed.
# NOTE: make the dracut-install binary (dracut-install resolves
# dependencies etc.)
@@ -431,8 +420,8 @@ initialize_dracut() {
# >>> make dracut-install
popd
fi
- cp "$(dirname "${BASH_SOURCE[0]}")/dracut/install/dracut-install" \
- "$(dirname "${BASH_SOURCE[0]}")/dracut/dracut-install"
+ cp "${_root_dir}/dracut/install/dracut-install" \
+ "${_root_dir}/dracut/dracut-install"
return $?
}
cleanup() {
@@ -445,9 +434,9 @@ cleanup() {
`cleanup`
'
local plugin_path
- plugin_path="$(dirname "${BASH_SOURCE[0]}")/modules.d/dnbd3-rootfs/"
+ plugin_path="${_root_dir}/modules.d/dnbd3-rootfs"
# shellcheck disable=SC1090
- source "${plugin_path}module-setup.sh"
+ source "${plugin_path}/module-setup.sh"
# shellcheck disable=SC2034
moddir="$(cd "$plugin_path" &>/dev/null && pwd)"
clean
@@ -558,17 +547,17 @@ main() {
# endregion
# region handle dependencies which can be resolved automatically
logging.info 'Checking dracut.'
- if [[ ! -f "$(dirname "${BASH_SOURCE[0]}")/dracut/dracut-install" ]]; then
+ if [[ ! -f "${_root_dir}/dracut/dracut-install" ]]; then
logging.info "Dracut isn't available yet loading it."
initialize_dracut
fi
- for _dracut_module in "$(dirname "${BASH_SOURCE[0]}")/modules.d/"*; do
+ for _dracut_module in "${_root_dir}/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}"
+ _dracut_module_target="${_root_dir}/dracut/modules.d/90${_dracut_module}"
if [[ ! -L "$_dracut_module_target" || "$(readlink \
"$_dracut_module_target")" != "$_dracut_module_relative_path" ]]
then
@@ -580,7 +569,7 @@ main() {
"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]}")/modules.d/$_dracut_module" \
+ "${_root_dir}/modules.d/$_dracut_module" \
"$_dracut_module_target"
fi
fi
@@ -602,8 +591,8 @@ main() {
fi
if [[ "$full_cleanup" == 'yes' ]]; then
logging.info 'Removing all modules.'
- rm "$(dirname "${BASH_SOURCE[0]}")/modules.d" \
- "$(dirname "${BASH_SOURCE[0]}")/dracut" --recursive --force
+ rm "${_root_dir}/modules.d" \
+ "${_root_dir}/dracut" --recursive --force
elif [[ "$cleanup" == 'yes' ]]; then
logging.info 'Removing distribution specific files.'
cleanup
@@ -619,7 +608,7 @@ main() {
logging.set_level debug
logging.set_commands_level debug
# shellcheck disable=SC2086
- "$(dirname "${BASH_SOURCE[0]}")/dracut/dracut.sh" --local \
+ "${_root_dir}/dracut/dracut.sh" --local \
$_loglevel --modules "$_modules" --conf /etc/dracut.conf \
--confdir /etc/dracut.conf.d "${dracut_parameter[@]}" \
"$file_path"