diff options
author | torben | 2015-10-29 12:04:34 +0100 |
---|---|---|
committer | torben | 2015-10-29 12:04:34 +0100 |
commit | b7f149761208c01922d708b150eab5d3c08162dc (patch) | |
tree | aa8d5199f680d97eff56f631b07ea28d93097280 /build_initramfs.sh | |
parent | Fix cli. (diff) | |
download | systemd-init-b7f149761208c01922d708b150eab5d3c08162dc.tar.gz systemd-init-b7f149761208c01922d708b150eab5d3c08162dc.tar.xz systemd-init-b7f149761208c01922d708b150eab5d3c08162dc.zip |
Adding dnbd3 compile routines.
Diffstat (limited to 'build_initramfs.sh')
-rwxr-xr-x | build_initramfs.sh | 101 |
1 files changed, 76 insertions, 25 deletions
diff --git a/build_initramfs.sh b/build_initramfs.sh index ed796153..d9f4dfb5 100755 --- a/build_initramfs.sh +++ b/build_initramfs.sh @@ -77,6 +77,7 @@ function build_initramfs() { local dependencies=(bash cpio git test shift echo mktemp cat rm sed \ wget xz tar grep) "$_SCOPE" _DEPENDENCIES="${dependencies[*]}" + "$_SCOPE" _KERNEL_MODULE_DIRECTORY="builder/dnbd3-qcow2-rootfs/kernel_modules/" "$_SCOPE" _STANDARD_OUTPUT=/dev/null "$_SCOPE" _ERROR_OUTPUT=/dev/null fi @@ -227,6 +228,71 @@ EOF ## endregion + function build_initramfs_initialize_dracut() { + # Downloads and compiles dracut. + # + # Examples: + # + # >>> build_initramfs_initialize_dracut + # ... + mkdir dracut 1>"$_STANDARD_OUTPUT" 2>"$_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" && \ + cd dracut 1>"$_STANDARD_OUTPUT" 2>"$_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" && \ + # 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" && \ + cd - 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 + cd "${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" && \ + cd - 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 + cd $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" && \ + return $? + # TODO rm -rf build + } + # endregion # region controller @@ -236,31 +302,16 @@ EOF build_initramfs_log 'error' 'Satisfying main dependencies failed.' build_initramfs_command_line_interface "$@" || return $? - ## TODO use seperate functions for each task - mkdir dracut - # 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 - cd dracut - # NOTE: On virtualbox shared folder symlinks are not allowed. - # make the dracut-install binary (dracut-install resolves dependencies etc.) - make install/dracut-install - # copy the binary to current (instead of symlink) - cp install/dracut-install dracut-install - ## if symlinks are available - #make dracut-install - - cd builder/dnbd3-qcow2-rootfs/kernel_modules/nbd/ - make - cd - - - # TODO build dnbd3.ko, nbd.ko (dnbd3-qcow2-rootfs/kernel_modules/Makefile) - # TODO add dnbd3-qcow2-rootfs to modules.d - - # build initramfs - ./dracut.sh --local --verbose --force - ## + build_initramfs_log 'Checking dracut.' + if ! [[ -d ./dracut ]]; then + build_initramfs_initialize_dracut && \ + build_initramfs_compile_nbd && \ + build_initramfs_compile_dnbd3 && \ + # TODO add dnbd3-qcow2-rootfs to modules.d + build_initramfs_log 'Build initramfs.' && \ + ./dracut.sh --local --verbose --force 1>"$_STANDARD_OUTPUT" \ + 2>"$_ERROR_OUTPUT" + fi fi return 0 |