diff options
author | Jonathan Bauer | 2020-05-14 15:15:41 +0200 |
---|---|---|
committer | Jonathan Bauer | 2020-05-14 15:15:41 +0200 |
commit | 8b758c9014f5396f8bbc33f4ebb8f9f5b8d31d4c (patch) | |
tree | c3223ecd4042f597fcd1ab1cb7e9eaf66feb1575 /build-initramfs.sh | |
parent | build-initramfs.sh: handle non-existing commit ids (diff) | |
download | systemd-init-8b758c9014f5396f8bbc33f4ebb8f9f5b8d31d4c.tar.gz systemd-init-8b758c9014f5396f8bbc33f4ebb8f9f5b8d31d4c.tar.xz systemd-init-8b758c9014f5396f8bbc33f4ebb8f9f5b8d31d4c.zip |
build-initramfs.sh: integrate bootstrap into main script
Diffstat (limited to 'build-initramfs.sh')
-rwxr-xr-x | build-initramfs.sh | 109 |
1 files changed, 84 insertions, 25 deletions
diff --git a/build-initramfs.sh b/build-initramfs.sh index 8aea10f6..d1c210aa 100755 --- a/build-initramfs.sh +++ b/build-initramfs.sh @@ -31,32 +31,63 @@ cleanup='no' full_cleanup='no' use_systemd_in_initramfs='no' - -declare -rg _bootstrap_modules="bootstrap.conf" +declare -rg _repo_dir="${_root_dir}/systemd-init" +declare -rg _dracut_dir="${_root_dir}/dracut" + +declare -A core_repo=( + [handler]="git" + [path]="$_repo_dir" + [url]="git://git.openslx.org/openslx-ng/systemd-init.git" + [branch]="downloader" +) + +declare -A core_dracut=( + [handler]="http" + [path]="$_dracut_dir" + [url]="https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-047.tar.gz" +) + +declare -A module_dnbd3=( + [handler]="git" + [path]="${_repo_dir}/modules.d/dnbd3-rootfs/binaries/dnbd3" + [url]="git://git.openslx.org/dnbd3.git" + [branch]="master" + [commit]="c881c79" +) + +declare -A module_qemu_xmount=( + [handler]="git" + [path]="${_repo_dir}/modules.d/dnbd3-rootfs/binaries/qemu-xmount" + [url]="git://github.com/eaas-framework/qemu.git" + [branch]="libxmount_input" + [commit]="4873cd023da8511ed9792a318d1456c949046123" +) + +declare -A module_xmount=( + [handler]="git" + [path]="${_repo_dir}/modules.d/dnbd3-rootfs/binaries/xmount" + [url]="git://github.com/eaas-framework/xmount.git" + [branch]="master" + [commit]="0151375" +) + +declare -A module_kernel_qcow2_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-linux.git" + [path]="${_repo_dir}/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-linux" + [branch]="kernel-qcow2-linux-4.19.y" +) + +declare -A module_kernel_qcow2_util_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-util-linux.git" + [path]="${_repo_dir}/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-util-linux" + [branch]="kernel-qcow2" +) + +declare -A override bootstrap() { - if [ ! -f "$_bootstrap_modules" ]; then - echo "Missing modules definition file: $_bootstrap_modules" - print_help_message 1 - exit 1 - fi - - . "$_bootstrap_modules" - - if [[ ! -v core_dracut[@] ]] || [[ ! -v core_repo[@] ]]; then - echo "Missing core modules for dracut & systemd-init" - exit 1 - fi - - declare -rg _repo_dir="$(readlink -f ${core_repo[path]})" - declare -rg _dracut_dir="$(readlink -f ${core_dracut[path]})" - - echo "Modules file: $_bootstrap_modules" - echo "Core modules: ${!core_*}" - echo "Modules: ${!module_*}" - echo "" - - for module in "${!core_@}" "${!module_@}"; do declare -n _ref="$module" if [ -n "$(ls -A "${_ref[path]}" 2> /dev/null)" ]; then @@ -64,11 +95,21 @@ bootstrap() { continue fi echo "######################### $module #########################" + if [ -n "${override["$module"]}" ]; then + echo "Module overriden: ${override["$module"]}" + IFS='|' read -r -a pairs <<< "${override["$module"]}" + declare -p pairs + for pair in "${pairs[@]}"; do + IFS='=' read -r key value <<< "$pair" + _ref["$key"]="$value" + done + fi echo "Handler: ${_ref[handler]}" echo " URL: ${_ref[url]}" echo " Branch: ${_ref[branch]}" echo " Commit: ${_ref[commit]}" echo " Path: ${_ref[path]}" + handler_${_ref[handler]} \ "${_ref[path]}" \ "${_ref[url]}" \ @@ -82,7 +123,6 @@ bootstrap() { patch -p1 < "$patch" done popd - done } @@ -250,6 +290,25 @@ parse_command_line() { shift update='yes' ;; + -O|--override-modules) + local given_argument="$1" + shift + # expects in format '<module_name>.<key>=<value>[|<key>=<value>|...]' + if ! [[ "$1" =~ ^[A-Za-z0-9_]+\.[A-Za-z0-9]+=.+$ ]]; then + echo \ + "Error with given option \"$given_argument\":" \ + "'$1' not in expected format: <module_name>.<key>=<value>" + return 1 + fi + override_module="${1%%.*}" + override_argument="${1#*.}" + if [ -n "${override["$override_module"]}" ]; then + # append to existing value + override_argument="|${override_argument}" + fi + override["$override_module"]+="$override_argument" + shift + ;; -) shift while [[ "$1" =~ ^.+$ ]]; do |