]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
2 years agoRemove unnecessary newline in log_step() 1501/head
Daan De Meyer [Mon, 24 Apr 2023 13:18:18 +0000 (15:18 +0200)] 
Remove unnecessary newline in log_step()

2 years agoRevert back to shell based chmod solution for bwrap
Daan De Meyer [Mon, 24 Apr 2023 13:11:11 +0000 (15:11 +0200)] 
Revert back to shell based chmod solution for bwrap

Mounting the host directories doesn't work because those directories
are owned by root on the host which translates to nobody in the user
namespace, breaking systemd tmpfiles tests.

2 years agoUse conditional apivfs with Debian/Ubuntu and Arch as well
Daan De Meyer [Mon, 24 Apr 2023 14:28:59 +0000 (16:28 +0200)] 
Use conditional apivfs with Debian/Ubuntu and Arch as well

Arch's filesystem package ships apivfs directories as well and
in Debian/Ubuntu, we don't want to have apivfs mounted when running
the apt update and when only downloading packages.

2 years agoUse stderr to check for tty in foreground()
Daan De Meyer [Mon, 24 Apr 2023 13:10:07 +0000 (15:10 +0200)] 
Use stderr to check for tty in foreground()

stdin/stdout might be redirected for other purposes, let's use stderr
instead to detect if we're connected to a terminal.

2 years agoDrop var_tmp() from MkosiState
Daan De Meyer [Mon, 24 Apr 2023 13:09:48 +0000 (15:09 +0200)] 
Drop var_tmp() from MkosiState

2 years agoMake --debug a boolean and add --debug-shell
Daan De Meyer [Mon, 24 Apr 2023 11:38:51 +0000 (13:38 +0200)] 
Make --debug a boolean and add --debug-shell

Let's drop the support for multiple string arguments since we only
have "run" anyway and make --boolean a simple yes/no option. To
get an interactive shell on failure, a new option --debug-shell is
added.

2 years agoSupport matching against any of a list of releases
Georges Discry [Mon, 24 Apr 2023 11:02:45 +0000 (13:02 +0200)] 
Support matching against any of a list of releases

2 years agoMerge pull request #1495 from DaanDeMeyer/stuff
Daan De Meyer [Mon, 24 Apr 2023 11:00:40 +0000 (13:00 +0200)] 
Merge pull request #1495 from DaanDeMeyer/stuff

Various refactorings and improvements

2 years agoRemove for_cache from MkosiState and centralize cached in build_image() 1495/head
Daan De Meyer [Sat, 22 Apr 2023 17:28:48 +0000 (19:28 +0200)] 
Remove for_cache from MkosiState and centralize cached in build_image()

Instead of passing these two booleans to every function, let's centralize
their usage in build_image().

2 years agoRemove --cache-initrd
Daan De Meyer [Sat, 22 Apr 2023 17:16:37 +0000 (19:16 +0200)] 
Remove --cache-initrd

2 years agoUse uid, gid directly instead of state.uid, state.gid
Daan De Meyer [Sat, 22 Apr 2023 17:12:42 +0000 (19:12 +0200)] 
Use uid, gid directly instead of state.uid, state.gid

2 years agoMove MkosiConfig and load_args() and config.py
Daan De Meyer [Fri, 21 Apr 2023 20:38:55 +0000 (22:38 +0200)] 
Move MkosiConfig and load_args() and config.py

And all the other related changes to make that work.

2 years agoMove MkosiState to state.py
Daan De Meyer [Fri, 21 Apr 2023 20:25:40 +0000 (22:25 +0200)] 
Move MkosiState to state.py

2 years agoRework bwrap run functions
Daan De Meyer [Fri, 21 Apr 2023 20:19:47 +0000 (22:19 +0200)] 
Rework bwrap run functions

- To split up our dependencies more, we need to make run.py
  independent of MkosiState, so let's do that.
- To get rid of the shell hacks in both functions to chmod /tmp,
  /var/tmp and /dev/shm, let's just mount the relevant files from
  the host which have the right permissions.
- Fixing the above exposed a bug in the logic to set up rpm based
  systems, which all ship a filesystem package that includes
  directories such as /tmp, /proc, /sys, ... which we overmount
  with apivfs or tmpfs filesystems when running rpm, causing errors
  when the filesystem package tries to set up these directories. To
  ensure these directories are created with the permissions from the
  filesystem package, the run_with_apivfs() function is renamed to
  bwrap() and gains an apivfs argument, which takes a path to set
  up apivfs directories in. If not provided, no apivfs is set up.
  This is then used to install the filesystem package without apivfs
  so that the directories can be created with the right permissions.
