]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
2 years agoAdd --verbose to kernel-install if --debug is specified 1347/head
Daan De Meyer [Tue, 14 Feb 2023 15:01:51 +0000 (16:01 +0100)] 
Add --verbose to kernel-install if --debug is specified

2 years agoFix need_cache_trees()
Daan De Meyer [Tue, 14 Feb 2023 14:31:30 +0000 (15:31 +0100)] 
Fix need_cache_trees()

2 years agoRelabel image when selinux policy is installed
Daan De Meyer [Tue, 14 Feb 2023 12:01:17 +0000 (13:01 +0100)] 
Relabel image when selinux policy is installed

If an selinux policy is installed in the image, let's relabel it
automatically.

2 years agoSimplify kernel image and initrd handling
Daan De Meyer [Thu, 9 Feb 2023 11:53:32 +0000 (12:53 +0100)] 
Simplify kernel image and initrd handling

- Let's stop writing files in /etc in favor of passing the
information via other ways
- Let's stop defaulting to "bls" layout which is intended
for type 1 images, we only use UKIs so we don't need the
"bls" layout
- kernel-install now defaults to the "other" layout, which
means it won't create the entry directory in /boot anymore.
We update the initrd find logic to take this into account
- Remove --machine-id as it was only really there for testing
the config parsing which we now deal with by not storing the
machine ID at all

2 years agoDrop TODO
Daan De Meyer [Fri, 10 Feb 2023 11:47:47 +0000 (12:47 +0100)] 
Drop TODO

We don't keep it up to date anyway, so let's drop it.

2 years agoSet timezone credential to current timezone by default
Daan De Meyer [Fri, 10 Feb 2023 09:40:03 +0000 (10:40 +0100)] 
Set timezone credential to current timezone by default

We don't configure a default timezone in the images, so let's set
a timezone credential by default to the current timezone to avoid
a prompt during first boot.

2 years agorun: Use is_symlink() instead of exists()
Daan De Meyer [Thu, 9 Feb 2023 21:51:23 +0000 (22:51 +0100)] 
run: Use is_symlink() instead of exists()

exists() will resolve the symlink in the host if it's absolute,
let's use is_symlink() which checks if the symlink exists.

2 years agocentos: Do not try to resolve symlink
Daan De Meyer [Thu, 9 Feb 2023 21:11:53 +0000 (22:11 +0100)] 
centos: Do not try to resolve symlink

We don't have chase_symlinks(), resolving the symlink actually
resolves it on the host instead of in the image. Instead, let's
just unconditionally remove the symlink.

2 years agocentos: Log when we remove the dangling symlink
Daan De Meyer [Thu, 9 Feb 2023 18:42:09 +0000 (19:42 +0100)] 
centos: Log when we remove the dangling symlink

2 years agoFix cache directory
Daan De Meyer [Thu, 9 Feb 2023 17:03:03 +0000 (18:03 +0100)] 
Fix cache directory

Make sure to use state.cache where applicable. Also get rid of
setup_package_cache() since it comes down to a one liner

2 years agocentos: Remove dangling syslog.service symlink
Daan De Meyer [Thu, 9 Feb 2023 16:47:20 +0000 (17:47 +0100)] 
centos: Remove dangling syslog.service symlink

Dangling symlinks trip up systemctl preset-all so let's remove this
one that's generated by the systemd spec in centos stream 8.

2 years agoUse shutil.move() to move /etc/resolv.conf symlink
Daan De Meyer [Thu, 9 Feb 2023 16:16:47 +0000 (17:16 +0100)] 
Use shutil.move() to move /etc/resolv.conf symlink

2 years agoMerge pull request #1334 from DaanDeMeyer/fix-network
Daan De Meyer [Thu, 9 Feb 2023 14:17:10 +0000 (15:17 +0100)] 
Merge pull request #1334 from DaanDeMeyer/fix-network

Fix bind mounting resolv.conf when it's a symlink

2 years agoDrop --include-directory
Daan De Meyer [Thu, 9 Feb 2023 09:01:07 +0000 (10:01 +0100)] 
Drop --include-directory

Let's get rid of one more source of mounts. --include-dir can be replaced
by using --incremental and reading includes from the cached build image
tree. In the future, once build images become regular images, users can
read includes by simply using --directory output and reading includes
from the regular image output tree.

