]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
20 months agoMove integration tests into python 2117/head
Daan De Meyer [Fri, 1 Dec 2023 10:22:21 +0000 (11:22 +0100)] 
Move integration tests into python

Instead of vendor locking ourselves to Github Actions, let's move
the integration tests into python so we can run them locally and
on other CI systems.

We opt to use unittest style test cases so that we can have a
configurable base class that can be used for various integration
tests. Unfortunately, I haven't found a nice and type safe way to
make pytest fixtures configurable so we opt for unittest instead.

Note that while we use the subTest() feature of unittest, pytest
still considers test_boot() a single test because it doesn't support
this particular feature of unittest. Ideally we switch our test runner
to something else in the future which does support the subTest() feature.

We always run steps that can run unprivileged without privileges even
if we're running as root so that tests can be run locally with root
privileges without ending up with a bunch of files owned by root
afterwards.

20 months agoUse mkosi.local.conf for local configuration
Daan De Meyer [Thu, 30 Nov 2023 19:59:15 +0000 (20:59 +0100)] 
Use mkosi.local.conf for local configuration

Let's move our common configuration to mkosi.conf now that we have
mkosi.local.conf for local configuration.

20 months agoFix licensing
Daan De Meyer [Thu, 30 Nov 2023 11:11:36 +0000 (12:11 +0100)] 
Fix licensing

Add GPL2 license to the repository and fix the SPDX license identifiers
for the dracut files to GPL-2.0-only.

20 months agodocs: format paths as monospace
Joerg Behrmann [Thu, 30 Nov 2023 08:36:19 +0000 (09:36 +0100)] 
docs: format paths as monospace

20 months agoFix ImageId= docs
Daan De Meyer [Wed, 29 Nov 2023 20:39:42 +0000 (21:39 +0100)] 
Fix ImageId= docs

- We don't patch it into partition labels anymore
- We already patch os-release ourselves so let's not use it as an
  example of what to do with $IMAGE_ID for users.

20 months agomkosi-initrd: Copy md and dm udev rules from dracut
Daan De Meyer [Wed, 29 Nov 2023 07:55:06 +0000 (08:55 +0100)] 
mkosi-initrd: Copy md and dm udev rules from dracut

Until these are upstreamed into their corresponding projects, let's
carry the rules in mkosi-initrd.

20 months agoRevert "ci: enable jammy-proposed-updates to get new libsolv"
Luca Boccassi [Wed, 29 Nov 2023 16:05:39 +0000 (16:05 +0000)] 
Revert "ci: enable jammy-proposed-updates to get new libsolv"

libsolv has migrated to jammy-updates, so we can disable the
proposed-updates repository again.

This reverts commit 698834c7794f0100eba8ff17125cffc8f6ac8a63.

20 months agoStop using workspace cache subdirectory
Daan De Meyer [Wed, 29 Nov 2023 11:53:05 +0000 (12:53 +0100)] 
Stop using workspace cache subdirectory

We don't do this for configured cache directories anymore, so don't
do it for workspace cache directories anymore either.

20 months agoMerge pull request #2084 from behrmann/reprouid
Daan De Meyer [Wed, 29 Nov 2023 10:37:55 +0000 (11:37 +0100)] 
Merge pull request #2084 from behrmann/reprouid

util: add a fallback username and home for INVOKING_USER

20 months agomounts: use INVOKING_USER in mount_passwd instead of hardcoding /home 2084/head
Joerg Behrmann [Wed, 29 Nov 2023 10:20:08 +0000 (11:20 +0100)] 
mounts: use INVOKING_USER in mount_passwd instead of hardcoding /home

20 months agoutil: make name and home of INVOKING_USER methods that cache their results
Joerg Behrmann [Tue, 21 Nov 2023 09:47:41 +0000 (10:47 +0100)] 
util: make name and home of INVOKING_USER methods that cache their results

At test time, e.g. during reproducible builds, usernames are not guaranteed to
be resolvable, because NSS is deliberately broken. Hence, only try to resolve
either only if needed and cache the result, so it stays the same across
invocations.

This unfortunately can no longer be achieved by combining @classmethod with
@property, since the combination, which had only been allowed since Python 3.9,
was deprecated again in Python 3.11.

