From 5265faaac56fce5a395288210a8bec21598f10de Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 6 Sep 2019 17:34:24 +0200 Subject: nobash! --- builder/build-initramfs.sh | 388 ++------------------- .../modules.d/conf-tgz/hooks/fetch-config-tgz.sh | 20 +- .../modules.d/conf-tgz/hooks/unpack-config-tgz.sh | 49 +-- builder/modules.d/conf-tgz/module-setup.sh | 35 +- builder/modules.d/dnbd3-rootfs/helper/build.inc | 1 - .../hooks/copy-dnbd3-service-into-newroot.sh | 23 +- .../copy-dracut-systemd-files-into-newroot.sh | 34 +- .../copy-openslx-configuration-into-newroot.sh | 22 -- .../modules.d/dnbd3-rootfs/hooks/fetch-config.sh | 27 +- .../hooks/load-custom-kernel-modules.sh | 20 +- .../dnbd3-rootfs/hooks/mount-root-device.sh | 20 -- .../dnbd3-rootfs/hooks/prepare-root-partition.sh | 41 +-- builder/modules.d/dnbd3-rootfs/module-setup.sh | 85 +---- builder/modules.d/dnbd3-rootfs/scripts/build.sh | 155 -------- .../dnbd3-rootfs/scripts/container-unpack-qemu.sh | 35 -- .../scripts/container-unpack-xmount.sh | 34 -- builder/modules.d/dnbd3-rootfs/scripts/rebash | 1 - builder/modules.d/dnbd3-rootfs/scripts/tools.sh | 105 ------ 18 files changed, 72 insertions(+), 1023 deletions(-) delete mode 100644 builder/modules.d/dnbd3-rootfs/scripts/build.sh delete mode 100755 builder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh delete mode 100755 builder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh delete mode 160000 builder/modules.d/dnbd3-rootfs/scripts/rebash delete mode 100644 builder/modules.d/dnbd3-rootfs/scripts/tools.sh (limited to 'builder') diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index 51ae5ddf..d9017e74 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -13,18 +13,11 @@ # This tool provides a generic way to install systemd based remote linux # initramfs. -# Examples -# -------- - -# Start install progress command (Assuming internet is available): -# >>> ./build-initramfs.sh - -# Note that you only get very necessary output until you provide "--verbose" as -# commandline options. declare -rg _root_dir="$(readlink -f $(dirname ${BASH_SOURCE[0]}))" declare -rg _repo_dir="${_root_dir}/systemd-init.git" declare -rg _git_source="git://git.openslx.org/openslx-ng/systemd-init.git" declare -rg _git_branch="master" + ## region ensure presence of needed dependencies set -o errexit if [ ! -e "$_repo_dir" ]; then @@ -67,16 +60,7 @@ if [ ! -e "$_repo_dir" ]; then fi set +o errexit ## endregion -# shellcheck source=./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 -core.import change_root -# endregion -# region properties -# shellcheck disable=SC2034 -build_initramfs__doc_test_setup__='exceptions.activate' + file_path='/boot/initramfs.img' dracut_parameter=(--force --no-hostonly) verbose='no' @@ -85,72 +69,9 @@ target='' cleanup='no' full_cleanup='no' use_systemd_in_initramfs='no' -# shellcheck disable=SC2034 -declare -A core_dependencies=( - [cat]='print messages' \ - [cpio]='pack initramfs' \ - ['dhclient arping']='support network connection in resulting initramfs' \ - [dirname]='core logic' \ - [dmsetup]='create a (temporary) writable layer during boot' \ - [grep]='retrieve right boot partition during boot' \ - [mktemp]='create save temporary files and dictionaries' \ - [pkg-config]='retrieve information of installed development packages' \ - [tee]='read from standard input and write to standard output and files' \ - [readlink]="connect dracut module with dracut's module system" \ - [rm]='remove (temporary) files' \ - [shift]='parse command line' \ - [sed]='process strings' \ - ['cmake gcc make']='dynamically compile needed resources against current or given kernel') -# shellcheck disable=SC2034 -declare -A optional_dependencies=( - [chroot]='build against a distribution other than this program runs in' \ - ['curl git gzip tar']='dynamically retrieve and unpack missing application which will be compiled for current or given kernel' \ - ['mkfs.ext4 fsck']='support for persistent binary diffs in image files') -# shellcheck disable=SC2034 -declare -A core_shared_library_pattern_dependencies=( - [libz]='compile dnbd3 for given or current kernel') -# shellcheck disable=SC2034 -declare -A optional_shared_library_pattern_dependencies=() -# shellcheck disable=SC2034 -declare -A core_package_dependencies=() -# shellcheck disable=SC2034 -declare -A optional_package_dependencies=( - ['fuse glib-2.0 pixman-1']='support template systems in container (usually used by virtual runtime environments)') -# endregion -# region functions -## region command line interface -print_usage_message() { - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Prints a description about how to use this program. - >>> print_usage_message &>/dev/null - ' - logging.cat << EOF -This program provides a generic way to install systemd based remote linux -initramfs. -EOF -} -print_usage_examples() { - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Prints a description about how to use this program by providing examples. - - >>> print_usage_examples &>/dev/null - ' - logging.cat << EOF -Start install progress: ->>> ./build_initramfs.sh -EOF -} print_command_line_option_description() { - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Prints descriptions about each available command line option. - - >>> print_command_line_option_description &>/dev/null - ' - logging.cat << EOF + cat << EOF -h --help Shows this help message. -v --verbose Tells you what is going on (default: "$verbose"). @@ -187,115 +108,7 @@ them via a single dash (-) (default: "$dracut_parameter" with concatenated.). EOF } -print_help_message() { - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Provides a help message for this module. - - >>> print_help_message &>/dev/null - ' - logging.plain "\nUsage: $0 [options]\n" - print_usage_message "$@" - logging.plain '\nExamples:\n' - print_usage_examples "$@" - logging.plain -e '\nOption descriptions:\n' - print_command_line_option_description "$@" - logging.plain -} parse_command_line() { - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Provides the command line interface and interactive questions. - - >>> parse_command_line -h &>/dev/null - - >>> echo "$verbose" - no - >>> logging.get_level - critical - >>> parse_command_line -v - >>> echo "$verbose" - >>> logging.get_level - yes - info - - >>> echo "$debug" - no - >>> parse_command_line --debug - >>> echo "$debug" - >>> logging.get_level - yes - debug - - >>> parse_command_line -p - +doc_test_capture_stderr - +doc_test_contains - +doc_test_ellipsis - Error with given option "-p": - Traceback (most recent call first): - ... - - >>> echo "$file_path" - /boot/initramfs.img - >>> parse_command_line -p /tmp/test.img - >>> echo "$file_path" - /tmp/test.img - - >>> echo "$cleanup" - no - >>> parse_command_line --cleanup - >>> echo "$cleanup" - yes - - >>> echo "$full_cleanup" - no - >>> parse_command_line --full-cleanup - >>> echo "$full_cleanup" - yes - - >>> echo "$full_cleanup" - no - >>> parse_command_line --full-cleanup - >>> echo "$full_cleanup" - yes - - >>> echo "$use_systemd_in_initramfs" - no - >>> parse_command_line -s - >>> echo "$use_systemd_in_initramfs" - yes - - >>> parse_command_line -t; echo $? - +doc_test_capture_stderr - +doc_test_contains - +doc_test_ellipsis - Error with given option "-t": - Traceback (most recent call first): - ... - - >>> [[ "$target" = "" ]] - >>> parse_command_line -t /tmp/ - >>> echo "$target" - /tmp/ - - >>> echo "${dracut_parameter[@]}" - --force --no-hostonly - >>> parse_command_line - --test - >>> echo "${dracut_parameter[@]}" - --force --no-hostonly --test - - >>> parse_command_line - --install "vim htop" - >>> echo "${dracut_parameter[3]}" - vim htop - - >>> parse_command_line --no-available-option; echo $? - +doc_test_capture_stderr - +doc_test_contains - +doc_test_ellipsis - Error with given option "--no-available-option": - Traceback (most recent call first): - ... - ' while true; do case "$1" in -h|--help) @@ -354,7 +167,7 @@ parse_command_line() { shift kernel_version="$1" if [ -z "$kernel_version" ]; then - logging.critical \ + echo \ "Error with given option \"$given_argument\": This option needs a kernel version to build the initramfs for." return 1 fi @@ -365,7 +178,7 @@ parse_command_line() { shift kernel_headers="$1" if [ -z "$kernel_headers" ]; then - logging.critical \ + echo \ "Error with given option \"$given_argument\": This option needs the path to the kernel headers." return 1 fi @@ -376,7 +189,7 @@ parse_command_line() { shift qcow_handler="$1" if [ -z "$qcow_handler" ]; then - logging.critical \ + echo \ "Error with given option \"$given_argument\": This options needs to be either 'xmount' or 'kernel'." return 1 fi @@ -397,18 +210,12 @@ parse_command_line() { break ;; *) - logging.critical \ + echo \ "Error with given option \"$1\": This argument is not available." return 1 esac done - if [ "$verbose" == 'yes' ]; then - logging.set_level info - fi - if [ "$debug" == 'yes' ]; then - logging.set_level debug - fi - # NOTE: Remove the following line if this sanity check should be performed. + return 0 if [[ "$UID" != '0' ]]; then logging.critical \ @@ -419,45 +226,7 @@ parse_command_line() { } ## endregion ## region helper -dependency_check() { - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Check for given dependencies with given dependency checker and log - corresponding messages. - - Example: - - `dependency_check core dependencies utils_dependency_check program` - ' - local result=0 - - # shellcheck disable=SC2016,SC1004 - eval 'for dependency_group in "${!'"$1"'_'"$2"'[@]}"; do - # NOTE: If "dependency_check_result" would be marked as local it is - # empty later. - dependency_check_result="$($3 $dependency_group)" || \ - local return_code=$? - if [[ $return_code == 1 ]]; then - echo "$dependency_check_result" - return $return_code - elif [[ $return_code == 2 ]]; then - while read dependency; do - eval "local reason=\${${1}_${2}[\"\$dependency_group\"]}" - local message="Missing $1 $4 dependency \"$dependency\" needed to $reason." - if [[ $1 == core ]]; then - logging.critical "$message" - else - logging.warn "$message" - fi - done <<< $dependency_check_result - result=2 - fi - return_code=0 - done' - return $result -} initialize_dracut() { - # shellcheck disable=SC2016,SC2034 local __doc__=' Downloads and compiles dracut. @@ -477,14 +246,14 @@ initialize_dracut() { dracut_resource_url="https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-$dracut_version.tar.gz" if [[ ! -f "${_root_dir}/dracut/install/dracut-install" ]]; then mkdir --parents "${_root_dir}/dracut" - logging.info "Download and extract dracut version $dracut_version" + echo "Download and extract dracut version $dracut_version" curl --location "$dracut_resource_url" | tar --extract --gzip \ --directory "${_root_dir}/dracut" --strip-components 1 pushd "${_root_dir}/dracut" # NOTE: On virtualbox shared folder symlinks are not allowed. # NOTE: make the dracut-install binary (dracut-install resolves # dependencies etc.) - logging.info 'Compiling dracut.' + echo 'Compiling dracut.' ./configure make install/dracut-install # NOTE: We have to copy the binary to current instead of symlinking @@ -499,6 +268,7 @@ initialize_dracut() { return $? } +# TODO does this even works? cleanup() { # shellcheck disable=SC2016,SC2034 local __doc__=' @@ -530,111 +300,30 @@ main() { `main` ' - exceptions.activate # 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:" + echo "Building for:" if [ -z "$kernel_version" ]; then kernel_version="$(uname -r)" fi - logging.info " * kernel version: $kernel_version" + echo " * 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.' + echo 'Missing core dependency "linux-headers" for version to compile against given or current kernel.' fi - logging.info " * kernel headers: $kernel_headers" + echo " * kernel headers: $kernel_headers" [ -n "$qcow_handler" ] && logging.info " * qcow2 handler: $qcow_handler" export _QCOW_HANDLER="$qcow_handler" # endregion - # 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 handle delegated operations to specified target - if [[ "$target" != '' ]]; then - _target="$target" - if [[ -f "$target" ]]; then - _target="$(mktemp --directory)" - _xmount_mountpoint_target="$(mktemp --directory)" - xmount --in qemu "$target" --out raw "$_xmount_mountpoint_target" - _xmount_device_target="$(losetup --find)" - losetup --partscan "$_xmount_device_target" \ - "${_xmount_mountpoint_target}/"*.dd - # TODO Use partscan - mount "$_xmount_device_target" "$_target" - fi - if [[ -d "$_target" ]]; then - _temporary_working_directory="$(chroot "$_target" mktemp --directory)" - mount --bind "$(pwd)" "${_target}${_temporary_working_directory}" - _parameter_skip=false - _parameter_to_forward=() - for _parameter; do - if $_parameter_skip; then - _parameter_skip=false - elif [[ "$_parameter" == '-t' ]] || \ - [[ "$_parameter" == '--target' ]]; then - _parameter_skip=true - else - _parameter_to_forward+=("$_parameter") - fi - done - # NOTE: We would have to temporary patch dracut to avoid removing the - # environment variables "LD_LIBRARY_PATH" and "LD_PRELOAD" to get - # "fakechroot" working with dracut. So we should remove this variables - # before running the patched dracut version to follow the initial - # intention. You should first do: - # >>> unset LD_LIBRARY_PATH - # >>> unset LD_PRELOAD - # and patch "dracut.sh" temporary to comment out: - # >>> unset LD_LIBRARY_PATH - # >>> unset LD_PRELOAD - # To avoid to broke the "fakechroot" environment pipe the ldconfig call - # to the native one: - # >>> FAKECHROOT_CMD_SUBST=/usr/bin/ldconfig=/usr/bin/ldconfig - # shellcheck disable=SC2086 - change_root "${_target}" \ - "${_temporary_working_directory}/${BASH_SOURCE[0]}" \ - ${_parameter_to_forward[*]} - mv "${_target}/$file_path" "$file_path" - # Do cleanup procedures. - umount "${_target}${_temporary_working_directory}" - rm --recursive --force "${_target}${_temporary_working_directory}" - if [[ -f "$target" ]]; then - umount "$_target" - losetup --detach "$_xmount_device_target" - umount "$_xmount_mountpoint_target" - rm --recursive --force "$_target" "$_xmount_mountpoint_target" - fi - fi - exit 0 - fi - # endregion - # region handle '--update' to update all the modules in 'modules.d' if [ "$update" == "yes" ]; then pushd "${_repo_dir}" git pull @@ -642,9 +331,9 @@ main() { fi # endregion # region handle dependencies which can be resolved automatically - logging.info 'Checking dracut.' + echo 'Checking dracut...' if [[ ! -f "${_root_dir}/dracut/dracut-install" ]]; then - logging.info "Dracut isn't available yet loading it." + echo "Dracut isn't available yet loading it." initialize_dracut fi @@ -653,16 +342,16 @@ main() { _dracut_module="$(basename $_dracut_module)" # shouldn't we use absolute paths here? _dracut_module_relative_path="../../modules.d/${_dracut_module}" - # TODO change to *not* always use '90' ... + # 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 - logging.info \ + 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 - logging.warn \ - "Linking \"$_dracut_module_relative_path\" to \"$_dracut_module_target\" failed." \ + echo \ + "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 \ "${_root_dir}/modules.d/$_dracut_module" \ @@ -678,59 +367,46 @@ main() { _loglevel='--verbose' fi _modules='dnbd3-rootfs conf-tgz' - logging.info "Default modules: ${_modules}" + echo "Default modules: ${_modules}" if [ "$debug" == 'yes' ]; then _loglevel="$_loglevel --stdlog 4" + # TODO check if we always want this _modules="$_modules i18n terminfo" fi + # TODO does non-systemd initramfs even works nowadays? + # Why you we want to do SysV-init style??? if [ "$use_systemd_in_initramfs" == 'yes' ]; then _modules="$_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 "${_root_dir}/modules.d" \ "${_root_dir}/dracut" --recursive --force elif [[ "$cleanup" == 'yes' ]]; then - logging.info 'Removing distribution specific files.' + echo 'Removing distribution specific files.' cleanup elif [[ "$initialize" == 'yes' ]]; then . "${_root_dir}/modules.d/dnbd3-rootfs/helper/build.inc" build_initialize_components else - 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 + echo 'Build initramfs.' "${_root_dir}/dracut/dracut.sh" --local \ $_loglevel --modules "$_modules" --conf /etc/dracut.conf \ --confdir /etc/dracut.conf.d "${dracut_parameter[@]}" \ --kver "${kernel_version}" "$file_path" _return_code=$? - logging.set_commands_level "$_commands_log_level_backup" - logging.set_level "$_log_level_backup" - if [[ "$_return_code" != 0 ]]; then - logging.error 'Building initial ram file system failed.' + if [ "$_return_code" != 0 ]; then + echo 'Building initial ram file system failed.' exit 1 fi - exceptions.activate # NOTE: dracut generate the initramfs with 0600 permissions chmod 0644 "${file_path}" fi - # endregion - exceptions.deactivate } # endregion -if core.is_main; then - main "$@" -fi +main "$@" + # region vim modline # vim: set tabstop=4 shiftwidth=4 expandtab: # vim: foldmethod=marker foldmarker=region,endregion: diff --git a/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh b/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh index 079d45be..1c8ace61 100755 --- a/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh +++ b/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh @@ -1,19 +1,11 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -exceptions.try -{ - # NOTE: "getarg" raises an exception so deactivate exceptions for now. - exceptions.deactivate slx_server="$(getarg slxsrv=)" slx_server_base="$(getarg slxbase=)" - exceptions.activate if [ -z "$SLX_NO_CONFIG_TGZ" ]; then # build config.tgz url @@ -26,18 +18,12 @@ exceptions.try conftgz_url="${conftgz_url}?uuid=${uuid}" fi fi - logging.info "Download config.tgz from '$conftgz_url'..." + info "Download config.tgz from '$conftgz_url'..." slx-tools download_retry -s "${conftgz_url}" > "/etc/config.tgz" if [[ ! -s "/etc/config.tgz" ]]; then - logging.warn \ + warn \ "Downloading 'config.tgz' from '${slx_server}' failed with: $return_code" - return 1 + # TODO handle error fi fi -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} diff --git a/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh b/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh index a2d550ce..a0da0cd3 100755 --- a/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh +++ b/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh @@ -1,9 +1,6 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # tarcopy @@ -19,50 +16,26 @@ tarcopy() { # this module unpacks the config.tgz temporary_extract_directory="$(mktemp -d)" -exceptions.try -{ - exceptions.activate if [[ -e "/etc/config.tgz" ]]; then tar --extract --preserve-permissions \ --file="/etc/config.tgz" \ --directory="$temporary_extract_directory" fi -} -exceptions.catch -{ - logging.error "Failed to extract '/etc/config.tgz' to '$temporary_extract_directory'." - logging.error "$exceptions_last_traceback" -} + warn "Failed to extract '/etc/config.tgz' to '$temporary_extract_directory'." + warn "$exceptions_last_traceback" # extracted to temporary directory, now check for SLX_LOCAL_CONFIGURATION + source "/etc/openslx" if [[ -n "$SLX_LOCAL_CONFIGURATION" ]]; then - exceptions.try - { - exceptions.activate - if [[ ! -d "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]]; then - logging.warn "SLX_LOCAL_CONFIGURATION is set but no corresponding folder found in '/etc/config.tgz'. Ignoring..." - else - tarcopy "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" "${temporary_extract_directory}" - fi - } - exceptions.catch - { - # errors here are not critical, so no emergency shell - logging.error "Failed to merge local configuration files for '$SLX_LOCAL_CONFIGURATION'." - logging.error "$exceptions_last_traceback" - } + if [[ ! -d "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]]; then + warn "SLX_LOCAL_CONFIGURATION is set but no corresponding folder found in '/etc/config.tgz'. Ignoring..." + else + tarcopy "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" "${temporary_extract_directory}" + fi fi -# now just copy everything from the temporary_extract_directory to the future root -exceptions.try -{ - exceptions.activate # purge openslx-configs/ rm -rf "${temporary_extract_directory}/openslx-configs" tarcopy "${temporary_extract_directory}" "$NEWROOT" -} -exceptions.catch -{ - # errors here are not critical, so no emergency shell - logging.error "Failed to copy extracted configuration files to '$NEWROOT'." - logging.error "$exceptions_last_traceback" -} + + + # TODO error handling diff --git a/builder/modules.d/conf-tgz/module-setup.sh b/builder/modules.d/conf-tgz/module-setup.sh index 353dc3a3..a07539cb 100755 --- a/builder/modules.d/conf-tgz/module-setup.sh +++ b/builder/modules.d/conf-tgz/module-setup.sh @@ -1,46 +1,13 @@ #!/usr/bin/env bash -# -*- coding: utf-8 -*- - -source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd '../' && \ - cd *'dnbd3-rootfs/scripts/rebash' && pwd)/core.sh" -core.import exceptions -core.import logging - check() { - local __doc__=' - Checks whether needed assumptions are satisfied. - - Example: - - `check` - ' - - # Here we could build our package file. - - # Tell dracut that this module should only be included if it is required - # explicitly. return 255 } depends() { - local __doc__=' - Outputs all dependent dracut modules to make this module work. - - >>> depends - +doc_test_contains - base - ' echo dnbd3-rootfs slx-tools } install() { - local __doc__=' - Copies all needed files into the initramfs image and registers all needed - dracut hooks. - - Example: - - `install` - ' inst_hook pre-mount 20 "$moddir/hooks/fetch-config-tgz.sh" inst_hook pre-pivot 20 "$moddir/hooks/unpack-config-tgz.sh" + # TODO check if busybox is enough inst_multiple tar mktemp gzip } diff --git a/builder/modules.d/dnbd3-rootfs/helper/build.inc b/builder/modules.d/dnbd3-rootfs/helper/build.inc index 894d0e10..114c3983 100644 --- a/builder/modules.d/dnbd3-rootfs/helper/build.inc +++ b/builder/modules.d/dnbd3-rootfs/helper/build.inc @@ -1,6 +1,5 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# shellcheck source=./rebash/core.sh declare -rg _mainmoddir="$(dirname "${BASH_SOURCE[0]}")/.." 2> /dev/null diff --git a/builder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh b/builder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh index 7f5dd1f6..ddfe4992 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh @@ -1,17 +1,6 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -# endregion -exceptions.try -{ -logging.set_commands_level debug -logging.set_level debug -[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx -logging.set_log_file "$SLX_LOG_FILE_PATH" systemd_system_unit_path="$(dirname \ "$(systemctl show -p FragmentPath dracut-mount.service | cut -c 14-)")" @@ -19,15 +8,5 @@ new_systemd_system_unit_path="${NEWROOT}/lib/systemd/system" cp "${systemd_system_unit_path}/dnbd3root.service" \ "${new_systemd_system_unit_path}/dnbd3root.service" mkdir --parents "${new_systemd_system_unit_path}/sysinit.target.wants" -! ln --symbolic '../dnbd3root.service' \ +ln --symbolic '../dnbd3root.service' \ "${new_systemd_system_unit_path}/sysinit.target.wants/dnbd3root.service" -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh b/builder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh index c722e734..5de1f2e9 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh @@ -1,17 +1,6 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -# endregion -exceptions.try -{ -logging.set_commands_level debug -logging.set_level debug -[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx -logging.set_log_file "$SLX_LOG_FILE_PATH" # Needed to be able to go back to dracut at system shutdown. temporary_directory_path="$(mktemp --directory)" @@ -19,15 +8,7 @@ mount --options bind / "$temporary_directory_path" cp --recursive --no-target-directory "$temporary_directory_path" /run/initramfs umount "$temporary_directory_path" rm --dir "$temporary_directory_path" -} -exceptions.catch -{ - logging.warn "Failed to copy initramfs to /run/initramfs, shutdown hooks" \ - "will not work." -} -exceptions.try -{ # Dracut may not be installed on the new root. Thus copy all services over. dracut_mount_unit_path="$(systemctl show -p FragmentPath dracut-mount.service \ | cut -c 14-)" @@ -50,18 +31,5 @@ do source_path="../${file}" target_path="${new_systemd_system_unit_path}/initrd.target.wants/${file}" ln --symbolic "$source_path" "$targetPath" &>/dev/null || \ - logging.warn "Failed to link \"$source_path\" to \"$target_path\"." + warn "Failed to link \"$source_path\" to \"$target_path\"." done -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} - -# region vim modline - -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: - -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh b/builder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh index 12dab27d..ff01474f 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh @@ -1,18 +1,7 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -# endregion -exceptions.try -{ source "/etc/openslx" -logging.set_commands_level debug -logging.set_level debug -[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx -logging.set_log_file "$SLX_LOG_FILE_PATH" mkdir --parents "${NEWROOT}/opt/openslx" cp "/etc/openslx" "${NEWROOT}/opt/openslx/config" @@ -27,14 +16,3 @@ fi if [ -n "${SLX_DEMO_PASS}" ] && grep -q '^demo' $NEWROOT/etc/shadow; then sed -i "s#^demo:[^:]*:#demo:$SLX_DEMO_PASS:#" $NEWROOT/etc/shadow fi - -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh b/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh index a1f8995c..cbdaef38 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh @@ -1,21 +1,11 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- # region imports -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh # endregion -exceptions.try -{ -logging.set_log_file "${SLX_LOG_FILE_PATH:-/var/log/openslx}" - -# NOTE: "getarg" raises an exception so deactivate exceptions for now. -exceptions.deactivate slx_server="$(getarg slxsrv=)" slx_server_base="$(getarg slxbase=)" -exceptions.activate # build config_url config_url="http://${slx_server#@}/${slx_server_base}/config" @@ -30,16 +20,16 @@ fi config_path="/etc/openslx.tmp" -logging.info "Downloading '$config_url'..." +echo "Downloading '$config_url'..." slx-tools download_retry -s "$config_url" > "$config_path" if [ ! -s "$config_path" ] ; then - logging.warn "Downloading OpenSLX configuration file from '$config_url' failed with: $return_code" + warn "Downloading OpenSLX configuration file from '$config_url' failed with: $return_code" emergency_shell "CRITICAL: System unusable." fi if ! ash -n "$config_path"; then - logging.warn "Downloaded OpenSLX configuration failed syntax check!" + warn "Downloaded OpenSLX configuration failed syntax check!" emergency_shell "CRITICAL: System unusable." fi @@ -57,14 +47,3 @@ cat "$config_path" >> /etc/openslx # slxsrv overrides SLX_DNBD3_SERVERS if prefixed with @ [ "${slx_server#@}" != "${slx_server}" ] && sed -i "s/^SLX_DNBD3_SERVERS=.*/SLX_DNBD3_SERVERS='${slx_server#@}'/" "/etc/openslx" - -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh b/builder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh index 8e7b1a7d..7eb77e87 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh @@ -1,30 +1,12 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -# endregion -exceptions.try -{ for kmod in dnbd3 \ loop \ loop_file_fmt_qcow \ loop_file_fmt_raw; do if ! modprobe "${kmod}"; then - logging.warn "Failed to load kernel module: $kmod" + warn "Failed to load kernel module: $kmod" ! : fi done - -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh index a5aceab6..9d49069c 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh @@ -1,16 +1,6 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import exceptions type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -# endregion -exceptions.try -{ -logging.set_commands_level debug -logging.set_level debug -[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx -logging.set_log_file "$SLX_LOG_FILE_PATH" if ! getarg root=; then source "/etc/openslx" @@ -21,13 +11,3 @@ if ! getarg root=; then echo "" > "$NEWROOT/etc/fstab" fi fi -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh index 619226f5..6a6b64f2 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -1,14 +1,7 @@ #!/usr/bin/env bash -# region imports type emergency_shell > /dev/null 2>&1 || source /lib/dracut-lib.sh source /etc/openslx -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging -# endregion -# region globals/helper -logging.set_log_file "${SLX_LOG_FILE_PATH:-/var/log/openslx}" # hardcode dnbd device path declare -rg _dnbd3_dev="/dev/dnbd0" @@ -20,18 +13,18 @@ container_unpack_xmount() { mkdir -p "$out_path" # check tools first if ! hash xmount systemd-preserve-process-marker; then - logging.warn "Missing xmount deps, will try raw..." 1>&2 + warn "Missing xmount deps, will try raw..." 1>&2 elif ! systemd-preserve-process-marker xmount \ --in qemu "$in_device" \ --out raw "$out_path" &>/dev/null; then - logging.warn "xmount call failed, assuming raw image." 1>&2 + warn "xmount call failed, assuming raw image." 1>&2 else in_device="${out_path}/${_dnbd3_dev##*/}.dd" fi local out_device="$(losetup -f)" if ! losetup "$out_device" "$in_device" --partscan; then - logging.warn "Failed to attach '$in_device' to '$out_device'." - return + warn "Failed to attach '$in_device' to '$out_device'." + return 1 fi udevadm settle echo "$out_device" @@ -41,7 +34,7 @@ container_unpack_losetup() { local in_device="$1" local out_device="$(losetup -f)" if ! losetup -r -t QCOW "$out_device" "$in_device" --partscan; then - logging.warn "Failed to attach '$in_device' to '$out_device'." + warn "Failed to attach '$in_device' to '$out_device'." return fi udevadm settle @@ -49,9 +42,6 @@ container_unpack_losetup() { } # endregion -exceptions.try -{ -# region connect dnbd3 image ( IFS=", " for host in ${SLX_DNBD3_SERVERS} FAIL; do @@ -60,7 +50,7 @@ for host in ${SLX_DNBD3_SERVERS} FAIL; do "${SLX_DNBD3_RID:+(revision: $SLX_DNBD3_RID)} " "from one of '$SLX_DNBD3_SERVERS' to '$_dnbd3_dev'." fi - logging.info "Trying host \"$host\"." + info "Trying host \"$host\"." if systemd-preserve-process-marker dnbd3-client \ --host "$host" \ --image "${SLX_DNBD3_IMAGE}" \ @@ -78,7 +68,7 @@ if [ "$SLX_QCOW_HANDLER" = "xmount" ]; then elif [ "$SLX_QCOW_HANDLER" = "kernel" ]; then read_only_device="$(container_unpack_losetup "$_dnbd3_dev")" else - logging.warn "Unsupported QCOW handler: $SLX_QCOW_HANDLER" + warn "Unsupported QCOW handler: $SLX_QCOW_HANDLER" fi # Fail fast if unpacking dnbd3 image failed. @@ -99,28 +89,15 @@ else eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" fi if [[ ! $? || -z "$read_only_partition" ]]; then - logging.error "Failed to find unique device with identifier" \ + warn "Failed to find unique device with identifier" \ "\"${SLX_SYSTEM_PARTITION_IDENTIFIER}\"; matched devices:" \ "\"${read_only_partition}\"" exit 1 fi -logging.info "Using read-only partition: $read_only_partition" +info "Using read-only partition: $read_only_partition" # endregion # region add rw layer to dnbd3 image # don't be fooled to think we are done, the next part is crucial dmsetup-slx-device "$read_only_partition" # endregion - -} -exceptions.catch -{ - logging.error "$exceptions_last_traceback" - emergency_shell "error in ${BASH_SOURCE[0]}" -} -# region vim modline - -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: - -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/module-setup.sh b/builder/modules.d/dnbd3-rootfs/module-setup.sh index 0356aa14..63bb0b29 100755 --- a/builder/modules.d/dnbd3-rootfs/module-setup.sh +++ b/builder/modules.d/dnbd3-rootfs/module-setup.sh @@ -1,13 +1,5 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# region imports -source "$(dirname "${BASH_SOURCE[0]}")/scripts/rebash/core.sh" -core.import exceptions -core.import logging -core.import utils -core.import "$(core_abs_path "$(dirname "${BASH_SOURCE[0]}")/helper/build.inc")" -# endregion -# region forward "build-initrfams.sh" logging configuration if present. _parse_dracut_args() { local __doc__=' Set log level via dracut logging options and returns current debug state. @@ -59,41 +51,23 @@ _parse_dracut_args() { local level $verbose && level=info $debug && level=debug - logging.set_level "$level" - logging.set_commands_level debug + #logging.set_level "$level" + #logging.set_commands_level debug done $debug return $? } +# WTF does this actually do aside from taking space! _debug=0 _parse_dracut_args ${dracut_args[*]} || _debug=$? # endregion -# region initialize function to build required components clean() { - local __doc__=' - Removes all compiled kernel specific files. - NOTE: This method is triggered manually and not supported by dracut itself. - - Example: - - `clean` - ' . "${moddir}/helper/build.inc" clean_components - return 0 } -# endregion # region dracut plugin api check() { - local __doc__=' - Checks wether all template system assumptions are satisfied. - - Example: - - `check` - ' - exceptions.activate build_initialize_components # NOTE: xmount must be compiled before qemu_xmount local xmount_is_built=true @@ -101,12 +75,11 @@ check() { [[ ! -f "$moddir/binaries/qemu-xmount/libxmount_input_qemu.so" ]]; then xmount_is_built=false fi - $xmount_is_built || logging.warn \ - "Compiling \"xmount\" failed." + # non-critical if failed + $xmount_is_built || warn "Compiling 'xmount'/'libxmount_input_qemu' failed." if [[ ! -f "$moddir/binaries/dnbd3/build/dnbd3.ko" ]] || \ - [[ ! -f "$moddir/binaries/dnbd3/build/dnbd3-client" ]] - then + [[ ! -f "$moddir/binaries/dnbd3/build/dnbd3-client" ]]; then CMAKE_FLAGS="-DKERNEL_VERSION=${kernel}" \ build_compile_dnbd3 "$moddir/binaries/dnbd3/" [[ $? != 0 ]] && return 1 @@ -116,6 +89,7 @@ check() { "$moddir/binaries/systemd-preserve-process-marker/" [[ $? != 0 ]] && return 1 fi + # TODO do we still need this ? # NOTE: This are workarounds for: # - distributions where "systemd-udevd" doesn't lives in "/usr/lib" but in # "/lib". @@ -125,39 +99,18 @@ check() { mkdir --parents "${initdir}${systemdutildir}" ln --symbolic --force "$alternate_systemd_udevd_location" \ "${initdir}${systemdutildir}/systemd-udevd" - #cp "$alternate_systemd_udevd_location" \ - # "${initdir}${systemdutildir}/systemd-udevd" 1>&2 fi + # WTF? # - "/usr/bin/sh" isn't available but "/bin/sh". if [[ ! -f /usr/bin/sh ]] && [[ -f /bin/sh ]]; then ln --symbolic --force /bin/sh /usr/bin/sh fi - exceptions.deactivate - # Tell dracut that this module should only be included if it is required - # explicitly. return 255 } depends() { - local __doc__=' - Outputs all dependent dracut modules to make this module work. - - >>> depends - +doc_test_contains - base - ' - #local network_module="network" - #dracut_module_included "systemd-initrd" && network_module="systemd-networkd-ext" - echo base bash kernel-modules shutdown slx-dmsetup slx-network # "$network_module" + echo base bash kernel-modules shutdown slx-dmsetup slx-network } installkernel() { - local __doc__=' - Copies all needed kernel modules into initramfs file needed work at - runtime. - - Example: - - `installkernel` - ' local block_kmod_dir="/lib/modules/${kernel}/kernel/drivers/block" # dnbd3 @@ -171,14 +124,6 @@ installkernel() { done } install() { - local __doc__=' - Copies all needed files into the initramfs image and registers all needed - dracut hooks. - - Example: - - `install` - ' # region binaries inst "$moddir/binaries/dnbd3/build/dnbd3-client" /usr/local/bin/dnbd3-client inst "$moddir/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker" \ @@ -202,7 +147,7 @@ install() { local losetup_qcow2_dir="$moddir/binaries/kernel-qcow2-util-linux" if [[ -f "${losetup_qcow2_dir}/.libs/losetup" ]]; then inst "${losetup_qcow2_dir}/.libs/losetup" /usr/local/bin/losetup - mkdir -p "${initdir}/usr/local/lib" + mkdir -p "${initdir}/usr/local/lib" cp -a "${losetup_qcow2_dir}/.libs/"*.so* "${initdir}/usr/local/lib" fi # endregion @@ -248,11 +193,6 @@ install() { "$moddir/hooks/copy-openslx-configuration-into-newroot.sh" # endregion # region scripts - local file_path - for file_path in "$moddir/scripts/rebash/"*; do - inst "$file_path" "/usr/lib/rebash/$(basename "$file_path")" - done - #inst "$moddir/scripts/tools.sh" "/usr/lib/openslx/tools.sh" # endregion # region configuration files # Use terminal readline settings from the template system. @@ -276,8 +216,3 @@ install() { sed sleep sort \ tee touch tr } -# endregion -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/scripts/build.sh b/builder/modules.d/dnbd3-rootfs/scripts/build.sh deleted file mode 100644 index 7da60a08..00000000 --- a/builder/modules.d/dnbd3-rootfs/scripts/build.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# shellcheck source=./rebash/core.sh -source "$(dirname "${BASH_SOURCE[0]}")/rebash/core.sh" -core.import logging - -build_compile_qemu_xmount() { - local __doc__=' - Compiles qemu libxmount. - NOTE: expects xmount installation under - $1/../xmount/trunk/build/release_build/ - - Provides the following file: - "$1/libxmount_input_qemu.so" - - Example: - - `build_compile_qemu_xmount /qemu_source /xmount/installation` - ' - pushd "$1" - local xmount_installation="../xmount/trunk/build/release_build/usr" - [ ! -z "$2" ] && xmount_installation="$2" - ./configure --enable-xmount-input --python="$(which python2)" \ - --extra-cflags="-fPIC" \ - --extra-cflags="-std=gnu99" \ - --extra-cflags="-I${xmount_installation}/include" \ - --extra-cflags="-I${xmount_installation}/include/xmount" \ - --disable-fdt --target-list="" - make -j libxmount_input_qemu.so - local ret=$? - popd - return $ret -} -build_clean_qemu_xmount() { - local __doc__='Clean the build of `build_compile_qemu_xmount`.' - pushd "$1" - make clean - local ret=$? - popd - return $ret -} -build_compile_xmount() { - local __doc__=' - Compiles xmount. - - Provides the xmount installation under: - "$1/trunk/build/release_build/" - - Example: - - `build_compile_xmount /xmount_source /xmount_source/build /usr` - ' - pushd "$1" - - local destination_directory="./release_build" - [ ! -z "$2" ] && destination_directory="$2" - local install_prefix="/usr" - [ ! -z "$3" ] && install_prefix="$3" - - mkdir --parents trunk/build - cd trunk/build || return 1 - cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$install_prefix" .. - make -j - make install DESTDIR="$destination_directory" - local ret=$? - popd - return $ret -} -build_clean_xmount() { - local __doc__='Clean the build of `build_compile_xmount`.' - rm --recursive --force "$1/trunk/build" -} -build_compile_dnbd3() { - local __doc__=' - Compiles dnbd3 kernel module and client. - - Provides the following file: - "$1/build/dnbd3.ko" - "$1/build/dnbd3-client" - - Examples: - - `build_compile_dnbd3 path/to/dnbd3/source/` - - Passing the kernel version to cmake: - `CMAKE_FLAGS="-DKERNEL_VERSION=4.14.6-openslx+" \ - build_compile_dnbd3 path/to/dnbd3/source/` - ' - pushd "$1" - # NOTE: The generic way would be: "./build.sh" but this tries to build - # more than we really need and takes more time. - mkdir --parents build - pushd build - # Inject CMAKE_FLAGS as a way to control how cmake is called, - # e.g. to pass the kernel version - cmake ${CMAKE_FLAGS} ../ - make -j dnbd3 dnbd3-client - local ret=$? - popd - return $ret -} -build_clean_dnbd3() { - local __doc__='Clean the build of `build_compile_dnbd3`.' - rm --recursive --force "$1/build" - return $? -} -build_compile_losetup_qcow() { - pushd "$1" - { - set -e - ./autogen.sh - ./configure - make -j losetup - } - local ret=$? - popd - return $ret -} -build_clean_losetup_qcow() { - pushd "$1" - make clean - local ret=$? - popd - return $ret -} -build_compile_systemd_preserve_process_marker() { - local __doc__=' - Compiles simple c program. - - Examples: - - `build_compile_systemd_preserve_process_marker path/to/program/folder` - ' - pushd "$1" - make - local ret=$? - popd - return $ret -} -build_clean_systemd_preserve_process_marker() { - local __doc__=' - Clean the build of - `build_compile_systemd_preserve_process_marker`. - ' - pushd "$1" - make clean - local ret=$? - popd - return $ret -} -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh b/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh deleted file mode 100755 index 53fd73dc..00000000 --- a/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -source "/usr/lib/rebash/core.sh" -core.import exceptions -exceptions.activate -# endregion - -in_device="$1" -nbd_device="$2" # TODO detect first free nbd device - -systemd-preserve-process-marker qemu-nbd --connect="$nbd_device" \ - "$in_device" --read-only --persistent --nocache - -# TODO better way to wait for the device to be made? -i=0 -while [ ! -b "$nbd_device" ]; do - [ $i -ge 20 ] && exit 1 - if [ $UDEVVERSION -ge 143 ]; then - udevadm settle --exit-if-exists="$nbd_device" - else - sleep 0.1 - fi - i=$(($i + 1)) -done - -# NBD doesn't emit uevents when it gets connected, so kick it -# TODO get path from $nbd_device -echo change > /sys/block/nbd0/uevent -udevadm settle - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh b/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh deleted file mode 100755 index c7e1b45c..00000000 --- a/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import logging -core.import utils -core.import exceptions -exceptions.activate -# endregion -logging.set_level info -logging.set_commands_level info - -# NOTE: All output has to be forwarded to standard error because determined -# device should be printed on standard output. -in_device="$1" -mkdir --parents /mnt/xmount -loop_device="$(losetup --find)" -if ! utils.dependency_check xmount; then - logging.warn "\"xmount\" not found, assuming raw image." 1>&2 -elif systemd-preserve-process-marker xmount --in qemu "$in_device" --out raw \ - /mnt/xmount &>/dev/null -then - in_device="/mnt/xmount/*.dd" -else - logging.warn "\"xmount\" call failed, assuming raw image." 1>&2 -fi -losetup "$loop_device" $in_device --partscan -udevadm settle -echo "$loop_device" - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/scripts/rebash b/builder/modules.d/dnbd3-rootfs/scripts/rebash deleted file mode 160000 index 6ca5b39c..00000000 --- a/builder/modules.d/dnbd3-rootfs/scripts/rebash +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6ca5b39c862aed6a13146f4121fb51f784b1eb48 diff --git a/builder/modules.d/dnbd3-rootfs/scripts/tools.sh b/builder/modules.d/dnbd3-rootfs/scripts/tools.sh deleted file mode 100644 index bace775e..00000000 --- a/builder/modules.d/dnbd3-rootfs/scripts/tools.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -# shellcheck source=./rebash/core.sh -source "/usr/lib/rebash/core.sh" -core.import logging -# endregion -tools__doc_test_setup__=' -lsblk() { - if [[ "${@: -1}" == "" ]];then - echo "lsblk: : not a block device" - return 1 - fi - if [[ "${@: -1}" != "/dev/sdb" ]];then - echo "/dev/sda disk" - echo "/dev/sda1 part SYSTEM_LABEL 0x7" - echo "/dev/sda2 part" - fi - if [[ "${@: -1}" != "/dev/sda" ]];then - echo "/dev/sdb disk" - echo "/dev/sdb1 part boot_partition " - echo "/dev/sdb2 part system_partition" - fi -} -blkid() { - [[ "${@: -1}" != "/dev/sda2" ]] && return 0 - echo "gpt" - echo "only discoverable by blkid" - echo "boot_partition" - echo "192d8b9e" -} -sleep() { - ((_test_sleep_time++)) -} -' - -tools_find_block_device() { - # shellcheck disable=SC2034,SC2016 - local __doc__=' - >>> tools.find_block_device "boot_partition" - /dev/sdb1 - >>> tools.find_block_device "boot_partition" /dev/sda - /dev/sda2 - >>> tools.find_block_device "discoverable by blkid" - /dev/sda2 - >>> tools.find_block_device "_partition" - /dev/sdb1 /dev/sdb2 - >>> tools.find_block_device "not matching anything"; echo $? - 1 - >>> tools.find_block_device ""; echo $? - 1 - - >>> local _test_sleep_time=0 - >>> tools.find_block_device "not matching anything" /dev/sda 10; echo $? - >>> echo $_test_sleep_time - 1 - 10 - ' - local partition_pattern="$1" - [ "$partition_pattern" = '' ] && return 1 - local device="$2" - local timeout=0 - [ ! -z "$3" ] && timeout="$3" - tools_find_block_device_simple() { - local device_info - lsblk --noheadings --list --paths --output \ - NAME,TYPE,LABEL,PARTLABEL,UUID,PARTUUID ${device:+"$device"} \ - | sort --unique | while read -r device_info; do - local current_device - current_device=$(echo "$device_info" | cut -d' ' -f1) - if [[ "$device_info" = *"${partition_pattern}"* ]]; then - echo "$current_device" - fi - done - } - tools_find_block_device_deep() { - local device_info - lsblk --noheadings --list --paths --output NAME ${device:+"$device"} \ - | sort --unique | cut -d' ' -f1 | while read -r current_device; do - blkid -p -o value "$current_device" \ - | while read -r device_info; do - if [[ "$device_info" = *"${partition_pattern}"* ]]; then - echo "$current_device" - fi - done - done - } - while ((timeout >= 0)); do - local candidates - candidates=($(tools_find_block_device_simple)) - (( ${#candidates[@]} == 0 )) && candidates=($(tools_find_block_device_deep)) - (( ${#candidates[@]} > 1 )) && echo "${candidates[@]}" && return 1 - (( ${#candidates[@]} == 1 )) && echo "${candidates[0]}" && return 0 - ((timeout == 0)) || sleep 1 - ((timeout--)) - done - # no candidates - return 1 -} -alias tools.find_block_device="tools_find_block_device" - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion -- cgit v1.2.3-55-g7522 From dd9b081f33052a3d48cb66e9856fe3804cdcd97d Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 16 Sep 2019 17:06:40 +0200 Subject: more cleanup --- builder/build-initramfs.sh | 118 ++++++--------------------------------------- 1 file changed, 16 insertions(+), 102 deletions(-) (limited to 'builder') diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index d9017e74..fa57857a 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -3,15 +3,14 @@ # region header # Copyright Torben Sickert (info["~at~"]torben.website) 29.10.2015 # Janosch Dobler (info["~at~"]jandob.com) 29.10.2015 - +# Jonathan Bauer (jonathan.bauer@rz.uni-freiburg.de) 19.09.2019 # License # ------- # This library written by Torben Sickert and Janosch Dobler stand under a # creative commons naming 3.0 unported license. # see http://creativecommons.org/licenses/by/3.0/deed.de -# This tool provides a generic way to install systemd based remote linux -# initramfs. +## endregion declare -rg _root_dir="$(readlink -f $(dirname ${BASH_SOURCE[0]}))" declare -rg _repo_dir="${_root_dir}/systemd-init.git" @@ -25,6 +24,7 @@ if [ ! -e "$_repo_dir" ]; then if ! hash git; then echo "Needed dependency \"git\" isn't available." echo "Please install \"git\" or provide the main repository in \"${_repo_dir}\"." + exit 1 fi git clone --branch "$_git_branch" --single-branch --depth 1 \ "$_git_source" "${_repo_dir}" @@ -70,44 +70,10 @@ cleanup='no' full_cleanup='no' use_systemd_in_initramfs='no' -print_command_line_option_description() { - cat << EOF --h --help Shows this help message. - --v --verbose Tells you what is going on (default: "$verbose"). - --d --debug Gives you any output from all tools which are used - (default: "$debug"). - --p --file-path Target location for initramfs file - (default: "$file_path"). - --c --cleanup Removes all distribution specific compiled files. - --f --full-cleanup Removes all retrieved and compiled files (usefull to retrieve latest version of all nested modules). - --t --target Creates an image against given target template filesystem. If not - explicitly specified current system will be used as template system - (default: "$target"). - --i --init Initializes the various repositories and build the required - dependencies but do not build the initramfs. Use this to accelerate - subsequent calls of this script. - --k --kernel-version Creates an image for the given kernel version. Will - require the presence of kernel headers for this version. - (default: "$(uname -r)") - --s --use-systemd-in-initramfs Use Systemd as init process in initramfs - (improved performance but less features) - (default: "$use_systemd_in_initramfs"). - -Additional dracut parameter and normal parameter can be added by delimiting -them via a single dash (-) (default: "$dracut_parameter" with -"--modules" and dynamically determined modules. Additional custom modules are -concatenated.). -EOF +print_help_message() { + echo "help" } + parse_command_line() { while true; do case "$1" in @@ -129,7 +95,7 @@ parse_command_line() { shift file_path="$1" if [[ "$file_path" == '' ]]; then - logging.critical \ + echo \ "Error with given option \"$given_argument\": This option needs a path to save initramfs image to." return 1 fi @@ -152,7 +118,7 @@ parse_command_line() { shift target="$1" if [[ "$target" == '' ]]; then - logging.critical \ + echo \ "Error with given option \"$given_argument\": This option needs a path create initramfs from." return 1 fi @@ -217,23 +183,10 @@ parse_command_line() { done return 0 - if [[ "$UID" != '0' ]]; then - logging.critical \ - "You have to run this script as \"root\" not as \"${USER}\"." - exit 2 - fi - return 0 } ## endregion ## region helper initialize_dracut() { - local __doc__=' - Downloads and compiles dracut. - - Example: - - `initialize_dracut` - ' # First check what version to get # Autodetect the kmod version present on the system to decide which dracut version to get # * v47 requires kmod >= 23 (Available in Ubuntu 18.04) @@ -270,37 +223,18 @@ initialize_dracut() { # TODO does this even works? cleanup() { - # shellcheck disable=SC2016,SC2034 - local __doc__=' - Removes distribution specific generated files. - - Example: - - `cleanup` - ' local plugin_path plugin_path="${_root_dir}/modules.d/dnbd3-rootfs" - # shellcheck disable=SC1090 source "${plugin_path}/module-setup.sh" - # shellcheck disable=SC2034 moddir="$(cd "$plugin_path" &>/dev/null && pwd)" clean return $? } -## endregion -# endregion -# region controller main() { - # 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` - ' - # region sanity check kernel version and qcow handler + if ! parse_command_line "$@"; then + print_help_message "$0" + exit 1 + fi # if no kernel was specified as dracut argument, use the running kernel's version echo "Building for:" if [ -z "$kernel_version" ]; then @@ -315,23 +249,16 @@ main() { echo 'Missing core dependency "linux-headers" for version to compile against given or current kernel.' fi echo " * kernel headers: $kernel_headers" - [ -n "$qcow_handler" ] && logging.info " * qcow2 handler: $qcow_handler" + [ -n "$qcow_handler" ] && echo " * qcow2 handler: $qcow_handler" export _QCOW_HANDLER="$qcow_handler" - # endregion - - if ! parse_command_line "$@"; then - print_help_message "$0" - exit 1 - fi if [ "$update" == "yes" ]; then pushd "${_repo_dir}" git pull popd fi - # endregion - # region handle dependencies which can be resolved automatically - echo 'Checking dracut...' + + echo 'Checking dracut...' if [[ ! -f "${_root_dir}/dracut/dracut-install" ]]; then echo "Dracut isn't available yet loading it." initialize_dracut @@ -359,25 +286,18 @@ main() { fi fi done - # endregion - # region prepare modules and perform final dracut call _loglevel='' if [ "$verbose" == 'yes' ]; then _loglevel='--verbose' fi - _modules='dnbd3-rootfs conf-tgz' + _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 - # TODO does non-systemd initramfs even works nowadays? - # Why you we want to do SysV-init style??? - if [ "$use_systemd_in_initramfs" == 'yes' ]; then - _modules="$_modules systemd systemd-initrd dracut-systemd" - fi # Preprocess done - start build, cleanup or full cleanup if [[ "$full_cleanup" == 'yes' ]]; then echo 'Removing all modules.' @@ -404,10 +324,4 @@ main() { chmod 0644 "${file_path}" fi } -# endregion main "$@" - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion -- cgit v1.2.3-55-g7522 From 08f3d006ea8d3afa9e70af5a0b8ba8c7d350e026 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 17 Sep 2019 18:31:06 +0200 Subject: more optimiziation --- .../hooks/prepare-kernel-command-line-parameter.sh | 89 ---------------------- .../dnbd3-rootfs/udev/70-openslx-disk.rules | 7 -- 2 files changed, 96 deletions(-) delete mode 100755 builder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh delete mode 100644 builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules (limited to 'builder') diff --git a/builder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh b/builder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh deleted file mode 100755 index 20041ecf..00000000 --- a/builder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import exceptions -core.import logging -# endregion -( -logging.set_commands_level debug -logging.set_level debug -[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx -logging.set_log_file "$SLX_LOG_FILE_PATH" - -SLX_INITIAL_KERNEL_COMMAND_LINE="$(cat /proc/cmdline | tr --delete '\n')" - -# This location will be used to have a writable kernel command line file -# location. -writeable_proc_cmdline_path='/writable_proc_cmdline/' -mkdir --parents "$writeable_proc_cmdline_path" -# NOTE: The fake writeable overlay have to be a temporary filesystem for the -# hack to work. -mount --types tmpfs tmpfs "$writeable_proc_cmdline_path" -echo -n "$SLX_INITIAL_KERNEL_COMMAND_LINE" > \ - "${writeable_proc_cmdline_path}/cmdline" - -logging.debug \ - '-----------------------Kernel-Command-Line:------------------------------' -logging.debug "${SLX_INITIAL_KERNEL_COMMAND_LINE}" -logging.debug \ - '-------------------------------------------------------------------------' - -for parameter in $(getargs BOOTIF=); do - logging.debug "PXE given boot interface $parameter" - dracut_interface_name="bootnet:$(echo $parameter | \ - sed --regexp-extended 's/.{2}[:\-]((.{2}[:\-]){5}.{2})/\1/' | \ - sed s/-/:/g)" - logging.debug "Dracut interface name is: $dracut_interface_name" - logging.plain -n " ifname=$dracut_interface_name" >> \ - "${writeable_proc_cmdline_path}cmdline" -done -for parameter in $(getargs ip=); do - temp="$parameter:" - set -- - while [ -n "$temp" ]; do - set -- "$@" "${temp%%:*}" - temp=${temp#*:} - done - - [ -n "$1" ] && ip=$1 - [ -n "$2" ] && server_ip=$2 - [ -n "$3" ] && gateway_ip=$3 - [ -n "$4" ] && net_mask=$4 - - logging.debug "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask" - dracut_ip_configuration="$ip::$gateway_ip:$net_mask::bootnet:off" - logging.debug "Dracut ip configuration is: $dracut_ip_configuration" - sed --regexp-extended "s/ip=[^ ]*/ip=$dracut_ip_configuration/g" \ - --in-place "${writeable_proc_cmdline_path}cmdline" -done - -if [ -z "$dracut_ip_configuration" ]; then - logging.warn 'No "ip" parameter found in the kernel command line.' -fi -if [ -z "$dracut_interface_name" ]; then - logging.warn 'No "BOOTIF" parameter found in the kernel command line.' -fi -mount --options bind "${writeable_proc_cmdline_path}cmdline" /proc/cmdline - -if [ -z "$(getargs slxsrv=)" ]; then - logging.warn 'No "slxsrv" parameter found in the kernel command line.' - exit 1 -fi -if [ -z "$(getargs slxbase=)" ]; then - logging.warn 'No "slxbase" parameter found in the kernel command line.' - exit 1 -fi - -logging.debug \ - '-----------------------Dracut-Kernel-Command-Line:-----------------------' -logging.debug "$(logging.cat /proc/cmdline)" -logging.debug \ - '-------------------------------------------------------------------------' -) -# region vim modline - -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: - -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules b/builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules deleted file mode 100644 index 9aad9a41..00000000 --- a/builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules +++ /dev/null @@ -1,7 +0,0 @@ -# GPT rules -KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="gpt" ENV{ID_PART_ENTRY_NAME}=="OPENSLX_TMP" RUN+="/sbin/prepare-persistent-disks %E{ID_PART_ENTRY_NAME} %k" -KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="gpt" ENV{ID_PART_ENTRY_NAME}=="OPENSLX_SYS" RUN+="/sbin/prepare-persistent-disks %E{ID_PART_ENTRY_NAME} %k" - -# MBR rules -KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="dos" ENV{ID_PART_ENTRY_TYPE}=="0x44" RUN+="/sbin/prepare-persistent-disks OPENSLX_TMP %k" -KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="dos" ENV{ID_PART_ENTRY_TYPE}=="0x46" RUN+="/sbin/prepare-persistent-disks OPENSLX_SYS %k" -- cgit v1.2.3-55-g7522 From 1f88b49018427cf37079e70dac3149f7a1dd94f4 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 17 Sep 2019 18:31:21 +0200 Subject: more improvements --- builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh | 5 ----- builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh | 1 + builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh | 14 ++++++-------- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'builder') diff --git a/builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh b/builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh index f159e3ae..323ec45e 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh @@ -3,8 +3,3 @@ # Enables magic sysrq kernel supported key combinations. echo 1 > /proc/sys/kernel/sysrq - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh b/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh index cbdaef38..a11332a7 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh @@ -47,3 +47,4 @@ cat "$config_path" >> /etc/openslx # slxsrv overrides SLX_DNBD3_SERVERS if prefixed with @ [ "${slx_server#@}" != "${slx_server}" ] && sed -i "s/^SLX_DNBD3_SERVERS=.*/SLX_DNBD3_SERVERS='${slx_server#@}'/" "/etc/openslx" +true diff --git a/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh index 9d49069c..702b6331 100755 --- a/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh +++ b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh @@ -2,12 +2,10 @@ # -*- coding: utf-8 -*- type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh -if ! getarg root=; then - source "/etc/openslx" - mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" $SLX_MOUNT_ROOT_OPTIONS - if [ -n "$SLX_GENERATE_FSTAB_SCRIPT" ]; then - eval "$SLX_GENERATE_FSTAB_SCRIPT" - else - echo "" > "$NEWROOT/etc/fstab" - fi +source "/etc/openslx" +mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" $SLX_MOUNT_ROOT_OPTIONS +if [ -n "$SLX_GENERATE_FSTAB_SCRIPT" ]; then + eval "$SLX_GENERATE_FSTAB_SCRIPT" +else + echo "" > "$NEWROOT/etc/fstab" fi -- cgit v1.2.3-55-g7522 From 6d494189f8b1059011bd53d468f832c98257f961 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 16 Oct 2019 14:42:03 +0200 Subject: [slx-dmsetup] fix encrypted scratch dev name --- builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builder') diff --git a/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device b/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device index c0f6a274..1756865e 100755 --- a/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device +++ b/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device @@ -273,7 +273,7 @@ save_partition_info "${scratch_device##*/}" "*" "1" "$scratch_device_size" # encrypt the scratch device, if configured if [ "$crypt" -ne 0 ] && encrypt_device \ "$scratch_device" "${scratch_device##*/}-crypt" "$scratch_device_size"; then - scratch_device="${scratch_device##*/}-crypt" + scratch_device="${scratch_device}-crypt" fi writable_device_allocated="$scratch_device_size" @@ -319,7 +319,7 @@ create_pool() { # create remaining thin volumes modprobe dm-thin-pool || echo "$0: dm-thin-pool load failed, maybe builtin?" # create temporary metadata device - data_block_size=256 + data_block_size=255 # calculate number of sectors needed and check boundaries: metadata_dev_size="$(( 48 * $writable_device_size / $data_block_size / 512 ))" # Min 2MB -> 4096 sectors, max 16GB -> 33554432 sectors -- cgit v1.2.3-55-g7522 From 575838e14470df890d017d49c980e2920d9a0fd9 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 16 Oct 2019 15:13:55 +0200 Subject: [slx-dmsetup] install xts kmod for dm-crypt --- builder/modules.d/slx-dmsetup/module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'builder') diff --git a/builder/modules.d/slx-dmsetup/module-setup.sh b/builder/modules.d/slx-dmsetup/module-setup.sh index 58c6e5cf..68e9b7b4 100755 --- a/builder/modules.d/slx-dmsetup/module-setup.sh +++ b/builder/modules.d/slx-dmsetup/module-setup.sh @@ -17,5 +17,8 @@ install() { } installkernel() { # install those modules in case the used kernel does not have them builtin - instmods dm-thin-pool dm-snapshot dm-crypt crc32c xfs ext4 + instmods \ + dm-thin-pool dm-snapshot \ + dm-crypt crc32c xts \ + xfs ext4 } -- cgit v1.2.3-55-g7522 From 909028480646abce1552d902495dbcec0808dc38 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 25 Oct 2019 13:12:54 +0200 Subject: [slx-network] wait 30sec for network to cope with some old/bad NICs that need >10sec to get up --- builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'builder') diff --git a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 index 4535ccd3..53ad8de9 100755 --- a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 +++ b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 @@ -31,9 +31,9 @@ wait_for_iface() { set -x ip link set dev "$SLX_PXE_NETIF" up -if ! wait_for_iface "$SLX_PXE_NETIF" 100; then - warn "'$SLX_PXE_NETIF' still not up after 10sec ... trying anyway." - # TODO handle case where we waited for 10sec and it is still not up +if ! wait_for_iface "$SLX_PXE_NETIF" 300; then + warn "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway." + # TODO handle case where we waited for 30sec and it is still not up fi # now determine whether we are in bridged/vlan/plain mode -- cgit v1.2.3-55-g7522 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(-) (limited to 'builder') 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 From 9de67bc23d45cd35760a4dd762219b1cf3dc4c24 Mon Sep 17 00:00:00 2001 From: Thiago Abdo Date: Mon, 4 Nov 2019 10:47:08 +0100 Subject: Change sync branch to nobash Signed-off-by: Thiago Abdo --- builder/build-initramfs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builder') diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index 647a42cd..5f6baf54 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -15,7 +15,7 @@ declare -rg _root_dir="$(readlink -f $(dirname ${BASH_SOURCE[0]}))" declare -rg _repo_dir="${_root_dir}/systemd-init.git" declare -rg _git_source="git://git.openslx.org/openslx-ng/systemd-init.git" -declare -rg _git_branch="master" +declare -rg _git_branch="nobash" ## region ensure presence of needed dependencies set -o errexit -- cgit v1.2.3-55-g7522 From 5e3fa459338acce9da194b72cf7e8f6a8dc9ee74 Mon Sep 17 00:00:00 2001 From: Thiago Abdo Date: Mon, 4 Nov 2019 12:21:55 +0100 Subject: Removing extra loggings from rebash Signed-off-by: Thiago Abdo --- builder/build-initramfs.sh | 2 +- builder/modules.d/dnbd3-rootfs/helper/build.inc | 34 ++++++++++++------------- dev-tools/exampleDracutModule/apply-package.sh | 6 ++--- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'builder') diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index 5f6baf54..b8599e43 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -309,7 +309,7 @@ main() { . "${_repo_dir}/builder/modules.d/dnbd3-rootfs/helper/build.inc" build_initialize_components if [[ "$initialize" == 'yes' ]]; then - logging.info "Initialized." + echo "Initialized." exit 0 fi echo 'Build initramfs.' diff --git a/builder/modules.d/dnbd3-rootfs/helper/build.inc b/builder/modules.d/dnbd3-rootfs/helper/build.inc index 2410c633..13ab9159 100644 --- a/builder/modules.d/dnbd3-rootfs/helper/build.inc +++ b/builder/modules.d/dnbd3-rootfs/helper/build.inc @@ -8,34 +8,34 @@ build_initialize_components() { local qcow_handler="$_QCOW_HANDLER" IFS='|' _pattern="^(${_supported_qcow_handlers[*]})$" export _pattern if [[ ! "$qcow_handler" =~ $_pattern ]] ; then - logging.warn "Unknown qcow handler '$qcow_handler' - will built all known." - logging.warn "Supported handlers: ${_supported_qcow_handlers[*]}" + echo "Unknown qcow handler '$qcow_handler' - will built all known." + echo "Supported handlers: ${_supported_qcow_handlers[*]}" fi _deps_base_dir="${_mainmoddir}/binaries" # We might want to move the "binaries" repos from the dnbd3-rootfs module to main repo one day... # TODO check for its existence using modinfo -k if [[ ! -f "${_deps_base_dir}/dnbd3/build/dnbd3.ko" ]] || \ [[ ! -f "${_deps_base_dir}/dnbd3/build/dnbd3-client" ]]; then - logging.info "Could not find dnbd3, building it..." + echo "Could not find dnbd3, building it..." if ! CMAKE_FLAGS="-DKERNEL_DIR=${kernel_headers}" \ build_compile_dnbd3 "${_deps_base_dir}/dnbd3/"; then - logging.error "Failed to build dnbd3." + echo "Failed to build dnbd3." return 1 fi fi # take care of the qcow handler if [ -z "$qcow_handler" ] || [ "$qcow_handler" = "xmount" ]; then if [[ ! -f "${_deps_base_dir}/xmount/trunk/build/src/xmount" ]]; then - logging.info "Could not find xmount binary, building it..." + echo "Could not find xmount binary, building it..." if ! build_compile_xmount "${_deps_base_dir}/xmount/"; then - logging.error "Failed to build xmount binary." + echo "Failed to build xmount binary." return 1 fi fi if [[ ! -f "${_deps_base_dir}/qemu-xmount/libxmount_input_qemu.so" ]]; then - logging.info "Could not find xmount qemu library, building it..." + echo "Could not find xmount qemu library, building it..." if ! build_compile_qemu_xmount "${_deps_base_dir}/qemu-xmount/"; then - logging error "Failed to build xmount qemu library." + echo "Failed to build xmount qemu library." return 1 fi fi @@ -44,16 +44,16 @@ build_initialize_components() { if [ ! -f "${_deps_base_dir}/kernel-qcow2-linux/drivers/block/loop/loop.ko" ] \ || [ ! -f "${_deps_base_dir}/kernel-qcow2-linux/drivers/block/loop/loop_file_fmt_qcow.ko" ] \ || [ ! -f "${_deps_base_dir}/kernel-qcow2-linux/drivers/block/loop/loop_file_fmt_raw.ko" ]; then - logging.info "Could not find loop kernel modules, building them..." + echo "Could not find loop kernel modules, building them..." if ! build_compile_kernel_qcow "${_deps_base_dir}/kernel-qcow2-linux"; then - logging.error "Failed to build qcow loop kernel modules." + echo "Failed to build qcow loop kernel modules." return 1 fi fi if [ ! -f "${_deps_base_dir}/kernel-qcow2-util-linux/losetup" ]; then - logging.info "Could not find losetup with qcow2 support, building it..." + echo "Could not find losetup with qcow2 support, building it..." if ! build_compile_losetup_qcow "${_deps_base_dir}/kernel-qcow2-util-linux"; then - logging.error "Failed to build losetup with qcow support." + echo "Failed to build losetup with qcow support." return 1 fi fi @@ -61,14 +61,14 @@ build_initialize_components() { # always compile this helper since it does not cost much to do so if [[ ! -f "${_deps_base_dir}/systemd-preserve-process-marker/systemd-preserve-process-marker" ]]; then - logging.info "Could not find systemd-preserve-process-marker binary, building it ..." + echo "Could not find systemd-preserve-process-marker binary, building it ..." if ! build_compile_systemd_preserve_process_marker \ "${_deps_base_dir}/systemd-preserve-process-marker/"; then - logging.error "Failed to build systemd-preserve-process-marker" + echo "Failed to build systemd-preserve-process-marker" return 1 fi fi - logging.info "Compilation of dnbd3-rootfs dependencies succeeded." + echo "Compilation of dnbd3-rootfs dependencies succeeded." return 0 } @@ -204,7 +204,7 @@ build_compile_kernel_qcow() { pushd "$1" # https://lab.ks.uni-freiburg.de/projects/kernel-qcow2/wiki if [ -z "$kernel_headers" ]; then - logging.error "Kernel header directory not set, ignoring." + echo "Kernel header directory not set, ignoring." return 1 fi mkdir -p "${kernel_headers}/drivers/block/loop" @@ -231,7 +231,7 @@ build_compile_kernel_qcow() { } build_clean_kernel_qcow() { if [ -z "$kernel_headers" ]; then - logging.error "Kernel header directory not set, ignoring." + echo "Kernel header directory not set, ignoring." return 1 fi pushd "$kernel_headers" diff --git a/dev-tools/exampleDracutModule/apply-package.sh b/dev-tools/exampleDracutModule/apply-package.sh index 07d3c0a5..25a685b2 100755 --- a/dev-tools/exampleDracutModule/apply-package.sh +++ b/dev-tools/exampleDracutModule/apply-package.sh @@ -16,11 +16,11 @@ exceptions.try slx_server_base="$(getarg slxbase=)" exceptions.activate - logging.info 'Getting package.' + echo 'Getting package.' IFS_backup="$IFS" IFS=',' for host in ${slx_server}; do - logging.info "Trying host \"$host\"." + echo "Trying host \"$host\"." if wget --timeout 5 \ "http://${host}/${slx_server_base}config.tar.gz" \ --output-document - | tar --extract --verbose --gzip --directory \ @@ -33,6 +33,6 @@ exceptions.try } exceptions.catch { - logging.error "$exceptions_last_traceback" + echo "$exceptions_last_traceback" emergency_shell "error in ${BASH_SOURCE[0]}" } -- cgit v1.2.3-55-g7522 From 30585ec1c9c5435b026841a92d588c7ee699136d Mon Sep 17 00:00:00 2001 From: Thiago Abdo Date: Tue, 5 Nov 2019 10:18:11 +0100 Subject: Moving sourcing of build.inc to global Signed-off-by: Thiago Abdo --- builder/modules.d/dnbd3-rootfs/module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'builder') diff --git a/builder/modules.d/dnbd3-rootfs/module-setup.sh b/builder/modules.d/dnbd3-rootfs/module-setup.sh index c2fea3b2..9f99f0d0 100755 --- a/builder/modules.d/dnbd3-rootfs/module-setup.sh +++ b/builder/modules.d/dnbd3-rootfs/module-setup.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- + +# Sourcing some helper functions +. "$(dirname "${BASH_SOURCE[0]}")/helper/build.inc" + _parse_dracut_args() { local __doc__=' Set log level via dracut logging options and returns current debug state. @@ -63,7 +67,6 @@ _parse_dracut_args ${dracut_args[*]} || _debug=$? # endregion clean() { - . "${moddir}/helper/build.inc" clean_components } # region dracut plugin api -- cgit v1.2.3-55-g7522 From 26e13ef50af8329ab58064abdc8f053575d7ceeb Mon Sep 17 00:00:00 2001 From: Thiago Abdo Date: Wed, 6 Nov 2019 10:38:18 +0100 Subject: fix include Signed-off-by: Thiago Abdo --- builder/modules.d/dnbd3-rootfs/module-setup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'builder') diff --git a/builder/modules.d/dnbd3-rootfs/module-setup.sh b/builder/modules.d/dnbd3-rootfs/module-setup.sh index 9f99f0d0..77543a54 100755 --- a/builder/modules.d/dnbd3-rootfs/module-setup.sh +++ b/builder/modules.d/dnbd3-rootfs/module-setup.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash # -*- coding: utf-8 -*- -# Sourcing some helper functions -. "$(dirname "${BASH_SOURCE[0]}")/helper/build.inc" _parse_dracut_args() { local __doc__=' @@ -67,10 +65,14 @@ _parse_dracut_args ${dracut_args[*]} || _debug=$? # endregion clean() { +# Sourcing some helper functions + . "$(dirname "${BASH_SOURCE[0]}")/helper/build.inc" clean_components } # region dracut plugin api check() { +# Sourcing some helper functions + . "$(dirname "${BASH_SOURCE[0]}")/helper/build.inc" if ! build_initialize_components; then echo "Failed to initialize components." return 1 -- cgit v1.2.3-55-g7522