summaryrefslogtreecommitdiff
path: root/test/units
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-07-23 16:49:13 +0200
committerLennart Poettering <lennart@poettering.net>2020-07-23 18:47:38 +0200
commitd64e32c245b6710f90f746d3bf970dd17f765d4b (patch)
tree6f62e13e51482d8461a95ba91472802493e0c6f1 /test/units
parent62b0ee9eb1b488e96359fa9b3f225c80e92cd082 (diff)
downloadsystemd-d64e32c245b6710f90f746d3bf970dd17f765d4b.tar.gz
nspawn: rework how /run/host/ is set up
Let's find the right os-release file on the host side, and only mount the one that matters, i.e. /etc/os-release if it exists and /usr/lib/os-release otherwise. Use the fixed path /run/host/os-release for that. Let's also mount /run/host as a bind mount on itself before we set up /run/host, and let's mount it MS_RDONLY after we are done, so that it remains immutable as a whole.
Diffstat (limited to 'test/units')
-rwxr-xr-xtest/units/testsuite-13.sh21
1 files changed, 17 insertions, 4 deletions
diff --git a/test/units/testsuite-13.sh b/test/units/testsuite-13.sh
index 0ad75ac8b0..b8fbf00ea6 100755
--- a/test/units/testsuite-13.sh
+++ b/test/units/testsuite-13.sh
@@ -66,12 +66,25 @@ if [ -n "${ID:+set}" ] && [ "${ID}" != "${container_host_id}" ]; then exit 1; fi
if [ -n "${VERSION_ID:+set}" ] && [ "${VERSION_ID}" != "${container_host_version_id}" ]; then exit 1; fi
if [ -n "${BUILD_ID:+set}" ] && [ "${BUILD_ID}" != "${container_host_build_id}" ]; then exit 1; fi
if [ -n "${VARIANT_ID:+set}" ] && [ "${VARIANT_ID}" != "${container_host_variant_id}" ]; then exit 1; fi
-cd /tmp; (cd /run/host/usr/lib; md5sum os-release) | md5sum -c
-if echo test >> /run/host/usr/lib/os-release; then exit 1; fi
-if echo test >> /run/host/etc/os-release; then exit 1; fi
+cd /tmp; (cd /run/host; md5sum os-release) | md5sum -c
+if echo test >> /run/host/os-release; then exit 1; fi
'
- systemd-nspawn --register=no -D /testsuite-13.nc-container --bind=/etc/os-release:/tmp/os-release /bin/sh -x -e -c "$_cmd"
+ local _os_release_source="/etc/os-release"
+ if [ ! -r "${_os_release_source}" ]; then
+ _os_release_source="/usr/lib/os-release"
+ elif [ -L "${_os_release_source}" ] && rm /etc/os-release; then
+ # Ensure that /etc always wins if available
+ cp /usr/lib/os-release /etc
+ echo MARKER=1 >> /etc/os-release
+ fi
+
+ systemd-nspawn --register=no -D /testsuite-13.nc-container --bind="${_os_release_source}":/tmp/os-release /bin/sh -x -e -c "$_cmd"
+
+ if grep -q MARKER /etc/os-release; then
+ rm /etc/os-release
+ ln -s ../usr/lib/os-release /etc/os-release
+ fi
}
function run {