]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
11 months agoinitrd: add --show-documentation option 2990/head
Jörg Behrmann [Thu, 5 Sep 2024 14:52:01 +0000 (16:52 +0200)] 
initrd: add --show-documentation option

11 months agoMove show_docs to its own module
Jörg Behrmann [Thu, 5 Sep 2024 14:22:45 +0000 (16:22 +0200)] 
Move show_docs to its own module

11 months agodoc: make documentation command take an argument
Jörg Behrmann [Fri, 30 Aug 2024 09:13:39 +0000 (11:13 +0200)] 
doc: make documentation command take an argument

Also let's leave out errors if things don't work, but we're still trying. This
way the last message "No manual entry for foo" will bubble up.

11 months agoMerge pull request #3005 from DaanDeMeyer/mypy
Daan De Meyer [Thu, 5 Sep 2024 13:34:13 +0000 (15:34 +0200)] 
Merge pull request #3005 from DaanDeMeyer/mypy

Various mypy fixes

11 months agoDon't delete reader in _tempfile() backport 3005/head
Daan De Meyer [Thu, 5 Sep 2024 12:30:52 +0000 (14:30 +0200)] 
Don't delete reader in _tempfile() backport

This is only passed Path.read_bytes so there is nothing to delete
hence drop this part since it confuses mypyc.

11 months agoMark all class variables as Final
Daan De Meyer [Thu, 5 Sep 2024 12:30:24 +0000 (14:30 +0200)] 
Mark all class variables as Final

11 months agoAnnotate two more variables that need it
Daan De Meyer [Thu, 5 Sep 2024 12:30:03 +0000 (14:30 +0200)] 
Annotate two more variables that need it

11 months agoMove KeySource.Type out of KeySource
Daan De Meyer [Thu, 5 Sep 2024 12:28:47 +0000 (14:28 +0200)] 
Move KeySource.Type out of KeySource

We've done this for our other nested classes as well, so let's do
it for KeySource.Type as well.

11 months agouser: Drop lru_cache() for home() and name()
Daan De Meyer [Thu, 5 Sep 2024 11:48:49 +0000 (13:48 +0200)] 
user: Drop lru_cache() for home() and name()

Not required anymore now that we don't change user anymore.

11 months agoMove code backported from cpython upstream to backport.py
Daan De Meyer [Thu, 5 Sep 2024 11:45:59 +0000 (13:45 +0200)] 
Move code backported from cpython upstream to backport.py

11 months agoDrop listify()
Daan De Meyer [Thu, 5 Sep 2024 11:34:46 +0000 (13:34 +0200)] 
Drop listify()

Causes issues with mypyc and wrapping the callsites in list() isn't
really any worse when it comes to readability.

11 months agomypy: Disable allow_redefinition
Daan De Meyer [Thu, 5 Sep 2024 11:03:05 +0000 (13:03 +0200)] 
mypy: Disable allow_redefinition

Let's not allow redefining variables with different types. Even
when allowed it causes issues with mypy so we're better off just
disabling it.

11 months agoFix mypyc warnings in sandbox.py
Daan De Meyer [Thu, 5 Sep 2024 11:09:35 +0000 (13:09 +0200)] 
Fix mypyc warnings in sandbox.py

Fixes the following two warnings when compiling sandbox.py with mypyc:

"""
➜  mkosi git:(mypy) mypyc mkosi/sandbox.py
mkosi/sandbox.py:356: warning: Treating generator comprehension as list
mkosi/sandbox.py:446: warning: Unsupported default attribute value
"""

11 months agosandbox: Use separate variable name when we change types
Daan De Meyer [Thu, 5 Sep 2024 10:35:46 +0000 (12:35 +0200)] 
sandbox: Use separate variable name when we change types

11 months agoMerge pull request #3003 from DaanDeMeyer/initrd
Daan De Meyer [Thu, 5 Sep 2024 10:34:27 +0000 (12:34 +0200)] 
Merge pull request #3003 from DaanDeMeyer/initrd

Various mkosi-initrd fixes

11 months agomkosi-initrd: Ignore gnupg subdirectory 3003/head
Daan De Meyer [Thu, 5 Sep 2024 09:55:37 +0000 (11:55 +0200)] 
mkosi-initrd: Ignore gnupg subdirectory

