Skip to content

Commit

Permalink
Merge 3bb9b3d into 68ee2ba
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanDeMeyer committed Apr 25, 2024
2 parents 68ee2ba + 3bb9b3d commit 6ed5c10
Show file tree
Hide file tree
Showing 30 changed files with 372 additions and 158 deletions.
21 changes: 15 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ meson_build_sh = find_program('tools/meson-build.sh')
want_tests = get_option('tests')
slow_tests = want_tests != 'false' and get_option('slow-tests')
fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
integration_tests = want_tests != 'false' and get_option('integration-tests')
install_tests = want_tests != 'false' and get_option('install-tests')

if add_languages('cpp', native : false, required : fuzzer_build)
Expand Down Expand Up @@ -2574,6 +2575,18 @@ endif
#####################################################################

mkosi = find_program('mkosi', required : false)
if integration_tests and not mkosi.found()
error('Could not find mkosi which is required to run the integration tests')
endif

mkosi_depends = public_programs

foreach executable : ['systemd-journal-remote', 'systemd-measure']
if executable in executables_by_name
mkosi_depends += [executables_by_name[executable]]
endif
endforeach

if mkosi.found()
custom_target('mkosi',
build_always_stale : true,
Expand All @@ -2588,13 +2601,9 @@ if mkosi.found()
'--build-dir', meson.current_build_dir() / 'mkosi.builddir',
'--force',
'--debug',
'build'
],
depends : public_programs + [
executables_by_name['systemd-journal-remote'],
executables_by_name['systemd-measure'],
ukify,
'build',
],
depends : mkosi_depends,
)
endif

Expand Down
24 changes: 24 additions & 0 deletions mkosi.images/minimal-0/mkosi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Config]
Dependencies=minimal-base

[Distribution]
CacheOnly=always

[Output]
Format=portable
SplitArtifacts=yes

[Content]
BaseTrees=%O/minimal-base
Environment=SYSTEMD_REPART_OVERRIDE_FSTYPE=squashfs
Bootable=no

BuildSources=
Packages=
BuildPackages=
VolatilePackages=

[Host]
Incremental=no
1 change: 1 addition & 0 deletions mkosi.images/minimal-0/mkosi.extra/opt/some_file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Service]
ExecStartPre=cat /usr/lib/os-release
ExecStart=sleep 120
11 changes: 11 additions & 0 deletions mkosi.images/minimal-0/mkosi.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux

mkdir -p "$BUILDROOT/var/lib/app1"

cat >>"$BUILDROOT/usr/lib/os-release" <<EOF
MARKER=1
PORTABLE_PREFIXES=app0 minimal minimal-app0
EOF
cp "$BUILDROOT/usr/lib/systemd/system/minimal-app0.service" "$BUILDROOT/usr/lib/systemd/system/minimal-app0-foo.service"
24 changes: 24 additions & 0 deletions mkosi.images/minimal-1/mkosi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Config]
Dependencies=minimal-base

[Distribution]
CacheOnly=always

[Output]
Format=portable
SplitArtifacts=yes

[Content]
BaseTrees=%O/minimal-base
Environment=SYSTEMD_REPART_OVERRIDE_FSTYPE=squashfs
Bootable=no

BuildSources=
Packages=
BuildPackages=
VolatilePackages=

[Host]
Incremental=no
1 change: 1 addition & 0 deletions mkosi.images/minimal-1/mkosi.extra/opt/some_file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Service]
ExecStartPre=cat /usr/lib/os-release
ExecStart=sleep 120
11 changes: 11 additions & 0 deletions mkosi.images/minimal-1/mkosi.postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux

mkdir -p "$BUILDROOT/var/lib/app1"

cat >>"$BUILDROOT/usr/lib/os-release" <<EOF
MARKER=2
PORTABLE_PREFIXES=app0 minimal minimal-app0
EOF
cp "$BUILDROOT/usr/lib/systemd/system/minimal-app0.service" "$BUILDROOT/usr/lib/systemd/system/minimal-app0-bar.service"
21 changes: 21 additions & 0 deletions mkosi.images/minimal-base/mkosi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Output]
ImageId=minimal-base
Format=directory
ImageId=minimal-base

[Content]
Bootable=no
@Locale=C.UTF-8
WithDocs=no

BuildSources=
Packages=
BuildPackages=
VolatilePackages=

