diff options
| author | Jonathan Bauer | 2020-05-13 11:07:40 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2020-05-13 11:07:40 +0200 |
| commit | dccf07414027454342188d0eb87a58634e3f798a (patch) | |
| tree | 1b220a0f2ae7191ebda23b708e4c62b3be6dfeaf | |
| parent | restructure repo (diff) | |
| download | systemd-init-dccf07414027454342188d0eb87a58634e3f798a.tar.gz systemd-init-dccf07414027454342188d0eb87a58634e3f798a.tar.xz systemd-init-dccf07414027454342188d0eb87a58634e3f798a.zip | |
initial bootstrap (old downloader) code
| -rwxr-xr-x | bootstrap.sh | 148 | ||||
| -rw-r--r-- | bootstrap/CentOS-7 | 63 | ||||
| -rw-r--r-- | bootstrap/CentOS-8 | 62 | ||||
| -rw-r--r-- | bootstrap/Ubuntu-18 | 52 |
4 files changed, 325 insertions, 0 deletions
diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 00000000..3bd46a75 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,148 @@ +#!/usr/bin/env bash +# -*- coding: utf-8 -*- +# region header +# Copyright Torben Sickert (info["~at~"]torben.website) 29.10.2015 +# Janosch Dobler (info["~at~"]jandob.com) 29.10.2015 +# Jonathan Bauer (jonathan.bauer@rz.uni-freiburg.de) 19.09.2019 +# Thiago Abdo (tjabdo@inf.ufpr.br) 06-11-2019 + +# License +# ------- +# This library written by Torben Sickert and Janosch Dobler stand under a +# creative commons naming 3.0 unported license. +# see http://creativecommons.org/licenses/by/3.0/deed.de +## endregion + +declare -g modules="modules.conf" + +print_help_message() { + echo "Bootstrapper script for systemd-init." + echo "" + echo "$0: [--help|-h] [--verbose|-v] <modules_config>" + exit "${1:-0}" +} + +parse_command_line() { + while [ $# -gt 0 ]; do + case "$1" in + --help|-h) + shift + print_help_message 0 + ;; + --verbose|-v) + shift + verbose='yes' + set -x + ;; + *) + modules="$1" + shift + ;; + esac + done + return 0 +} + +vecho() { + [ -n "$verbose" ] && echo $@ +} + +handler_git() { + local path="$1" + local url="$2" + local branch="$3" + local commit="$4" + + rm -rf "$path" + mkdir -p "$path" + + local gitargs=( \ + "--depth" "1" \ + "--single-branch" \ + ) + if [ -n "$branch" ]; then + gitargs+=("--branch" "$branch") + fi + git clone "${gitargs[@]}" "${url}" "${path}" + + [ -z "$commit" ] && return 0 + + # make sure given commit in in the fetched history + local revision="$branch" + if [ -n "$commit" ]; then + revision="$commit" + fi + + # manual "shallow clone" since not all server allow it... + pushd "$path" + local i=50 + while ! git rev-parse --quiet --verify $revision^{commit}; do + git fetch --depth=$(( i+=50 )) + done + git reset --hard "$revision" + popd +} + +handler_http() { + local path="$1" + local url="$2" + + rm -rf "$path" + mkdir --parents "$path" + + curl \ + --location \ + --max-redirs 5 \ + --max-time 7 \ + --connect-timeout 2 \ + --retry 3 \ + --retry-max-time 12 \ + "$url" \ + | tar \ + --extract \ + --gzip \ + --directory "$path" \ + --strip-components 1 +} + +parse_command_line $@ + +if [ ! -f "$modules" ]; then + echo "Missing modules definition file: $modules" + print_help_message 1 +fi + +. $modules + +vecho "Modules file: $modules" +vecho "Modules: ${!module_*}" +vecho "" + +# checkout modules, starting with systemd-init defined in '_core'. +for module in _core "${!module_@}"; do + declare -n _ref="$module" + echo "######################### $module #########################" + vecho "Handler: ${_ref[handler]}" + vecho " URL: ${_ref[url]}" + vecho " Branch: ${_ref[branch]}" + vecho " Commit: ${_ref[commit]}" + vecho " Path: ${_ref[path]}" + handler_${_ref[handler]} \ + "${_ref[path]}" \ + "${_ref[url]}" \ + "${_ref[branch]}" \ + "${_ref[commit]}" +done + +# look for patches and apply them to their module's path +for _dir in $(find $PWD/${_core[path]}/builder/patches/* -maxdepth 0 -type d); do + patches=( ${_dir}/*.patch ) + target_dir="${_dir##*/}" + declare -n target_module="module_${target_dir//-/_}" + pushd "${target_module[path]}" + for patch in "${patches[@]}"; do + patch -p1 < "$patch" + done + popd +done + diff --git a/bootstrap/CentOS-7 b/bootstrap/CentOS-7 new file mode 100644 index 00000000..5a3f2d8c --- /dev/null +++ b/bootstrap/CentOS-7 @@ -0,0 +1,63 @@ + +declare -A module_core=( + [handler]="git" + [path]="systemd-init" + [url]="git://git.openslx.org/openslx-ng/systemd-init.git" + [branch]="stable" + [commit]="c63e555a86" +) + +declare -A module_dracut=( + [handler]="http" + [path]="${module_core[path]}/builder/dracut" + [url]="https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-047.tar.gz" +) + +declare -A module_dnbd3=( + [handler]="git" + [path]="${module_core[path]}/builder/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]="${module_core[path]}/builder/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]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/xmount" + [url]="git://github.com/eaas-framework/xmount.git" + [branch]="master" + [commit]="0151375" +) + +declare -A module_kernel_qcow2_util_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-util-linux.git" + [path]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-util-linux" + [branch]="kernel-qcow2" + [commit]="0692b96" +) + +declare -A module_kernel_qcow2_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-linux.git" + [path]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-linux" + [branch]="kernel-qcow2-linux-4.19.y" + [commit]="f9b4646" +) + +declare -A module_rebash=( + [handler]="git" + [url]="https://github.com/jandob/rebash.git" + [path]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/scripts/rebash" + [branch]="master" + [commit]="6ca5b39" +) + diff --git a/bootstrap/CentOS-8 b/bootstrap/CentOS-8 new file mode 100644 index 00000000..cc7b1ad9 --- /dev/null +++ b/bootstrap/CentOS-8 @@ -0,0 +1,62 @@ + +declare -A module_core=( + [handler]="git" + [path]="systemd-init" + [url]="git://git.openslx.org/openslx-ng/systemd-init.git" + [branch]="downloader" +) + +declare -A module_dracut=( + [handler]="http" + [path]="${module_core[path]}/builder/dracut" + [url]="https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-047.tar.gz" +) + +declare -A module_dnbd3=( + [handler]="git" + [path]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/dnbd3" + [url]="git://git.openslx.org/dnbd3-ng.git" + [branch]="master" + [commit]="b57dadc2d" +) + +declare -A module_qemu_xmount=( + [handler]="git" + [path]="${module_core[path]}/builder/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]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/xmount" + [url]="git://github.com/eaas-framework/xmount.git" + [branch]="master" + [commit]="0151375" +) + +declare -A module_kernel_qcow2_util_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-util-linux.git" + [path]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-util-linux" + [branch]="kernel-qcow2" + [commit]="0692b96" +) + +declare -A module_kernel_qcow2_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-linux.git" + [path]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-linux" + [branch]="kernel-qcow2-linux-4.18.x-centos" + [commit]="0761b3e9e03" +) + +declare -A module_rebash=( + [handler]="git" + [url]="https://github.com/jandob/rebash.git" + [path]="${module_core[path]}/builder/modules.d/dnbd3-rootfs/scripts/rebash" + [branch]="master" + [commit]="6ca5b39" +) + diff --git a/bootstrap/Ubuntu-18 b/bootstrap/Ubuntu-18 new file mode 100644 index 00000000..7f73db72 --- /dev/null +++ b/bootstrap/Ubuntu-18 @@ -0,0 +1,52 @@ +declare -A _core=( + [handler]="git" + [path]="systemd-init" + [url]="git://git.openslx.org/openslx-ng/systemd-init.git" + [branch]="downloader" +) + +declare -A module_dracut=( + [handler]="http" + [path]="${_core[path]}/builder/dracut" + [url]="https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-047.tar.gz" +) + +declare -A module_dnbd3=( + [handler]="git" + [path]="${_core[path]}/builder/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]="${_core[path]}/builder/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]="${_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/xmount" + [url]="git://github.com/eaas-framework/xmount.git" + [branch]="master" + [commit]="0151375" +) + +declare -A module_kernel_qcow2_util_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-util-linux.git" + [path]="${_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-util-linux" + [branch]="kernel-qcow2" + [commit]="0692b96" +) + +declare -A module_kernel_qcow2_linux=( + [handler]="git" + [url]="git://git.openslx.org/openslx/kernel-qcow2-linux.git" + [path]="${_core[path]}/builder/modules.d/dnbd3-rootfs/binaries/kernel-qcow2-linux" + [branch]="kernel-qcow2-linux-4.19.y" + [commit]="f9b4646" +) |
