summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-qcow2-rootfs/scripts/utils.sh
diff options
context:
space:
mode:
Diffstat (limited to 'builder/dnbd3-qcow2-rootfs/scripts/utils.sh')
-rw-r--r--builder/dnbd3-qcow2-rootfs/scripts/utils.sh61
1 files changed, 59 insertions, 2 deletions
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
+}