- The various rpm distributions now install the filesystem package
  instead of the setup package by default, so we can disable apivfs
  properly while filesystem is being installed. system-user-root
  was removed for opensuse because the filesystem package depends on
  it.

2 years agoFix rpmdb symlinks
Daan De Meyer [Mon, 24 Apr 2023 10:42:48 +0000 (12:42 +0200)] 
Fix rpmdb symlinks

On CentOS, we were creating the wrong symlink. Let's use a proper
relative symlink that always works regardless of whether we're chrooted
or not.

On Debian/Ubuntu, we weren't creating a symlink at all. So let's make
sure we also create a symlink there and use a relative symlink there as
well.

We use os.path.relpath() because Path().relative_to() can only do relative
paths to subpaths which isn't the case here. In the future we can set
strict=False and use relative_to().

2 years agoRename backend.py to util.py
Daan De Meyer [Fri, 21 Apr 2023 19:47:07 +0000 (21:47 +0200)] 
Rename backend.py to util.py

backend.py is a horrible name, let's use util.py instead.

2 years agoUse an entry point instead of a script
Georges Discry [Thu, 20 Apr 2023 20:10:06 +0000 (22:10 +0200)] 
Use an entry point instead of a script

The use of a custom script to launch mkosi has several shortcomings:

1. It translates `$PKEXEC_UID` into various `$SUDO_`* variables. That
   translation is lost if mkosi is run as a zipapp or as a module with
   `pkexec python3 -m mkosi`.
2. It has to muck around with `$PYTHONPATH` to launch mkosi directly
   from its source code.
3. It is tied to setuptools and has no equivalent in the standard
   project metadata (as in pyproject.toml).
4. And it also has to find the correct interpreter and maybe muck around
   with `$PYTHONPATH` to launch mkosi from its installation, which may
   be on the system, in the user's sitedir or in a virtualenv, as a
   standard or an editable installation.

Point 1 is not needed anymore now that `mkosi.backend.current_user()` is
used everywhere.

Point 2 can be done by directly running mkosi as a module from its
sources with:

- `[sudo|pkexec] python3 -m mkosi` inside the project directory
- `[sudo] PYTHONPATH=<PROJECT_PATH> python3 -m mkosi` from anywhere
- `[sudo|pkexec] <PROJECT_PATH>/bin/mkosi` from anywhere. The script is
  now a simple shim that is only used for this use case and not
  installed anymore.

Point 3 and 4 are better supported by using a `"console_scripts"` entry
point when installed. However, it is not possible anymore to run a
user-installed mkosi with sudo/pkexec.

2 years agoAdd missing complete_step() when installing build packages
Daan De Meyer [Mon, 24 Apr 2023 07:55:26 +0000 (09:55 +0200)] 
Add missing complete_step() when installing build packages

2 years agofix duplicate entry in github action
Malte Poll [Mon, 24 Apr 2023 07:52:19 +0000 (09:52 +0200)] 
fix duplicate entry in github action

2 years agoUse `getpass.getuser()` to get the name of the current user
Georges Discry [Sun, 23 Apr 2023 20:35:38 +0000 (22:35 +0200)] 
Use `getpass.getuser()` to get the name of the current user

`os.getlogin()` can fail and has no fallback, whereas
`getpass.getuser()` takes the environment variables into account and
falls back on `pwd`.

2 years agoDisallow `<SOURCE>:<TARGET>` with an empty target
Georges Discry [Sun, 23 Apr 2023 12:51:08 +0000 (14:51 +0200)] 
Disallow `<SOURCE>:<TARGET>` with an empty target

The configurations of the form `<SOURCE>[:<TARGET>]` require an absolute
target if given. However, `<SOURCE>:` would be ambiguously interpreted
as `<SOURCE>` so it is now disallowed.

For reference, `systemd-nspawn --bind` uses a similar form and refuses
to take an empty target.

2 years agoAllow setting empty environment variables
Georges Discry [Sun, 23 Apr 2023 12:47:44 +0000 (14:47 +0200)] 
Allow setting empty environment variables

Trying to set an empty environment variable with `FOO=` would instead
pass the `FOO` variable from the host, which is the expected behavior
when `=` is missing.

2 years agodebian: Add TODO to drop /var/lib/dpkg/status logic when possible
Daan De Meyer [Sat, 22 Apr 2023 20:41:33 +0000 (22:41 +0200)] 
debian: Add TODO to drop /var/lib/dpkg/status logic when possible

It's created automatically by apt since apt 2.5.4 so add a note that
we can drop it once that version is widely available. Also disable
dpkg locking since it causes a apt failure due to not being able to
access the lock file in /var/lib/dpkg. Since we're building in a
chroot, we don't care about locking anyway.

