]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
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 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 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

2 years agoUse kernel-core instead of kernel in CI for some distros
Daan De Meyer [Mon, 17 Apr 2023 08:23:28 +0000 (10:23 +0200)] 
Use kernel-core instead of kernel in CI for some distros

kernel-core is smaller and has fewer dependencies.

2 years agomkosi: boldify section header and important values in summary 1444/head
Zbigniew Jędrzejewski-Szmek [Sun, 16 Apr 2023 17:33:06 +0000 (19:33 +0200)] 
mkosi: boldify section header and important values in summary

2 years agomkosi: indent synopsis in --help by two spaces
Zbigniew Jędrzejewski-Szmek [Sun, 16 Apr 2023 17:17:16 +0000 (19:17 +0200)] 
mkosi: indent synopsis in --help by two spaces

This way the commands align to the options table. It just
looks better™.

2 years agomkosi: use pager for --help
Zbigniew Jędrzejewski-Szmek [Sun, 16 Apr 2023 17:14:02 +0000 (19:14 +0200)] 
mkosi: use pager for --help

2 years agomkosi: add --pager option and page summary
Zbigniew Jędrzejewski-Szmek [Sun, 16 Apr 2023 16:26:45 +0000 (18:26 +0200)] 
mkosi: add --pager option and page summary

This makes 'summary' behave similarly to various systemd and git commands that
start a pager whenever lengthy output is expected. The interesting part of the
summary is often near the top, paging makes it easier to immediately see the
interesting lines.

The pager is enabled by default (when on tty, etc.), but can be disabled with
--pager=no.

This copies the implementation I wrote for rpmautospec [1].
Same as in rpmautospec, we don't want to page normal output, but only stuff
like 'summary' and '--help', where we can generate the whole string upfront and
pass it to the built-in pager. The only tweak that is made is that $LESS is set
in the environment so that the output looks nice. $MKOSI_LESS can be used to
override the options if desired.

[1] https://pagure.io/fedora-infra/rpmautospec/c/8833528b70829a56a8c4a7094f6b9c5433d5face

When 'timedatectl' was ran with stdin=tty, stdout=PIPE, mkosi would get stopped
by SIGTTY. I don't understand why this happens — 'timedatectl' shouldn't touch
its stdin at all. Redirecting it from /dev/null solves the issue, and seems the
right thing to do anyway.

2 years agofedora: use dnf5 if available
Zbigniew Jędrzejewski-Szmek [Sat, 15 Apr 2023 14:53:58 +0000 (16:53 +0200)] 
fedora: use dnf5 if available

Fedora plans to switch to dnf5 for F40. For now, the new binary is called
'dnf5', and the old 'dnf'. Let's try to call 'dnf5' if available. It is
generally faster. E.g.
'mkosi build' in the mkosi directory after all packages have been downloaded:
   950 ms with dnf5
  1350 ms with dnf

Dnf5 also doesn't download file metadata by default, so it'll be faster if
downloads are necessary too.

Let's try the new shiny to save some time on installations.

For some reason, dnf5 doesn't like it if command options are before the
command. Old dnf is fine with either order, so let's just move the command
earlier.

2 years agoMerge pull request #1432 from DaanDeMeyer/install-packages
Daan De Meyer [Sat, 15 Apr 2023 17:38:14 +0000 (19:38 +0200)] 
Merge pull request #1432 from DaanDeMeyer/install-packages

Package installation streamlining

2 years agoMount over passwd and related files from host 1432/head
Daan De Meyer [Fri, 14 Apr 2023 08:36:22 +0000 (10:36 +0200)] 
Mount over passwd and related files from host

Package managers have the annoying quirk that they use the user
and group information from the host system instead of the user and
group information from the chroot. As a workaround, in
run_with_apivfs(), let's overmount the files from the host with the
ones from the root if they exist.

Let's also always install a distribution in 2 steps. First, we install
the package that provides passwd. Then, we install the rest of the
packages, during which passwd and related files will be overmounted.

2 years agoStreamline package installation
Daan De Meyer [Thu, 13 Apr 2023 12:19:12 +0000 (14:19 +0200)] 
Streamline package installation

