diff options
18 files changed, 66 insertions, 117 deletions
@@ -1,4 +1,4 @@ -dracut +builder/dracut builder/dnbd3-qcow2-rootfs/kernel_modules/nbd/* !builder/dnbd3-qcow2-rootfs/kernel_modules/nbd/Makefile diff --git a/builder/INSTALL b/builder/INSTALL index e52f0c39..a20a93a5 100644 --- a/builder/INSTALL +++ b/builder/INSTALL @@ -1,10 +1,10 @@ This subfolder is dedicated to dracut related files. The folder 'dnbd3-qcow2-rootfs' is a dracut module used to setup -a client's rootfs based on a (read-only) dnbd3 export made writable -through the qcow2 container format of the qemu ecosystem. +a client's rootfs based on a (read-only) dnbd3 export made writable +through the kernel device mapper features. -To use this module within dracut, you simply need to copy/link/mount +To use this module within dracut, you simply need to copy/link/mount the above mentioned folder to '/usr/lib/dracut/modules.d' prefixed with a numerical priority. We used '90' so far, so the module was linked to '/usr/lib/dracut/modules.d/90dnbd3-qcow2-rootfs'. @@ -12,7 +12,7 @@ to '/usr/lib/dracut/modules.d/90dnbd3-qcow2-rootfs'. Once the module has been integrated in dracut's modules, you can build the initramfs with the following command: - dracut --no-hostonly --modules "dnbd3-qcow2-rootfs" <target_path> + dracut --no-hostonly --modules "dnbd3-qcow2-rootfs" <target_path> Note that the '--no-hostonly' is critical if the machine dracut is executed on and the clients supposed to boot the resulting initramfs diff --git a/build_initramfs.sh b/builder/build-initramfs.sh index 968777b1..f10e9586 100755 --- a/build_initramfs.sh +++ b/builder/build-initramfs.sh @@ -52,13 +52,6 @@ # as file name) for lines containing a match to the given # PATTERN. By default, grep prints the matching lines. -# Optional dependencies -# --------------------- - -# TODO - -# TODO - __NAME__='build_initramfs' # endregion @@ -183,61 +176,6 @@ EOF fi return 0 } - function build_initramfs_log() { - # Handles logging messages. Returns non zero and exit on log level - # error to support chaining the message into toolchain. - # - # Examples: - # - # >>> build_initramfs_log - # info: test - # >>> build_initramfs_log debug message - # debug: message - # >>> build_initramfs_log info message '\n' - # - # info: message - local loggingType='info' && \ - local message="$1" && \ - if [ "$2" ]; then - loggingType="$1" - message="$2" - fi - if [ "$_VERBOSE" == 'yes' ] || [ "$loggingType" == 'error' ] || \ - [ "$loggingType" == 'critical' ]; then - if [ "$3" ]; then - echo -e -n "$3" - fi - echo -e "${loggingType}: $message" - fi - if [ "$loggingType" == 'error' ]; then - exit 1 - fi - return 0 - } - - ## endregion - - ## region tools - - function build_initramfs_perform_dependency_check() { - # This function check if all given dependencies are present. - # - # Examples: - # - # >>> build_initramfs_perform_dependency_check "mkdir pacstrap mktemp" - # ... - local dependenciesToCheck="$1" && \ - local result=0 && \ - local dependency && \ - for dependency in ${dependenciesToCheck[*]}; do - if ! hash "$dependency" 1>"$_STANDARD_OUTPUT" 2>/dev/null; then - build_initramfs_log 'critical' \ - "Needed dependency \"$dependency\" isn't available." && \ - result=1 - fi - done - return $result - } ## endregion @@ -270,44 +208,6 @@ EOF popd 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" return $? } - function build_initramfs_compile_nbd() { - # Downloads and compiles nbd. - # - # Examples: - # - # >>> build_initramfs_compile_nbd - # ... - # Provides the following file: - # ${_KERNEL_MODULE_DIRECTORY}/nbd/nbd.ko - pushd "${_KERNEL_MODULE_DIRECTORY}/nbd" \ - 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ - build_initramfs_log 'Compile the nbd kernel module.' && \ - make 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ - popd 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" - return $? - # TODO make clean - } - function build_initramfs_compile_dnbd3() { - # Downloads and compiles dnbd3. - # - # Examples: - # - # >>> build_initramfs_compile_dnbd3 - # ... - # Provides the following file: - # ${_KERNEL_MODULE_DIRECTORY}/dnbd3/build/dnbd3.ko - rm --recursive --force ${_KERNEL_MODULE_DIRECTORY}/dnbd3 \ - 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ - pushd $_KERNEL_MODULE_DIRECTORY \ - 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ - git clone git://git.openslx.org/dnbd3.git \ - 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ - cd dnbd3 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ - ./build.sh 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \ - popd 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" - return $? - # TODO rm -rf build - } function build_initramfs_create_qcow2_system() { # TODO qemu-img create -f qcow2 "${CONTAINER_PATH}" "${QCOW_SIZE}" @@ -328,10 +228,6 @@ EOF build_initramfs_log "Dracut isn't available yet loading it." && \ build_initramfs_initialize_dracut fi - # TODO Provide note if compilation doesn't work that we need - # "linux-headers". - build_initramfs_compile_nbd && \ - build_initramfs_compile_dnbd3 && \ build_initramfs_log 'Build initramfs.' && \ build_initramfs_log \ 'Copy dnbd3 qcow2 plugin into dracut modules folder.' && \ diff --git a/builder/dnbd3-qcow2-rootfs/TODO b/builder/dnbd3-qcow2-rootfs/TODO deleted file mode 100644 index 93ef7081..00000000 --- a/builder/dnbd3-qcow2-rootfs/TODO +++ /dev/null @@ -1,4 +0,0 @@ -* Dynamic building of systemd-preserver-process-marker if needed anymore. - -* Research whether the dracut busybox module satisfies our requirements -* If not, compiling busybox should be done somehow diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/endless b/builder/dnbd3-qcow2-rootfs/debugging-tools/endless Binary files differindex de7a8c0a..de7a8c0a 100755 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/endless +++ b/builder/dnbd3-qcow2-rootfs/debugging-tools/endless diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/endless.c b/builder/dnbd3-qcow2-rootfs/debugging-tools/endless.c index 22c9bc50..22c9bc50 100644 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/endless.c +++ b/builder/dnbd3-qcow2-rootfs/debugging-tools/endless.c diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/network.functions b/builder/dnbd3-qcow2-rootfs/debugging-tools/network.functions index 89ca5a20..89ca5a20 100644 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/network.functions +++ b/builder/dnbd3-qcow2-rootfs/debugging-tools/network.functions diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/setup-network.sh b/builder/dnbd3-qcow2-rootfs/debugging-tools/setup-network.sh index 3b32a68c..3b32a68c 100644 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/setup-network.sh +++ b/builder/dnbd3-qcow2-rootfs/debugging-tools/setup-network.sh diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/busybox b/builder/dnbd3-qcow2-rootfs/debugging_tools/busybox Binary files differdeleted file mode 100755 index 1212ae20..00000000 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/busybox +++ /dev/null diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/nbd-client b/builder/dnbd3-qcow2-rootfs/debugging_tools/nbd-client Binary files differdeleted file mode 100755 index 7bb2207f..00000000 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/nbd-client +++ /dev/null diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/nbd-debugging.ko b/builder/dnbd3-qcow2-rootfs/debugging_tools/nbd-debugging.ko Binary files differdeleted file mode 100644 index 47cf6cd6..00000000 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/nbd-debugging.ko +++ /dev/null diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/qemu-nbd b/builder/dnbd3-qcow2-rootfs/debugging_tools/qemu-nbd Binary files differdeleted file mode 100755 index b34a3ff7..00000000 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/qemu-nbd +++ /dev/null diff --git a/builder/dnbd3-qcow2-rootfs/debugging_tools/qemu-nbd-systemd-mark b/builder/dnbd3-qcow2-rootfs/debugging_tools/qemu-nbd-systemd-mark Binary files differdeleted file mode 100755 index 03c2a6b1..00000000 --- a/builder/dnbd3-qcow2-rootfs/debugging_tools/qemu-nbd-systemd-mark +++ /dev/null diff --git a/builder/dnbd3-qcow2-rootfs/module-setup.sh b/builder/dnbd3-qcow2-rootfs/module-setup.sh index eb81f347..b9134871 100755 --- a/builder/dnbd3-qcow2-rootfs/module-setup.sh +++ b/builder/dnbd3-qcow2-rootfs/module-setup.sh @@ -5,7 +5,8 @@ source "$moddir/scripts/utils.sh" check() { compile_nbd && \ compile_dnbd3 && \ - compile_systemd_preserve_process_marker && + compile_systemd_preserve_process_marker + return $? } depends() { diff --git a/builder/dnbd3-qcow2-rootfs/scripts/utils.sh b/builder/dnbd3-qcow2-rootfs/scripts/utils.sh index 62f6509f..0e0c9479 100644 --- a/builder/dnbd3-qcow2-rootfs/scripts/utils.sh +++ b/builder/dnbd3-qcow2-rootfs/scripts/utils.sh @@ -1,4 +1,35 @@ -function build_initramfs_compile_nbd() { +function log() { + # Handles logging messages. Returns non zero and exit on log level + # error to support chaining the message into toolchain. + # + # Examples: + # + # >>> build_initramfs_log + # info: test + # >>> build_initramfs_log debug message + # debug: message + # >>> build_initramfs_log info message '\n' + # + # info: message + local loggingType='info' && \ + local message="$1" && \ + if [ "$2" ]; then + loggingType="$1" + message="$2" + fi + if [ "$_VERBOSE" == 'yes' ] || [ "$loggingType" == 'error' ] || \ + [ "$loggingType" == 'critical' ]; then + if [ "$3" ]; then + echo -e -n "$3" + fi + echo -e "${loggingType}: $message" + fi + if [ "$loggingType" == 'error' ]; then + exit 1 + fi + return 0 +} +function compile_nbd() { # Downloads and compiles nbd. # # Examples: @@ -15,7 +46,7 @@ function build_initramfs_compile_nbd() { return $? # TODO make clean } -function build_initramfs_compile_dnbd3() { +function compile_dnbd3() { # Downloads and compiles dnbd3. # # Examples: @@ -36,3 +67,29 @@ function build_initramfs_compile_dnbd3() { return $? # TODO rm -rf build } +function compile_systemd_preserve_process_marker() { + # Compiles simple c program. + pushd && \ + make && \ + popd + return $? +} +function perform_dependency_check() { + # This function check if all given dependencies are present. + # + # Examples: + # + # >>> build_initramfs_perform_dependency_check "mkdir pacstrap mktemp" + # ... + local dependenciesToCheck="$1" && \ + local result=0 && \ + local dependency && \ + for dependency in ${dependenciesToCheck[*]}; do + if ! hash "$dependency" 1>"$_STANDARD_OUTPUT" 2>/dev/null; then + build_initramfs_log 'critical' \ + "Needed dependency \"$dependency\" isn't available." && \ + result=1 + fi + done + return $result +} diff --git a/builder/dnbd3-qcow2-rootfs/udev/70-openslx-disk.rules b/builder/dnbd3-qcow2-rootfs/udev/70-openslx-disk.rules index 3f5e382f..5cb3fa52 100644 --- a/builder/dnbd3-qcow2-rootfs/udev/70-openslx-disk.rules +++ b/builder/dnbd3-qcow2-rootfs/udev/70-openslx-disk.rules @@ -5,4 +5,3 @@ KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="gpt" ENV{ID_PART # MBR rules KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="dos" ENV{ID_PART_ENTRY_TYPE}=="0x44" RUN+="/sbin/prepare-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-disks OPENSLX_SYS %k" - diff --git a/dev_tools/snippets.sh b/dev-tools/snippets.sh index 6f4f21cc..6f4f21cc 100644 --- a/dev_tools/snippets.sh +++ b/dev-tools/snippets.sh diff --git a/dev_tools/startup.nsh b/dev-tools/startup.nsh index 197beb46..197beb46 100755 --- a/dev_tools/startup.nsh +++ b/dev-tools/startup.nsh |