/etc/pacman.d/gnupg is already made available by mkosi's internal
logic so we don't need to copy it in. This prevents failures when
running unprivileged as /etc/pacman.d/gnupg can have rather strict
permissions.

11 months agomkosi-initrd: Only set --cacheonly=metadata when running as root
Daan De Meyer [Thu, 5 Sep 2024 09:47:10 +0000 (11:47 +0200)] 
mkosi-initrd: Only set --cacheonly=metadata when running as root

If we're not running as root, we don't use the host's package cache,
but we still use the host's repositories. It's very unlikely that the
user's default package cache directory will have an up-to-date repository
metadata snapshot, so let's update the repository metadata if we're not
running as root.

11 months agomkosi-initrd: Add --debug-shell argument
Daan De Meyer [Thu, 5 Sep 2024 09:46:22 +0000 (11:46 +0200)] 
mkosi-initrd: Add --debug-shell argument

This is passed through directly to mkosi. To make this work we also
pass through stdout/stdin directly to the invoked mkosi process.

11 months agoMerge pull request #3002 from DaanDeMeyer/cherry-pick
Daan De Meyer [Thu, 5 Sep 2024 09:43:57 +0000 (11:43 +0200)] 
Merge pull request #3002 from DaanDeMeyer/cherry-pick

Various commits from #2990

11 months agonews: add note to change where the manual pages are 3002/head
Jörg Behrmann [Fri, 30 Aug 2024 09:36:02 +0000 (11:36 +0200)] 
news: add note to change where the manual pages are

11 months agoinitrd: flatten module into a single file
Jörg Behrmann [Fri, 30 Aug 2024 09:31:46 +0000 (11:31 +0200)] 
initrd: flatten module into a single file

11 months agosandbox: flatten module into a single file
Jörg Behrmann [Fri, 30 Aug 2024 09:30:00 +0000 (11:30 +0200)] 
sandbox: flatten module into a single file

11 months agocli: add missing completion stubs to pyproject.toml
Jörg Behrmann [Fri, 30 Aug 2024 09:23:24 +0000 (11:23 +0200)] 
cli: add missing completion stubs to pyproject.toml

11 months agodoc: move man pages to resources/man
Jörg Behrmann [Fri, 30 Aug 2024 09:16:50 +0000 (11:16 +0200)] 
doc: move man pages to resources/man

11 months agocli: use ellipsis ligature instead of writing out ...
Jörg Behrmann [Fri, 30 Aug 2024 09:06:15 +0000 (11:06 +0200)] 
cli: use ellipsis ligature instead of writing out ...

11 months agoMove various functions to bootloader.py
Daan De Meyer [Wed, 4 Sep 2024 13:44:55 +0000 (15:44 +0200)] 
Move various functions to bootloader.py

Our main file is growing too large again, so let's split off a bunch
of bootloader stuff into bootloader.py

This is very rough, the kernel stuff should probably move somewhere
else as well, but I wanted to move stuff without actually changing
code.

11 months agoUpdate NEWS.md
Daan De Meyer [Wed, 4 Sep 2024 13:18:37 +0000 (15:18 +0200)] 
Update NEWS.md

11 months agoSimplify package cache dir mirror key
Daan De Meyer [Wed, 4 Sep 2024 10:25:00 +0000 (12:25 +0200)] 
Simplify package cache dir mirror key

Let's just replace slashes with hyphens.

11 months agoMerge pull request #2998 from DaanDeMeyer/ci
Daan De Meyer [Wed, 4 Sep 2024 08:04:13 +0000 (10:04 +0200)] 
Merge pull request #2998 from DaanDeMeyer/ci

ci: Enable debug logging for systemd-repart

11 months agobase64 encode mirror if we put it in package cache dir key
Daan De Meyer [Tue, 3 Sep 2024 20:55:33 +0000 (22:55 +0200)] 
base64 encode mirror if we put it in package cache dir key

Mirrors contain / characters. Paths can't contain / characters. Let's
base64 encode the mirrors to avoid this issue.

11 months agotests: Show debug messages on console 2998/head
Daan De Meyer [Wed, 4 Sep 2024 07:14:57 +0000 (09:14 +0200)] 
tests: Show debug messages on console

Should help debug the spurious OpenSUSE CI failures.

11 months agoci: Drop machine-id commit timeout drop-in
Daan De Meyer [Wed, 4 Sep 2024 07:09:31 +0000 (09:09 +0200)] 
ci: Drop machine-id commit timeout drop-in