2 years agoUse python logging module for logging
Daan De Meyer [Fri, 21 Apr 2023 19:18:14 +0000 (21:18 +0200)] 
Use python logging module for logging

Let's get rid of our home grown solution and use python's logging
module instead.

2 years agoSupport matching against any of a list of distributions
Daan De Meyer [Sun, 23 Apr 2023 12:35:55 +0000 (14:35 +0200)] 
Support matching against any of a list of distributions

2 years agoDisplay "Skeleton Trees" in the summary again
Georges Discry [Sat, 22 Apr 2023 10:13:30 +0000 (12:13 +0200)] 
Display "Skeleton Trees" in the summary again

The skeleton trees were lost from the summary with e1bbc39.

2 years agoFix installation of essential packages on Debian stretch
Georges Discry [Fri, 21 Apr 2023 23:24:24 +0000 (01:24 +0200)] 
Fix installation of essential packages on Debian stretch

There is a bug in Debian stretch where `libuuid1` (which is essential)
unnecessarily depends on `passwd`. When configuring the essential
packages and their dependencies, `passwd` is configured before
`base-passwd` and the installation fails.

debootstrap did not have this issue because it explicitly orders the
installation of some essential packages, including `base-passwd`.

By explicitly installing `base-passwd` first, the rest of the essential
packages can then be configured without failure.

2 years agoUse shlex escaping in Environment
Georges Discry [Fri, 21 Apr 2023 19:56:10 +0000 (21:56 +0200)] 
Use shlex escaping in Environment

The Environment configuration takes lists of space-separated values and
combine them in a single list, splitting the values on spaces and
newlines. However, environment variables might sometimes need a space in
their value, which is currently impossible to configure.

Instead of blindly splitting the values on spaces and newlines, they are
now split with shlex. Spaces, newlines and backslashes can be escaped
with backslashes, single quotes and double quotes.

This behavior also more closely matches the Environment directive of systemd.

2 years agoAdd MakeInitrd=
Daan De Meyer [Fri, 21 Apr 2023 11:40:21 +0000 (13:40 +0200)] 
Add MakeInitrd=

Instead of automatically making cpio's initrds, let's put this behind
a MakeInitrd= option. This allows booting directly into cpios with systemd
when they're not configured as an initramfs.

2 years agoMerge pull request #1472 from gdiscry/path-expansion
Daan De Meyer [Fri, 21 Apr 2023 17:49:45 +0000 (19:49 +0200)] 
Merge pull request #1472 from gdiscry/path-expansion

Path expansion

2 years agoApply path expansion when parsing 1472/head
Georges Discry [Thu, 20 Apr 2023 20:09:58 +0000 (22:09 +0200)] 
Apply path expansion when parsing

When the `extra_search_paths` configuration was introduced, it would
perform path expansions with the environment variables (using $) and the
home directories (starting with ~). Home directories would not be
expanded when mkosi was run with sudo or pkexec. Instead, `$SUDO_HOME`
could be used but only when run with sudo or pkexec.

However, those expansions were not applied to other paths in the
configuration and were broken with the rewrite of the configuration
loading, as the parser would check if the paths exist before expanding.

Those expansions are now handled directly in the parser and are
performed before validation. Environment variables expansion is enabled
for all paths and home directory expansion is enabled for all paths on
the host.

Furthermore, home directory expansion is always available, with `~`
expanding to the user's home directory when sudo or pkexec are used (and
not `/root`), replacing the need for `$SUDO_HOME`.

2 years agoUnify the parsers for the path options
Georges Discry [Thu, 20 Apr 2023 20:09:56 +0000 (22:09 +0200)] 
Unify the parsers for the path options

There were several parsers for path options/arguments, each with their
own implementation. They now all use `parse_path` internally.

2 years agoUnify loading the current user info
Georges Discry [Thu, 20 Apr 2023 20:09:54 +0000 (22:09 +0200)] 
Unify loading the current user info

There are a few places where mkosi wants to know who is the current user
invoking the script with sudo or pkexec, instead of root. Some
combinations of `$SUDO_UID`, `$PKEXEC_UID` and `$SUDO_USER` are used,
but without consistency. Furthermore, when pkexec is used, several
places depend on `bin/mkosi` setting the correct `$SUDO_`* environment
variables.

Those places now use the `mkosi.backend.current_user()` function.
Furthermore, that function returns an `InvokingUser` wrapping the
complete passwd entry from the `pwd` module instead of just the uid/gid.

2 years agoMerge pull request #1468 from DaanDeMeyer/base-tree
Daan De Meyer [Fri, 21 Apr 2023 11:47:59 +0000 (13:47 +0200)] 
Merge pull request #1468 from DaanDeMeyer/base-tree

Split up --base-image into --base-tree and --overlay