2 years agoFix bind mounting resolv.conf when it's a symlink 1334/head
Daan De Meyer [Thu, 9 Feb 2023 14:03:36 +0000 (15:03 +0100)] 
Fix bind mounting resolv.conf when it's a symlink

bwrap doesn't support mounting over symlinks, so let's take that
into account.

2 years agoFix path expansion
Daan De Meyer [Thu, 9 Feb 2023 14:03:23 +0000 (15:03 +0100)] 
Fix path expansion

2 years agoEnable unprivileged image builds
Daan De Meyer [Sun, 22 Jan 2023 17:29:49 +0000 (18:29 +0100)] 
Enable unprivileged image builds

To enable this, when doing a build, we unshare a user namespace
with it's own private set of uids/gids obtained using newuidmap
and newgidmap. We also map the current user to the last UID/GID
in the UID/GID range from /etc/subuid and /etc/subgid. Together
with unsharing the mount namespace, this allows us to do
unprivileged bind and overlay mounts.

Next, we replace all usages of systemd-nspawn during the image build
with bubblewrap. systemd-nspawn cannot run as an unprivileged user
yet so we use bubblewrap which can. bubblewrap can also be used to
setup a chroot environment with API VFS filesystems so we make use
of that to setup chroot environments and remove all our homegrown
logic for it. This allows us to significantly reduce the amount of
mounts we do in mkosi itself.

To further reduce the amount of mounts, we modify the invocations
of all package managers to specify the cache directory via the
relevant option instead of mounting the cache directory into the
chroot. For apt, to accomplish this, we switch from using
DPkg::Chroot-Directory to setting the "--root" option for each
invocation of dpkg so that dpkg can access files outside of the
chroot.

Finally, we remove some options which become obsolete with this
commit, --idmap, --chown and --nspawn-keep-unit.

We also remove --source-file-transfer, --source-file-transfer-final
and the corresponding symlink options. Instead, we default to mounting
source files into the build tree. In the future, we'll add virtiofsd
support to allow accessing source files in qemu VMs.

We also move stuff around and create a few new files to store
helpers to avoid circular imports. There's also a little bit of
refactoring and cleanup all around.

2 years agoRun preset-all on the final image
Daan De Meyer [Tue, 7 Feb 2023 13:45:02 +0000 (14:45 +0100)] 
Run preset-all on the final image

Let's run preset-all on the finalized image so that read-only
images (e.g. initrds) have the preset settings configured in the
image itself at creation time.

2 years agoFix --checksum true
Manuel Mausz [Thu, 2 Feb 2023 12:40:56 +0000 (12:40 +0000)] 
Fix --checksum true

File should be opened for reading

2 years agoMerge pull request #1328 from DaanDeMeyer/stuff
Daan De Meyer [Wed, 1 Feb 2023 10:32:41 +0000 (11:32 +0100)] 
Merge pull request #1328 from DaanDeMeyer/stuff

stuff

2 years agoDrop --all and --all-directory 1328/head
Daan De Meyer [Tue, 31 Jan 2023 18:56:57 +0000 (19:56 +0100)] 
Drop --all and --all-directory

Job control should be delegated to a build system so let's drop this
from mkosi.

2 years agotests: Drop config parser tests
Daan De Meyer [Tue, 31 Jan 2023 18:56:18 +0000 (19:56 +0100)] 
tests: Drop config parser tests

These have never caught anything useful and are understood by nobody,
let's just drop them.

2 years agoRemove btrfs subvolume deletion logic
Daan De Meyer [Tue, 31 Jan 2023 18:37:28 +0000 (19:37 +0100)] 
Remove btrfs subvolume deletion logic

Deleting btrfs subvolumes requires root. Given that we'll be moving
to primarily unprivileged execution soon, let's drop the logic for
deleting btrfs subvolumes. They're still deleted if the corresponding
directory is removed, it's just slightly slower.

2 years agoRemove leftover references to old output formats
Daan De Meyer [Tue, 31 Jan 2023 18:24:39 +0000 (19:24 +0100)] 
Remove leftover references to old output formats

2 years agoCreate secure boot auto enrollment files
Jan Janssen [Tue, 31 Jan 2023 17:08:21 +0000 (18:08 +0100)] 
Create secure boot auto enrollment files

2 years agoqemu: Always use usermode networking
Daan De Meyer [Mon, 30 Jan 2023 15:34:04 +0000 (16:34 +0100)] 
qemu: Always use usermode networking