Let's see if we still need this.

11 months agoAdd 'login' to Debian/Ubuntu/Kali package list
Luca Boccassi [Tue, 3 Sep 2024 08:10:45 +0000 (09:10 +0100)] 
Add 'login' to Debian/Ubuntu/Kali package list

The login package as provided by util-linux is 'Protected' but no
longer 'Essential' and that's intentional, so it will not be pulled
in by default. Add it to the list.

11 months agoBump github/codeql-action from 3.25.15 to 3.26.6
dependabot[bot] [Sun, 1 Sep 2024 22:29:52 +0000 (22:29 +0000)] 
Bump github/codeql-action from 3.25.15 to 3.26.6

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.15 to 3.26.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/afb54ba388a7dca6ecae48f608c4ff05ff4cc77a...4dd16135b69a43b6c8efb853346f8437d92d3c93)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
11 months agoMerge pull request #2993 from keszybz/cat-config
Daan De Meyer [Sat, 31 Aug 2024 13:48:53 +0000 (15:48 +0200)] 
Merge pull request #2993 from keszybz/cat-config

Add cat-config verb

11 months agoReformat comments and shorten error messages 2993/head
Zbigniew Jędrzejewski-Szmek [Sat, 31 Aug 2024 07:25:37 +0000 (10:25 +0300)] 
Reformat comments and shorten error messages

11 months agodocs: describe cat-config
Zbigniew Jędrzejewski-Szmek [Sat, 31 Aug 2024 08:51:01 +0000 (11:51 +0300)] 
docs: describe cat-config

Also adjust surrounding text a bit.

11 months agoAdd new 'cat-config' verb
Zbigniew Jędrzejewski-Szmek [Sat, 31 Aug 2024 07:16:41 +0000 (10:16 +0300)] 
Add new 'cat-config' verb

This is similar to 'systemd-analyze cat-config'. With many config
files, it can be a bit difficult to figure out where some setting is
set.

11 months agoShortcut chase() if root == "/"
Daan De Meyer [Sat, 31 Aug 2024 09:31:48 +0000 (11:31 +0200)] 
Shortcut chase() if root == "/"

11 months agoconfig: match against verb value not verb name
Zbigniew Jędrzejewski-Szmek [Sat, 31 Aug 2024 07:25:01 +0000 (10:25 +0300)] 
config: match against verb value not verb name

For the existing verbs, those are the same. But for a verb with
a dash, which I want to add next, the name has the underscore,
which will not match the verb on the commandline.

11 months agoMerge pull request #2991 from DaanDeMeyer/fix
Jörg Behrmann [Fri, 30 Aug 2024 11:29:48 +0000 (13:29 +0200)] 
Merge pull request #2991 from DaanDeMeyer/fix

Don't change the working directory in chase()

11 months agoDon't change the working directory in chase() 2991/head
Daan De Meyer [Fri, 30 Aug 2024 09:49:20 +0000 (11:49 +0200)] 
Don't change the working directory in chase()

11 months agoAdd missing return type declaration
Daan De Meyer [Fri, 30 Aug 2024 09:49:07 +0000 (11:49 +0200)] 
Add missing return type declaration

11 months agoMerge pull request #2986 from behrmann/nochown
Jörg Behrmann [Fri, 30 Aug 2024 09:02:35 +0000 (11:02 +0200)] 
Merge pull request #2986 from behrmann/nochown

sandbox: introduce the MKOSI_CHROOT_SUPPRESS_CHOWN variable

11 months agoMerge pull request #2989 from DaanDeMeyer/azure
Daan De Meyer [Fri, 30 Aug 2024 08:59:34 +0000 (10:59 +0200)] 
Merge pull request #2989 from DaanDeMeyer/azure

Detect Azure Linux properly

11 months agoOnly run sync scripts if we're going to build the image
Daan De Meyer [Thu, 29 Aug 2024 15:59:21 +0000 (17:59 +0200)] 
Only run sync scripts if we're going to build the image

11 months agoDetect Azure Linux properly 2989/head
Daan De Meyer [Thu, 29 Aug 2024 20:29:03 +0000 (22:29 +0200)] 
Detect Azure Linux properly

Fixes #2988

11 months agoazure: Don't try to install erofs-utils
Daan De Meyer [Fri, 30 Aug 2024 08:20:14 +0000 (10:20 +0200)] 
azure: Don't try to install erofs-utils

