From 75a5b2cf725fcc93f88a69cfb3f449b982ac3c38 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 25 Oct 2019 13:53:37 +0200 Subject: oops - bad merge of build-initramfs.sh --- builder/build-initramfs.sh | 133 +++++---------------------------------------- 1 file changed, 15 insertions(+), 118 deletions(-) diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index 039cc321..647a42cd 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -220,7 +220,9 @@ initialize_dracut() { return $? } -# TODO does this even works? +# The idea here was to source each module-setup.sh from our +# custom dracut modules and call their clean() function. +# TODO: Does this still work? cleanup() { local plugin_path plugin_path="${_root_dir}/modules.d/dnbd3-rootfs" @@ -230,7 +232,6 @@ cleanup() { return $? } main() { -<<<<<<< HEAD if ! parse_command_line "$@"; then print_help_message "$0" exit 1 @@ -252,64 +253,6 @@ main() { [ -n "$qcow_handler" ] && echo " * qcow2 handler: $qcow_handler" export _QCOW_HANDLER="$qcow_handler" -======= - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Main Entry point for the build initramfs logic. Triggers command line - parsing and calls sub routines depending on given command line arguments. - - Example: - - `main` - ' - exceptions.activate - # region dependency checks and command line parsing - result=0 - dependency_check core dependencies utils_dependency_check program || \ - result=$? - dependency_check core shared_library_pattern_dependencies \ - utils_dependency_check_shared_library 'shared library' || result=$? - dependency_check core package_dependencies utils_dependency_check_pkgconfig \ - package || result=$? - [[ $result == 0 ]] || exit $result - - logging.set_commands_level debug - logging.set_level critical - - if ! parse_command_line "$@"; then - print_help_message "$0" - exit 1 - fi - - dependency_check optional dependencies utils_dependency_check program || \ - result=$? - dependency_check optional shared_library_pattern_dependencies \ - utils_dependency_check_shared_library 'shared library' || result=$? - dependency_check optional package_dependencies \ - utils_dependency_check_pkgconfig package || result=$? - [[ $result == 1 ]] && exit $result - # endregion - - # region sanity check kernel version and qcow handler - # if no kernel was specified as dracut argument, use the running kernel's version - logging.info "Building for:" - if [ -z "$kernel_version" ]; then - kernel_version="$(uname -r)" - fi - logging.info " * kernel version: $kernel_version" - # similar for kernel headers needed to compile dnbd3 against. - if [ -z "$kernel_headers" ]; then - kernel_headers="/lib/modules/${kernel_version}/build" - fi - if [ ! -f "${kernel_headers}/Makefile" ]; then - logging.critical 'Missing core dependency "linux-headers" for version to compile against given or current kernel.' - fi - logging.info " * kernel headers: $kernel_headers" - [ -n "$qcow_handler" ] && logging.info " * qcow2 handler: $qcow_handler" - # endregion - - # region handle '--update' to update all the modules in 'modules.d' ->>>>>>> master if [ "$update" == "yes" ]; then pushd "${_repo_dir}" git pull @@ -322,23 +265,6 @@ main() { initialize_dracut fi -<<<<<<< HEAD - 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}" - # TODO introduce module priority - _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 - echo \ - "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 - echo \ - "Linking '$_dracut_module_relative_path' to '$_dracut_module_target' failed." \ -======= for _dracut_module_dir in "${_repo_dir}/builder/modules.d/"*; do [ -d "${_dracut_module_dir}" ] || continue _dracut_module="$(basename $_dracut_module_dir)" @@ -346,12 +272,11 @@ main() { _dracut_module_target="${_root_dir}/dracut/modules.d/00${_dracut_module}" if [[ ! -L "$_dracut_module_target" || "$(readlink \ "$_dracut_module_target")" != "$_dracut_module_dir" ]]; then - logging.info \ + echo \ "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 \ + echo \ "Linking \"$_dracut_module_dir\" to \"$_dracut_module_target\" failed." \ ->>>>>>> master " 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 \ "$_dracut_module_dir" \ @@ -364,59 +289,31 @@ main() { if [ "$verbose" == 'yes' ]; then _loglevel='--verbose' fi -<<<<<<< HEAD - _modules='dnbd3-rootfs conf-tgz systemd systemd-initrd dracut-systemd' - echo "Default modules: ${_modules}" - if [ "$debug" == 'yes' ]; then - _loglevel="$_loglevel --stdlog 4" - # TODO check if we always want this - _modules="$_modules i18n terminfo" - fi - # Preprocess done - start build, cleanup or full cleanup - if [[ "$full_cleanup" == 'yes' ]]; then - echo 'Removing all modules.' - rm "${_root_dir}/modules.d" \ - "${_root_dir}/dracut" --recursive --force -======= _modules=(dnbd3-rootfs conf-tgz) - logging.info "Default modules: ${_modules[@]}" + echo "Default modules: ${_modules[@]}" if [ "$debug" == 'yes' ]; then _loglevel="$_loglevel --stdlog 4" - _modules+=(i18n terminfo) + _modules+=(i18n terminfo) fi if [ "$use_systemd_in_initramfs" == 'yes' ]; then - _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 - logging.info 'Removing all modules.' + echo 'Removing all modules.' rm "${_repo_dir}" "${_root_dir}/dracut" --recursive --force ->>>>>>> master elif [[ "$cleanup" == 'yes' ]]; then echo 'Removing distribution specific files.' cleanup else -<<<<<<< HEAD - echo 'Build initramfs.' -======= . "${_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"). - exceptions.deactivate - # NOTE: We temporary allow dracut to forward all messages since we - # forward all logging configurations. - _commands_log_level_backup="$(logging.get_commands_level)" - _log_level_backup="$(logging.get_level)" - logging.set_level debug - logging.set_commands_level debug - # shellcheck disable=SC2086 ->>>>>>> master + if [[ "$initialize" == 'yes' ]]; then + logging.info "Initialized." + exit 0 + fi + echo 'Build initramfs.' + "${_root_dir}/dracut/dracut.sh" --local \ $_loglevel --modules "${_modules[*]}" --conf /etc/dracut.conf \ --confdir /etc/dracut.conf.d "${dracut_parameter[@]}" \ -- cgit v1.2.3-55-g7522