Skip to content

Commit a13ca29

Browse files
committed
scripts/build-image: use libosinfo to detect installer
When using virt-install --location disk.iso the libosinfo library is used to detect operating system and path to kernel and initramdisk on the ISO image. This is done by comparing disk label against its database of known OSes. While most of the images I tested do work, to fully ensure this is the case and to prevent regressions, let's run this tool after image is built in case it is an ISO. For unknown OS versions, the database contains "unknown" entries which are still recognized as unreleased versions, so this should work even if our runners will have older version of the library.
1 parent d6a6c96 commit a13ca29

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

test/scripts/build-image

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import argparse
33
import json
44
import os
5+
import sys
56

67
import imgtestlib as testlib
78

@@ -64,6 +65,19 @@ def main():
6465
}
6566
testlib.write_build_info(build_dir, build_info)
6667

68+
# Test ISO installer with libosinfo to ensure that virt-install can locate embedded
69+
# kernel and initrd for direct boot.
70+
image_path = testlib.find_image_file(build_dir)
71+
print(f"🔍 Testing ISO installer with libosinfo: {image_path}")
72+
if image_path.endswith('.iso'):
73+
stdout, stderr = testlib.runcmd(["osinfo-detect", image_path])
74+
output = stdout.decode() + stderr.decode()
75+
76+
if "Media is an installer" not in output:
77+
print("❌ osinfo-detect output does not detect the image as a valid installer:")
78+
print(output)
79+
sys.exit(1)
80+
6781

6882
if __name__ == "__main__":
6983
main()

test/scripts/install-dependencies

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ dnf -y install \
88
btrfs-progs-devel \
99
cloud-utils \
1010
device-mapper-devel \
11+
libosinfo \
12+
gettext \
1113
libvirt-devel \
1214
gcc \
1315
go \
@@ -32,3 +34,16 @@ dnf install -y lorax
3234
# we need this for the qemu boot tests and for any python tests but
3335
# could skip it for other testing.
3436
pip install .
37+
38+
# latest database for libosinfo-detect checks
39+
OSDB_DIR=$(mktemp -d -t osinfodb.XXXXXX)/osinfo-db
40+
cleanup() {
41+
test "$OSDB_DIR" && rm -rf "$OSDB_DIR"
42+
}
43+
trap cleanup EXIT INT TERM
44+
45+
git clone https://gitlab.com/libosinfo/osinfo-db "$OSDB_DIR"
46+
pushd "$OSDB_DIR"
47+
# install into $HOME/.config/osinfo
48+
make install -j2
49+
popd

0 commit comments

Comments
 (0)