Let's move most of the logic related to installing packages into
install_packages() for each distribution, and only keep the first
time installation stuff in install(). This allows us to move most
of the base_image checks out of the distribution specific files into
a single check in install_distribution() where if a base image is
provided, we call install_packages(). Otherwise, we call install().

2 years agoSet more apt options in apt config
Daan De Meyer [Fri, 14 Apr 2023 14:29:44 +0000 (16:29 +0200)] 
Set more apt options in apt config

2 years agoChange invoke_apt() Iterable argument to Sequence
Daan De Meyer [Fri, 14 Apr 2023 14:27:42 +0000 (16:27 +0200)] 
Change invoke_apt() Iterable argument to Sequence

2 years agoDrop unused stdout argument from invoke_apt()
Daan De Meyer [Fri, 14 Apr 2023 14:25:42 +0000 (16:25 +0200)] 
Drop unused stdout argument from invoke_apt()

2 years agoDrop syslog.service removal logic on centos
Daan De Meyer [Fri, 14 Apr 2023 14:23:26 +0000 (16:23 +0200)] 
Drop syslog.service removal logic on centos

Another case where we should stop mucking around with distro defaults
too much.

2 years agoDrop centos logic to rebuild database to bdb format
Daan De Meyer [Fri, 14 Apr 2023 14:21:49 +0000 (16:21 +0200)] 
Drop centos logic to rebuild database to bdb format

This image might just be a base image that's intended to be added
onto with sysexts and such. If so, we need to keep the database in
sqlite format so that it can still be written to by rpm on the host.
So let's leave the rebuilding to be done in a postinst script by the
user.

2 years agoDrop fedora authselect default selection
Daan De Meyer [Fri, 14 Apr 2023 08:22:20 +0000 (10:22 +0200)] 
Drop fedora authselect default selection

Let's not muck around with distro defaults after all. This is trivial
to fix in a postinst script and should be done there instead of by
default in mkosi.

2 years agoDrop dpkg docs removal logic
Daan De Meyer [Thu, 13 Apr 2023 11:35:48 +0000 (13:35 +0200)] 
Drop dpkg docs removal logic

We install minbase with debootstrap which should already be very
minimal, so if there's docs in there let's assume they're critical.

We already specify --no-install-recommends for apt which should
exclude docs packages as they're optional so there's no need for
dpkg specific overrides to exclude docs on top of that.

2 years agoStop install ca-certificates by default on Debian/Ubuntu
Daan De Meyer [Thu, 13 Apr 2023 11:33:06 +0000 (13:33 +0200)] 
Stop install ca-certificates by default on Debian/Ubuntu

Now that we run apt/dpkg on the host, we don't need ca-certificates
in the image anymore by default.

2 years agoSet dpkg unsafe-io differently
Daan De Meyer [Thu, 13 Apr 2023 11:27:58 +0000 (13:27 +0200)] 
Set dpkg unsafe-io differently

Let's use stuff that we don't have to clean up afterwards.

2 years agomkosi: "Manifest.json" → "json" in summary output
Zbigniew Jędrzejewski-Szmek [Sat, 15 Apr 2023 14:18:52 +0000 (16:18 +0200)] 
mkosi: "Manifest.json" → "json" in summary output

2 years agoMerge pull request #1438 from DaanDeMeyer/absolute-paths
Luca Boccassi [Sat, 15 Apr 2023 11:15:59 +0000 (12:15 +0100)] 
Merge pull request #1438 from DaanDeMeyer/absolute-paths

Use absolute paths everywhere

2 years agoChange debian default preset to "ignore *"
Daan De Meyer [Sat, 15 Apr 2023 06:46:21 +0000 (08:46 +0200)] 
Change debian default preset to "ignore *"

Instead of disabling all services on Debian, let's adopt the new
preset directive "ignore" which tells preset to ignore any matching
services (neither enable nor disable). This makes sure we don't
override any defaults set by individual Debian services. On older
systemd, preset will simply ignore any line it can't parse so this
doesn't break those systems but will only result in a harmless
warning message.

2 years agoBuild systemctl in the github action
Daan De Meyer [Fri, 14 Apr 2023 20:06:29 +0000 (22:06 +0200)] 
Build systemctl in the github action

To make sure systemctl understands to new ignore directive in preset.

2 years agoUse absolute paths everywhere 1438/head
Daan De Meyer [Fri, 14 Apr 2023 20:48:41 +0000 (22:48 +0200)] 
Use absolute paths everywhere

