diff options
| author | torben | 2015-10-29 11:35:08 +0100 |
|---|---|---|
| committer | torben | 2015-10-29 11:35:08 +0100 |
| commit | d44ccb00b8c57048efcb202014d3d0c3551687c8 (patch) | |
| tree | 1c486aec9db6c828dcc88c3d0452397d1b35d21f | |
| parent | fix dndb3 kernel path (diff) | |
| download | systemd-init-d44ccb00b8c57048efcb202014d3d0c3551687c8.tar.gz systemd-init-d44ccb00b8c57048efcb202014d3d0c3551687c8.tar.xz systemd-init-d44ccb00b8c57048efcb202014d3d0c3551687c8.zip | |
Fix cli.
| -rwxr-xr-x | build_initramfs.sh | 136 |
1 files changed, 54 insertions, 82 deletions
diff --git a/build_initramfs.sh b/build_initramfs.sh index 202d2bcf..ed796153 100755 --- a/build_initramfs.sh +++ b/build_initramfs.sh @@ -203,97 +203,69 @@ EOF ## endregion + ## region tools + + function build_initramfs_perform_dependency_check() { + # This function check if all given dependencies are present. + # + # Examples: + # + # >>> archInstallPerformDependencyCheck "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 + archInstallLog 'critical' \ + "Needed dependency \"$dependency\" isn't available." && \ + result=1 + fi + done + return $result + } + + ## endregion + # endregion # region controller if [[ "$0" == *"${__NAME__}.bash" ]]; then - archInstallPerformDependencyCheck "${_DEPENDENCIES[*]}" || \ - archInstallLog 'error' 'Satisfying main dependencies failed.' - archInstallCommandLineInterface "$@" || return $? - _PACKAGES="${_BASIC_PACKAGES[*]} ${_ADDITIONAL_PACKAGES[*]}" && \ - if [ "$_INSTALL_COMMON_ADDITIONAL_PACKAGES" == 'yes' ]; then - _PACKAGES+=' '${_COMMON_ADDITIONAL_PACKAGES[*]} - fi - if [ ! -e "$_OUTPUT_SYSTEM" ]; then - mkdir --parents "$_OUTPUT_SYSTEM" 1>"$_STANDARD_OUTPUT" \ - 2>"$_ERROR_OUTPUT" - fi - if [ -d "$_OUTPUT_SYSTEM" ]; then - _MOUNTPOINT_PATH="$_OUTPUT_SYSTEM" && \ - if [[ ! "$_MOUNTPOINT_PATH" =~ .*/$ ]]; then - _MOUNTPOINT_PATH+='/' - fi - elif [ -b "$_OUTPUT_SYSTEM" ]; then - _PACKAGES+=' efibootmgr' && \ - archInstallPerformDependencyCheck \ - "${_BLOCK_INTEGRATION_DEPENDENCIES[*]}" || \ - archInstallLog 'error' \ - 'Satisfying block device dependencies failed.' && \ - if echo "$_OUTPUT_SYSTEM" | grep --quiet --extended-regexp '[0-9]$' - then - archInstallFormatSystemPartition || \ - archInstallLog 'error' 'System partition creation failed.' - else - archInstallDetermineAutoPartitioning && \ - archInstallPrepareBlockdevices || \ - archInstallLog 'error' 'Preparing blockdevices failed.' - fi - else - archInstallLog 'error' \ - "Could not install into an existing file \"$_OUTPUT_SYSTEM\"." - fi - archInstallPrepareInstallation || \ - archInstallLog 'error' 'Preparing installation failed.' - if [[ "$UID" == 0 ]] && [[ "$_PREVENT_USING_PACSTRAP" == 'no' ]] && \ - hash pacstrap 1>"$_STANDARD_OUTPUT" 2>/dev/null - then - archInstallWithPacstrap || \ - archInstallLog 'error' 'Installation with pacstrap failed.' - else - archInstallGenericLinuxSteps || \ - archInstallLog 'error' \ - 'Installation via generic linux steps failed.' - fi - archInstallTidyUpSystem && \ - archInstallConfigure || \ - archInstallLog 'error' 'Configuring installed system failed.' - archInstallPrepareNextBoot || \ - archInstallLog 'error' 'Preparing reboot failed.' - archInstallPackResult || \ - archInstallLog 'error' \ - 'Packing system into archiv with files owned by root failed.' - archInstallLog \ - "Generating operating system into \"$_OUTPUT_SYSTEM\" has successfully finished." + build_initramfs_perform_dependency_check "${_DEPENDENCIES[*]}" || \ + 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 + ## + fi return 0 # endregion - - - 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 } # region footer |
