diff --git a/test/TEST-50-DISSECT/test.sh b/test/TEST-50-DISSECT/test.sh index 831c0db31c..f274b73522 100755 --- a/test/TEST-50-DISSECT/test.sh +++ b/test/TEST-50-DISSECT/test.sh @@ -40,7 +40,7 @@ test_create_image() { mkdir -p $initdir setup_basic_dirs install_basic_tools - inst /usr/lib/os-release + cp $os_release $initdir/usr/lib/os-release ln -s ../usr/lib/os-release $initdir/etc/os-release echo MARKER=1 >> $initdir/usr/lib/os-release mksquashfs $initdir $oldinitdir/usr/share/minimal.raw diff --git a/test/create-busybox-container b/test/create-busybox-container index 3ff14b5fd3..5ded42950a 100755 --- a/test/create-busybox-container +++ b/test/create-busybox-container @@ -9,7 +9,8 @@ mkdir -p "$root" mkdir "$root/bin" cp $(type -P busybox) "$root/bin" -ID_LIKE=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' /etc/os-release) +os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release) +ID_LIKE=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' $os_release) if [[ "$ID_LIKE" = *"suse"* ]]; then mkdir -p "$root/lib" mkdir -p "$root/lib64" diff --git a/test/test-functions b/test/test-functions index 863cc18aef..68d780b983 100644 --- a/test/test-functions +++ b/test/test-functions @@ -4,9 +4,10 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH -LOOKS_LIKE_DEBIAN=$(source /etc/os-release && [[ "$ID" = "debian" || " $ID_LIKE " = *" debian "* ]] && echo yes || :) -LOOKS_LIKE_ARCH=$(source /etc/os-release && [[ "$ID" = "arch" || " $ID_LIKE " = *" arch "* ]] && echo yes || :) -LOOKS_LIKE_SUSE=$(source /etc/os-release && [[ " $ID_LIKE " = *" suse "* ]] && echo yes || :) +os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release) +LOOKS_LIKE_DEBIAN=$(source $os_release && [[ "$ID" = "debian" || " $ID_LIKE " = *" debian "* ]] && echo yes || :) +LOOKS_LIKE_ARCH=$(source $os_release && [[ "$ID" = "arch" || " $ID_LIKE " = *" arch "* ]] && echo yes || :) +LOOKS_LIKE_SUSE=$(source $os_release && [[ " $ID_LIKE " = *" suse "* ]] && echo yes || :) KERNEL_VER=${KERNEL_VER-$(uname -r)} KERNEL_MODS="/lib/modules/$KERNEL_VER/" QEMU_TIMEOUT="${QEMU_TIMEOUT:-infinity}" @@ -940,7 +941,7 @@ install_config_files() { inst /etc/shells inst_any /etc/nsswitch.conf /usr/etc/nsswitch.conf inst /etc/pam.conf || : - inst /etc/os-release + inst_any /etc/os-release /usr/lib/os-release inst /etc/localtime # we want an empty environment > $initdir/etc/environment diff --git a/test/units/testsuite-50.sh b/test/units/testsuite-50.sh index 376d4c9e23..d6e1a3557a 100755 --- a/test/units/testsuite-50.sh +++ b/test/units/testsuite-50.sh @@ -28,22 +28,24 @@ cp /usr/share/minimal.* "${image_dir}/" image="${image_dir}/minimal" roothash="$(cat ${image}.roothash)" +os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release) + systemd-dissect --json=short ${image}.raw | grep -q -F '{"rw":"ro","designator":"root","partition_uuid":null,"fstype":"squashfs","architecture":null,"verity":"external"' systemd-dissect ${image}.raw | grep -q -F "MARKER=1" -systemd-dissect ${image}.raw | grep -q -F -f /usr/lib/os-release +systemd-dissect ${image}.raw | grep -q -F -f $os_release mv ${image}.verity ${image}.fooverity mv ${image}.roothash ${image}.foohash systemd-dissect --json=short ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F '{"rw":"ro","designator":"root","partition_uuid":null,"fstype":"squashfs","architecture":null,"verity":"external"' systemd-dissect ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F "MARKER=1" -systemd-dissect ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F -f /usr/lib/os-release +systemd-dissect ${image}.raw --root-hash=${roothash} --verity-data=${image}.fooverity | grep -q -F -f $os_release mv ${image}.fooverity ${image}.verity mv ${image}.foohash ${image}.roothash mkdir -p ${image_dir}/mount ${image_dir}/mount2 systemd-dissect --mount ${image}.raw ${image_dir}/mount -cat ${image_dir}/mount/usr/lib/os-release | grep -q -F -f /usr/lib/os-release -cat ${image_dir}/mount/etc/os-release | grep -q -F -f /usr/lib/os-release +cat ${image_dir}/mount/usr/lib/os-release | grep -q -F -f $os_release +cat ${image_dir}/mount/etc/os-release | grep -q -F -f $os_release cat ${image_dir}/mount/usr/lib/os-release | grep -q -F "MARKER=1" # Verity volume should be shared (opened only once) systemd-dissect --mount ${image}.raw ${image_dir}/mount2 @@ -118,11 +120,11 @@ VERITY_UUID=$(systemd-id128 -u show $(tail -c 32 ${image}.roothash) -u | tail -n systemd-dissect --json=short --root-hash ${roothash} ${image}.gpt | grep -q '{"rw":"ro","designator":"root","partition_uuid":"'$ROOT_UUID'","fstype":"squashfs","architecture":"x86-64","verity":"yes","node":' systemd-dissect --json=short --root-hash ${roothash} ${image}.gpt | grep -q '{"rw":"ro","designator":"root-verity","partition_uuid":"'$VERITY_UUID'","fstype":"DM_verity_hash","architecture":"x86-64","verity":null,"node":' systemd-dissect --root-hash ${roothash} ${image}.gpt | grep -q -F "MARKER=1" -systemd-dissect --root-hash ${roothash} ${image}.gpt | grep -q -F -f /usr/lib/os-release +systemd-dissect --root-hash ${roothash} ${image}.gpt | grep -q -F -f $os_release systemd-dissect --root-hash ${roothash} --mount ${image}.gpt ${image_dir}/mount -cat ${image_dir}/mount/usr/lib/os-release | grep -q -F -f /usr/lib/os-release -cat ${image_dir}/mount/etc/os-release | grep -q -F -f /usr/lib/os-release +cat ${image_dir}/mount/usr/lib/os-release | grep -q -F -f $os_release +cat ${image_dir}/mount/etc/os-release | grep -q -F -f $os_release cat ${image_dir}/mount/usr/lib/os-release | grep -q -F "MARKER=1" umount ${image_dir}/mount