2 years agoSplit up --base-image into --base-tree and --overlay 1468/head
Daan De Meyer [Thu, 20 Apr 2023 10:46:04 +0000 (12:46 +0200)] 
Split up --base-image into --base-tree and --overlay

--base-tree indicates a base image. It differs from --skeleton-tree
in that use of --base-tree indicates that we've already installed a
distribution and should only install extra packages, not install the
distribution from scratch.

If --overlay is not specified, we just copy all the specified base trees
to the root directory before doing anything else (even before copying the
skeleton trees) and after that we operate as usual.

If --overlay is specified, instead of copying all the base trees to
the root directory, we set up an overlayfs mount with all the base
trees as lowerdirs. After that we operate as usual. The effect is that
all our usual steps will operate on a full view of the image, but the
output will only contain the additions we made on top of the specified
base trees.

2 years agoEmpty install directory before running build script
Daan De Meyer [Fri, 21 Apr 2023 10:25:01 +0000 (12:25 +0200)] 
Empty install directory before running build script

The install directory is shared between distros, and depending on
the distro, different files might be installed. Let's make sure we
empty the install directory before running the build so that files
from different distros don't end up mixed in the install directory.

2 years agoFix stdin being redirect to /dev/null when running ssh, shell or qemu
Daan De Meyer [Fri, 21 Apr 2023 09:51:20 +0000 (11:51 +0200)] 
Fix stdin being redirect to /dev/null when running ssh, shell or qemu

30b8996a22022289bbf9820b6a04c5bfaf771d5e changed the default of
stdin to /dev/null, which is great, but for the ssh, shell, boot and
qemu commands, we actually need it connected to stdin of the calling
terminal, so let's fix that.

2 years agoCheck if already root in become_root
Georges Discry [Thu, 20 Apr 2023 20:09:34 +0000 (22:09 +0200)] 
Check if already root in become_root

Instead of requiring the check for `os.getuid() != 0` before calling
`mkosi.run.become_root()`, that check is now performed at the beginning
with an early return if the user is already root.

2 years agoOverride sys.excepthook when calling main
Georges Discry [Thu, 20 Apr 2023 20:31:45 +0000 (22:31 +0200)] 
Override sys.excepthook when calling main

Overriding `sys.excepthook` with `mkosi.run.excepthook` has to happen
when calling `mkosi.__main__.main()`, otherwise it is not applied when
`main` is simply imported and then called (by using a zipapp or a
console script entry point).

2 years agoMerge pull request #1467 from keszybz/run-stdin
Daan De Meyer [Thu, 20 Apr 2023 12:40:56 +0000 (14:40 +0200)] 
Merge pull request #1467 from keszybz/run-stdin

Redirect run() input from /dev/null, adjust formatting

2 years agoUse the appropriate quote type 1467/head
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2023 11:56:08 +0000 (13:56 +0200)] 
Use the appropriate quote type

2 years agoWhen invoking qemu, put all -drive args adjacent
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2023 08:30:00 +0000 (10:30 +0200)] 
When invoking qemu, put all -drive args adjacent

The -smbios args are very long. I was checking out secureboot config,
and I thought that the second -drive argument is missing. Let's make
them adjacent again.

2 years agoReformat run commands to have "--option", "value" pairs on the same line
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2023 08:27:05 +0000 (10:27 +0200)] 
Reformat run commands to have "--option", "value" pairs on the same line

We were already doing this for the majority of invocations, but there
were some exceptions. Since this makes it much easier to mentally
split the command into logical parts, let's do this everywhere.

To make the command stand out a bit, add one space of seperation between
"[" and the first argument and between the last argument and "]".

2 years agoSet stdin=/dev/null for all commands invoked by run()
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2023 08:12:01 +0000 (10:12 +0200)] 
Set stdin=/dev/null for all commands invoked by run()

In ed93e8c49fc2afb9255280d1dec9b7d81d07ff94 I added this for two
commands that were invoked directly from summary. But the same issue
occurs for other commands that we invoke. Instead of handling them
one-by-one, let's set stdin for all commands. We don't want anything that
we invoke to ever read input from the console, so this is a suitable
default for us.

2 years agoFix trees doc names
Daan De Meyer [Thu, 20 Apr 2023 11:06:53 +0000 (13:06 +0200)] 
Fix trees doc names

These are plural

2 years agoMove --initrd to the Content group
Daan De Meyer [Thu, 20 Apr 2023 10:11:32 +0000 (12:11 +0200)] 
Move --initrd to the Content group

2 years agoFix invocation of kernel-install --verbose
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2023 15:26:46 +0000 (17:26 +0200)] 
Fix invocation of kernel-install --verbose