With the upcoming support for unprivileged image builds, we can't
use getuid() to check for root anymore as we might be in a user
namespace. Instead of trying to fix the detection, let's just
always use usermode networking when running in qemu.

2 years agocentos: Install epel-release in both build and final images
Daan De Meyer [Sun, 29 Jan 2023 14:29:40 +0000 (15:29 +0100)] 
centos: Install epel-release in both build and final images

This allows mkosi.prepare scripts to install extra dependencies
from epel as well.

2 years agocentos: Refactor epel handling
Daan De Meyer [Fri, 27 Jan 2023 11:39:37 +0000 (12:39 +0100)] 
centos: Refactor epel handling

- Use URLs from CentOS itself and metalinks everywhere.
- Add epel-testing, disabled by default
- Move everything into a common function

2 years agoRework roothash handling
Daan De Meyer [Fri, 27 Jan 2023 10:22:02 +0000 (11:22 +0100)] 
Rework roothash handling

First, we clean up the leftover remnants of our qemu direct linux
boot support from install_unified_kernel(). Then we simplify passing
around data from invoke_repart() to install_unified_kernel() by only
passing around a single argument, the roothash/usrhash argument.
Finally, now that repart has "roothash" set on every verity sibling
partition, we can just read "roothash" off of any of them. We also
change the logic so that if we find a roothash, it always has
precedence over a usrhash.

2 years agoNever export bytecode
Daan De Meyer [Fri, 27 Jan 2023 09:17:21 +0000 (10:17 +0100)] 
Never export bytecode

2 years agotighten types on functions that have no or very few str callers
Joerg Behrmann [Wed, 25 Jan 2023 16:08:51 +0000 (17:08 +0100)] 
tighten types on functions that have no or very few str callers

2 years agoRework copying
Daan De Meyer [Wed, 25 Jan 2023 14:21:19 +0000 (15:21 +0100)] 
Rework copying

Let's just delegate to `cp` and get rid of a ton of cruft and speed
things up at the same time.

2 years agocentos: Use ext4 as the default filesystem instead of xfs
Daan De Meyer [Tue, 24 Jan 2023 11:04:51 +0000 (12:04 +0100)] 
centos: Use ext4 as the default filesystem instead of xfs

2 years agoRemove leftover reference to "RepositoryDirectory"
Daan De Meyer [Tue, 24 Jan 2023 10:57:41 +0000 (11:57 +0100)] 
Remove leftover reference to "RepositoryDirectory"

2 years agoUse plural Credentials= in config files
Daan De Meyer [Tue, 24 Jan 2023 10:56:58 +0000 (11:56 +0100)] 
Use plural Credentials= in config files

2 years agoMake sure args_find_path() works with as_list
Daan De Meyer [Tue, 24 Jan 2023 10:55:07 +0000 (11:55 +0100)] 
Make sure args_find_path() works with as_list

The default when using list arguments is [], so let's modify the
check to account for this.

2 years agoAdd missing check=False
Daan De Meyer [Mon, 23 Jan 2023 14:10:09 +0000 (15:10 +0100)] 
Add missing check=False

2 years agoRemove default kernel command line arguments
Daan De Meyer [Fri, 20 Jan 2023 09:15:56 +0000 (10:15 +0100)] 
Remove default kernel command line arguments

The defaults are rather intrusive so let's not enable them by default
but leave them for users to configure manually.

2 years agocentos: Default to glibc-minimal-langpack on CentOS Stream 8
Daan De Meyer [Thu, 19 Jan 2023 14:29:57 +0000 (15:29 +0100)] 
centos: Default to glibc-minimal-langpack on CentOS Stream 8

2 years agocentos: Remove "-stream" from releases
Daan De Meyer [Tue, 17 Jan 2023 19:41:35 +0000 (20:41 +0100)] 
centos: Remove "-stream" from releases

We don't support non centos stream releases anymore, so let's remove
the "-stream" suffix from centos releases.

2 years agoMerge pull request #1309 from DaanDeMeyer/extras
Daan De Meyer [Tue, 17 Jan 2023 13:58:54 +0000 (14:58 +0100)] 
Merge pull request #1309 from DaanDeMeyer/extras

centos: Add extras repo on centos stream 9