It's not actually available yet.

11 months agoInline apivfs_script_cmd 2986/head
Jörg Behrmann [Thu, 29 Aug 2024 09:05:37 +0000 (11:05 +0200)] 
Inline apivfs_script_cmd

11 months agosandbox: introduce the MKOSI_CHROOT_SUPPRESS_CHOWN variable
Jörg Behrmann [Wed, 28 Aug 2024 16:18:41 +0000 (18:18 +0200)] 
sandbox: introduce the MKOSI_CHROOT_SUPPRESS_CHOWN variable

This allows suppressing chowns in scripts. Also inline chroot_script_cmd since
it only as a single user.

11 months agoFix typo
Daan De Meyer [Wed, 28 Aug 2024 08:14:35 +0000 (10:14 +0200)] 
Fix typo

We were resetting the list on every iteration of the loop when using
ephemeral build sources which is obviously wrong.

11 months agoMerge pull request #2984 from DaanDeMeyer/sandbox
Daan De Meyer [Wed, 28 Aug 2024 07:44:36 +0000 (09:44 +0200)] 
Merge pull request #2984 from DaanDeMeyer/sandbox

Don't mount stuff twice from different sources in sandbox

11 months agoMount /etc/ld.so.cache into the sandbox if it exists 2984/head
Daan De Meyer [Wed, 28 Aug 2024 07:20:23 +0000 (09:20 +0200)] 
Mount /etc/ld.so.cache into the sandbox if it exists

Otherwise libraries in non-standard locations won't be found at runtime.

11 months agoDon't mount stuff twice from different sources in sandbox
Daan De Meyer [Wed, 28 Aug 2024 06:53:57 +0000 (08:53 +0200)] 
Don't mount stuff twice from different sources in sandbox

We were mounting /var/tmp and /etc/resolv.conf twice in chroot_cmd(),
let's make sure we avoid doing that by moving the CLI options into
the respective _script_cmd() functions.

11 months agoUse system python if python binary is interpreter is not in /usr
Daan De Meyer [Tue, 27 Aug 2024 15:05:03 +0000 (17:05 +0200)] 
Use system python if python binary is interpreter is not in /usr

Same fix as #2982, but for the python_binary() function.

11 months agoSpecify --noprep when building rpms from source
Daan De Meyer [Tue, 27 Aug 2024 11:04:48 +0000 (13:04 +0200)] 
Specify --noprep when building rpms from source

rpm upstream is moving in this direction as well so let's update our
docs to match.

11 months agoUse python3 in sandbox if host interpreter is not in /usr
Daan De Meyer [Tue, 27 Aug 2024 12:57:48 +0000 (14:57 +0200)] 
Use python3 in sandbox if host interpreter is not in /usr

We only mount /usr into the sandbox, so if mkosi is invoked from a
venv we'll fail to execute the apivfs script or chroot script in the
sandbox as it will try to use an interpreter that isn't available.

Let's check if the used interpreter is relative to /usr and only use
it to execute the chroot and apivfs scripts in the sandbox if it is.

11 months agoMerge pull request #2980 from DaanDeMeyer/sync-scripts
Jörg Behrmann [Tue, 27 Aug 2024 10:42:48 +0000 (12:42 +0200)] 
Merge pull request #2980 from DaanDeMeyer/sync-scripts

Run sync scripts for all images again

11 months agoRun sync scripts for all images again 2980/head
Daan De Meyer [Tue, 27 Aug 2024 09:12:50 +0000 (11:12 +0200)] 
Run sync scripts for all images again

Fixes https://github.com/systemd/mkosi/commit/af66d2391b17d21b6892759e4f4f97684ba1945b

11 months agoMake running sync scripts possible without a context
Daan De Meyer [Tue, 27 Aug 2024 09:10:17 +0000 (11:10 +0200)] 
Make running sync scripts possible without a context

11 months agoMove sandbox tree logic into Config.sandbox()
Daan De Meyer [Tue, 27 Aug 2024 09:08:40 +0000 (11:08 +0200)] 
Move sandbox tree logic into Config.sandbox()

11 months agoRename internal pkgmngr dir to sandbox_tree
Daan De Meyer [Tue, 27 Aug 2024 08:51:45 +0000 (10:51 +0200)] 
Rename internal pkgmngr dir to sandbox_tree

11 months agodocs: Sort list of universal settings
Daan De Meyer [Tue, 27 Aug 2024 08:42:13 +0000 (10:42 +0200)] 
docs: Sort list of universal settings

11 months agoman: mention the empty arguments in help
Zbigniew Jędrzejewski-Szmek [Mon, 26 Aug 2024 16:08:43 +0000 (19:08 +0300)] 
man: mention the empty arguments in help

The autogenerated help for --distribution/--format/… looks like {a,b,…,} (with
an emtpy arg at the end), and it is not obvious what this means. Describe the
empty args in the man page.

11 months agoazure: Deal with repository changes
Daan De Meyer [Mon, 26 Aug 2024 09:41:54 +0000 (11:41 +0200)] 
azure: Deal with repository changes

The preview repositories are now a layer on top of the prod repositories,
so let's adapt mkosi to that.

11 months agoDon't skip build if output format is "none"
Daan De Meyer [Mon, 26 Aug 2024 08:35:23 +0000 (10:35 +0200)] 
Don't skip build if output format is "none"

If the output format is none we always want to rebuild.

11 months agoRework grub conditions
Daan De Meyer [Mon, 26 Aug 2024 09:16:47 +0000 (11:16 +0200)] 
Rework grub conditions

- Use -o instead of || as it's unclear whether || is supported or not
- Use quotes more
- Use [ ] as alias for test

Fixes #2974

11 months agoman: fix SourceDateEpoch= section
Antonio Alvarez Feijoo [Mon, 26 Aug 2024 08:26:37 +0000 (10:26 +0200)] 
man: fix SourceDateEpoch= section

11 months agoMerge pull request #2973 from DaanDeMeyer/metadata
Daan De Meyer [Fri, 23 Aug 2024 20:13:17 +0000 (22:13 +0200)] 
Merge pull request #2973 from DaanDeMeyer/metadata

Rework repository metadata handling

11 months agoMake more trees required 2973/head
Daan De Meyer [Fri, 23 Aug 2024 18:34:23 +0000 (20:34 +0200)] 
Make more trees required

- Tools tree is a universal setting and has to be available at the start
- Sandbox trees are a universal setting and have to be available at the start
- Skeleton trees should be available at the start to make sure caching works
  properly

11 months agoRename package manager trees to sandbox trees
Daan De Meyer [Fri, 23 Aug 2024 18:28:05 +0000 (20:28 +0200)] 
Rename package manager trees to sandbox trees

The package manager trees are mounted in for every command we run
so let's rename them to sandbox trees instead of package manager
trees.

11 months agoRework repository metadata handling
Daan De Meyer [Fri, 23 Aug 2024 17:01:46 +0000 (19:01 +0200)] 
Rework repository metadata handling

- Stop copying repository metadata into the image.

This is too fragile to ever work properly. If the image is ever
used as a base tree, the caller would also need the exact same package
manager configuration for this to be remotely useful, as well as constantly
rebuild the image to keep the repository metadata up to date.

- Stop picking up repository metadata from the image

For the same reason, we can't use repository metadata from any
base trees automatically. It should be explicitly provided by the user
along with the required package manager configuration.

- Share the same repository metadata snapshot between the main and subimage
  builds

Let's ensure that the main image and all subimages are built of the
exact same repository metadata snapshot. Now that we enforce that all
subimages use the same distro, release, architecture, repositories and
everything else that's package manager related, we can use the same
metadata snapshot for every build.

- Rename package_cache_dir in Context to metadata_dir as there's only
metadata in this directory and never any packages.

11 months agoDo not allow configuring universal collection based settings in subimages
Daan De Meyer [Fri, 23 Aug 2024 17:00:09 +0000 (19:00 +0200)] 
Do not allow configuring universal collection based settings in subimages

For the next commit, we want to enforce all subimages to use the same
package manager trees, repositories and package directories, so let's
not allow adding any extra of those in subimages anymore.

11 months agoSimplify run_verb() logic
Daan De Meyer [Fri, 23 Aug 2024 16:44:04 +0000 (18:44 +0200)] 
Simplify run_verb() logic

- Handle Verb.clean separately from builds
- Move most checks to the front before we clean up the previous results.
- Get rid of check_outputs()
- If main image needs a build, clean all subimages as well

11 months agoPrepend extra search paths to $PATH earlier
Daan De Meyer [Thu, 22 Aug 2024 19:35:47 +0000 (21:35 +0200)] 
Prepend extra search paths to $PATH earlier

We should do this before checking if tools are available to make
sure the tools in extra search paths are taken into account.

11 months agoDon't fork for run_sync()
Daan De Meyer [Thu, 22 Aug 2024 18:27:56 +0000 (20:27 +0200)] 
Don't fork for run_sync()

Not required so let's be more efficient by not forking

11 months agoAdd missing directory checks in copy_tree()
Daan De Meyer [Thu, 22 Aug 2024 13:46:06 +0000 (15:46 +0200)] 
Add missing directory checks in copy_tree()

11 months agoci: Disable Arch Linux image with Ubuntu tools tree
Daan De Meyer [Thu, 22 Aug 2024 13:06:35 +0000 (15:06 +0200)] 
ci: Disable Arch Linux image with Ubuntu tools tree

archlinux-keyring in Ubuntu Noble is already too old. Until it's
updated, let's disable the CI build.

For the Github Action we add the kernel-utils ppa which does have
an updated archlinux-keyring.

11 months agofedora: Get rawhide GPG key from github
Daan De Meyer [Thu, 22 Aug 2024 10:10:50 +0000 (12:10 +0200)] 
fedora: Get rawhide GPG key from github

fedora.gpg is always out-of-date when rawhide branches, so let's
instead fetch the rawhide key from distribution-gpg-keys on Github
which does seem to get updated before rawhide branches.

11 months agoMerge pull request #2967 from DaanDeMeyer/fix
Daan De Meyer [Thu, 22 Aug 2024 12:52:34 +0000 (14:52 +0200)] 
Merge pull request #2967 from DaanDeMeyer/fix

Two fixes

11 months agoMove creation of context.root out of Context() 2967/head
Daan De Meyer [Thu, 22 Aug 2024 11:42:20 +0000 (13:42 +0200)] 
Move creation of context.root out of Context()

On btrfs systems, we're unnecessarily creating a subvolume only to
remove it again immediately afterwards if we're building from a cached
image. So let's move the creation of root outside of Context() so
we can only create it as a subvolume after we've potentially checked
caches first.

11 months agoDon't run run_clean() in a forked child anymore
Daan De Meyer [Thu, 22 Aug 2024 11:43:33 +0000 (13:43 +0200)] 
Don't run run_clean() in a forked child anymore

No need anymore so let's not fork unnecessarily.

11 months agoOptimize copy_tree() a little
Daan De Meyer [Thu, 22 Aug 2024 11:18:30 +0000 (13:18 +0200)] 
Optimize copy_tree() a little

Only run cp_version() if we absolutely need to. If we do a btrfs
snapshot or the destination does not exist or is empty, there's no
need to add --keep-directory-symlink and thus we don't need to run
cp_version() either.

11 months agoMerge pull request #2833 from DaanDeMeyer/azure
Daan De Meyer [Thu, 22 Aug 2024 10:51:56 +0000 (12:51 +0200)] 
Merge pull request #2833 from DaanDeMeyer/azure

Add support for Azure Linux

11 months agoAdd support for Azure Linux 2833/head
Daan De Meyer [Thu, 4 Jul 2024 12:34:17 +0000 (14:34 +0200)] 
Add support for Azure Linux

Azure Linux looks a lot like Fedora Linux so we opt to share configuration
between Azure and Fedora/CentOS and inherit the Azure definition from
Fedora.

11 months agoFix fixup_vmlinuz_location()
Daan De Meyer [Thu, 4 Jul 2024 12:30:52 +0000 (14:30 +0200)] 
Fix fixup_vmlinuz_location()

We have to resolve the path before we check if the symlink is relative
to /boot.

11 months agoSpecify --renumber-inodes when calling cpio
Daan De Meyer [Thu, 22 Aug 2024 08:22:41 +0000 (10:22 +0200)] 
Specify --renumber-inodes when calling cpio

This helps with making initrds reproducible as the sequence of inodes
will always be stable starting from 1.

11 months agoMerge pull request #2956 from DaanDeMeyer/var
Daan De Meyer [Thu, 22 Aug 2024 09:28:48 +0000 (11:28 +0200)] 
Merge pull request #2956 from DaanDeMeyer/var

Introduce mkosi-sandbox and stop using subuids for image builds

