From 704ac40db0c9d15ea6747229cf5fa412921526db Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 18 Sep 2019 14:16:47 +0200 Subject: builds-initramfs.sh: improve modules.d handling and always call build_initialize_components --- builder/build-initramfs.sh | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index dedc4f9e..fe5786ec 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -63,12 +63,11 @@ if [ ! -e "$_repo_dir" ]; then done 2>/dev/null ' popd - ln -s "${_repo_dir}/builder/modules.d" "${_root_dir}/modules.d" fi set +o errexit ## endregion # shellcheck source=./dnbd3-rootfs/scripts/rebash/core.sh -source "${_root_dir}/modules.d/dnbd3-rootfs/scripts/rebash/core.sh" +source "${_repo_dir}/builder/modules.d/dnbd3-rootfs/scripts/rebash/core.sh" core.import exceptions core.import logging core.import utils @@ -649,24 +648,21 @@ main() { initialize_dracut fi - 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}" + for _dracut_module_dir in "${_repo_dir}/builder/modules.d/"*; do + [ -d "${_dracut_module_dir}" ] || continue + _dracut_module="$(basename $_dracut_module_dir)" # TODO change to *not* always use '90' ... _dracut_module_target="${_root_dir}/dracut/modules.d/00${_dracut_module}" if [[ ! -L "$_dracut_module_target" || "$(readlink \ - "$_dracut_module_target")" != "$_dracut_module_relative_path" ]]; then + "$_dracut_module_target")" != "$_dracut_module_dir" ]]; then logging.info \ - "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 + "Link ${_dracut_module} plugin into dracut modules folder ($_dracut_module_dir -> $_dracut_module_target)." + if ! ln --symbolic --force "$_dracut_module_dir" "$_dracut_module_target"; then logging.warn \ - "Linking \"$_dracut_module_relative_path\" to \"$_dracut_module_target\" failed." \ + "Linking \"$_dracut_module_dir\" 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 \ - "${_root_dir}/modules.d/$_dracut_module" \ + "$_dracut_module_dir" \ "$_dracut_module_target" fi fi @@ -678,14 +674,14 @@ main() { if [ "$verbose" == 'yes' ]; then _loglevel='--verbose' fi - _modules='dnbd3-rootfs conf-tgz' + _modules=(dnbd3-rootfs conf-tgz) logging.info "Default modules: ${_modules}" if [ "$debug" == 'yes' ]; then _loglevel="$_loglevel --stdlog 4" - _modules="$_modules i18n terminfo" + _modules+=(i18n terminfo) fi if [ "$use_systemd_in_initramfs" == 'yes' ]; then - _modules="$_modules systemd systemd-initrd dracut-systemd" + _modules+=(systemd systemd-initrd dracut-systemd) fi # Preprocess done - start build, cleanup or full cleanup if [[ "$full_cleanup" == 'yes' ]]; then @@ -695,10 +691,13 @@ main() { elif [[ "$cleanup" == 'yes' ]]; then logging.info 'Removing distribution specific files.' cleanup - elif [[ "$initialize" == 'yes' ]]; then - . "${_root_dir}/modules.d/dnbd3-rootfs/helper/build.inc" - build_initialize_components else + . "${_repo_dir}/builder/modules.d/dnbd3-rootfs/helper/build.inc" + build_initialize_components + if [[ "$initialize" == 'yes' ]]; then + logging.info "Initialized." + exit 0 + fi logging.info 'Build initramfs.' # NOTE: We deactivate our exception handle since dracut returns "1" if # it is launched with help parameter ("-h" or "--help"). @@ -711,7 +710,7 @@ main() { logging.set_commands_level debug # shellcheck disable=SC2086 "${_root_dir}/dracut/dracut.sh" --local \ - $_loglevel --modules "$_modules" --conf /etc/dracut.conf \ + $_loglevel --modules "${_modules[*]}" --conf /etc/dracut.conf \ --confdir /etc/dracut.conf.d "${dracut_parameter[@]}" \ --kver "${kernel_version}" "$file_path" _return_code=$? -- cgit v1.2.3-55-g7522