2 years agoAdd check_config_file=False to all dnf repo definitions 1309/head
Daan De Meyer [Tue, 17 Jan 2023 12:48:36 +0000 (13:48 +0100)] 
Add check_config_file=False to all dnf repo definitions

By default, dnf will always refresh repository metadata if the timestamp
of the config file has changed. Since we always rewrite the config file,
this will always be the case, so let's make sure we don't refresh the
metadata every time.

2 years agocentos: Add extras repo on centos stream 9
Daan De Meyer [Tue, 17 Jan 2023 12:23:52 +0000 (13:23 +0100)] 
centos: Add extras repo on centos stream 9

We already add the extras repository on centos stream 8, let's do
the same on centos stream 9.

2 years agoMerge pull request #1308 from DaanDeMeyer/centos-modern
Daan De Meyer [Mon, 16 Jan 2023 15:39:19 +0000 (16:39 +0100)] 
Merge pull request #1308 from DaanDeMeyer/centos-modern

Centos fixes

2 years agocentos: Modernize repo URLs 1308/head
Daan De Meyer [Mon, 16 Jan 2023 12:45:55 +0000 (13:45 +0100)] 
centos: Modernize repo URLs

Let's use DNF variables where we can. We also modify releasever to
be only the release version without "-stream" and use $stream when
we need the releasever with "-stream". This matches the upstream
usages of these variables.

2 years agocentos: Use lowercase repo identifiers everywhere
Daan De Meyer [Mon, 16 Jan 2023 12:23:33 +0000 (13:23 +0100)] 
centos: Use lowercase repo identifiers everywhere

2 years agoFix man page to mention apt requirement on host
Daan De Meyer [Mon, 16 Jan 2023 09:38:11 +0000 (10:38 +0100)] 
Fix man page to mention apt requirement on host

2 years agoMerge pull request #1302 from DaanDeMeyer/repart-format
Daan De Meyer [Sun, 15 Jan 2023 19:23:48 +0000 (20:23 +0100)] 
Merge pull request #1302 from DaanDeMeyer/repart-format

Default to the distro preferred filesystem instead of ext4

2 years agoMerge pull request #1305 from DaanDeMeyer/stuff
Daan De Meyer [Fri, 13 Jan 2023 16:13:15 +0000 (17:13 +0100)] 
Merge pull request #1305 from DaanDeMeyer/stuff

Assorted changes

2 years agocentos: Install epel-release if EPEL repository is configured 1305/head
Daan De Meyer [Fri, 13 Jan 2023 15:01:03 +0000 (16:01 +0100)] 
centos: Install epel-release if EPEL repository is configured

2 years agocentos: Remove duplicate code
Daan De Meyer [Fri, 13 Jan 2023 15:00:37 +0000 (16:00 +0100)] 
centos: Remove duplicate code

2 years agocentos: Move epel selection to --repositories option
Daan De Meyer [Fri, 13 Jan 2023 12:15:08 +0000 (13:15 +0100)] 
centos: Move epel selection to --repositories option

Instead of having different distros for epel, let's just enable it
via the --repositories option.

2 years agoStreamline --repositories
Daan De Meyer [Fri, 13 Jan 2023 13:58:29 +0000 (14:58 +0100)] 
Streamline --repositories

2 years agoMake --repository-directory take multiple arguments
Daan De Meyer [Fri, 13 Jan 2023 12:53:21 +0000 (13:53 +0100)] 
Make --repository-directory take multiple arguments

2 years agoRemove --use-host-repositories
Daan De Meyer [Fri, 13 Jan 2023 12:06:45 +0000 (13:06 +0100)] 
Remove --use-host-repositories

This option is superseded by --repository-directory which can be
used for exactly the same purpose so let's remove this very specific
option in favor of using --repository-directory.

2 years agoMerge pull request #1281 from behrmann/python39
Daan De Meyer [Fri, 13 Jan 2023 15:19:02 +0000 (16:19 +0100)] 
Merge pull request #1281 from behrmann/python39

Bump Python to 3.9

2 years agoactions: bump checkout to v3 to remove spuriours node.js version warnings 1281/head
Joerg Behrmann [Fri, 13 Jan 2023 12:26:46 +0000 (13:26 +0100)] 
actions: bump checkout to v3 to remove spuriours node.js version warnings