bwrap seems to run into permission errors with relative paths in
some cases so let's follow systemd best practices and convert all
config paths to absolute paths as we're parsing them.

Fixes #1430

2 years agoMake sure we have the same working directory in run_with_apivfs()
Daan De Meyer [Sat, 15 Apr 2023 06:29:04 +0000 (08:29 +0200)] 
Make sure we have the same working directory in run_with_apivfs()

By default, bubblewrap uses / as the working directory, let's make
sure that we remain in the same directory in run_with_apivfs().

2 years agoMerge pull request #1435 from DaanDeMeyer/opensuse-rework
Daan De Meyer [Fri, 14 Apr 2023 14:16:01 +0000 (16:16 +0200)] 
Merge pull request #1435 from DaanDeMeyer/opensuse-rework

Rework opensuse module

2 years agoMerge pull request #1434 from DaanDeMeyer/drop-more
Daan De Meyer [Fri, 14 Apr 2023 13:12:57 +0000 (15:12 +0200)] 
Merge pull request #1434 from DaanDeMeyer/drop-more

Drop --hostname and default locale configuration

2 years agoRework opensuse module 1435/head
Daan De Meyer [Fri, 14 Apr 2023 10:11:48 +0000 (12:11 +0200)] 
Rework opensuse module

Instead of doing everything via zypper, let's just write the repo
definition files ourselves directly. Also, to mimick what we do
with dnf, let's write the repo files outside of the root instead of
inside the root and leave installing repos inside the root up to
the user.

2 years agoFix doc typo
Daan De Meyer [Fri, 14 Apr 2023 12:17:13 +0000 (14:17 +0200)] 
Fix doc typo

2 years agoopensuse: Remove pam workaround
Daan De Meyer [Fri, 14 Apr 2023 10:09:25 +0000 (12:09 +0200)] 
opensuse: Remove pam workaround

Let's not muck around with distro defaults and leave this as
something to fix in opensuse itself.

2 years agoUse https for opensuse default mirror
Daan De Meyer [Fri, 14 Apr 2023 12:05:30 +0000 (14:05 +0200)] 
Use https for opensuse default mirror

2 years agoAdd some debugging for the Arch geo mirror
Daan De Meyer [Thu, 13 Apr 2023 18:05:34 +0000 (20:05 +0200)] 
Add some debugging for the Arch geo mirror

2 years agoDrop unused functions and variables 1434/head
Daan De Meyer [Thu, 13 Apr 2023 20:00:19 +0000 (22:00 +0200)] 
Drop unused functions and variables

2 years agoDrop --hostname and default locale configuration
Daan De Meyer [Thu, 13 Apr 2023 18:43:22 +0000 (20:43 +0200)] 
Drop --hostname and default locale configuration

These are trivial to configure manually and with credentials, so
let's drop the options for them.

2 years agoAdd --needed to pacman invocation
Daan De Meyer [Thu, 13 Apr 2023 08:04:44 +0000 (10:04 +0200)] 
Add --needed to pacman invocation

When installing build packages, we might install packages that were
already installed previously. Let's make sure we don't reinstall
those.

2 years agoMerge pull request #1422 from DaanDeMeyer/packages
Daan De Meyer [Wed, 12 Apr 2023 15:19:47 +0000 (17:19 +0200)] 
Merge pull request #1422 from DaanDeMeyer/packages

Remove --bootable, --base-packages and stop installing packages by default

2 years agoDrop --base-packages option 1422/head
Daan De Meyer [Thu, 6 Apr 2023 11:24:46 +0000 (13:24 +0200)] 
Drop --base-packages option

It's not necessary anymore now that we don't install any packages
by default anymore.

2 years agoStop installing openssh if --ssh is specified
Daan De Meyer [Thu, 6 Apr 2023 11:17:25 +0000 (13:17 +0200)] 
Stop installing openssh if --ssh is specified

This way, we don't install any extra packages by default and the full
list of packages is left entirely up to the user.

2 years agoRemove --bootable option
Daan De Meyer [Thu, 6 Apr 2023 11:11:57 +0000 (13:11 +0200)] 
Remove --bootable option

