Merge pull request #16872 from keszybz/test-50
Improve handling of os-release in tests
This commit is contained in:
commit
7efbe21850
|
@ -28,7 +28,6 @@ test_create_image() {
|
||||||
instmods dm_verity =md
|
instmods dm_verity =md
|
||||||
install_dmevent
|
install_dmevent
|
||||||
generate_module_dependencies
|
generate_module_dependencies
|
||||||
inst_binary sfdisk
|
|
||||||
inst_binary losetup
|
inst_binary losetup
|
||||||
|
|
||||||
BASICTOOLS=(
|
BASICTOOLS=(
|
||||||
|
@ -41,7 +40,7 @@ test_create_image() {
|
||||||
mkdir -p $initdir
|
mkdir -p $initdir
|
||||||
setup_basic_dirs
|
setup_basic_dirs
|
||||||
install_basic_tools
|
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
|
ln -s ../usr/lib/os-release $initdir/etc/os-release
|
||||||
echo MARKER=1 >> $initdir/usr/lib/os-release
|
echo MARKER=1 >> $initdir/usr/lib/os-release
|
||||||
mksquashfs $initdir $oldinitdir/usr/share/minimal.raw
|
mksquashfs $initdir $oldinitdir/usr/share/minimal.raw
|
||||||
|
|
|
@ -9,7 +9,8 @@ mkdir -p "$root"
|
||||||
mkdir "$root/bin"
|
mkdir "$root/bin"
|
||||||
cp $(type -P busybox) "$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
|
if [[ "$ID_LIKE" = *"suse"* ]]; then
|
||||||
mkdir -p "$root/lib"
|
mkdir -p "$root/lib"
|
||||||
mkdir -p "$root/lib64"
|
mkdir -p "$root/lib64"
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
LOOKS_LIKE_DEBIAN=$(source /etc/os-release && [[ "$ID" = "debian" || " $ID_LIKE " = *" debian "* ]] && echo yes || :)
|
os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release)
|
||||||
LOOKS_LIKE_ARCH=$(source /etc/os-release && [[ "$ID" = "arch" || " $ID_LIKE " = *" arch "* ]] && echo yes || :)
|
LOOKS_LIKE_DEBIAN=$(source $os_release && [[ "$ID" = "debian" || " $ID_LIKE " = *" debian "* ]] && echo yes || :)
|
||||||
LOOKS_LIKE_SUSE=$(source /etc/os-release && [[ " $ID_LIKE " = *" suse "* ]] && 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_VER=${KERNEL_VER-$(uname -r)}
|
||||||
KERNEL_MODS="/lib/modules/$KERNEL_VER/"
|
KERNEL_MODS="/lib/modules/$KERNEL_VER/"
|
||||||
QEMU_TIMEOUT="${QEMU_TIMEOUT:-infinity}"
|
QEMU_TIMEOUT="${QEMU_TIMEOUT:-infinity}"
|
||||||
|
@ -639,7 +640,8 @@ install_dmevent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
install_systemd() {
|
install_systemd() {
|
||||||
# install compiled files
|
ddebug "Install compiled systemd"
|
||||||
|
|
||||||
local _ninja_bin=$(type -P ninja || type -P ninja-build)
|
local _ninja_bin=$(type -P ninja || type -P ninja-build)
|
||||||
if [[ -z "$_ninja_bin" ]]; then
|
if [[ -z "$_ninja_bin" ]]; then
|
||||||
dfatal "ninja was not found"
|
dfatal "ninja was not found"
|
||||||
|
@ -648,9 +650,6 @@ install_systemd() {
|
||||||
(set -x; DESTDIR=$initdir "$_ninja_bin" -C $BUILD_DIR install)
|
(set -x; DESTDIR=$initdir "$_ninja_bin" -C $BUILD_DIR install)
|
||||||
# remove unneeded documentation
|
# remove unneeded documentation
|
||||||
rm -fr $initdir/usr/share/{man,doc}
|
rm -fr $initdir/usr/share/{man,doc}
|
||||||
# we strip binaries since debug symbols increase binaries size a lot
|
|
||||||
# and it could fill the available space
|
|
||||||
strip_binaries
|
|
||||||
|
|
||||||
[[ "$LOOKS_LIKE_SUSE" ]] && setup_suse
|
[[ "$LOOKS_LIKE_SUSE" ]] && setup_suse
|
||||||
|
|
||||||
|
@ -940,7 +939,7 @@ install_config_files() {
|
||||||
inst /etc/shells
|
inst /etc/shells
|
||||||
inst_any /etc/nsswitch.conf /usr/etc/nsswitch.conf
|
inst_any /etc/nsswitch.conf /usr/etc/nsswitch.conf
|
||||||
inst /etc/pam.conf || :
|
inst /etc/pam.conf || :
|
||||||
inst /etc/os-release
|
inst_any /etc/os-release /usr/lib/os-release
|
||||||
inst /etc/localtime
|
inst /etc/localtime
|
||||||
# we want an empty environment
|
# we want an empty environment
|
||||||
> $initdir/etc/environment
|
> $initdir/etc/environment
|
||||||
|
|
|
@ -28,22 +28,24 @@ cp /usr/share/minimal.* "${image_dir}/"
|
||||||
image="${image_dir}/minimal"
|
image="${image_dir}/minimal"
|
||||||
roothash="$(cat ${image}.roothash)"
|
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 --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 "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}.verity ${image}.fooverity
|
||||||
mv ${image}.roothash ${image}.foohash
|
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 --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 "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}.fooverity ${image}.verity
|
||||||
mv ${image}.foohash ${image}.roothash
|
mv ${image}.foohash ${image}.roothash
|
||||||
|
|
||||||
mkdir -p ${image_dir}/mount ${image_dir}/mount2
|
mkdir -p ${image_dir}/mount ${image_dir}/mount2
|
||||||
systemd-dissect --mount ${image}.raw ${image_dir}/mount
|
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/usr/lib/os-release | grep -q -F -f $os_release
|
||||||
cat ${image_dir}/mount/etc/os-release | grep -q -F -f /usr/lib/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"
|
cat ${image_dir}/mount/usr/lib/os-release | grep -q -F "MARKER=1"
|
||||||
# Verity volume should be shared (opened only once)
|
# Verity volume should be shared (opened only once)
|
||||||
systemd-dissect --mount ${image}.raw ${image_dir}/mount2
|
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","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 --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 "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
|
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/usr/lib/os-release | grep -q -F -f $os_release
|
||||||
cat ${image_dir}/mount/etc/os-release | grep -q -F -f /usr/lib/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"
|
cat ${image_dir}/mount/usr/lib/os-release | grep -q -F "MARKER=1"
|
||||||
umount ${image_dir}/mount
|
umount ${image_dir}/mount
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue