mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 14:55:37 +03:00
21838f36a6
The packages are installed to provide the dhcpd binary, used by test/test-network/systemd-networkd-tests.py, but we don't need the units to run, and in fact in some cases the image fails to boot because of them: Spawning container image on /home/runner/work/systemd/systemd/image.raw. Press ^] three times within 1s to kill container. ● isc-dhcp-server.service loaded failed failed ISC DHCP IPv4 server ● isc-dhcp-server6.service loaded failed failed ISC DHCP IPv6 server Container image failed with error code 1. Error: Process completed with exit code 1. Mask the units with an --extra-tree.
40 lines
1.2 KiB
Bash
Executable File
40 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
# shellcheck disable=SC2064
|
|
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
EC=0
|
|
TEMPFILE="$(mktemp)"
|
|
TEMP_EXTRA_TREE="$(mktemp --directory)"
|
|
trap "rm -rf '$TEMPFILE' '$TEMP_EXTRA_TREE'" EXIT
|
|
|
|
# We need isc-dhcp-server to be installed for the networkd unit tests, but we don't want to
|
|
# run it by default. mktemp creates the directory as 700, so change it, otherwise it will
|
|
# affect the image's root folder permissions.
|
|
chmod 755 "$TEMP_EXTRA_TREE"
|
|
mkdir -p "$TEMP_EXTRA_TREE/etc/systemd/system/"
|
|
ln -s /dev/null "$TEMP_EXTRA_TREE/etc/systemd/system/isc-dhcp-server.service"
|
|
ln -s /dev/null "$TEMP_EXTRA_TREE/etc/systemd/system/isc-dhcp-server6.service"
|
|
|
|
for ((i = 0; i < 5; i++)); do
|
|
EC=0
|
|
(sudo python3 -m mkosi --extra-tree="$TEMP_EXTRA_TREE" "$@") |& tee "$TEMPFILE" || EC=$?
|
|
if [[ $EC -eq 0 ]]; then
|
|
# The command passed — let's return immediately
|
|
break
|
|
fi
|
|
|
|
if ! grep -E "Failed to dissect image .+: Connection timed out" "$TEMPFILE"; then
|
|
# The command failed for other reason than the dissect-related timeout -
|
|
# let's exit with the same EC
|
|
exit $EC
|
|
fi
|
|
|
|
# The command failed due to the dissect-related timeout — let's try again
|
|
sleep 1
|
|
done
|
|
|
|
exit $EC
|