Packages=
bash
coreutils
util-linux
10 changes: 10 additions & 0 deletions mkosi.images/minimal-base/mkosi.conf.d/10-arch.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=arch

[Content]
Packages=
inetutils
iproute
openbsd-netcat
12 changes: 12 additions & 0 deletions mkosi.images/minimal-base/mkosi.conf.d/10-centos-fedora.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=|centos
Distribution=|fedora

[Content]
Packages=
hostname
iproute
iproute-tc
netcat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=|debian
Distribution=|ubuntu

[Content]
Packages=
hostname
iproute2
netcat-openbsd
11 changes: 11 additions & 0 deletions mkosi.images/minimal-base/mkosi.conf.d/10-opensuse.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=opensuse

[Content]
Packages=
hostname
iproute2
netcat-openbsd
patterns-base-minimal_base
3 changes: 3 additions & 0 deletions mkosi.images/minimal-base/mkosi.extra/etc/resolv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

# This is a stub resolv.conf intended as a mountpoint for the host's resolv.conf
11 changes: 11 additions & 0 deletions mkosi.images/system/mkosi.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Config]
Dependencies=
minimal-0
minimal-1

[Output]
@Format=directory

[Content]
Autologin=yes
ExtraTrees=
%D/mkosi.crt:/usr/lib/verity.d/mkosi.crt # sysext verification key
%O/minimal-0.root-%a.raw:/usr/share/minimal_0.raw
%O/minimal-0.root-%a-verity.raw:/usr/share/minimal_0.verity
%O/minimal-0.root-%a-verity-sig.raw:/usr/share/minimal_0.verity.sig
%O/minimal-1.root-%a.raw:/usr/share/minimal_1.raw
%O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity
%O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig

Packages=
acl
Expand Down
1 change: 1 addition & 0 deletions mkosi.images/system/mkosi.conf.d/10-arch/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Packages=
quota-tools
sbsigntools
shadow
squashfs-tools
tpm2-tss
vim

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Packages=
selinux-policy
selinux-policy-targeted
setools-console
squashfs-tools
util-linux
vim-common

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Packages=
psmisc
quota
sbsigntool
squashfs-tools
tzdata
xxd

Expand Down
1 change: 1 addition & 0 deletions mkosi.images/system/mkosi.conf.d/10-opensuse/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Packages=
sbsigntools
sed
shadow
squashfs
timezone
user(bin)
user(daemon)
Expand Down
4 changes: 4 additions & 0 deletions mkosi.images/system/mkosi.postinst.chroot
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ if command -v sbsign &>/dev/null; then
ukify build --secureboot-private-key mkosi.key --secureboot-certificate mkosi.crt --cmdline this_should_be_here -o "$addons_dir/good.addon.efi"
ukify build --cmdline this_should_not_be_here -o "$addons_dir/bad.addon.efi"
fi

for f in "$BUILDROOT"/usr/share/*.verity.sig; do
jq --join-output '.rootHash' "$f" >"${f%.verity.sig}.roothash"
done
1 change: 1 addition & 0 deletions src/test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
test_env.set('PATH', project_build_root + ':' + path)
test_env.set('PROJECT_BUILD_ROOT', project_build_root)
test_env.set('SYSTEMD_SLOW_TESTS', slow_tests ? '1' : '0')
test_env.set('SYSTEMD_INTEGRATION_TESTS', integration_tests ? '1' : '0')

if efi_addon != ''
test_env.set('EFI_ADDON', efi_addon)
Expand Down
4 changes: 4 additions & 0 deletions test/integration-test-wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@


def main():
if not bool(int(os.getenv("SYSTEMD_INTEGRATION_TESTS", "0"))):
print("SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping", file=sys.stderr)
exit(77)

parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--meson-source-dir', required=True, type=Path)
parser.add_argument('--meson-build-dir', required=True, type=Path)
Expand Down
3 changes: 3 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ if get_option('integration-tests')
integration_tests = {
'01': 'TEST-01-BASIC',
'02': 'TEST-02-UNITTESTS',
'29': 'TEST-29-PORTABLE',
'43': 'TEST-43-PRIVATEUSER-UNPRIV',
'50': 'TEST-50-DISSECT',
}
foreach test_number, dirname : integration_tests
test_params = {
Expand Down

0 comments on commit 6ed5c10

Please sign in to comment.