2 years agogentoo: fix unsupported escape sequence in regex
Joerg Behrmann [Fri, 13 Jan 2023 09:07:31 +0000 (10:07 +0100)] 
gentoo: fix unsupported escape sequence in regex

2 years agoUpdate typing to use generics for standard container classes
Joerg Behrmann [Fri, 13 Jan 2023 09:20:45 +0000 (10:20 +0100)] 
Update typing to use generics for standard container classes

Also use the non-deprecated typing imports

2 years agoRemove casts that are no longer necessary with Python 3.9
Joerg Behrmann [Fri, 13 Jan 2023 09:07:07 +0000 (10:07 +0100)] 
Remove casts that are no longer necessary with Python 3.9

2 years agoUpdate pathlib call sites to use Python 3.9 features
Joerg Behrmann [Tue, 29 Nov 2022 13:17:59 +0000 (14:17 +0100)] 
Update pathlib call sites to use Python 3.9 features

These are:
- the unlink method gained the parameter missing_ok=
- Path objects now have a readlink method

2 years agoUse the walrus operator were applicable
Joerg Behrmann [Fri, 13 Jan 2023 09:01:25 +0000 (10:01 +0100)] 
Use the walrus operator were applicable

2 years agoUse removeprefix and removesuffix were applicable
Joerg Behrmann [Tue, 29 Nov 2022 12:54:18 +0000 (13:54 +0100)] 
Use removeprefix and removesuffix were applicable

2 years agoDrop subprocess workaround for pre python 3.9
Joerg Behrmann [Thu, 1 Sep 2022 14:41:10 +0000 (16:41 +0200)] 
Drop subprocess workaround for pre python 3.9

2 years agoBump python version in config files
Joerg Behrmann [Thu, 1 Sep 2022 14:40:41 +0000 (16:40 +0200)] 
Bump python version in config files

2 years agoMerge pull request #1304 from DaanDeMeyer/fix-rpmdb
Jörg Behrmann [Thu, 12 Jan 2023 15:04:11 +0000 (16:04 +0100)] 
Merge pull request #1304 from DaanDeMeyer/fix-rpmdb

Fix rpmdb

2 years agoci: Add opensuse 1302/head
Daan De Meyer [Thu, 12 Jan 2023 11:27:29 +0000 (12:27 +0100)] 
ci: Add opensuse

We run opensuse CI in systemd so we should do the same in mkosi.

2 years agoopensuse: Disable dracut hostonly via dropin
Daan De Meyer [Thu, 12 Jan 2023 11:55:21 +0000 (12:55 +0100)] 
opensuse: Disable dracut hostonly via dropin

Unlike the centos variants, opensuse does not have a
dracut-config-generic package to disable hostonly mode, so we do
it via a dropin instead.

2 years agoremove if check that's always true
Daan De Meyer [Thu, 12 Jan 2023 11:40:15 +0000 (12:40 +0100)] 
remove if check that's always true

2 years agoDefault to the distro preferred filesystem instead of ext4
Daan De Meyer [Tue, 10 Jan 2023 14:43:15 +0000 (15:43 +0100)] 
Default to the distro preferred filesystem instead of ext4

Note that we don't default to btrfs due to an issue where mounting
COW copies of the same filesystem more than once fails with EBUSY.
Until that is fixed, btrfs is pretty much unusable for building
images as systemd-repart will fail to build btrfs images.

2 years agofedora: Remove keys for EOL releases 1304/head
Daan De Meyer [Thu, 12 Jan 2023 13:48:21 +0000 (14:48 +0100)] 
fedora: Remove keys for EOL releases

2 years agocentos: Fix rpmdb location
Daan De Meyer [Thu, 12 Jan 2023 13:47:06 +0000 (14:47 +0100)] 
centos: Fix rpmdb location

The previous logic was not working correctly. Let's simplify the
logic by only executing it for centos and only working in one
direction, if the rpmdb is written to /usr/lib/sysimage/rpm, let's
move it back to /var/lib/rpm on CentOS.

2 years ago[gentoo] merge usrmerge
Paymon MARANDI [Mon, 5 Sep 2022 21:39:04 +0000 (17:39 -0400)] 
[gentoo] merge usrmerge

upstream finally has merged-usr profiles/stage3s [1].
this makes `no-multilib/systemd/merged-usr`, and related stage3, default
for us.

[1] https://bugs.gentoo.org/843818#c2