‣   Running kernel-install…
+ bwrap --unshare-ipc --unshare-pid --unshare-cgroup --bind /home/zbyszek/src/mkosi/.mkosi.tmpj5z62xil/root / --tmpfs /run --tmpfs /tmp --dev /dev --proc /proc --ro-bind /sys /sys --bind /home/zbyszek/src/mkosi/.mkosi.tmpj5z62xil/var-tmp /var/tmp --die-with-parent --unshare-net sh -c 'chmod 1777 /tmp /var/tmp /dev/shm && PATH=$PATH:/usr/bin:/usr/sbin exec kernel-install add 6.2.11-300.fc38.x86_64 /lib/modules/6.2.11-300.fc38.x86_64/vmlinuz --verbose || exit $?'
Error: initrd '--verbose' not a file.

2 years agoFail with a clear error if sd-stub is not installed in the image
Daan De Meyer [Wed, 19 Apr 2023 19:39:07 +0000 (21:39 +0200)] 
Fail with a clear error if sd-stub is not installed in the image

2 years agoFail with a clear error if sd-stub is not installed in the image
Daan De Meyer [Wed, 19 Apr 2023 19:39:07 +0000 (21:39 +0200)] 
Fail with a clear error if sd-stub is not installed in the image

2 years agoMerge pull request #1463 from keszybz/error-printing-reformat
Daan De Meyer [Thu, 20 Apr 2023 06:27:19 +0000 (08:27 +0200)] 
Merge pull request #1463 from keszybz/error-printing-reformat

Reformat error printing a bit

2 years agoDo not print hint about exception for RuntimeError 1463/head
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2023 14:21:16 +0000 (16:21 +0200)] 
Do not print hint about exception for RuntimeError

If debug is already on, the hint is not useful. Also, if we already printed an
error, we don't need to tell the user that we internally used an exception,
this is not relevant to the user.

Also, change str(e) to e.__class__.__name__. 'str(e)' is the same as 'e' here,
and is not guaranteed to contain any message. E.g. for 'raise ValueError',
str(e) is just ''. Let's say "internal exception CLASS" instead.

I still don't think RuntimeError is a great choice. It'd be totally unsuitable
if mkosi was used as a library. We don't do this right now, so it's not so bad,
but we could still get confused by RuntimeError generated in some sloppy code
in one of the packages that we call. This is hopefully unlikely, but our own
custom exception would be clearer and free of this risk. Alas, RuntimeError was
added purposefully in e25d746f9d7668edc5134cde4ec381c8b2da0136, so I'm not
changing it.

2 years agoReformat hint and don't print as part of the error
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2023 14:18:08 +0000 (16:18 +0200)] 
Reformat hint and don't print as part of the error

The error about SecureBoot keys was line-broken in the source code and looked
strange on the tty: the line break was in the middle of the terminal. Let's
rework things a bit to print the hint in gray and print the two filenames at
the end so it is easy to select-and-paste into an actual command. Also
use hint= in other cases where part of the error is advisory.

2 years agoFix grammar in comment
Zbigniew Jędrzejewski-Szmek [Wed, 19 Apr 2023 09:37:33 +0000 (11:37 +0200)] 
Fix grammar in comment

2 years agoMerge pull request #1462 from DaanDeMeyer/cpio
Jörg Behrmann [Wed, 19 Apr 2023 15:27:33 +0000 (17:27 +0200)] 
Merge pull request #1462 from DaanDeMeyer/cpio

Allow booting cpio images in qemu

2 years agoUpdate default Fedora release to 38
Daan De Meyer [Wed, 19 Apr 2023 14:48:02 +0000 (16:48 +0200)] 
Update default Fedora release to 38

2 years agoUse merged usr path in kernel_image() 1462/head
Daan De Meyer [Wed, 19 Apr 2023 14:14:02 +0000 (16:14 +0200)] 
Use merged usr path in kernel_image()

Let's assume merged usr everywhere.

2 years agoAlways check in usr/lib/modules for the kernel image
Daan De Meyer [Wed, 19 Apr 2023 14:10:48 +0000 (16:10 +0200)] 
Always check in usr/lib/modules for the kernel image

This helps with finding self compiled kernels that are installed
in another location than the distro default.

2 years agoAllow booting cpio images in qemu
Daan De Meyer [Wed, 19 Apr 2023 13:48:47 +0000 (15:48 +0200)] 
Allow booting cpio images in qemu

Let's add back some form of direct linux boot by allowing to boot
cpio images. To make this work, either the user has to pass -kernel
or a kernel has to be installed inside the cpio, which we'll copy
out and use as the -kernel argument.

2 years agoShow exception string when we fail
Daan De Meyer [Wed, 19 Apr 2023 13:47:10 +0000 (15:47 +0200)] 
Show exception string when we fail