Fixes: #2081
20 months agoSpeed up empty_directory()
Daan De Meyer [Tue, 28 Nov 2023 16:36:27 +0000 (17:36 +0100)] 
Speed up empty_directory()

Let's invoke rm once instead of N times.

20 months agoSet atime and mtime of scripts to zero
Daan De Meyer [Tue, 28 Nov 2023 16:35:03 +0000 (17:35 +0100)] 
Set atime and mtime of scripts to zero

Otherwise, stuff like meson reconfigure will rerun every time because
we write the script again every time we run the build script.

20 months agoAdd useradd script
Daan De Meyer [Tue, 28 Nov 2023 11:39:59 +0000 (12:39 +0100)] 
Add useradd script

Let's automatically invoke useradd with --root when executed outside
of the image chroot.

Fixes #2089

20 months agoFix --genkey-valid-days and --genkey-common-name
Daan De Meyer [Tue, 28 Nov 2023 11:44:46 +0000 (12:44 +0100)] 
Fix --genkey-valid-days and --genkey-common-name

Fixes #2077

20 months agoUse zst as zstd file extension
Daan De Meyer [Tue, 28 Nov 2023 16:04:14 +0000 (17:04 +0100)] 
Use zst as zstd file extension

20 months agoFix user provided kernel not being used
Daan De Meyer [Tue, 28 Nov 2023 13:33:11 +0000 (14:33 +0100)] 
Fix user provided kernel not being used

20 months agoUse the main tool name in error when tool is not found
Zbigniew Jędrzejewski-Szmek [Tue, 28 Nov 2023 11:10:11 +0000 (12:10 +0100)] 
Use the main tool name in error when tool is not found

We would say that we cannnot find /usr/lib/systemd/ukify, which
is somewhat confusing, since we're looking for ukify in $PATH
first, and only for /usr/lib/systemd/ukify as a fallback.

This also avoids a second which call on the results of a which call.

20 months agoAdd microcode support
Daan De Meyer [Tue, 28 Nov 2023 10:39:04 +0000 (11:39 +0100)] 
Add microcode support

Let's make sure we add early CPIO initrds containing microcode when
building bootable images. To make early loading of microcode work, an
uncompressed initrd has to be prepended to the list of initrds containing
the microcode at a canonical location.

20 months agoRun depmod even if Bootable=no
Daan De Meyer [Tue, 28 Nov 2023 09:17:51 +0000 (10:17 +0100)] 
Run depmod even if Bootable=no

Bootable=no disables the kernel modules logic but users might still want
to generate a bootable image so let's run the depmod logic unconditionally.

20 months agoDo not trigger bwrap's max arg limit when running modinfo
Daan De Meyer [Tue, 28 Nov 2023 09:38:01 +0000 (10:38 +0100)] 
Do not trigger bwrap's max arg limit when running modinfo

We might potentially pass a lot of modules at once to modinfo which
could trigger bwrap's max argument limit so make sure to chunk things
up to avoid hitting the limit.

20 months agoautologin: use a helper method to reduce boilerplate
Zbigniew Jędrzejewski-Szmek [Mon, 27 Nov 2023 11:12:25 +0000 (12:12 +0100)] 
autologin: use a helper method to reduce boilerplate

I kept the generated option strings exactly the same. In some cases we
put the baud before the device name or placeholder, and in other cases in
the opposite order, but maybe there's some reason for this.

The unit file is changed to use just 'aggety' instead of the full path,
and the leading whitespace is dropped. Both things should have no effect,
but make the resulting file nicer to read.