Signed-off-by: Paymon MARANDI <darwinskernel@gmail.com>
2 years agocentos: Stop installing systemd-boot on CentOS Stream 9
Daan De Meyer [Tue, 10 Jan 2023 14:58:03 +0000 (15:58 +0100)] 
centos: Stop installing systemd-boot on CentOS Stream 9

With CentOS Stream 9 moving to systemd v252, systemd-boot has been
added back to the systemd-udev package, so we don't need to install
it from EPEL anymore.

2 years agoRemove --qemu-boot option
Daan De Meyer [Tue, 10 Jan 2023 14:33:45 +0000 (15:33 +0100)] 
Remove --qemu-boot option

Given that we're standardizing more and more on UEFI and unified
kernel images, let's drop support for qemu direct linux boot, to
drop yet another seldomly exercised codepath.

2 years agoRemove annotations import from __future__
Joerg Behrmann [Wed, 11 Jan 2023 09:32:33 +0000 (10:32 +0100)] 
Remove annotations import from __future__

PEP 563 is a PEP that stringifies type annotations. The feature was made
available as opt in. It is still very much in flux or under consideration
upstream and has fallen so much out of favour that the Python steering council
added the note [1]

    PEP 563 Postponed Evaluation of Annotations (the from __future__ import
    annotations future statement) that was originally planned for release in
    Python 3.10 has been put on hold indefinitely. See this message from the
    Steering Council for more information.

in the release notes of CPython 3.11 after punting on accepting the PEP for two
releases. The import does a lot more, but we only use the type
stringification. There is little gain from using this, but with one of the main
features of the import indefinitely on hold, it seems prudent not to use it.

With Python 3.11 the PEP 673 Self type was introduced [2], that will solve this
problem for us, once we move on to 3.11.

[1] https://docs.python.org/3.11/whatsnew/3.11.html#pep-563-may-not-be-the-future
[2] https://docs.python.org/3.11/whatsnew/3.11.html#whatsnew311-pep673

2 years agoAdd __init__.py to resources/repart
Daan De Meyer [Tue, 10 Jan 2023 11:49:43 +0000 (12:49 +0100)] 
Add __init__.py to resources/repart

This makes sure the repart/ directory in resources is included as
well.

2 years agoAdd --credential option to set systemd credentials
Daan De Meyer [Mon, 9 Jan 2023 15:40:56 +0000 (16:40 +0100)] 
Add --credential option to set systemd credentials

2 years agoidmap: fix kernel version comparison
Quentin Deslandes [Thu, 5 Jan 2023 17:39:31 +0000 (18:39 +0100)] 
idmap: fix kernel version comparison

packaging.version.parse() would create a Version object for "5.12" and a
LegacyVersion object for versions like "6.0.8-200.fc36.x86_64". This
leads to failed comparison (such as "6.0.8-200.fc36.x86_64 >= 5.12").

Use `systemd-analyze compare-versions` instead, which produce the
expected behaviour. This brings mkosi more in line with systemd
ecosystem when it comes to version strings parsing.

2 years agoMigrate to ukify
Daan De Meyer [Wed, 21 Dec 2022 15:04:02 +0000 (16:04 +0100)] 
Migrate to ukify

Let's start using ukify to generate unified kernel images instead
of implementing the logic ourselves. This also fixes issues with
overlapping PE sections.

2 years agofix invalid cross-device link
Benedict Schlueter [Fri, 23 Dec 2022 15:41:50 +0000 (16:41 +0100)] 
fix invalid cross-device link

when the workspace directory is on another filesystem (i.e. /tmp) mkosi
fails.
replace os.rename with shutil.move when we may cross filesystem
boundaries. Furthermore, chown the resulting files if the flag is set
accordingly.

2 years agofix "qemu-img convert" error
Benedict Schlueter [Fri, 23 Dec 2022 11:47:16 +0000 (12:47 +0100)] 
fix "qemu-img convert" error

the same path was used as in and output for qemu-img, this results in an
error. Use another path as output and rename the output afterward.

2 years agoMerge pull request #1276 from DaanDeMeyer/repart
Daan De Meyer [Wed, 21 Dec 2022 13:44:51 +0000 (14:44 +0100)] 
Merge pull request #1276 from DaanDeMeyer/repart

Migrate disk image building to systemd-repart