To at least give a little information to users about what went wrong

2 years agoStop compressing split kernel
Daan De Meyer [Wed, 19 Apr 2023 13:39:15 +0000 (15:39 +0200)] 
Stop compressing split kernel

The individual components of the UKI are already compressed so it
doesn't make sense to compress the UKI itself as well.

2 years agoDon't run kernel-install if the output format is a cpio
Daan De Meyer [Wed, 19 Apr 2023 13:29:31 +0000 (15:29 +0200)] 
Don't run kernel-install if the output format is a cpio

If we're building a cpio, we're very likely not going to want to
install a kernel, so don't do it if bootable is in "auto" mode.

2 years agoSymlink /etc/initrd-release to /etc/os-release
Daan De Meyer [Wed, 19 Apr 2023 13:28:03 +0000 (15:28 +0200)] 
Symlink /etc/initrd-release to /etc/os-release

This also does the trick and is simpler than renaming os-release.

2 years agoRework compression
Daan De Meyer [Wed, 19 Apr 2023 13:26:18 +0000 (15:26 +0200)] 
Rework compression

Let's introduce an enum and a helper to refer to the compressed output
path.

We also go back to always reading the password in find_password() if
set in a mkosi.rootpw file. This was changed to only be done during
a build so that the file could be owned by root, but this doesn't apply
anymore because mkosi doesn't need to be root anymore to do a build.

2 years agoUse default zstd compression level
Daan De Meyer [Wed, 19 Apr 2023 12:40:04 +0000 (14:40 +0200)] 
Use default zstd compression level

The current compression level takes a really long time to complete
when the output is large. Let's use the default compression level
instead so compression is a bit faster while still giving good results.

2 years agoDon't make output an absolute path while parsing
Daan De Meyer [Tue, 18 Apr 2023 19:48:10 +0000 (21:48 +0200)] 
Don't make output an absolute path while parsing

Fixes a regression from 2a6aa720f59e4f66ba63d311f5fa79c3a3ac0a61.

2 years agoRun systemd-sysusers during the build
Daan De Meyer [Tue, 18 Apr 2023 11:54:33 +0000 (13:54 +0200)] 
Run systemd-sysusers during the build

Same as systemd-preset, let's run systemd-sysusers as part of the
build process.

2 years agoConfigure both hvc0 and ttyS0
Daan De Meyer [Tue, 18 Apr 2023 11:53:35 +0000 (13:53 +0200)] 
Configure both hvc0 and ttyS0

When hvc0 doesn't work for some reason, we can switch back to ttyS0
and still have a working console.

2 years agoStop copying the cached build overlay
Daan De Meyer [Wed, 19 Apr 2023 08:20:30 +0000 (10:20 +0200)] 
Stop copying the cached build overlay

The build overlay is not modified during the final build, it's only
used to run the build script which cannot touch the build image. Let's
enforce this even more by mounting the build overlay read-only when
running the script.

With this assurance, we can stop copying the cached build overlay every
time and just use it directly since we're certain it cannot be modified
anyway.

2 years agoMerge pull request #1287 from keszybz/man-qemu-direct
Daan De Meyer [Wed, 19 Apr 2023 10:18:48 +0000 (12:18 +0200)] 
Merge pull request #1287 from keszybz/man-qemu-direct

Document various ways to boot with qemu directly and how to override kernel command lines

2 years agoman: explain various qemu booting options 1287/head
Zbigniew Jędrzejewski-Szmek [Tue, 20 Dec 2022 12:47:52 +0000 (13:47 +0100)] 
man: explain various qemu booting options

2 years agodocs: use better highlighter for command examples
Zbigniew Jędrzejewski-Szmek [Tue, 20 Dec 2022 13:35:08 +0000 (14:35 +0100)] 
docs: use better highlighter for command examples

2 years agoman: regenerate man page
Zbigniew Jędrzejewski-Szmek [Sun, 16 Apr 2023 12:35:37 +0000 (14:35 +0200)] 
man: regenerate man page

2 years agoReplace _run() with an extra argument log
Daan De Meyer [Tue, 18 Apr 2023 20:11:58 +0000 (22:11 +0200)] 
Replace _run() with an extra argument log

Let's just add an argument log to run that's true by default which
allows us to disable logging if the command failed. We also disable
logging in run_ssh(), run_qemu() and run_shell() since we expect
those to fail and shouldn't log if they do (like we did before).

2 years agodebian: Simplify cmdline to get the list of packages to install
Daan De Meyer [Tue, 18 Apr 2023 19:13:39 +0000 (21:13 +0200)] 
debian: Simplify cmdline to get the list of packages to install