11 months agoIntroduce mkosi-sandbox and stop using subuids for image builds 2956/head
Daan De Meyer [Fri, 16 Aug 2024 21:41:49 +0000 (23:41 +0200)] 
Introduce mkosi-sandbox and stop using subuids for image builds

Over the last years, we've accumulated a rather nasty set of workarounds
for various issues in bubblewrap:

- We contributed setpgid to util-linux and use it if available because
  bubblewrap does not support making its child process the foreground
  process.
- We added the innerpid logic to run() because bubblewrap does not forward
  signals to the separate child process it runs in the sandbox which meant
  they were getting SIGKILLed when we killed bubblewrap, preventing proper
  cleanup from happening.
- bubblewrap does not provide a proper way to detect whether the command
  was found in the sandbox or not, which meant we had to execute command -v
  within the sandbox separately to check whether the command exists or not.
- We had to add extra logic to make sure / was a mount in the initramfs to
  allow running mkosi in the initramfs as bubblewrap does not fall back to
  MS_MOVE if pivot_root() doesn't work.
- We had to stitch together shell invocations after bubblewrap but before
  executing the actual command we want to run to make sure directories had
  the correct mode as bubblewrap creates everything with mode 0700 which was
  too restrictive in many cases for us. This was fixed with new --perms and
  --chmod options in bubblewrap 0.5 but we had to keep compat with 0.4
  because that's what's shipped in CentOS Stream 9.
- We had to figure out a shell hack to do overlayfs mounts as these are not
  supported by bubblewrap (even though a PR for the feature has been open for
  years).
- We had to introduce a Mount struct to pass around mounts so we could deduplicate
  and sort them before passing them to bubblewrap as bubblewrap did not do this
  itself.
- Debugging all the above was made all the harder by the fact that bubblewrap's
  source code is full of tech debt from its history of being a setuid tool
  instead of using user namespaces. Getting any fixes into upstream is almost
  impossible as the tool is practically unmaintained.

Aside from bubblewrap, our other source of troubles has been newuidmap/newgidmap.
Running as a user within the subuid range configured in /etc/sub{u,g}id has
meant we're constantly fixing ownership and permissions issues where stuff needs
to be chowned and chmodded everywhere to make sure the current user and the
subuid user can access the proper files. Another unfortunate side effect is that
users end up with many files owned by the subuid root user in their home
directories when building images with mkosi;

Let's fix all these issues at once by getting rid of bubblewrap and
newuidmap/newgidmap.

bubblewrap is replaced with a new tool mkosi-sandbox. It looks and behaves a
lot like bubblewrap, except it's much less code and much more flexible to fit
our needs, allowing us to get rid of all the hacks we've built up over the years to
work around issues that didn't get fixed in bubblewrap.

To get rid of newuidmap/newgidmap, a rework of our user namespacing was needed.
The need to use newuidmap/newgidmap came from the assumption that we need a full
65k subuid range to do unprivileged image builds, as distributions ship packages
containing files and directories that are not owned by the root user. After some
investigation, it turns out that there's very few files and directories not owned
by root in distribution packages if you ignore /var. If we could temporarily
ignore the ownership on these files and directories until we can get distributions
to only ship root owned files in /usr and /etc of their packages, we could simply
map the current user to root in a user namespace and get rid of the subuid range
completely.

Turns out that's possible with a seccomp filter. seccomp allows you to make all
chown() syscalls succeed without actually doing anything. The files and directories
end up owned by the root user instead. If we assume this is OK and are OK with
instructing users to use tmpfiles to fix up the permissions on first boot if needed,
a seccomp filter like this is sufficient to allow us to get rid of doing image
builds within a subuid user namespace.

It turns out we can go one step further. It turns out that for the majority of
the image build, one doesn't actually need to be the root user. Only package
managers and systemd-repart need the current user to be mapped to root to do their
job correctly. The reason we did the entire build mapped to root until now was
that we need to do a few mounts as part of the image build process and for now
I was under the assumption that you needed to be root for that. It turns out that
when you unshare a user namespace, you get a full set of capabilities regardless
of whether you're root or some other uid in the user namespace. The only difference
is that when you exec a subprocess as root, the capabilities aren't lost, whereas
they are when you exec a subprocess as a non-root user. This can be avoided by
adding the capabilities of the non-root user to the inheritable and ambient set.
Once that's done, any subprocess exec'd by a non-root user in the user namespace
can mount as many bind and overlay mounts as they can think of.