2 years agoMigrate disk image building to systemd-repart 1276/head
Daan De Meyer [Mon, 28 Nov 2022 14:45:31 +0000 (15:45 +0100)] 
Migrate disk image building to systemd-repart

Let's switch to systemd-repart to build disk images. systemd-repart
allows building disk images declaratively. repart will assemble a
disk image according to a set of partition definition files, which
it will search for in a set of predefined locations or in the locations
provided via the --definitions option. Partition definition files are
defined in the usual systemd ini style and define a single partition
each. Many aspects of the partition can be configured, including its
size, type, and how it should be populated.

Of note should be the CopyFiles= setting that allows providing a set
of files/directories from which the partition should be populated. The
CopyFiles= setting takes a list of path pairs, where the first path in
a pair defines the source location, and the second path the destination
location in the partition. If combined with repart's --root or --image
options, the source path is resolved relative to the given root directory.

Along with switching to systemd-repart, we also rework how we build
images. Previously, we first provisioned the disk image with all its
partitions, then mounted the disk image and finally populated it with
contents. Now, we provision to a regular directory on the host filesystem
first, followed by creating the disk image with systemd-repart. The partition
definition files can be supplied via the --repart-directory option or
in the mkosi.repart/ directory. If not provided, a default configuration
consisting of an automatically sized root partition and an ESP partition of
256M is used.

repart's --root switch is used so that the partition definition files
don't need to encode the full path to the root directory of the image
we're building. For example, to copy the root directory to a root
partition, it's sufficient to specify "CopyFiles=/:/" in the definition
file.

If we're building non-bootable images, any ESP partition definitions
are excluded. To allow building UKIs with an embedded roothash cmdline
parameter, we run repart twice, first to populate all partitions except
the ESP/XBOOTLDR partitions, and again to populate the ESP/XBOOTLDR
partitions including any UKIs with embedded roothash cmdline parameter
(which we determined when running repart the first time).

Because we don't know up-front anymore where the ESP partition will be
mounted, all boot loader files are installed to /boot. So to populate
an ESP partition, you'd use "CopyFiles=/boot:/" in the partition
definition file of the ESP partition.

Also, since we don't know up-front anymore which filesystem we'll be
building for, we stop installing filesystem related packages by default.
Users will be required to add the necessary filesystem packages themselves.
Similarly, we also stop installing cryptsetup and device-mapper by default
since we don't know upfront anymore whether partitions will be verity
protected or encrypted.

By switching to systemd-repart, we also set ourselves up for building
images without needing root privileges or loop devices. systemd-repart
is fully capable (from v253 onwards) of building disk images without
needing root privileges or loop devices. After we switch to
systemd-repart, we'll only need root privileges to be able to run
systemd-nspawn (which should not be necessary in the future anymore).

This PR also removes all the option related to disk image building that
can now be specified in repart definition files instead. This includes:

