summaryrefslogtreecommitdiffstats
path: root/builder/build-initramfs.sh
diff options
context:
space:
mode:
Diffstat (limited to 'builder/build-initramfs.sh')
-rwxr-xr-xbuilder/build-initramfs.sh113
1 files changed, 44 insertions, 69 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh
index 66dbf172..e10ac67c 100755
--- a/builder/build-initramfs.sh
+++ b/builder/build-initramfs.sh
@@ -22,21 +22,20 @@
# Note that you only get very necessary output until you provide "--verbose" as
# commandline options.
declare -rg _root_dir="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
+declare -rg _repo_dir="${_root_dir}/systemd-init.git"
declare -rg _git_source="git://git.openslx.org/openslx-ng/systemd-init.git"
declare -rg _git_branch="master"
## region ensure presence of needed dependencies
set -o errexit
-_needed_location="${_root_dir}/modules.d"
-if ! [[ -d "$_needed_location" ]]; then
- echo "The dracut modules aren't available, loading them."
+if [ ! -e "$_repo_dir" ]; then
+ echo "Missing dracut modules repository, loading them."
if ! hash git; then
echo "Needed dependency \"git\" isn't available."
- echo "Please install \"git\" or provide the repositories data structure in \"${_root_dir}\"."
+ echo "Please install \"git\" or provide the main repository in \"${_repo_dir}\"."
fi
- _temporary_repository_location="$(mktemp --directory)"
git clone --branch "$_git_branch" --single-branch --depth 1 \
- "$_git_source" "$_temporary_repository_location"
- pushd "$_temporary_repository_location"
+ "$_git_source" "${_repo_dir}"
+ pushd "${_repo_dir}"
git submodule init
# try to clone submodules as shallowy as possible, since we cannot just
# use '--depth 1' on submodules residing on non-master branches...
@@ -46,10 +45,11 @@ if ! [[ -d "$_needed_location" ]]; then
branch="$(git config -f .gitmodules --get submodule.${mod}.branch)"
commit="$(git submodule status $path | grep -oE '[0-9a-f]{40}')"
depth_arg=("--shallow-since")
- [ "$mod" = "dnbd3" ] && depth_arg+=("2019-02-12")
- [ "$mod" = "rebash" ] && depth_arg+=("2016-11-30")
- [ "$mod" = "qemu-xmount" ] && depth_arg+=("2016-01-01")
- [ "$mod" = "xmount" ] && depth_arg+=("2015-11-05")
+ [ "$mod" = "dnbd3" ] && depth_arg+=("2019-02-12")
+ [ "$mod" = "rebash" ] && depth_arg+=("2016-11-30")
+ [ "$mod" = "qemu-xmount" ] && depth_arg+=("2016-01-01")
+ [ "$mod" = "xmount" ] && depth_arg+=("2015-11-05")
+ [ "$mod" = "kernel-qcow2-util-linux" ] && depth_arg+=("2019-08-15")
git clone -n --no-tags "${depth_arg[@]}" --branch "$branch" "$url" "$path"
pushd "$path"
git checkout "$commit"
@@ -62,11 +62,7 @@ if ! [[ -d "$_needed_location" ]]; then
done 2>/dev/null
'
popd
- # finally copy all dracut modules under modules.d/
- cp --recursive \
- "${_temporary_repository_location}/builder/modules.d/" \
- "$(dirname $_needed_location)"
- rm --recursive --force "$_temporary_repository_location"
+ ln -s "${_repo_dir}/builder/modules.d" "${_root_dir}/modules.d"
fi
set +o errexit
## endregion
@@ -374,6 +370,21 @@ parse_command_line() {
fi
shift
;;
+ -q|--qcow-handler)
+ local given_argument="$1"
+ shift
+ qcow_handler="$1"
+ if [ -z "$qcow_handler" ]; then
+ logging.critical \
+ "Error with given option \"$given_argument\": This options needs to be either 'xmount' or 'kernel'."
+ return 1
+ fi
+ shift
+ ;;
+ -u|--update)
+ shift
+ update='yes'
+ ;;
-)
shift
while [[ "$1" =~ ^.+$ ]]; do
@@ -486,55 +497,7 @@ 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
- # TODO check for its existence using modinfo -k <kernel_version>
- 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..."
- if ! CMAKE_FLAGS="-DKERNEL_DIR=${kernel_headers}" \
- 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__='
@@ -567,11 +530,13 @@ main() {
`main`
'
exceptions.activate
- # region sanity check kernel version
+ # region sanity check kernel version and qcow handler
# if no kernel was specified as dracut argument, use the running kernel's version
+ logging.info "Building for:"
if [ -z "$kernel_version" ]; then
kernel_version="$(uname -r)"
fi
+ logging.info " * kernel version: $kernel_version"
# similar for kernel headers needed to compile dnbd3 against.
if [ -z "$kernel_headers" ]; then
kernel_headers="/lib/modules/${kernel_version}/build"
@@ -579,7 +544,8 @@ main() {
if [ ! -f "${kernel_headers}/Makefile" ]; then
logging.critical 'Missing core dependency "linux-headers" for version to compile against given or current kernel.'
fi
- logging.info "Building for kernel version: ${kernel_version}."
+ logging.info " * kernel headers: $kernel_headers"
+ [ -n "$qcow_handler" ] && logging.info " * qcow2 handler: $qcow_handler"
# endregion
# region dependency checks and command line parsing
result=0
@@ -666,6 +632,13 @@ main() {
exit 0
fi
# endregion
+ # region handle '--update' to update all the modules in 'modules.d'
+ if [ "$update" == "yes" ]; then
+ pushd "${_repo_dir}"
+ git pull
+ popd
+ fi
+ # endregion
# region handle dependencies which can be resolved automatically
logging.info 'Checking dracut.'
if [[ ! -f "${_root_dir}/dracut/dracut-install" ]]; then
@@ -719,10 +692,12 @@ 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
+ . "${_root_dir}/modules.d/dnbd3-rootfs/helper/build.inc"
+ initialize_components
+ if [[ "$initialize" == 'yes' ]]; then
+ exit 0
+ fi
logging.info 'Build initramfs.'
# NOTE: We deactivate our exception handle since dracut returns "1" if
# it is launched with help parameter ("-h" or "--help").