20 months agoAdd ability to create passwordless root account (#2093)
Nils K [Mon, 27 Nov 2023 22:14:28 +0000 (23:14 +0100)] 
Add ability to create passwordless root account (#2093)

To create a passwordless root account one may specify `hashed:` without passing
an actual hash.

20 months agoMerge pull request #2073 from behrmann/ttyama0
Zbigniew Jędrzejewski-Szmek [Mon, 27 Nov 2023 10:39:13 +0000 (11:39 +0100)] 
Merge pull request #2073 from behrmann/ttyama0

Ttyama0

20 months agokmod: normalise module names
Joerg Behrmann [Sun, 26 Nov 2023 13:14:32 +0000 (14:14 +0100)] 
kmod: normalise module names

The file names of modules use dashes, e.g.

    /usr/lib/modules/6.6.2-arch1-1/kernel/drivers/nvme/common/nvme-common.ko.zst

but the dependency names modinfo gives us use underscores, e.g.

    name=nvme_common

Fixes: #2092
20 months agoAdd Building RHEL and RHEL UBI images with mkosi to README
Joerg Behrmann [Sat, 25 Nov 2023 10:52:08 +0000 (11:52 +0100)] 
Add Building RHEL and RHEL UBI images with mkosi to README

20 months agoFixed capitalization of `SignExpectedPcr`
Michael Ferrari [Wed, 22 Nov 2023 12:47:12 +0000 (13:47 +0100)] 
Fixed capitalization of `SignExpectedPcr`

Fixes: #2086
21 months agoUpdate default of QemuMem in mkosi.md
Nils K [Mon, 20 Nov 2023 01:27:36 +0000 (02:27 +0100)] 
Update default of QemuMem in mkosi.md

The default changed to 2G a while ago though the docs still referred to the old value of 1G.

21 months agokmod: remove doubled root prefix
Joerg Behrmann [Sat, 18 Nov 2023 12:35:19 +0000 (13:35 +0100)] 
kmod: remove doubled root prefix

21 months agoci: enable jammy-proposed-updates to get new libsolv
Luca Boccassi [Sat, 18 Nov 2023 18:15:44 +0000 (18:15 +0000)] 
ci: enable jammy-proposed-updates to get new libsolv

rawhide and tumbleweed now compress repodata with zstd which cannot be
handled by libsolv in jammy. Enable jammy-proposed to get new version
with the fix.

This reverts commit 4cec733f9186edec10904c30b4afd3d1c8857d9d.

21 months agofix ruff lint warnings 2073/head
Joerg Behrmann [Thu, 16 Nov 2023 09:43:42 +0000 (10:43 +0100)] 
fix ruff lint warnings

21 months agoMerge pull request #2074 from behrmann/zstdrename
Zbigniew Jędrzejewski-Szmek [Fri, 17 Nov 2023 15:26:22 +0000 (16:26 +0100)] 
Merge pull request #2074 from behrmann/zstdrename

Rename Compression.zst to Compression.zstd

21 months agoautologin: add dropin for ttyAMA0 on arm64
Joerg Behrmann [Thu, 16 Nov 2023 09:38:53 +0000 (10:38 +0100)] 
autologin: add dropin for ttyAMA0 on arm64

ARM64 hardware uses the PL011 driver, which exposes serial terminals as
ttyAMA0.

Fixes: #2068
21 months agoconfig: also default config_default_compression for OutputFormat.tar 2074/head
Joerg Behrmann [Thu, 16 Nov 2023 10:40:48 +0000 (11:40 +0100)] 
config: also default config_default_compression for OutputFormat.tar

The man page suggests this to be the case

21 months agoman: update section on CompressOutput
Joerg Behrmann [Thu, 16 Nov 2023 10:40:37 +0000 (11:40 +0100)] 
man: update section on CompressOutput

21 months agoRename Compression.zst to Compression.zstd
Joerg Behrmann [Thu, 16 Nov 2023 10:22:20 +0000 (11:22 +0100)] 
Rename Compression.zst to Compression.zstd

But also leave a fallback Compression.zst with value "zstd" as a fallback in
case anybody used that. To test this we also change the construction of
Compression instances in test_config.py to use __get_item__ instead of __new__,
since that actually supports construction via the value and is also the one
actually used in config.py

Fixes: #2072
21 months agoMore post-release news
Joerg Behrmann [Wed, 15 Nov 2023 15:04:59 +0000 (16:04 +0100)] 
More post-release news

21 months agoPost-release NEWS updates
Joerg Behrmann [Wed, 15 Nov 2023 11:23:36 +0000 (12:23 +0100)] 
Post-release NEWS updates

This moves a few things further up to make them more prominent, like the
renaming of presets and the addition of profiles and also adds a the new esp
output format and a note about resolv.conf now needing WithNetwork=true to be
mapped during script runtime.

21 months agoRelease 19 2069/head v19
Zbigniew Jędrzejewski-Szmek [Wed, 15 Nov 2023 10:15:52 +0000 (11:15 +0100)] 
Release 19

21 months agoNEWS: mention "burn"
Zbigniew Jędrzejewski-Szmek [Wed, 15 Nov 2023 10:11:15 +0000 (11:11 +0100)] 
NEWS: mention "burn"

21 months agoNEWS: add periods to sentences, order by subject
Zbigniew Jędrzejewski-Szmek [Wed, 15 Nov 2023 10:04:46 +0000 (11:04 +0100)] 
NEWS: add periods to sentences, order by subject

This is always a bit subjective, but I find a NEWS file much easier to read if
it's thematically organized. I think support for a new distro is important, so
put that first, then new verbs and options, then new configuration features,
and then all the other smaller changes.

21 months agomkosi: add "burn" verb 🔥🔥🔥
Lennart Poettering [Fri, 10 Nov 2023 09:00:19 +0000 (10:00 +0100)] 
mkosi: add "burn" verb 🔥🔥🔥

This simply dd's the resulting image to a block device. (Doesn't
actually dd though, uses systemd-repart --copy-from)

i.e. run "mkosi -f burn /dev/sda"

21 months agoDrop compression suffix for directory output
Zbigniew Jędrzejewski-Szmek [Fri, 10 Nov 2023 12:18:05 +0000 (13:18 +0100)] 
Drop compression suffix for directory output

The automatic logic would produce a name like "initrd_6.6.0.zst", even though
there is no compression.

21 months agoOnly mount over /etc/resolv.conf if network access is enabled
Daan De Meyer [Fri, 10 Nov 2023 10:28:00 +0000 (11:28 +0100)] 
Only mount over /etc/resolv.conf if network access is enabled

This allows users to mess with /etc/resolv.conf in postinst scripts
without having to unmount it first.

21 months agoDebug log when firmware is missing
Daan De Meyer [Fri, 10 Nov 2023 11:47:09 +0000 (12:47 +0100)] 
Debug log when firmware is missing

Sometimes missing firmware can cause issues in the initrd so let's
at least debug log if we can't find some firmware.

21 months agoMerge pull request #2060 from DaanDeMeyer/esp-size
Jörg Behrmann [Thu, 9 Nov 2023 21:03:09 +0000 (22:03 +0100)] 
Merge pull request #2060 from DaanDeMeyer/esp-size

Set ESP output minimum size based on sector size

21 months agoSet ESP output minimum size based on sector size 2060/head
Daan De Meyer [Thu, 9 Nov 2023 18:30:39 +0000 (19:30 +0100)] 
Set ESP output minimum size based on sector size

Based on the sector size, a minimum size is required for FAT32 to
be bootable by OVMF. Instead of wasting space by always using 512MB,
let's set the minimum size based on the given sector size.

21 months agoAdd proper parser for sector size
Daan De Meyer [Thu, 9 Nov 2023 18:30:14 +0000 (19:30 +0100)] 
Add proper parser for sector size

21 months agoisort test_json.py
Daan De Meyer [Thu, 9 Nov 2023 18:36:07 +0000 (19:36 +0100)] 
isort test_json.py

21 months agoMerge pull request #2057 from DaanDeMeyer/esp
Daan De Meyer [Thu, 9 Nov 2023 16:01:40 +0000 (17:01 +0100)] 
Merge pull request #2057 from DaanDeMeyer/esp

Add esp output format

21 months agoAdd esp output format 2057/head
Daan De Meyer [Thu, 9 Nov 2023 11:05:36 +0000 (12:05 +0100)] 
Add esp output format

This is largely the same as the uki output format, but additionally
we wrap the uki in a disk image with just an ESP.

21 months agoAdd extension() method to OutputFormat
Daan De Meyer [Thu, 9 Nov 2023 11:52:16 +0000 (12:52 +0100)] 
Add extension() method to OutputFormat

21 months agoUse one more dict comprehension
Daan De Meyer [Thu, 9 Nov 2023 11:50:05 +0000 (12:50 +0100)] 
Use one more dict comprehension

21 months agoMove unified kernel status message into build_uki()
Daan De Meyer [Thu, 9 Nov 2023 10:58:04 +0000 (11:58 +0100)] 
Move unified kernel status message into build_uki()

This makes sure we get a status message when building uki outputs
as well.

21 months agoFix want_uki()
Daan De Meyer [Thu, 9 Nov 2023 10:31:46 +0000 (11:31 +0100)] 
Fix want_uki()

If we're building a UKI image, we always want a UKI regardless of
the other options.

21 months agoUse INVOKING_USER.home to find home in the workspace logic
Joerg Behrmann [Thu, 9 Nov 2023 13:58:51 +0000 (14:58 +0100)] 
Use INVOKING_USER.home to find home in the workspace logic

21 months agoMake default workspace directory logic more robust
Daan De Meyer [Thu, 9 Nov 2023 13:26:35 +0000 (14:26 +0100)] 
Make default workspace directory logic more robust

When running with sudo, $HOME won't be set, so let's rework the
logic to not rely on that.

21 months agodon't fail on non-controlling ttys
Paul Meyer [Tue, 7 Nov 2023 20:03:20 +0000 (21:03 +0100)] 
don't fail on non-controlling ttys

21 months agoAdd kernel-install plugin from mkosi-initrd
Daan De Meyer [Sun, 5 Nov 2023 13:00:59 +0000 (14:00 +0100)] 
Add kernel-install plugin from mkosi-initrd

Let's support kernel-install natively in mkosi. This commit moves
the kernel-install plugin from mkosi-initrd into mkosi itself with
a few adaptations:

- We look for initrd configuration in /usr/lib/mkosi-initrd and
  /etc/mkosi-initrd using "--include"
- We always include the host's kernel modules using --extra-tree
- We skip the mkosi-initrd plugin unless initrd_generator is
  explicitly set to "mkosi-initrd". This allows the mkosi package
  to be installed without also using it as the initrd generator if
  initrd_generator is not configured explicitly.

This commit also extends the default fedora image to build the mkosi
rpm if the spec sources are mounted at rpm/ using BuildSources=. We
also configure the default image to use mkosi-initrd as the initrd
generator and ukify as the uki generator, so that running kernel-install
in the booted image will build a UKI using mkosi-initrd and ukify.

21 months agoAdd missing raise
Daan De Meyer [Wed, 8 Nov 2023 14:18:31 +0000 (15:18 +0100)] 
Add missing raise

21 months agobuilding rpms from source doc improvements
Daan De Meyer [Wed, 8 Nov 2023 12:37:33 +0000 (13:37 +0100)] 
building rpms from source doc improvements

- Use env --chdir= instead of spawning a shell
- Document that scripts are executed in the same directory that
  mkosi is running in and get rid of all uses of $SRCDIR and
  $CHROOT_SRCDIR in favor of relative paths. We have to use $PWD
  when actually building the rpm as some macros expect the topdir
  to be an absolute path.

21 months agoFix LocalMirror= for Fedora
Daan De Meyer [Wed, 8 Nov 2023 12:12:24 +0000 (13:12 +0100)] 
Fix LocalMirror= for Fedora

21 months agoUse package manager specific subdirectories in the cache directory
Daan De Meyer [Wed, 8 Nov 2023 11:29:39 +0000 (12:29 +0100)] 
Use package manager specific subdirectories in the cache directory

We want to be able to set --cache-dir=/var/cache to automatically
reuse the system cache for each installed package manager, so let's
make sure we use the right subdirectories for each package manager
to make that work properly.

21 months agoAdd QemuDrives= option
Daan De Meyer [Tue, 7 Nov 2023 21:10:47 +0000 (22:10 +0100)] 
Add QemuDrives= option

This option allows specifying extra qemu drives to pass to qemu.
mkosi will create a file (optionally in the given directory) of
the given size and pass it to qemu via -drive, optionally with some
extra options.

Doing this in mkosi allows mkosi to automatically manage the lifetime
of the file backing the drive. We can create it as needed and remove it
when we exit.

Example usage:

```conf
[Host]
QemuDrives=btrfs:10G
           ext4:20G
QemuArgs=-device nvme,serial=btrfs,drive=btrfs
         -device nvme,serial=ext4,drive=ext4
```

21 months agosummary: Fix copy pasta for KernelModulesInitrdExclude
Joakim Nohlgård [Mon, 6 Nov 2023 15:02:00 +0000 (16:02 +0100)] 
summary: Fix copy pasta for KernelModulesInitrdExclude

21 months agoAdd BuildSourcesEphemeral= to the rpms from source doc.
Daan De Meyer [Tue, 7 Nov 2023 08:43:13 +0000 (09:43 +0100)] 
Add BuildSourcesEphemeral= to the rpms from source doc.

rpmbuild with --build-in-place is a top offender when it comes to
writing files to the source directory, so let's suggest enabling
BuildSourcesEphemeral= in the building rpms from source doc.

21 months agoPass file descriptor to /dev/kvm to qemu on newer versions
Daan De Meyer [Sat, 21 Oct 2023 14:19:20 +0000 (16:19 +0200)] 
Pass file descriptor to /dev/kvm to qemu on newer versions

Newer versions of qemu support passing the kvm device to use as a
file descriptor. Let's make use of this if the qemu version is
recent enough.

At the same time, also do some general cleanup of the KVM logic.

21 months agoMerge pull request #2046 from DaanDeMeyer/ephemeral
Daan De Meyer [Tue, 7 Nov 2023 08:39:52 +0000 (09:39 +0100)] 
Merge pull request #2046 from DaanDeMeyer/ephemeral

Add BuildSourcesEphemeral=

21 months agoAdd BuildSourcesEphemeral= 2046/head
Daan De Meyer [Mon, 6 Nov 2023 20:35:09 +0000 (21:35 +0100)] 
Add BuildSourcesEphemeral=

Unfortunately there are use cases where it's useful to persist
changes to the source directory. A prime example is projects with
Makefile that do not provide a properly functioning `make install`.
The only way to use those with mkosi build scripts is to do an
in-tree build in the build script and then mounting the source
directory into the VM or container when booting it. For this to work
we need changes to the source directory to be persisted. To support
this use case, let's gate the ephemeral source directories behind an
option that's disabled by default (for backwards compatibitity reasons).

21 months agoDon't show the same "Generating disk image" message 3x times
Daan De Meyer [Tue, 7 Nov 2023 07:34:56 +0000 (08:34 +0100)] 
Don't show the same "Generating disk image" message 3x times

Let's show a custom message each time we call systemd-repart. Let's
also not call it a third time if split artifacts were not requested.

21 months agoStop logging about cleaning up overlayfs
Daan De Meyer [Tue, 7 Nov 2023 07:25:20 +0000 (08:25 +0100)] 
Stop logging about cleaning up overlayfs

These steps aren't exactly useful for users, so let's not log about
them.

21 months agoAdd --debug-workspace
Daan De Meyer [Mon, 6 Nov 2023 19:47:17 +0000 (20:47 +0100)] 
Add --debug-workspace

Fixes #2036

21 months agoFix KernelModulesInclude=
Daan De Meyer [Mon, 6 Nov 2023 19:54:31 +0000 (20:54 +0100)] 
Fix KernelModulesInclude=

We have to store the relative path, not the full path for the check
to work correctly.

21 months agoDocument that we automatically handle roothash= for verity partitions
Daan De Meyer [Mon, 6 Nov 2023 19:15:25 +0000 (20:15 +0100)] 
Document that we automatically handle roothash= for verity partitions

21 months agoUpdate NEWS
Daan De Meyer [Tue, 7 Nov 2023 07:47:25 +0000 (08:47 +0100)] 
Update NEWS

21 months agoMerge pull request #2041 from DaanDeMeyer/fixes
Jörg Behrmann [Mon, 6 Nov 2023 16:51:49 +0000 (17:51 +0100)] 
Merge pull request #2041 from DaanDeMeyer/fixes

Various fixes and improvements

21 months agoMake source directories ephemeral when running scripts 2041/head
Daan De Meyer [Mon, 6 Nov 2023 13:04:26 +0000 (14:04 +0100)] 
Make source directories ephemeral when running scripts

Various tools like to write to the source directory, which we want
to avoid. Let's make source directories ephemeral when running scripts
so tools can write to it as much as they want but we can throw away all
those changes when we're done running scripts.

Specifically, this makes running rpmbuild as documented in
docs/building-rpm-from-source.md a lot nicer as the source directory won't be
polluted with all manner of temporary files anymore.

21 months agoStop using workspace directories in source directories
Daan De Meyer [Mon, 6 Nov 2023 12:58:56 +0000 (13:58 +0100)] 
Stop using workspace directories in source directories

Preparation for making source directories volatile while running
scripts. Overlapping overlayfs directories cause massive mayhem so
to keep our sanity, let's make sure the workspace directory is never
a subdirectory of any source directories.

XDG doesn't provide an equivalent of /var/tmp but when running in /home
we really want the workspace to be located in /home as well so we can use
reflinks if /home is a separate partition so we opt to use XDG_CACHE_HOME
or $HOME/.cache instead.

21 months agoCreate volatile overlay if no upperdir is specified
Daan De Meyer [Mon, 6 Nov 2023 11:13:10 +0000 (12:13 +0100)] 
Create volatile overlay if no upperdir is specified

21 months agoUse same chroot scripts for all postinst/finalize scripts
Daan De Meyer [Mon, 6 Nov 2023 11:05:25 +0000 (12:05 +0100)] 
Use same chroot scripts for all postinst/finalize scripts

21 months agoMerge mount_volatile_overlay() into mount_build_overlay()
Daan De Meyer [Mon, 6 Nov 2023 10:29:34 +0000 (11:29 +0100)] 
Merge mount_volatile_overlay() into mount_build_overlay()

Let's reduce the number of mounts by merging the volatile build
overlay logic into the build overlay logic.

21 months agoFix mount_overlay() with multiple lowerdirs
Daan De Meyer [Mon, 6 Nov 2023 10:28:16 +0000 (11:28 +0100)] 
Fix mount_overlay() with multiple lowerdirs

Multiple lower directories are specified by delimiting with colons,
not by specifying the lowerdir= option multiple times. Also, the
lowerdirs are stacked right to left so make sure we reverse the given
list.

21 months agoFix RuntimeTrees=
Daan De Meyer [Mon, 6 Nov 2023 14:40:19 +0000 (15:40 +0100)] 
Fix RuntimeTrees=

We previously made the target path non-optional but this doesn't actually
work for RuntimeTrees=, where we need optional paths. So instead, let's
introduce ConfigTree to abstract the tree concept and have a class where
we can define methods on to make working with trees easier.

21 months agoAdd nano to default images
Daan De Meyer [Sun, 5 Nov 2023 12:55:46 +0000 (13:55 +0100)] 
Add nano to default images

21 months agoUse rpm to install rpms in building rpms from source doc
Daan De Meyer [Sun, 5 Nov 2023 12:15:50 +0000 (13:15 +0100)] 
Use rpm to install rpms in building rpms from source doc

Let's get rid of an unnecessary indirection and just use rpm directly
to install the rpms we built in the previous step as all the dependencies
will be installed already and as such we don't need dnf.

21 months agoUse right dnf5 options for plugin stuff
Daan De Meyer [Sun, 5 Nov 2023 12:14:47 +0000 (13:14 +0100)] 
Use right dnf5 options for plugin stuff

Let's use the non-compat dnf5 options for plugins.

21 months agoAdd rpm script to run rpm on the build root
Daan De Meyer [Sun, 5 Nov 2023 12:14:14 +0000 (13:14 +0100)] 
Add rpm script to run rpm on the build root

We provide a dnf script, so we should also provide an rpm script.

21 months agoVarious fixes for building-rpms-from-source.md
Daan De Meyer [Sun, 5 Nov 2023 11:13:51 +0000 (12:13 +0100)] 
Various fixes for building-rpms-from-source.md

- Fix quotes in rpms from source doc

These statements should not be surrounded by quotes as we don't want
them to expand to the empty string if unset.

- Use fewer subshells
- Don't use line continuations for pipes

21 months agoSkip symlink when prefixing everything in staging directory
Daan De Meyer [Fri, 3 Nov 2023 19:53:26 +0000 (20:53 +0100)] 
Skip symlink when prefixing everything in staging directory

The symlink shouldn't be prefixed so make sure we skip it.

21 months agoconfig: right strip newlines from contents read via path_read_text
Joerg Behrmann [Thu, 2 Nov 2023 21:19:49 +0000 (22:19 +0100)] 
config: right strip newlines from contents read via path_read_text

This so far only affects mkosi.version and mkosi.rootpw.

Fixes: 2031
21 months agoAdd journalctl and coredumpctl verbs
Sam Leonard [Mon, 30 Oct 2023 17:11:35 +0000 (17:11 +0000)] 
Add journalctl and coredumpctl verbs

21 months agoVarious followups for merged PRs
Daan De Meyer [Thu, 2 Nov 2023 11:01:03 +0000 (12:01 +0100)] 
Various followups for merged PRs

21 months agoRestore subdirectory use for $BUILDDIR
Zbigniew Jędrzejewski-Szmek [Mon, 30 Oct 2023 17:20:41 +0000 (18:20 +0100)] 
Restore subdirectory use for $BUILDDIR

Sharing of a directory for the (package) cache seems fine. The package manager
shall use subdirectories and/or unique file names, so there should be no
accidental conflict, and using the same cache directory allows the cache to be
reused when possible. OTOH, sharing of the directory for the build directory is
unlikely to be useful (since at least the configuration will usually be
different, so the build would generally mean rebuilding anything anyway), but
also the build system might not do cache invalidation strongly enough, leading
to inadvertetent sharing of build artifacts. Let's avoid the issue completely
but not sharing the build directory between different distributions releases or
architectures.

This partially reverts b17810b4b571d0acbb307a6f7cd5c6456a45e4d3.

21 months agoAdd doc on building rpms from source with mkosi
Daan De Meyer [Sat, 28 Oct 2023 17:18:00 +0000 (19:18 +0200)] 
Add doc on building rpms from source with mkosi

I use this all over the place so let's document it in one place so
I can easily find it when needed and so others can make use of it
as well.

21 months agoMerge pull request #2023 from keszybz/mkosi-chroot-no-args
Daan De Meyer [Thu, 2 Nov 2023 10:37:54 +0000 (11:37 +0100)] 
Merge pull request #2023 from keszybz/mkosi-chroot-no-args

mkosi-chroot: just run shell if no arguments are specified

21 months agoAllow overriding dnf selection with $MKOSI_DNF
Zbigniew Jędrzejewski-Szmek [Fri, 27 Oct 2023 12:09:45 +0000 (14:09 +0200)] 
Allow overriding dnf selection with $MKOSI_DNF

dnf5 is nice, but it has some issues, for example installation of rhel9
currently fails with some error about signature. Using dnf instead works around
the problem. Allow the user to override the selection using an environment
variable (or Environment=).

(We have the tools directory, but it doesn't help here because we want to use
'dnf' instead of 'dnf5' and not a different version of 'dnf5'.)

21 months agospawn: inherit parent $PATH by default
Malte Poll [Mon, 30 Oct 2023 14:24:54 +0000 (15:24 +0100)] 
spawn: inherit parent $PATH by default

Spawn should be able to find binaries in $PATH by default.

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
21 months agoFix incremental caching
Daan De Meyer [Wed, 1 Nov 2023 11:49:52 +0000 (12:49 +0100)] 
Fix incremental caching

- Make sure the distribution, release and architecture are also part
of the cache manifest
- Remove the output name from the cache key and use the distribution,
release, architecture and optionally image name instead.
- Use MkosiEncoder to serialize the cache manifest.

21 months agoqemu: allow checking device availability with actually used flags
Joerg Behrmann [Wed, 1 Nov 2023 14:16:14 +0000 (15:16 +0100)] 
qemu: allow checking device availability with actually used flags

Also use an actual os.open instead of os.access, because os.access might fail
with certain flags in cases where os.open will not.

This works around the case where kernel modules after an upgrade cannot be
loaded anymore because it is no longer available for the running kernel.

21 months agoAdd mkosi-as-caller helper 2023/head
Zbigniew Jędrzejewski-Szmek [Sun, 29 Oct 2023 17:22:45 +0000 (18:22 +0100)] 
Add mkosi-as-caller helper

This helper can be used to replace the following pattern which is similar to
something used in the systemd codebase:

SU="setpriv --reuid=${MKOSI_UID:-0} --regid=${MKOSI_GID:-0} --clear-groups"
$SU meson setup "$BUILDDIR/build" "$SRCDIR"
$SU meson compile -C "$BUILDDIR/build"
meson install -C "$BUILDDIR/build" --no-rebuild

With the helper this becomes:

mkosi-as-caller meson setup "$BUILDDIR/build" "$SRCDIR"
mkosi-as-caller meson compile -C "$BUILDDIR/build"
meson install -C "$BUILDDIR/build" --no-rebuild