summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xbuilder/build-initramfs.sh (renamed from build-initramfs.sh)55
-rwxr-xr-xbuilder/dnbd3-qcow2-rootfs/module-setup.sh3
-rw-r--r--builder/dnbd3-qcow2-rootfs/scripts/utils.sh61
4 files changed, 62 insertions, 59 deletions
diff --git a/.gitignore b/.gitignore
index d49884db..5752bb3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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/build-initramfs.sh b/builder/build-initramfs.sh
index ae71bada..f10e9586 100755
--- a/build-initramfs.sh
+++ b/builder/build-initramfs.sh
@@ -176,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
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
+}