summaryrefslogtreecommitdiffstats
path: root/builder
diff options
context:
space:
mode:
Diffstat (limited to 'builder')
-rwxr-xr-xbuilder/build-initramfs.sh26
-rw-r--r--builder/dnbd3-rootfs/scripts/utils.sh52
2 files changed, 40 insertions, 38 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh
index 8687f3cb..4ac686ac 100755
--- a/builder/build-initramfs.sh
+++ b/builder/build-initramfs.sh
@@ -52,7 +52,7 @@
# as file name) for lines containing a match to the given
# PATTERN. By default, grep prints the matching lines.
-source dnbd3-qcow2-rootfs
+source dnbd3-rootfs/scripts/utils.sh
__NAME__='build_initramfs'
@@ -142,8 +142,8 @@ EOF
;;
-d|--debug)
shift
- _STANDARD_OUTPUT=/dev/stdout
- _ERROR_OUTPUT=/dev/stderr
+ UTILS_STANDARD_OUTPUT=/dev/stdout
+ UTILS_ERROR_OUTPUT=/dev/stderr
;;
-l|--load-environment)
shift
@@ -185,26 +185,26 @@ EOF
#
# >>> build_initramfs_initialize_dracut
# ...
- mkdir dracut 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ mkdir dracut 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
build_initramfs_log 'Download and extract dracut.' && \
curl --location \
https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-043.tar.gz | \
tar --extract --gzip --directory dracut --strip-components 1 \
- 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
- pushd dracut 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
+ pushd dracut 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
# NOTE: On virtualbox shared folder symlinks are not allowed.
# make the dracut-install binary (dracut-install resolves dependencies etc.)
build_initramfs_log 'Compile dracut.' && \
- make install/dracut-install 1>"$_STANDARD_OUTPUT" \
- 2>"$_ERROR_OUTPUT" && \
+ make install/dracut-install 1>"$UTILS_STANDARD_OUTPUT" \
+ 2>"$UTILS_ERROR_OUTPUT" && \
# NOTE: We have to copy the binary to current instead of symlinking
# them since this feature isn't supported in shared virtual box
# machine folders. If symlinks would be available we could simply
# use:
# >>> make dracut-install
- cp install/dracut-install dracut-install 1>"$_STANDARD_OUTPUT" \
- 2>"$_ERROR_OUTPUT" && \
- popd 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
+ cp install/dracut-install dracut-install 1>"$UTILS_STANDARD_OUTPUT" \
+ 2>"$UTILS_ERROR_OUTPUT" && \
+ popd 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT"
return $?
}
function build_initramfs_create_qcow2_system() {
@@ -231,9 +231,9 @@ EOF
utils_log 'Copy dnbd3 qcow2 plugin into dracut modules folder.' && \
cp --recursive builder/dnbd3-qcow2-rootfs/ \
dracut/modules.d/90dndb3-qcow2-rootfs \
- 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
dracut/dracut.sh --local --verbose --force \
- 1>"$_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT"
+ 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT"
fi
return 0
diff --git a/builder/dnbd3-rootfs/scripts/utils.sh b/builder/dnbd3-rootfs/scripts/utils.sh
index 3c72dbca..66d370ba 100644
--- a/builder/dnbd3-rootfs/scripts/utils.sh
+++ b/builder/dnbd3-rootfs/scripts/utils.sh
@@ -1,6 +1,6 @@
-UTILS_KERNEL_MODULE_DIRECTORY="builder/dnbd3-qcow2-rootfs/kernel_modules/"
UTILS_STANDARD_OUTPUT=/dev/null
UTILS_ERROR_OUTPUT=/dev/null
+UTILS_VERBOSE=false
function utils_log() {
# Handles logging messages. Returns non zero and exit on log level
@@ -21,7 +21,7 @@ function utils_log() {
loggingType="$1"
message="$2"
fi
- if [ "$_VERBOSE" == 'yes' ] || [ "$loggingType" == 'error' ] || \
+ if [ "$UTILS_VERBOSE" == 'yes' ] || [ "$loggingType" == 'error' ] || \
[ "$loggingType" == 'critical' ]; then
if [ "$3" ]; then
echo -e -n "$3"
@@ -33,49 +33,51 @@ function utils_log() {
fi
return 0
}
-function compile_nbd() {
+function utils_compile_nbd() {
# Downloads and compiles nbd.
#
# Examples:
#
- # >>> build_initramfs_compile_nbd
+ # >>> build_initramfs_compile_nbd path/to/nbd/directory/
# ...
# 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"
+ # "$1/nbd.ko"
+ pushd "$1" 1>"$UTILS_STANDARD_OUTPUT" 2>"$_ERROR_OUTPUT" && \
+ utils_log 'Compile the nbd kernel module.' && \
+ make 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
+ popd 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT"
return $?
# TODO make clean
}
-function compile_dnbd3() {
+function utils_compile_dnbd3() {
# Downloads and compiles dnbd3.
#
# Examples:
#
- # >>> build_initramfs_compile_dnbd3
+ # >>> build_initramfs_compile_dnbd3 path/to/dnbd3/directory/
# ...
# 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" && \
+ # "$1/build/dnbd3.ko"
+ rm --recursive --force "$1" 1>"$UTILS_STANDARD_OUTPUT" \
+ 2>"$UTILS_ERROR_OUTPUT" && \
+ pushd "$1" 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_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"
+ 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
+ cd dnbd3 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
+ ./build.sh 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
+ popd 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT"
return $?
# TODO rm -rf build
}
function compile_systemd_preserve_process_marker() {
# Compiles simple c program.
- pushd && \
- make && \
- popd
+ #
+ # Examples:
+ #
+ # >>> utils_compile_systemd_preserve_process_marker path/to/program/folder
+ pushd "$1" 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
+ make 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT" && \
+ popd 1>"$UTILS_STANDARD_OUTPUT" 2>"$UTILS_ERROR_OUTPUT"
return $?
}
function utils_dependency_check() {
@@ -83,7 +85,7 @@ function utils_dependency_check() {
#
# Examples:
#
- # >>> build_initramfs_perform_dependency_check "mkdir pacstrap mktemp"
+ # >>> utils_dependency_check "mkdir pacstrap mktemp"
# ...
local dependenciesToCheck="$1" && \
local result=0 && \