Let's not bother with file descriptor inheritance and just write
the list of packages to a temporary file.

2 years agoMerge pull request #1457 from DaanDeMeyer/debian
Daan De Meyer [Tue, 18 Apr 2023 16:19:40 +0000 (18:19 +0200)] 
Merge pull request #1457 from DaanDeMeyer/debian

debian: Stop setting DPkg::Path

2 years agodebian: Fix bug in Debug::pkgDpkgPm=1 call 1457/head
Daan De Meyer [Tue, 18 Apr 2023 15:28:00 +0000 (17:28 +0200)] 
debian: Fix bug in Debug::pkgDpkgPm=1 call

This was inspired from mmdebstrap's perl construct and I forgot to
replace $fd with f.fileno() in one case.

We also drop the redirection to /dev/null when executing apt because
the extra output is minimal and it allows us to simplify the logic
quite a bit.

2 years agodebian: Stop setting DPkg::Path
Daan De Meyer [Tue, 18 Apr 2023 14:53:46 +0000 (16:53 +0200)] 
debian: Stop setting DPkg::Path

While this achieved the desired effect of dpkg being looked up in
the PATH, it also modified the PATH variable for everything executed
by dpkg, which we don't want. Let's just lookup dpkg in PATH before
running apt and put the result in Dir::Bin::dpkg which looks up
dpkg in the PATH without modifying the PATH used by dpkg itself.

Fixes #1456

2 years agoRework exception handling
Daan De Meyer [Tue, 18 Apr 2023 13:09:58 +0000 (15:09 +0200)] 
Rework exception handling

Let's always use regular exceptions and stop outputting stack traces
on exceptions by default. To get a stacktrace, users can run mkosi with
--debug run and we will output the usual stacktrace.

2 years agogenerate the summary in a multiline f-string
Joerg Behrmann [Mon, 17 Apr 2023 12:44:26 +0000 (14:44 +0200)] 
generate the summary in a multiline f-string

This also makes all outut that was conditional on some other settings
unconditional, since it was a bit mixed what we always showed and for which we
defaulted to some fallback string anyway.

with_docs was conditioned on which distributions supported it, but distribution
support for other features has been mixed as well and accompanying settings have
been shown regardless.

2 years agodebian: Add debugging for oDebug::pkgDpkgPm=1 command
Daan De Meyer [Tue, 18 Apr 2023 12:02:15 +0000 (14:02 +0200)] 
debian: Add debugging for oDebug::pkgDpkgPm=1 command

Let's make sure we get an error message should this command fail
to run.

2 years agoAdd back --bootable option
Daan De Meyer [Mon, 17 Apr 2023 20:14:43 +0000 (22:14 +0200)] 
Add back --bootable option

There are valid scenarios where one might want to install a kernel
without wanting a bootable image, so let's add back the --bootable=
option as a feature option. It defaults to "auto" which is the current
behavior, but can also be explicitly enabled or disabled. If enabled,
we'll fail if we can't produce a bootable image. If disabled, we won't
generate a bootable image even if all the necessary components are
available.

2 years agoMerge pull request #1453 from mrc0mmand/fedora-gpg
Jörg Behrmann [Tue, 18 Apr 2023 11:11:41 +0000 (13:11 +0200)] 
Merge pull request #1453 from mrc0mmand/fedora-gpg

fedora: fix gpg key location

2 years agofedora: fix gpg key location 1453/head
Frantisek Sumsal [Tue, 18 Apr 2023 10:40:10 +0000 (12:40 +0200)] 
fedora: fix gpg key location

With the new Fedora website the location of the gpg keys has changed.
Also, all the gpg keys are now in one file instead of having a separate
file for each release.

See: https://fedoraproject.org/security/

2 years agoMake sure we resolve relative paths in config files correctly
Daan De Meyer [Mon, 17 Apr 2023 13:58:08 +0000 (15:58 +0200)] 
Make sure we resolve relative paths in config files correctly

Relative paths in config files should always be interpreted relative
to their config file. We could pass the directory to each parse method,
but that's rather verbose, so let's use chdir() so that relative paths
are resolved correctly instead.

2 years agoMake sure the /efi mountpoint exists for every distro
Daan De Meyer [Mon, 17 Apr 2023 19:17:50 +0000 (21:17 +0200)] 
Make sure the /efi mountpoint exists for every distro

https://0pointer.net/blog/linux-boot-partitions.html recommends
using the /efi mountpoint universally so let's accomodate that
and do it for every distro.

2 years agoAdd missing newline in /etc/shadow
Zbigniew Jędrzejewski-Szmek [Mon, 17 Apr 2023 12:17:11 +0000 (14:17 +0200)] 
Add missing newline in /etc/shadow

