diff options
| author | Jonathan Bauer | 2017-03-07 11:14:32 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2017-03-07 11:14:32 +0100 |
| commit | 9b61577c3ceb809c2473d4757590a01054466eaf (patch) | |
| tree | 2bbbd2dc0a7e79f8509b53bef2f1aba939900489 /builder/dnbd3-rootfs/scripts | |
| parent | Yannick Bilger's WLAN boot prototype (diff) | |
| download | systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.tar.gz systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.tar.xz systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.zip | |
moved all dracut modules to modules.d/ + support
Diffstat (limited to 'builder/dnbd3-rootfs/scripts')
| -rw-r--r-- | builder/dnbd3-rootfs/scripts/build.sh | 126 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/scripts/container-unpack-qemu.sh | 35 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/scripts/container-unpack-xmount.sh | 34 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/scripts/device-add-write-layer.sh | 26 | ||||
| m--------- | builder/dnbd3-rootfs/scripts/rebash | 0 | ||||
| -rw-r--r-- | builder/dnbd3-rootfs/scripts/tools.sh | 105 |
6 files changed, 0 insertions, 326 deletions
diff --git a/builder/dnbd3-rootfs/scripts/build.sh b/builder/dnbd3-rootfs/scripts/build.sh deleted file mode 100644 index 47e5dcc7..00000000 --- a/builder/dnbd3-rootfs/scripts/build.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# shellcheck source=./rebash/core.sh -source "$(dirname "${BASH_SOURCE[0]}")/rebash/core.sh" -core.import logging - -build_compile_qemu_xmount() { - local __doc__=' - Compiles qemu libxmount. - NOTE: expects xmount installation under - $1/../xmount/trunk/build/release_build/ - - Provides the following file: - "$1/libxmount_input_qemu.so" - - Example: - - `build_compile_qemu_xmount /qemu_source /xmount/installation` - ' - pushd "$1" - local xmount_installation="../xmount/trunk/build/release_build/usr" - [ ! -z "$2" ] && xmount_installation="$2" - ./configure --enable-xmount-input --python="$(which python2)" \ - --extra-cflags="-fPIC" \ - --extra-cflags="-std=gnu99" \ - --extra-cflags="-I${xmount_installation}/include" \ - --extra-cflags="-I${xmount_installation}/include/xmount" \ - --disable-fdt --target-list="" - make -j4 libxmount_input_qemu.so - local ret=$? - popd - return $ret -} -build_clean_qemu_xmount() { - local __doc__='Clean the build of `build_compile_qemu_xmount`.' - pushd "$1" - make clean - popd - return $? -} -build_compile_xmount() { - local __doc__=' - Compiles xmount. - - Provides the xmount installation under: - "$1/trunk/build/release_build/" - - Example: - - `build_compile_xmount /xmount_source /xmount_source/build /usr` - ' - pushd "$1" - - local destination_directory="./release_build" - [ ! -z "$2" ] && destination_directory="$2" - local install_prefix="/usr" - [ ! -z "$3" ] && install_prefix="$3" - - mkdir --parents trunk/build - cd trunk/build || return 1 - cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$install_prefix" .. - make -j4 - make install DESTDIR="$destination_directory" - local ret=$? - popd - return $ret -} -build_clean_xmount() { - local __doc__='Clean the build of `build_compile_xmount`.' - rm --recursive --force "$1/trunk/build" -} -build_compile_dnbd3() { - local __doc__=' - Compiles dnbd3 kernel module and client. - - Provides the following file: - "$1/build/dnbd3.ko" - "$1/build/dnbd3-client" - - Examples: - - `build_compile_dnbd3 path/to/dnbd3/source/` - ' - pushd "$1" - # NOTE: The generic way would be: "./build.sh" but this tries to build - # more than we really need and takes more time. - mkdir --parents build - pushd build - cmake ../ - make -j4 dnbd3 dnbd3-client - popd - return $? -} -build_clean_dnbd3() { - local __doc__='Clean the build of `build_compile_dnbd3`.' - rm --recursive --force "$1/build" - return $? -} -build_compile_systemd_preserve_process_marker() { - local __doc__=' - Compiles simple c program. - - Examples: - - `build_compile_systemd_preserve_process_marker path/to/program/folder` - ' - pushd "$1" - make - popd - return $? -} -build_clean_systemd_preserve_process_marker() { - local __doc__=' - Clean the build of - `build_compile_systemd_preserve_process_marker`. - ' - pushd "$1" - make clean - popd - return $? -} -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/dnbd3-rootfs/scripts/container-unpack-qemu.sh b/builder/dnbd3-rootfs/scripts/container-unpack-qemu.sh deleted file mode 100755 index 53fd73dc..00000000 --- a/builder/dnbd3-rootfs/scripts/container-unpack-qemu.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -source "/usr/lib/rebash/core.sh" -core.import exceptions -exceptions.activate -# endregion - -in_device="$1" -nbd_device="$2" # TODO detect first free nbd device - -systemd-preserve-process-marker qemu-nbd --connect="$nbd_device" \ - "$in_device" --read-only --persistent --nocache - -# TODO better way to wait for the device to be made? -i=0 -while [ ! -b "$nbd_device" ]; do - [ $i -ge 20 ] && exit 1 - if [ $UDEVVERSION -ge 143 ]; then - udevadm settle --exit-if-exists="$nbd_device" - else - sleep 0.1 - fi - i=$(($i + 1)) -done - -# NBD doesn't emit uevents when it gets connected, so kick it -# TODO get path from $nbd_device -echo change > /sys/block/nbd0/uevent -udevadm settle - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/dnbd3-rootfs/scripts/container-unpack-xmount.sh b/builder/dnbd3-rootfs/scripts/container-unpack-xmount.sh deleted file mode 100755 index c7e1b45c..00000000 --- a/builder/dnbd3-rootfs/scripts/container-unpack-xmount.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -source '/usr/lib/rebash/core.sh' -core.import logging -core.import utils -core.import exceptions -exceptions.activate -# endregion -logging.set_level info -logging.set_commands_level info - -# NOTE: All output has to be forwarded to standard error because determined -# device should be printed on standard output. -in_device="$1" -mkdir --parents /mnt/xmount -loop_device="$(losetup --find)" -if ! utils.dependency_check xmount; then - logging.warn "\"xmount\" not found, assuming raw image." 1>&2 -elif systemd-preserve-process-marker xmount --in qemu "$in_device" --out raw \ - /mnt/xmount &>/dev/null -then - in_device="/mnt/xmount/*.dd" -else - logging.warn "\"xmount\" call failed, assuming raw image." 1>&2 -fi -losetup "$loop_device" $in_device --partscan -udevadm settle -echo "$loop_device" - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/dnbd3-rootfs/scripts/device-add-write-layer.sh b/builder/dnbd3-rootfs/scripts/device-add-write-layer.sh deleted file mode 100755 index 2e4116a7..00000000 --- a/builder/dnbd3-rootfs/scripts/device-add-write-layer.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -# shellcheck source=./rebash/core.sh -source "/usr/lib/rebash/core.sh" -core.import exceptions -exceptions.activate -# endregion - -combined_device_name="$1" -read_only_device="$2" -writable_device="$3" -persistent="$4" # P or N -chunksize='1' - -partition_size="$(blockdev --getsz "$read_only_device")" -writable_partition_name='root' -modprobe dm_snapshot -dmsetup create "$combined_device_name" --noudevsync --table \ - "0 $partition_size snapshot $read_only_device $writable_device $persistent $chunksize" -dmsetup mknodes --noudevsync "$combined_device_name" - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion diff --git a/builder/dnbd3-rootfs/scripts/rebash b/builder/dnbd3-rootfs/scripts/rebash deleted file mode 160000 -Subproject 6ca5b39c862aed6a13146f4121fb51f784b1eb4 diff --git a/builder/dnbd3-rootfs/scripts/tools.sh b/builder/dnbd3-rootfs/scripts/tools.sh deleted file mode 100644 index bace775e..00000000 --- a/builder/dnbd3-rootfs/scripts/tools.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -# region imports -# shellcheck source=./rebash/core.sh -source "/usr/lib/rebash/core.sh" -core.import logging -# endregion -tools__doc_test_setup__=' -lsblk() { - if [[ "${@: -1}" == "" ]];then - echo "lsblk: : not a block device" - return 1 - fi - if [[ "${@: -1}" != "/dev/sdb" ]];then - echo "/dev/sda disk" - echo "/dev/sda1 part SYSTEM_LABEL 0x7" - echo "/dev/sda2 part" - fi - if [[ "${@: -1}" != "/dev/sda" ]];then - echo "/dev/sdb disk" - echo "/dev/sdb1 part boot_partition " - echo "/dev/sdb2 part system_partition" - fi -} -blkid() { - [[ "${@: -1}" != "/dev/sda2" ]] && return 0 - echo "gpt" - echo "only discoverable by blkid" - echo "boot_partition" - echo "192d8b9e" -} -sleep() { - ((_test_sleep_time++)) -} -' - -tools_find_block_device() { - # shellcheck disable=SC2034,SC2016 - local __doc__=' - >>> tools.find_block_device "boot_partition" - /dev/sdb1 - >>> tools.find_block_device "boot_partition" /dev/sda - /dev/sda2 - >>> tools.find_block_device "discoverable by blkid" - /dev/sda2 - >>> tools.find_block_device "_partition" - /dev/sdb1 /dev/sdb2 - >>> tools.find_block_device "not matching anything"; echo $? - 1 - >>> tools.find_block_device ""; echo $? - 1 - - >>> local _test_sleep_time=0 - >>> tools.find_block_device "not matching anything" /dev/sda 10; echo $? - >>> echo $_test_sleep_time - 1 - 10 - ' - local partition_pattern="$1" - [ "$partition_pattern" = '' ] && return 1 - local device="$2" - local timeout=0 - [ ! -z "$3" ] && timeout="$3" - tools_find_block_device_simple() { - local device_info - lsblk --noheadings --list --paths --output \ - NAME,TYPE,LABEL,PARTLABEL,UUID,PARTUUID ${device:+"$device"} \ - | sort --unique | while read -r device_info; do - local current_device - current_device=$(echo "$device_info" | cut -d' ' -f1) - if [[ "$device_info" = *"${partition_pattern}"* ]]; then - echo "$current_device" - fi - done - } - tools_find_block_device_deep() { - local device_info - lsblk --noheadings --list --paths --output NAME ${device:+"$device"} \ - | sort --unique | cut -d' ' -f1 | while read -r current_device; do - blkid -p -o value "$current_device" \ - | while read -r device_info; do - if [[ "$device_info" = *"${partition_pattern}"* ]]; then - echo "$current_device" - fi - done - done - } - while ((timeout >= 0)); do - local candidates - candidates=($(tools_find_block_device_simple)) - (( ${#candidates[@]} == 0 )) && candidates=($(tools_find_block_device_deep)) - (( ${#candidates[@]} > 1 )) && echo "${candidates[@]}" && return 1 - (( ${#candidates[@]} == 1 )) && echo "${candidates[0]}" && return 0 - ((timeout == 0)) || sleep 1 - ((timeout--)) - done - # no candidates - return 1 -} -alias tools.find_block_device="tools_find_block_device" - -# region vim modline -# vim: set tabstop=4 shiftwidth=4 expandtab: -# vim: foldmethod=marker foldmarker=region,endregion: -# endregion |
