From 66001e17be2aa8b4fc4bba120130ef7144b44c51 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 9 Aug 2018 13:18:10 +0200 Subject: introduce '--init' option Use it to precompile all the dependencies for the dnbd3-rootfs module. Assuming the current packer/ansible workflow that generates base images once and use these for provisioning runs, precompiling the dependencies of the dnbd3-rootfs module in the base image would avoid to compile these in every provisioning run. This will speed up the process. --- builder/build-initramfs.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'builder/build-initramfs.sh') diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh index 47171ff4..2addea63 100755 --- a/builder/build-initramfs.sh +++ b/builder/build-initramfs.sh @@ -327,10 +327,15 @@ parse_command_line() { fi shift ;; + -i|--init) + shift + initialize='yes' + ;; -) shift while [[ "$1" =~ ^.+$ ]]; do dracut_parameter+=("$1") + [ "$1" == "--kver" ] && kernel_version="$2" shift done ;; @@ -431,6 +436,57 @@ initialize_dracut() { "${_root_dir}/dracut/dracut-install" return $? } +initialize_dnbd3_rootfs_module() { + # shellcheck disable=SC2016,SC2034 + local __doc__=' + Initialize dependency of dnbd3-rootfs modules: + xmount, qemu-xmount, dnbd3 + + Example: + + `initialize_dnbd3_rootfs_module` + ' + core.import "${_root_dir}/modules.d/dnbd3-rootfs/scripts/build.sh" + # We might want to move the "binaries" repos from the dnbd3-rootfs module to main repo one day... + _deps_base_dir="${_root_dir}/modules.d/dnbd3-rootfs/binaries" + if [[ ! -f "${_deps_base_dir}/xmount/trunk/build/src/xmount" ]]; then + logging.info "Could not find xmount binary, building it..." + if ! build_compile_xmount "${_deps_base_dir}/xmount/"; then + logging.error "Failed to build xmount binary." + return 1 + fi + fi + if [[ ! -f "${_deps_base_dir}/qemu-xmount/libxmount_input_qemu.so" ]]; then + logging.info "Could not find xmount qemu library, building it..." + if ! build_compile_qemu_xmount "${_deps_base_dir}/qemu-xmount/"; then + logging error "Failed to build xmount qemu library." + return 1 + fi + fi + if [[ ! -f "${_deps_base_dir}/dnbd3/build/dnbd3.ko" ]] || \ + [[ ! -f "${_deps_base_dir}/dnbd3/build/dnbd3-client" ]]; then + logging.info "Could not find dnbd3, building it..." + # fallback to running kernel if the kernel version was not + # specified as the dracut argument '--kver' + [ -z "$kernel_version" ] && kernel_version="$(uname -r)" + if ! CMAKE_FLAGS="-DKERNEL_VERSION=${kernel_version}" \ + build_compile_dnbd3 "${_deps_base_dir}/dnbd3/"; then + logging.error "Failed to build dnbd3." + return 1 + fi + + fi + if [[ ! -f "${_deps_base_dir}/systemd-preserve-process-marker/systemd-preserve-process-marker" ]]; then + logging.info "Could not find systemd-preserve-process-marker binary, building it ..." + if ! build_compile_systemd_preserve_process_marker \ + "${_deps_base_dir}/systemd-preserve-process-marker/"; then + logging.error "Failed to build systemd-preserve-process-marker" + return 1 + fi + fi + logging.info "Compilation of dnbd3-rootfs dependencies succeeded." + return 0 +} cleanup() { # shellcheck disable=SC2016,SC2034 local __doc__=' @@ -605,6 +661,9 @@ main() { elif [[ "$cleanup" == 'yes' ]]; then logging.info 'Removing distribution specific files.' cleanup + elif [[ "$initialize" == 'yes' ]]; then + logging.info 'Prepare dnbd3-rootfs module dependencies.' + initialize_dnbd3_rootfs_module else logging.info 'Build initramfs.' # NOTE: We deactivate our exception handle since dracut returns "1" if -- cgit v1.2.3-55-g7522