Instead, we just do the necessary setup for a bootable image if all
the required components are available in the image. In practice, this
means that if a user installs systemd-boot, the kernel, and dracut,
they'll get a bootable image.

2 years agoOnly install basic filesystem package by default
Daan De Meyer [Thu, 6 Apr 2023 09:27:24 +0000 (11:27 +0200)] 
Only install basic filesystem package by default

Let's trim down on the default packages we install, and only install
the most basic filesystem package by default. We'll leave everything
else up to the user.

This change is important when considering mkosi's use to build system
extensions and similar, where even the default packages we have now
are too much.

2 years agoSimplify autologin
Daan De Meyer [Fri, 7 Apr 2023 17:00:07 +0000 (19:00 +0200)] 
Simplify autologin

agetty actually has a -f option to skip pam authentication, so let's
use that instead of all the pam hacks to get autologin.

2 years agoAdd --die-with-parent when invoking bubblewrap
Daan De Meyer [Tue, 11 Apr 2023 12:49:19 +0000 (14:49 +0200)] 
Add --die-with-parent when invoking bubblewrap

rpm blocks most signals when doing a transaction. dnf doesn't block
anything. The end result is that when we do ctrl+c when dnf is running
the rpm transaction, dnf gets interrupted and exits, which means mkosi
exits and tries to remove the workspace directory on which rpm is still
operating, causing all kinds of nastiness.

Because we don't care about transaction safety since we're operating on
a chroot, let's add --die-with-parent when running bubblewrap. This makes
bubblewrap ensure cleanup of all child processes underneath it, and
because rpm can't ignore SIGKILL, it also cleans up rpm properly, fixing
the issue.

2 years agoFix typo
Daan De Meyer [Thu, 6 Apr 2023 12:19:37 +0000 (14:19 +0200)] 
Fix typo

2 years agoMerge pull request #1425 from DaanDeMeyer/stuff
Daan De Meyer [Fri, 7 Apr 2023 16:34:17 +0000 (18:34 +0200)] 
Merge pull request #1425 from DaanDeMeyer/stuff

Move more configuration parsing logic to config.py

2 years agoAdd PathExists= match 1425/head
Daan De Meyer [Fri, 7 Apr 2023 13:32:56 +0000 (15:32 +0200)] 
Add PathExists= match

It's also useful to be able to match against stuff that isn't the
current configuration. Let's add a PathExists= match that is satisfied
when the given path exists.

This will be useful in systemd where we conditionally build a kernel if
mkosi.kernel/ exists in the top level repo directory. With this setting,
we can only install the necessary packages to build the kernel if the
mkosi.kernel/ path actually exists.

2 years agoStop returning namespace in parse_config()
Daan De Meyer [Fri, 7 Apr 2023 13:27:51 +0000 (15:27 +0200)] 
Stop returning namespace in parse_config()

We don't use the return value at all so let's make it None.

2 years agoMove more configuration parsing logic to config.py
Daan De Meyer [Fri, 7 Apr 2023 12:39:37 +0000 (14:39 +0200)] 
Move more configuration parsing logic to config.py

2 years agoMake --repart-dir take a list of paths
Daan De Meyer [Fri, 7 Apr 2023 12:05:44 +0000 (14:05 +0200)] 
Make --repart-dir take a list of paths

systemd-repart supports multiple definition directories so let's
extend that to mkosi as well.

2 years agoIndicate required paths in list path settings
Daan De Meyer [Fri, 7 Apr 2023 12:04:34 +0000 (14:04 +0200)] 
Indicate required paths in list path settings

2 years agoMerge pull request #1424 from DaanDeMeyer/config
Daan De Meyer [Fri, 7 Apr 2023 11:26:04 +0000 (13:26 +0200)] 
Merge pull request #1424 from DaanDeMeyer/config

Rework configuration parsing ordering and overrides

2 years agoRework configuration parsing ordering and overrides 1424/head
Daan De Meyer [Fri, 7 Apr 2023 10:32:58 +0000 (12:32 +0200)] 
Rework configuration parsing ordering and overrides

Currently, aside from list based settings, if a setting is used
multiple times across different configuration files, the later
assignments override earlier assignments. On top of that, the CLI
arguments are parsed last and override everything from config files.

This has worked very well until now, but breaks now that we have
[Match] sections. If we override a setting using the CLI, we want
any configured [Match] sections to compare against the value specified
via the CLI. Because the CLI values are applied last, this currently
isn't the case.

