Skip to content

Commit

Permalink
Merge 00d1b56 into c929c6a
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanDeMeyer committed Apr 25, 2024
2 parents c929c6a + 00d1b56 commit 7197bee
Show file tree
Hide file tree
Showing 74 changed files with 515 additions and 306 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"
22 changes: 22 additions & 0 deletions mkosi.images/minimal-base/mkosi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
grep
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,12 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=|debian
Distribution=|ubuntu

[Content]
Packages=
hostname
iproute2
mount
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
1 change: 1 addition & 0 deletions mkosi.images/minimal-base/mkosi.extra/etc/os-release
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
1 change: 1 addition & 0 deletions mkosi.images/system/mkosi.conf.d/10-centos/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Distribution=centos
[Content]
Packages=
rpmautospec-rpm-macros
kernel-modules # For squashfs
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ enable dbus-broker.service
enable systemd-networkd.service
enable systemd-networkd-wait-online.service

# systemd-resolved is disable by default on CentOS so make sure it is enabled.
enable systemd-resolved.service

# We install dnf in some images but it's only going to be used rarely,
# so let's not have dnf create its cache.
disable dnf-makecache.*
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
3 changes: 1 addition & 2 deletions src/ac-power/ac-power.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ static int run(int argc, char *argv[]) {
/* This is mostly intended to be used for scripts which want
* to detect whether AC power is plugged in or not. */

log_parse_environment();
log_open();
log_setup();

r = parse_argv(argc, argv);
if (r <= 0)
Expand Down
4 changes: 1 addition & 3 deletions src/ask-password/ask-password.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ static int run(int argc, char *argv[]) {
usec_t timeout;
int r;

log_show_color(true);
log_parse_environment();
log_open();
log_setup();

r = parse_argv(argc, argv);
if (r <= 0)
Expand Down
3 changes: 1 addition & 2 deletions src/boot/bless-boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,7 @@ static int run(int argc, char *argv[]) {

int r;

log_parse_environment();
log_open();
log_setup();

r = parse_argv(argc, argv);
if (r <= 0)
Expand Down
3 changes: 1 addition & 2 deletions src/boot/boot-check-no-failures.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ static int run(int argc, char *argv[]) {
uint32_t n;
int r;

log_parse_environment();
log_open();
log_setup();

r = parse_argv(argc, argv);
if (r <= 0)
Expand Down
4 changes: 1 addition & 3 deletions src/boot/measure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,7 @@ static int measure_main(int argc, char *argv[]) {
static int run(int argc, char *argv[]) {
int r;

log_show_color(true);
log_parse_environment();
log_open();
log_setup();

r = parse_argv(argc, argv);
if (r <= 0)
Expand Down
4 changes: 1 addition & 3 deletions src/cryptenroll/cryptenroll.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,7 @@ static int run(int argc, char *argv[]) {
size_t vks;
int slot, slot_to_wipe, r;

log_show_color(true);
log_parse_environment();
log_open();
log_setup();

r = parse_argv(argc, argv);
if (r <= 0)
Expand Down
3 changes: 1 addition & 2 deletions src/environment-d-generator/environment-d-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ static int load_and_print(void) {
static int run(int argc, char *argv[]) {
int r;

log_parse_environment();
log_open();
log_setup();

if (argc > 1)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
Expand Down
3 changes: 1 addition & 2 deletions src/fuzz/fuzz.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ static inline void fuzz_setup_logging(void) {
* in a fuzzing mode, so disable most of the logging. */
log_set_assert_return_is_critical(true);
log_set_max_level(LOG_CRIT);
log_parse_environment();
log_open();
log_setup();
}

/* Force value to not be optimized away. */
Expand Down
3 changes: 1 addition & 2 deletions src/hwdb/hwdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ static int hwdb_main(int argc, char *argv[]) {
static int run(int argc, char *argv[]) {
int r;

log_parse_environment();
log_open();
log_setup();

r = parse_argv(argc, argv);
if (r <= 0)
Expand Down
3 changes: 1 addition & 2 deletions src/journal-remote/journal-remote-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,7 @@ static int run(int argc, char **argv) {
_cleanup_free_ char *cert = NULL, *trust = NULL;
int r;

log_show_color(true);
log_parse_environment();
log_setup();

/* The journal merging logic potentially needs a lot of fds. */
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
Expand Down

0 comments on commit 7197bee

Please sign in to comment.