config: reword help message for --root-{password,shell}
"system root" doesn't seem right, because it sounds like we're talking about
the file system. We would often say just "root password", but that's nor
gramatically correct. "root's password" would be correct, but seems strange.
So let's rephase this to avoid the awkwardness.
@@ -85,6 +85,6 @@
- --bootable [FEATURE] Generate ESP partition with systemd-boot and UKIs for
- installed kernels
--kernel-command-line OPTIONS
Set the kernel command line (only bootable images)
+ --bootable [FEATURE] Generate ESP partition with systemd-boot and UKIs for
+ installed kernels
Daan De Meyer [Tue, 20 Jun 2023 14:07:49 +0000 (16:07 +0200)]
Remove --install-directory= option
We don't benefit from the caching anymore since we started emptying
the directory completely on reuse as otherwise old leftover files
might get installed. Without the caching, the option does not have
a ton of use anymore, so let's remove it.
Daan De Meyer [Wed, 14 Jun 2023 15:41:32 +0000 (17:41 +0200)]
Run systemd-repart before booting image with systemd-nspawn
To match the behavior when running in qemu, let's run systemd-repart
on the image before running it in systemd-nspawn to make sure that
all the necessary partitions are added if the image has repart
definition files included.
Daan De Meyer [Tue, 13 Jun 2023 13:45:11 +0000 (15:45 +0200)]
qemu: Use SOCK_STREAM for notify socket
The CentOS 8 Stream kernel does not support SOCK_SEQPACKET for
AF_VSOCK so let's use SOCK_STREAM instead and explicitly instruct
systemd running in the VM to use SOCK_STREAM as well.
Daan De Meyer [Mon, 12 Jun 2023 13:12:01 +0000 (15:12 +0200)]
Ensure we return the same exit code in debug mode
When running in debug mode, we shouldn't return a different exit
code compared to when we run outside of debug mode.
A trivial example is when running the boot or qemu verbs where we
exit with the exit code of the container/VM by raising an instance
of CalledProcessError. In --debug mode, this exception is handled
as an unhandled exception by the python runtime which always exits
with 1 when an unhandled exception is encountered, whereas outside
of debug mode we exit with the value contained in
CalledProcessError.returncode.
With this commit, we'll always exit with the return value in
CalledProcessError.returncode.
Daan De Meyer [Sun, 11 Jun 2023 19:55:06 +0000 (21:55 +0200)]
apt: Set "Dir" instead of "Dir::Etc" and set it via APT_CONFIG
We need to use APT_CONFIG to set "Dir" as otherwise the value of "Dir"
won't be taken into account by apt when looking for configuration files
as options set via the CLI are applied last after parsing the apt
configuration files.
Daan De Meyer [Sun, 11 Jun 2023 18:24:10 +0000 (20:24 +0200)]
dnf: Write repos to /etc/yum.repos.d/<distribution>.repo
Let's allow providing a config file for dnf without also overriding
all the default repositories by writing the default repositories to
a file in /etc/yum.repos.d/.
Daan De Meyer [Sun, 11 Jun 2023 18:10:53 +0000 (20:10 +0200)]
Do not overwrite package manager config files if they exist
Let's allow users to override mkosi's default package manager
settings by providing their own package manager config file. This
is especially important for distributions built using dnf as dnf
does not yet have support for dropins.
Daan De Meyer [Sun, 11 Jun 2023 18:03:30 +0000 (20:03 +0200)]
arch: Drop useless options from config
CheckSpace isn't really useful as we'll just fail a little later
while unpacking or installing packages. HoldPkg isn't useful either
as there's no chance of breaking the system by uninstalling packages
when we're just building an image.
Daan De Meyer [Thu, 8 Jun 2023 15:42:35 +0000 (17:42 +0200)]
Prefer configuration via CLI over configuration via config file
This makes it easier to debug things with --debug as all the options
used will be logged instead of having to go and figure out what's in
the config file.
Daan De Meyer [Wed, 7 Jun 2023 14:40:04 +0000 (16:40 +0200)]
Install dmsetup in the initrd on Debian/Ubuntu
On other distros, just installing systemd and udev is sufficient to
make verity work. On Debian and Ubuntu, we need to explicitly install
dmsetup as well to make sure verity works, so let's do that.
Daan De Meyer [Tue, 6 Jun 2023 09:59:55 +0000 (11:59 +0200)]
Make matches work more like systemd conditions
Let's make matches behave like systemd conditions. We drop support
for list matches. Instead, we add support for match negation and
trigger matches. A match is a trigger match if it's prefixed with
the pipe symbol (|). A match is satisfied if all its regular matches
and one of its trigger matches are satisfied.
Daan De Meyer [Wed, 7 Jun 2023 12:01:51 +0000 (14:01 +0200)]
Don't unpack extra/skeleton archives if a target is provided
ExtraTrees= and SkeletonTrees= are currently ambiguous when a target
location is provided. The user could either mean that the archive has
to be unpacked to the target location or the user could mean that he
wants to copy the archive to that location in the image.
We should still try to resolve the ambiguity, but for now, let's assume
that when a target is provided that the user wants to copy the archive
into the image instead of unpacking the archive to that specific location.
To make this work, we also modify the logic slightly to create only the
parent directories of the target so that cp doesn't fail because we try
to copy a file to a directory.
Daan De Meyer [Mon, 29 May 2023 20:41:31 +0000 (22:41 +0200)]
Rework architecture handling
Let's lock architectures down by making it an enum instead of a
free form string. We also introduce a bunch of mapping functions
to map the Architecture enum to qemu, distribution arches, efi
arches. We only support the architectures defined in the discoverable
partitions spec and use those architectures as the default representation.
Daan De Meyer [Sat, 27 May 2023 08:54:20 +0000 (10:54 +0200)]
Make sure we handle any exceptions thrown in MkosiAsyncioThread()
Any unhandled exceptions from run() are by default just printed to
stderr. Let's make sure that these exceptions cause mkosi itself to
fail by catching them and re-raising them when the thread is joined.
Daan De Meyer [Fri, 26 May 2023 10:01:35 +0000 (12:01 +0200)]
Various improvements
- Move workspace and install/cache directory handling into MkosiState
- Stop running the build as the user running mkosi, this makes things
simpler as the root user in the userns can write to directories owned
by the user running mkosi but vice versa is not possible. The build
script still can't modify the build image as we mount the build overlay
read-only.
- Create directories that need to be owned by the user running mkosi
before switching to the user namespace
- Various refactorings
Daan De Meyer [Fri, 26 May 2023 10:16:50 +0000 (12:16 +0200)]
debian: Fix foreign architecture builds
--force-architecture forces dpkg to install packages for other
architectures than the host architecture. --force-depends is required
because when building for arm64 it seems it can't quite figure out
all the pre-depends. For extra safety, we also set APT::Architectures
on top of APT::Architecture.
Before this would have the uid:gid of root in the uidmap space
The link is now created in the staging area first to make the change atomic,
so that the wrong uid:gid pair is never seen in the output directory
Malte Poll [Thu, 25 May 2023 09:53:47 +0000 (11:53 +0200)]
ukify: always sign kernel inside of uki if secure boot is enabled
This overrides the auto detection of ukify and always signs the kernel bevore embedding it in the uki (even if the kernel is already signed).
Rationale: When building Fedora 37 images, the Fedora provided kernel is signed with an expired key (id 2574709492).
I would like to add an additional signature with my own signing key to enable kexec and other features that require a correctly signed kernel image.
Co-authored-by: Otto Bittner <cobittner@posteo.net>
Daan De Meyer [Wed, 24 May 2023 12:33:49 +0000 (14:33 +0200)]
Firstboot improvements
- Merge --root-password-hashed and --root-password-file into
--root-password. If prefixed with hashed:, we treat it as a hashed
root password.
- When not building an initrd, also store corresponding credentials
in /usr/lib/credstore, so that the settings work even if only /usr
is shipped in the final image. We don't do this for initrds since
those generally ship with /etc populated.
- Drop setting of firstboot.hostname which isn't actually used by
systemd-firstboot
Daan De Meyer [Sun, 21 May 2023 15:08:51 +0000 (17:08 +0200)]
Make mkosi the foreground process again when child process finishes
We currently get "Job mkosi has stopped" when fetching running the
summary verb. Let's fix this by making sure we make mkosi the foreground
process again when we finish running a child process.