Similarly, if we add 90-local.conf to override the distribution release
used for Debian, all the config files that are processed earlier will
still compare against the default release configured for Debian in
50-debian.conf. If we rename 90-local.conf to 00-local.conf, the default
release in 50-debian.conf will still override that value. Only by putting
the override after the config file that assigns the default release but
before the first config file that matches on that release can we make this
work, but depending on the configuration this might require a lot of
different override files which isn't ideal.

Also, because later values can override earlier ones, it's possible to have
[Match] sections that match against different values of the same setting
both apply, if the setting happens to be reassigned inbetween, which is not
intuitive and error prone. Ideally, [Match] settings only apply to the final
value of a setting.

To fix these problems, this commit reworks the way we order and override
settings. Instead of having later assignments override earlier ones, for
all settings aside from list settings, the first assignment is the one that
is used. All later assignments of the same setting are ignored. Along with, we
switch to parsing CLI arguments first, which means that any settings assigned
in CLI args take precedence over those configured in config files.

Because the first value is immediately the final value, any [Match] sections
will only ever see the final value. One caveat is default values for settings.
We only want to assign these at the end of parsing, if no value has been
explicitly configured, but we also want [Match] sections to apply to default
values if no value is explicitly configured. The solution to this is that if
we encounter a setting in a [Match] section and it has not been explicitly
assigned a value yet, it is assigned its default value.

For list based settings, ! now configures an ignore glob, which means that if any
later assignments try to assign values that match an ignore glob, those values
are ignored. We also prepend list values instead of appending so that list
values that are configured in a preceeding config file appear later in the final
list value than values configured in a later assignment.

Implementation wise, this commit reworks config parser functions to return the
new value that should be assigned instead of assigning it themselves. This makes
the config parsing functions slightly more generic.

2 years agoAdd back AutoBump config setting
Daan De Meyer [Fri, 7 Apr 2023 10:51:17 +0000 (12:51 +0200)] 
Add back AutoBump config setting

This was accidentally removed in an earlier commit.

2 years agoAllow missing secure boot key/cert if running genkey
Daan De Meyer [Thu, 6 Apr 2023 19:53:00 +0000 (21:53 +0200)] 
Allow missing secure boot key/cert if running genkey

2 years agoMerge pull request #1420 from DaanDeMeyer/config
Daan De Meyer [Thu, 6 Apr 2023 18:49:38 +0000 (20:49 +0200)] 
Merge pull request #1420 from DaanDeMeyer/config

Rework configuration parsing

2 years agoRework configuration parsing 1420/head
Daan De Meyer [Mon, 3 Apr 2023 09:51:33 +0000 (11:51 +0200)] 
Rework configuration parsing

Instead of messing with the internals of argparse, let's implement
proper configuration file parsing.

- Parsing classes and functions are located in a new file config.py
- Configuration settings are split up from CLI settings in a list of
the new ConfigSetting dataclass
- The CLI options for configuration settings now share the same
argparse setting which simply delegates parsing to the corresponding
configuration setting parser.
- We add support for [Match] sections to enable conditionally including
configuration files. Currently Match support is implemented for
Distribution= and Release=.
- Configuration file searching is reworked. In mkosi.conf.d/, we parse
all files ending with ".conf" and directories. If a directory is parsed,
we parse mkosi.conf, mkosi.conf.d/ and all mkosi specific paths in it.
All paths are interpreted relative to the directory that we're parsing.

2 years agoPrint cmdline in run() before doing fspath() conversion
Daan De Meyer [Mon, 3 Apr 2023 08:41:47 +0000 (10:41 +0200)] 
Print cmdline in run() before doing fspath() conversion

2 years agoRemove Additional Configuration Options argparse group
Daan De Meyer [Sun, 2 Apr 2023 19:10:15 +0000 (21:10 +0200)] 
Remove Additional Configuration Options argparse group

Let's move these settings to the top level group along with the other
CLI arguments that aren't really config.

2 years agoMove --auto-bump under Content section
Daan De Meyer [Sun, 2 Apr 2023 19:06:07 +0000 (21:06 +0200)] 
Move --auto-bump under Content section

Let's collocate --auto-bump with --image-version which it is closely
related to.