The above allows us to run most of the image build under the current user uid
instead of root, only switching to root when running package managers, invoking
systemd-repart or systemd-tmpfiles, or when chroot-ing into the image. This allows
us to get rid of various hacks we had to look up the proper user name or home
directory.

Specifically, we can get rid of the following:

- mkosi-as-caller can become a noop since we now by default run the build as the
  caller.
- Lots of chmod()'s and chown()'s can be removed
- All uses of INVOKING_USER.uid/gid can be removed, and most can be replaced with
  simple os.getuid()/os.getgid()
- We can use /etc/passwd and /etc/group from the host instead of building our own
- We can get rid of the Acl= option as the user will now be able to remove (almost)
  all files written by mkosi.
- We don't have to rchown the package manager cache directory anymore after each
  build. Root user builds will now use the system cache instead of the per user
  cache.
- We can get rid of the Mount struct as mkosi-sandbox dedups and sorts operations
  itself.

One thing to note is that if we're invoked as root, none of the seccomp or capabilities
stuff applies and it is all skipped as it's not required in that case. This means that
when building as root it's still possible to have more than one user in the generated
image unlike when building unprivileged. Also note that users can still be added to
/etc/passwd and such, they just can't own any files or directories in the image itself
until the image is booted.

11 months agoSet DEFAULT_HOSTNAME in os-release when specified (fixes #2673)
Septatrix [Tue, 20 Aug 2024 19:05:02 +0000 (21:05 +0200)] 
Set DEFAULT_HOSTNAME in os-release when specified (fixes #2673)

11 months agoapt: Remove mounts argument from invoke()
Daan De Meyer [Wed, 21 Aug 2024 06:17:51 +0000 (08:17 +0200)] 
apt: Remove mounts argument from invoke()

11 months agoMerge pull request #2954 from NekkoDroid/executable-mkosi-version
Daan De Meyer [Tue, 20 Aug 2024 10:42:17 +0000 (12:42 +0200)] 
Merge pull request #2954 from NekkoDroid/executable-mkosi-version

Add executable `mkosi.version` support for generating the version dynamically

11 months agoClean up version bump logic 2954/head
Michael Ferrari [Wed, 14 Aug 2024 20:19:00 +0000 (22:19 +0200)] 
Clean up version bump logic

11 months agoAdd executable `mkosi.version` support
Michael Ferrari [Wed, 7 Aug 2024 09:37:48 +0000 (11:37 +0200)] 
Add executable `mkosi.version` support

`mkosi.version` is executed during configuration parsing, as opposed
to reading the contents of `mkosi.version`. This allows querying the
version before the build without needing to manually adjust the version
beforehand.

This allows using date based versioning by writing a script outputting
`date '+%Y-%m-%d'` or using git tag based versioning by outputting
`git describe --tags`.

11 months agoDo not generate random seed when running bootctl install
Daan De Meyer [Mon, 19 Aug 2024 13:15:40 +0000 (15:15 +0200)] 
Do not generate random seed when running bootctl install

11 months agoDon't include excluded subimages in default dependencies
Daan De Meyer [Mon, 19 Aug 2024 11:22:54 +0000 (13:22 +0200)] 
Don't include excluded subimages in default dependencies

11 months agoMerge pull request #2959 from DaanDeMeyer/split
Jörg Behrmann [Mon, 19 Aug 2024 08:53:13 +0000 (10:53 +0200)] 
Merge pull request #2959 from DaanDeMeyer/split

Various improvements

11 months agoci: Add missing shebangs 2959/head
Daan De Meyer [Fri, 16 Aug 2024 22:47:56 +0000 (00:47 +0200)] 
ci: Add missing shebangs

No clue how this worked before.

11 months agoci: Improve formatting a bit
Daan De Meyer [Fri, 16 Aug 2024 22:47:17 +0000 (00:47 +0200)] 
ci: Improve formatting a bit

11 months agomkosi-initrd: Remove /var/cache/ldconfig/aux-cache
Daan De Meyer [Sun, 18 Aug 2024 12:54:10 +0000 (14:54 +0200)] 
mkosi-initrd: Remove /var/cache/ldconfig/aux-cache

The file is not reproducible so let's remove it so that reproducible
initrds can be built by default.

Fixes #2957