summaryrefslogtreecommitdiffstats
path: root/builder
diff options
context:
space:
mode:
authorJonathan Bauer2019-10-25 13:16:34 +0200
committerJonathan Bauer2019-10-25 13:16:34 +0200
commit5c15661dcc9d99745f5128b1aba9727fa066e6b6 (patch)
treea8c485a407201eb370b958c41b80e999a0acf60a /builder
parentmore improvements (diff)
parent[slx-network] wait 30sec for network (diff)
downloadsystemd-init-5c15661dcc9d99745f5128b1aba9727fa066e6b6.tar.gz
systemd-init-5c15661dcc9d99745f5128b1aba9727fa066e6b6.tar.xz
systemd-init-5c15661dcc9d99745f5128b1aba9727fa066e6b6.zip
Merge branch 'master' into nobash
Diffstat (limited to 'builder')
-rwxr-xr-xbuilder/build-initramfs.sh120
-rw-r--r--builder/modules.d/dnbd3-rootfs/helper/build.inc13
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/module-setup.sh18
-rwxr-xr-xbuilder/modules.d/slx-dmsetup/module-setup.sh5
-rwxr-xr-xbuilder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device4
-rwxr-xr-xbuilder/modules.d/slx-network/scripts/setup-bootif-network.stage36
6 files changed, 144 insertions, 22 deletions
diff --git a/builder/build-initramfs.sh b/builder/build-initramfs.sh
index fa57857a..039cc321 100755
--- a/builder/build-initramfs.sh
+++ b/builder/build-initramfs.sh
@@ -32,7 +32,7 @@ if [ ! -e "$_repo_dir" ]; then
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...
- for mod in $(awk '$1 == "[submodule" {gsub(/"|]/,"",$2); print $2}' .gitmodules); do
+ for mod in $(grep -Po '(?<=^\[submodule ")([^"]+)' .gitmodules); do
url="$(git config -f .gitmodules --get submodule.${mod}.url)"
path="$(git config -f .gitmodules --get submodule.${mod}.path)"
branch="$(git config -f .gitmodules --get submodule.${mod}.branch)"
@@ -56,7 +56,6 @@ if [ ! -e "$_repo_dir" ]; then
done 2>/dev/null
'
popd
- ln -s "${_repo_dir}/builder/modules.d" "${_root_dir}/modules.d"
fi
set +o errexit
## endregion
@@ -231,6 +230,7 @@ cleanup() {
return $?
}
main() {
+<<<<<<< HEAD
if ! parse_command_line "$@"; then
print_help_message "$0"
exit 1
@@ -252,6 +252,64 @@ main() {
[ -n "$qcow_handler" ] && echo " * qcow2 handler: $qcow_handler"
export _QCOW_HANDLER="$qcow_handler"
+=======
+ # shellcheck disable=SC2016,SC2034
+ local __doc__='
+ Main Entry point for the build initramfs logic. Triggers command line
+ parsing and calls sub routines depending on given command line arguments.
+
+ Example:
+
+ `main`
+ '
+ exceptions.activate
+ # region dependency checks and command line parsing
+ result=0
+ dependency_check core dependencies utils_dependency_check program || \
+ result=$?
+ dependency_check core shared_library_pattern_dependencies \
+ utils_dependency_check_shared_library 'shared library' || result=$?
+ dependency_check core package_dependencies utils_dependency_check_pkgconfig \
+ package || result=$?
+ [[ $result == 0 ]] || exit $result
+
+ logging.set_commands_level debug
+ logging.set_level critical
+
+ if ! parse_command_line "$@"; then
+ print_help_message "$0"
+ exit 1
+ fi
+
+ dependency_check optional dependencies utils_dependency_check program || \
+ result=$?
+ dependency_check optional shared_library_pattern_dependencies \
+ utils_dependency_check_shared_library 'shared library' || result=$?
+ dependency_check optional package_dependencies \
+ utils_dependency_check_pkgconfig package || result=$?
+ [[ $result == 1 ]] && exit $result
+ # endregion
+
+ # 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"
+ fi
+ 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 " * kernel headers: $kernel_headers"
+ [ -n "$qcow_handler" ] && logging.info " * qcow2 handler: $qcow_handler"
+ # endregion
+
+ # region handle '--update' to update all the modules in 'modules.d'
+>>>>>>> master
if [ "$update" == "yes" ]; then
pushd "${_repo_dir}"
git pull
@@ -264,6 +322,7 @@ main() {
initialize_dracut
fi
+<<<<<<< HEAD
for _dracut_module in "${_root_dir}/modules.d/"*; do
[ -d "${_dracut_module}" ] || continue
_dracut_module="$(basename $_dracut_module)"
@@ -279,9 +338,23 @@ main() {
"$_dracut_module_target"; then
echo \
"Linking '$_dracut_module_relative_path' to '$_dracut_module_target' failed." \
+=======
+ for _dracut_module_dir in "${_repo_dir}/builder/modules.d/"*; do
+ [ -d "${_dracut_module_dir}" ] || continue
+ _dracut_module="$(basename $_dracut_module_dir)"
+ # TODO allow module-specific priority
+ _dracut_module_target="${_root_dir}/dracut/modules.d/00${_dracut_module}"
+ if [[ ! -L "$_dracut_module_target" || "$(readlink \
+ "$_dracut_module_target")" != "$_dracut_module_dir" ]]; then
+ logging.info \
+ "Link ${_dracut_module} plugin into dracut modules folder ($_dracut_module_dir -> $_dracut_module_target)."
+ if ! ln --symbolic --force "$_dracut_module_dir" "$_dracut_module_target"; then
+ logging.warn \
+ "Linking \"$_dracut_module_dir\" to \"$_dracut_module_target\" failed." \
+>>>>>>> master
" We will copy them. So we have to recopy it every time to ensure that recompiled things take effect."
cp --recursive --force --no-target-directory \
- "${_root_dir}/modules.d/$_dracut_module" \
+ "$_dracut_module_dir" \
"$_dracut_module_target"
fi
fi
@@ -291,6 +364,7 @@ main() {
if [ "$verbose" == 'yes' ]; then
_loglevel='--verbose'
fi
+<<<<<<< HEAD
_modules='dnbd3-rootfs conf-tgz systemd systemd-initrd dracut-systemd'
echo "Default modules: ${_modules}"
if [ "$debug" == 'yes' ]; then
@@ -303,16 +377,48 @@ main() {
echo 'Removing all modules.'
rm "${_root_dir}/modules.d" \
"${_root_dir}/dracut" --recursive --force
+=======
+ _modules=(dnbd3-rootfs conf-tgz)
+ logging.info "Default modules: ${_modules[@]}"
+ if [ "$debug" == 'yes' ]; then
+ _loglevel="$_loglevel --stdlog 4"
+ _modules+=(i18n terminfo)
+ fi
+ if [ "$use_systemd_in_initramfs" == 'yes' ]; then
+ _modules+=(systemd systemd-initrd dracut-systemd)
+ fi
+ # Preprocess done - start build, cleanup or full cleanup
+ if [[ "$full_cleanup" == 'yes' ]]; then
+ logging.info 'Removing all modules.'
+ rm "${_repo_dir}" "${_root_dir}/dracut" --recursive --force
+>>>>>>> master
elif [[ "$cleanup" == 'yes' ]]; then
echo 'Removing distribution specific files.'
cleanup
- elif [[ "$initialize" == 'yes' ]]; then
- . "${_root_dir}/modules.d/dnbd3-rootfs/helper/build.inc"
- build_initialize_components
else
+<<<<<<< HEAD
echo 'Build initramfs.'
+=======
+ . "${_repo_dir}/builder/modules.d/dnbd3-rootfs/helper/build.inc"
+ build_initialize_components
+ if [[ "$initialize" == 'yes' ]]; then
+ logging.info "Initialized."
+ 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").
+ exceptions.deactivate
+ # NOTE: We temporary allow dracut to forward all messages since we
+ # forward all logging configurations.
+ _commands_log_level_backup="$(logging.get_commands_level)"
+ _log_level_backup="$(logging.get_level)"
+ logging.set_level debug
+ logging.set_commands_level debug
+ # shellcheck disable=SC2086
+>>>>>>> master
"${_root_dir}/dracut/dracut.sh" --local \
- $_loglevel --modules "$_modules" --conf /etc/dracut.conf \
+ $_loglevel --modules "${_modules[*]}" --conf /etc/dracut.conf \
--confdir /etc/dracut.conf.d "${dracut_parameter[@]}" \
--kver "${kernel_version}" "$file_path"
_return_code=$?
diff --git a/builder/modules.d/dnbd3-rootfs/helper/build.inc b/builder/modules.d/dnbd3-rootfs/helper/build.inc
index bb992de1..2410c633 100644
--- a/builder/modules.d/dnbd3-rootfs/helper/build.inc
+++ b/builder/modules.d/dnbd3-rootfs/helper/build.inc
@@ -19,8 +19,8 @@ build_initialize_components() {
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
+ logging.error "Failed to build dnbd3."
+ return 1
fi
fi
# take care of the qcow handler
@@ -181,10 +181,15 @@ build_compile_dnbd3() {
# 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
+ cd build
# Inject CMAKE_FLAGS as a way to control how cmake is called,
# e.g. to pass the kernel version
- cmake ${CMAKE_FLAGS} ../
+ cmake ${CMAKE_FLAGS} \
+ -DBUILD_FUSE_CLIENT=OFF \
+ -DBUILD_KERNEL_MODULE=ON \
+ -DBUILD_SERVER=OFF \
+ -DBUILD_STRESSTEST=OFF \
+ ../
make -j dnbd3 dnbd3-client
local ret=$?
popd
diff --git a/builder/modules.d/dnbd3-rootfs/module-setup.sh b/builder/modules.d/dnbd3-rootfs/module-setup.sh
index 63bb0b29..c2fea3b2 100755
--- a/builder/modules.d/dnbd3-rootfs/module-setup.sh
+++ b/builder/modules.d/dnbd3-rootfs/module-setup.sh
@@ -68,7 +68,10 @@ clean() {
}
# region dracut plugin api
check() {
- build_initialize_components
+ if ! build_initialize_components; then
+ echo "Failed to initialize components."
+ return 1
+ fi
# NOTE: xmount must be compiled before qemu_xmount
local xmount_is_built=true
if [[ ! -f "$moddir/binaries/xmount/trunk/build/src/xmount" ]] ||
@@ -118,10 +121,15 @@ installkernel() {
inst "${moddir}/binaries/dnbd3/build/dnbd3.ko" "${block_kmod_dir}/dnbd3.ko"
# kqcow2 kernel
- mkdir -p "${initdir}/${block_kmod_dir}/loop"
- for kmod in "${moddir}/binaries/kernel-qcow2-linux/drivers/block/loop/"*.ko ; do
- inst "$kmod" "${block_kmod_dir}/loop/$(basename $kmod)"
- done
+ local kqcow_loop_kmod_dir="${moddir}/binaries/kernel-qcow2-linux/drivers/block/loop"
+ if [ -e "${kqcow_loop_kmod_dir}/loop.ko" ] && \
+ [ -e "${kqcow_loop_kmod_dir}/loop_file_fmt_raw.ko" ] && \
+ [ -e "${kqcow_loop_kmod_dir}/loop_file_fmt_qcow.ko" ]; then
+ mkdir -p "${initdir}/${block_kmod_dir}/loop"
+ for kmod in "${kqcow_loop_kmod_dir}/"*.ko ; do
+ inst "$kmod" "${block_kmod_dir}/loop/$(basename $kmod)"
+ done
+ fi
}
install() {
# region binaries
diff --git a/builder/modules.d/slx-dmsetup/module-setup.sh b/builder/modules.d/slx-dmsetup/module-setup.sh
index 58c6e5cf..68e9b7b4 100755
--- a/builder/modules.d/slx-dmsetup/module-setup.sh
+++ b/builder/modules.d/slx-dmsetup/module-setup.sh
@@ -17,5 +17,8 @@ install() {
}
installkernel() {
# install those modules in case the used kernel does not have them builtin
- instmods dm-thin-pool dm-snapshot dm-crypt crc32c xfs ext4
+ instmods \
+ dm-thin-pool dm-snapshot \
+ dm-crypt crc32c xts \
+ xfs ext4
}
diff --git a/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device b/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
index c0f6a274..1756865e 100755
--- a/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
+++ b/builder/modules.d/slx-dmsetup/scripts/dmsetup-slx-device
@@ -273,7 +273,7 @@ save_partition_info "${scratch_device##*/}" "*" "1" "$scratch_device_size"
# encrypt the scratch device, if configured
if [ "$crypt" -ne 0 ] && encrypt_device \
"$scratch_device" "${scratch_device##*/}-crypt" "$scratch_device_size"; then
- scratch_device="${scratch_device##*/}-crypt"
+ scratch_device="${scratch_device}-crypt"
fi
writable_device_allocated="$scratch_device_size"
@@ -319,7 +319,7 @@ create_pool() {
# create remaining thin volumes
modprobe dm-thin-pool || echo "$0: dm-thin-pool load failed, maybe builtin?"
# create temporary metadata device
- data_block_size=256
+ data_block_size=255
# calculate number of sectors needed and check boundaries:
metadata_dev_size="$(( 48 * $writable_device_size / $data_block_size / 512 ))"
# Min 2MB -> 4096 sectors, max 16GB -> 33554432 sectors
diff --git a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3
index 4535ccd3..53ad8de9 100755
--- a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3
+++ b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3
@@ -31,9 +31,9 @@ wait_for_iface() {
set -x
ip link set dev "$SLX_PXE_NETIF" up
-if ! wait_for_iface "$SLX_PXE_NETIF" 100; then
- warn "'$SLX_PXE_NETIF' still not up after 10sec ... trying anyway."
- # TODO handle case where we waited for 10sec and it is still not up
+if ! wait_for_iface "$SLX_PXE_NETIF" 300; then
+ warn "'$SLX_PXE_NETIF' still not up after 30sec ... trying anyway."
+ # TODO handle case where we waited for 30sec and it is still not up
fi
# now determine whether we are in bridged/vlan/plain mode