Fixup for 1f3e619a0fe4a22c517e2ebaeab68402df2f4f0d.

2 years agoMerge pull request #1442 from DaanDeMeyer/fixes
Jörg Behrmann [Mon, 17 Apr 2023 11:03:28 +0000 (13:03 +0200)] 
Merge pull request #1442 from DaanDeMeyer/fixes

Get rid of debootstrap dependency

2 years agoMerge pull request #1446 from keszybz/shadow-writing-enoent
Daan De Meyer [Mon, 17 Apr 2023 10:27:20 +0000 (12:27 +0200)] 
Merge pull request #1446 from keszybz/shadow-writing-enoent

Do not fail when writing root password and /etc/shadow is missing

2 years agoFix display of password in summary 1446/head
Zbigniew Jędrzejewski-Szmek [Mon, 17 Apr 2023 10:07:02 +0000 (12:07 +0200)] 
Fix display of password in summary

We would skip reading the file and say "(default)").

2 years agoDo not fail when writing root password and /etc/shadow is missing
Zbigniew Jędrzejewski-Szmek [Mon, 17 Apr 2023 09:41:42 +0000 (11:41 +0200)] 
Do not fail when writing root password and /etc/shadow is missing

I had this failure when testing https://github.com/systemd/mkosi/pull/1442. But
it would happen whenever the installed system has no /etc/shadow and we want to
set the password, so it's worth fixing regardless.

2 years agoMerge pull request #1444 from keszybz/use-pager-for-summary-and-help
Daan De Meyer [Mon, 17 Apr 2023 09:44:52 +0000 (11:44 +0200)] 
Merge pull request #1444 from keszybz/use-pager-for-summary-and-help

Use pager for summary and help

2 years agoGet rid of debootstrap dependency 1442/head
Daan De Meyer [Sat, 15 Apr 2023 23:14:27 +0000 (01:14 +0200)] 
Get rid of debootstrap dependency

Let's get rid of our dependency on debootstrap by replicating its
core functionality ourselves. To make sure the necessary tools for
maintainer scripts to run are available in the chroot, we have to
extract the essential debs manually first before installing all the
essential debs.

This also allows us to get rid of our skeleton tree hack we added for
debootstrap.

2 years agoSimplify apt invocation
Daan De Meyer [Sun, 16 Apr 2023 09:41:41 +0000 (11:41 +0200)] 
Simplify apt invocation

2 years agoDrop Debian ignore preset workaround
Daan De Meyer [Sun, 16 Apr 2023 12:49:54 +0000 (14:49 +0200)] 
Drop Debian ignore preset workaround

Let's continue to stop mucking around with distro defaults and leave
the ignore * preset for users to apply in a postinst script.

2 years agoDrop debian os-release workaround
Daan De Meyer [Sun, 16 Apr 2023 10:04:01 +0000 (12:04 +0200)] 
Drop debian os-release workaround

Current Debian stable boots fine in qemu with systemd-boot with this
workaround removed, so let's drop it.

2 years agoOnly write repositories to image on Debian/Ubuntu if apt was installed
Daan De Meyer [Sat, 15 Apr 2023 19:03:18 +0000 (21:03 +0200)] 
Only write repositories to image on Debian/Ubuntu if apt was installed

For other distributions, we don't install the repositories at all but
because Debian and Ubuntu do not have an easy way to install the
repositories via a package we give them some leeway and install the
repositories if apt was installed.

We also rework repository handling to accomodate this. When running
apt ourselves on the host, we now use the apt directory in the
workspace as the config directory for apt instead of using etc/apt
in the image.

Additionally, we also use the keyring from the host instead of the
one from the image when running apt.

Finally, we switch to the http mirror for debian security updates
to avoid having to install ca-certificates in the image for apt
to work properly.

2 years agoMake sure we create /var/lib/dpkg with the right access mode
Daan De Meyer [Sat, 15 Apr 2023 18:12:59 +0000 (20:12 +0200)] 
Make sure we create /var/lib/dpkg with the right access mode

2 years agoDrop absolute() usage in debian.py
Daan De Meyer [Sat, 15 Apr 2023 17:49:50 +0000 (19:49 +0200)] 
Drop absolute() usage in debian.py

We now make sure paths are absolute when parsing them so no need to
do so anymore in debian.py

2 years agoDrop DEBIAN_KERNEL_ARCHITECTURES
Daan De Meyer [Sat, 15 Apr 2023 17:44:14 +0000 (19:44 +0200)] 
Drop DEBIAN_KERNEL_ARCHITECTURES

2 years agoFix comments
Daan De Meyer [Sat, 15 Apr 2023 17:40:50 +0000 (19:40 +0200)] 
Fix comments