- Format=gpt_xxx options are replaced with a single "disk" options.
Filesystem can now be specified with repart's Format= option
- Format=plain_squashfs (Can be reproduced by a single repart squashfs
root partition combined with SplitArtifacts=yes)
- Verity= (Replaced by repart's Verity= options)
- Encrypt= (Replaced by repart's Encrypt= option)
- RootSize=, HomeSize=, VarSize=, TmpSize=, ESPSize=, SwapSize=, SrvSize=
(Replaced by repart's size options)
- UsrOnly= (replaced with `CopyFiles=/:/usr` in a usr partition definition)
- OutputSplitRoot=, OutputSplitVerity=, (Replaced by repart's SplitName= option)
- OutputSplitKernel= (UKI is now always written to its own output file)
- GPTFirstLBA (Removed, no equivalent in repart)
- ReadOnly= (Replaced by repart's ReadOnly= option per partition)
- Minimize= (Replaced by repart's Minimize= option per partition)
- CompressFs= (No equivalent in repart, can be replicated by replacing mkfs.<fs>
in $PATH with a script that adds the necessary command line option)
- MkSquashfs= (Can be replaced with a script in $PATH that invokes
the correct binary)

We also remove the WithoutUnifiedKernelImages= switch as building unified
kernel images is trivial and fast these days.

2 years agomypy: Fix version comparison
Daan De Meyer [Thu, 15 Dec 2022 14:54:34 +0000 (14:54 +0000)] 
mypy: Fix version comparison

2 years agoMake config.build_sources non-optional
Daan De Meyer [Tue, 13 Dec 2022 19:29:33 +0000 (19:29 +0000)] 
Make config.build_sources non-optional

It already was non-optional in practice, let's encode this in the
type.

2 years agoci: Rework integration tests
Daan De Meyer [Mon, 28 Nov 2022 14:42:13 +0000 (15:42 +0100)] 
ci: Rework integration tests

The current approach where we build the image as part of the integration
test is the wrong approach. Instead, we'll move to integration tests that
are integrated with a build system where building images and using them
in integration tests are separate steps. Building an image for use in an
integration test will be a regular target (custom_target()) in a build
system. Building an image that's not intended to be used in any other test
will be a regular test.

Because this model is going to be substantially different from what we have
now, let's get rid of the integration test machinery we added and temporarily
switch to the basic approach that's also used in the systemd repo for integration
tests.

2 years agoBump alma/rocky default release to "9"
Daan De Meyer [Fri, 25 Nov 2022 20:19:18 +0000 (21:19 +0100)] 
Bump alma/rocky default release to "9"

2 years agoDrop HostonlyInitrd
Daan De Meyer [Fri, 18 Nov 2022 10:07:27 +0000 (11:07 +0100)] 
Drop HostonlyInitrd

Adding this option was a mistake (mea culpa), we should limit host
impact on image builds as much as possible so let's drop this option
that makes the initrd generated by dracut host specific. This will
slow down initrd generation but once we switch to generating initrds
with mkosi we'll have a proper fix for that.

2 years agoAllow for UID mapping to be disabled
Quentin Deslandes [Wed, 16 Nov 2022 12:03:28 +0000 (13:03 +0100)] 
Allow for UID mapping to be disabled

By default, mkosi would bind mount directories with nspawn's rootidmap
option to provide consistent files ownership. If the system doesn't
support ID mapping, mkosi would fail.

Add --idmap option, default to True, to allow users to disabled UID
mapping (--idmap=no).

2 years agoRename --no-chown option to --chown
Quentin Deslandes [Wed, 16 Nov 2022 12:22:08 +0000 (13:22 +0100)] 
Rename --no-chown option to --chown

Rename --no-chown to --chown and defaults to true. This will make it
easier to reason on the code behaviour when this option is used.

2 years agoFix qemu tpm device name on aarch64
Daan De Meyer [Tue, 13 Dec 2022 12:51:48 +0000 (12:51 +0000)] 
Fix qemu tpm device name on aarch64

2 years agoidmap: also check for kernel version
Luca Boccassi [Mon, 12 Dec 2022 23:59:00 +0000 (23:59 +0000)] 
idmap: also check for kernel version

Not only nspawn 252 is required, but also kernel 5.12 for id-mapped mounts
to be available

2 years agoMerge pull request #1282 from wally-mageia/main
Daan De Meyer [Mon, 5 Dec 2022 08:12:24 +0000 (09:12 +0100)] 
Merge pull request #1282 from wally-mageia/main

Update Mageia DistributionInstaller

2 years agomageia: use release where applicable instead of state.config.release for consistency 1282/head
Jani Välimaa [Sun, 4 Dec 2022 16:35:16 +0000 (18:35 +0200)] 
mageia: use release where applicable instead of state.config.release for consistency

2 years agomageia: don't add update repo for cauldron
Jani Välimaa [Sun, 4 Dec 2022 11:00:05 +0000 (13:00 +0200)] 
mageia: don't add update repo for cauldron

2 years agomageia: add release version to repo name
Jani Välimaa [Sun, 4 Dec 2022 10:57:58 +0000 (12:57 +0200)] 
mageia: add release version to repo name

2 years agomageia: don't hardcode x86_64 arch to mirror urls
Jani Välimaa [Sun, 4 Dec 2022 10:35:09 +0000 (12:35 +0200)] 
mageia: don't hardcode x86_64 arch to mirror urls

2 years agoMerge pull request #1217 from behrmann/split4
Daan De Meyer [Tue, 29 Nov 2022 10:41:34 +0000 (11:41 +0100)] 
Merge pull request #1217 from behrmann/split4

Split v4

2 years agoRemove scaffolding for DistributionInstaller possibly being None 1217/head
Joerg Behrmann [Thu, 24 Nov 2022 16:14:40 +0000 (17:14 +0100)] 
Remove scaffolding for DistributionInstaller possibly being None