]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
2 months agomkosi-tools: Install man tool and pages as part of misc profile 3742/head
Daan De Meyer [Tue, 27 May 2025 08:43:30 +0000 (10:43 +0200)] 
mkosi-tools: Install man tool and pages as part of misc profile

Man pages are generally shipped together with tools, so we need a
man viewer inside the tools tree to be able to read those man pages.

While we're at it, make sure we also install the basic Linux man pages
since those are always useful to have around.

2 months agoEnforce C.UTF-8 locale for all commands we run
Daan De Meyer [Tue, 27 May 2025 09:00:07 +0000 (11:00 +0200)] 
Enforce C.UTF-8 locale for all commands we run

So this is a shitty situation either way. We generally have no idea
which locales will be available in the tools tree. Most likely, it'll
just be the C.UTF-8 one. In that case, using the locale environment
variables from the host is pointless and leads to annoying errors from
lots of tools.

We could make sure all locales are installed but glibc-all-langpacks is
> 200M installed size on Fedora which feels like too much. So let's
instead always use C.UTF-8, it's not like mkosi itself is locale aware
anyway.

2 months agoFix version bump check if image version was passed on CLI
Daan De Meyer [Mon, 26 May 2025 13:44:42 +0000 (15:44 +0200)] 
Fix version bump check if image version was passed on CLI

We only want to generate a new version if no version was specified on
the CLI. To do that we need to check that the version on the CLI is None,
not the opposite.

Replaces #3721

2 months agoapt: Install apt sources if apt was installed via base tree
Daan De Meyer [Mon, 26 May 2025 13:31:49 +0000 (15:31 +0200)] 
apt: Install apt sources if apt was installed via base tree

Fixes #3715.

2 months agoMake sure git doesn't fail when running as root
Daan De Meyer [Thu, 22 May 2025 12:26:14 +0000 (14:26 +0200)] 
Make sure git doesn't fail when running as root

We have to mark the .git directory we're checking as safe otherwise
git operate on it.

2 months agorepart: use --append-fstab=auto if available
Alberto Planas [Thu, 24 Apr 2025 13:57:56 +0000 (15:57 +0200)] 
repart: use --append-fstab=auto if available

When generating images there is a chance that a pre-existent /etc/fstab
is present in the mkosi buildroot.  systemd-repart can merge the already
existing fstab with the one generated, separating the sections in a way
that the systemd-repart can be reused several times.

Signed-off-by: Alberto Planas <aplanas@suse.com>
2 months agosandbox: handle case where dev node for tty doesn't exist
Clayton Craft [Wed, 21 May 2025 22:59:36 +0000 (15:59 -0700)] 
sandbox: handle case where dev node for tty doesn't exist

This fixes this crash, which happens even when isatty(2) is True:

Traceback (most recent call last):
  File "/sandbox.py", line 1095, in <module>
    main()
  File "/sandbox.py", line 891, in main
    ttyname = os.ttyname(2) if os.isatty(2) else ""
              ^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory

IIUC this is because isatty(2) is a valid file descriptor (inherited
from the parent process?), but ttyname() is unable find a device node
for it because it's not mounted in the sandbox.

2 months agoinitrd: shadow-utils removal is only necessary on old Fedora
Zbigniew Jędrzejewski-Szmek [Tue, 20 May 2025 12:23:05 +0000 (14:23 +0200)] 
initrd: shadow-utils removal is only necessary on old Fedora

On rawhide, we get:
"No packages to remove for argument: shadow-utils"

2 months agoUse SPDX identifier instead of file path for license in pyproject.toml
Björn Wachtendorf [Wed, 21 May 2025 05:33:35 +0000 (07:33 +0200)] 
Use SPDX identifier instead of file path for license in pyproject.toml

2 months agoRevert license-files property
Björn Wachtendorf [Tue, 20 May 2025 16:46:09 +0000 (18:46 +0200)] 
Revert license-files property

2 months agoMerge pull request #3722 from behrmann/versiontweaks
Zbigniew Jędrzejewski-Szmek [Tue, 20 May 2025 13:47:46 +0000 (15:47 +0200)] 
Merge pull request #3722 from behrmann/versiontweaks

Minor version improvements

2 months agomake version test more readable 3722/head
Jörg Behrmann [Fri, 9 May 2025 16:47:49 +0000 (18:47 +0200)] 
make version test more readable

2 months agoversion: add __repr__ to GenericVersion
Jörg Behrmann [Fri, 16 May 2025 09:54:16 +0000 (11:54 +0200)] 
version: add __repr__ to GenericVersion

2 months agoFix licenses path in pyproject.toml
Björn Wachtendorf [Mon, 19 May 2025 13:08:27 +0000 (15:08 +0200)] 
Fix licenses path in pyproject.toml

2 months agoMerge pull request #3702 from aafeijoo-suse/initrd-kmp
Jörg Behrmann [Thu, 15 May 2025 15:16:33 +0000 (17:16 +0200)] 
Merge pull request #3702 from aafeijoo-suse/initrd-kmp

mkosi-initrd: handle KMPs and symlinks under weak-updates

2 months agobuild(deps): bump github/codeql-action from 3.28.13 to 3.28.16
dependabot[bot] [Thu, 1 May 2025 22:16:51 +0000 (22:16 +0000)] 
build(deps): bump github/codeql-action from 3.28.13 to 3.28.16

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.13 to 3.28.16.
- [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/1b549b9259bda1cb5ddde3b41741a82a2d15a841...28deaeda66b76a05916b6923827895f2b14ab387)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 months agoSupress ssh unit generation if sshd is not present
Septatrix [Tue, 29 Apr 2025 14:57:20 +0000 (16:57 +0200)] 
Supress ssh unit generation if sshd is not present

3 months agoPartially revert 640000a861e9cd9a3807e4158e110a098c74d078
Daan De Meyer [Mon, 28 Apr 2025 10:11:46 +0000 (12:11 +0200)] 
Partially revert 640000a861e9cd9a3807e4158e110a098c74d078

This doesn't quite work as on the second run, mkosi.tools will be
picked up as the default value of ToolsTree= instead of "default"
so we lose cache invalidation.

Let's revert for now until we find a better solution.

3 months agoDon't use default value if optional settings are set to none
Daan De Meyer [Thu, 24 Apr 2025 12:31:32 +0000 (14:31 +0200)] 
Don't use default value if optional settings are set to none

Just like it's possible to disable usage of default values for collection
based settings, we should also support it for optional settings.
This can be used to disable usage of the tools tree even if mkosi.tools.conf
exists by setting ToolsTree= in mkosi.local.conf.

3 months agomkosi-initrd: handle symlinks under weak-updates 3702/head
Antonio Alvarez Feijoo [Wed, 23 Apr 2025 14:50:28 +0000 (16:50 +0200)] 
mkosi-initrd: handle symlinks under weak-updates

The weak-updates folder of the current kernel directory may contain symlinks to
an old kernel:

```
$ tree /usr/lib/modules/6.14.1-1-default/weak-updates/
/usr/lib/modules/6.14.1-1-default/weak-updates/
└── updates
    ├── hdaps.ko -> /usr/lib/modules/6.14.0-1-default/updates/hdaps.ko
    ├── nvidia-open-driver-G06-signed-570.133.07
    │   ├── nvidia-drm.ko.zst -> /usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia-drm.ko.zst
    │   ├── nvidia.ko.zst -> /usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia.ko.zst
    │   ├── nvidia-modeset.ko.zst -> /usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia-modeset.ko.zst
    │   └── nvidia-uvm.ko.zst -> /usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia-uvm.ko.zst
    ├── thinkpad_ec.ko -> /usr/lib/modules/6.14.0-1-default/updates/thinkpad_ec.ko
    └── tp_smapi.ko -> /usr/lib/modules/6.14.0-1-default/updates/tp_smapi.ko
```

These symlinks to a different kernel directory make mkosi to fail:

```
‣  Applying kernel module filters
‣   Running modinfo to fetch kernel module dependencies
modinfo: ERROR: could not get modinfo from 'nvidia': No such file or directory
libkmod: ERROR: kmod_module_parse_depline: ctx=0x55cda95602a0 path=/usr/lib/modules/6.14.1-1-default/weak-updates/updates/thinkpad_ec.ko error=No such file or directory
modinfo: ERROR: could not get modinfo from 'hdaps': No such file or directory
libkmod: ERROR: kmod_module_parse_depline: ctx=0x55cda95602a0 path=/usr/lib/modules/6.14.1-1-default/weak-updates/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia-modeset.ko.zst error=No such file or directory
modinfo: ERROR: could not get modinfo from 'nvidia_drm': No such file or directory
libkmod: ERROR: kmod_module_parse_depline: ctx=0x55cda95602a0 path=/usr/lib/modules/6.14.1-1-default/weak-updates/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia.ko.zst error=No such file or directory
modinfo: ERROR: could not get modinfo from 'nvidia_uvm': No such file or directory
modinfo: ERROR: could not get modinfo from 'thinkpad_ec': No such file or directory
libkmod: ERROR: kmod_module_parse_depline: ctx=0x55cda95602a0 path=/usr/lib/modules/6.14.1-1-default/weak-updates/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia.ko.zst error=No such file or directory
modinfo: ERROR: could not get modinfo from 'nvidia_modeset': No such file or directory
libkmod: ERROR: kmod_module_parse_depline: ctx=0x55cda95602a0 path=/usr/lib/modules/6.14.1-1-default/weak-updates/updates/thinkpad_ec.ko error=No such file or directory
modinfo: ERROR: could not get modinfo from 'tp_smapi': No such file or directory
```

Also, do not run `depmod` for this old kernel directory that contains only the
`update` directory.

3 months agomkosi-initrd: perform basic checks on the kernel dir before calling mkosi
Antonio Alvarez Feijoo [Wed, 23 Apr 2025 11:37:09 +0000 (13:37 +0200)] 
mkosi-initrd: perform basic checks on the kernel dir before calling mkosi

openSUSE ships Kernel Module Packages (KMPs), e.g.:

```
$ rpm -ql nvidia-open-driver-G06-signed-kmp-default
/usr/lib/modules/6.14.0-1-default
/usr/lib/modules/6.14.0-1-default/updates
/usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07
/usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia-drm.ko.zst
/usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia-modeset.ko.zst
/usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia-uvm.ko.zst
/usr/lib/modules/6.14.0-1-default/updates/nvidia-open-driver-G06-signed-570.133.07/nvidia.ko.zst
```

These KMPs install their kernel modules under the updates folder of a certain
kernel directory, even with that kernel directory without any other content:

```
$ tree /usr/lib/modules/6.14.0-1-default
/usr/lib/modules/6.14.0-1-default
└── updates
    ├── hdaps.ko
    ├── nvidia-open-driver-G06-signed-570.133.07
    │   ├── nvidia-drm.ko.zst
    │   ├── nvidia.ko.zst
    │   ├── nvidia-modeset.ko.zst
    │   └── nvidia-uvm.ko.zst
    ├── thinkpad_ec.ko
    └── tp_smapi.ko
```

That of course will make mkosi fail:

```
$ mkosi-initrd -k 6.14.0-1-default
‣ Validating certificates and keys
‣ Copying repository metadata
‣ Building main image
‣  Copying in sandbox trees…
‣  Installing openSUSE
...
‣  Applying kernel module filters
‣   Running modinfo to fetch kernel module dependencies
modinfo: ERROR: Module nvidia not found.
modinfo: ERROR: Module thinkpad-ec not found.
modinfo: ERROR: Module nvidia-modeset not found.
modinfo: ERROR: Module tp-smapi not found.
modinfo: ERROR: Module hdaps not found.
modinfo: ERROR: Module nvidia-uvm not found.
modinfo: ERROR: Module nvidia-drm not found.
‣ "modinfo --set-version 6.14.0-1-default --null nvidia thinkpad-ec nvidia-modeset tp-smapi hdaps nvidia-uvm nvidia-drm" returned non-zero exit code 1.
```

But, there is no need fail so far (after calling the package manager within
mkosi), some basic checks can be performed before spawning other processes.

3 months agoUse a default tools tree by default if mkosi.tools.conf exists
Daan De Meyer [Sun, 20 Apr 2025 18:18:11 +0000 (20:18 +0200)] 
Use a default tools tree by default if mkosi.tools.conf exists

3 months agomkosi: Override misconfigured gitconfig HTTP/HTTPS proxy with ProxyUrl
Ryan Wilson [Mon, 21 Apr 2025 17:00:53 +0000 (10:00 -0700)] 
mkosi: Override misconfigured gitconfig HTTP/HTTPS proxy with ProxyUrl

When running mkosi on a server with an outgoing HTTP/HTTPS proxy,
Build.ProxyUrl must be set. However, some repositories (e.g. systemd)
call git in their mkosi scripts (e.g. cloning package repositories for
distros) and .gitconfig can also contain different http.proxy and https.proxy
settings. Thus, if .gitconfig is misconfigured with the wrong proxy,
the user will get confusing errors related to git fetching repositories.

To ensure we use a consistent proxy across git and mkosi, we override
git http proxy configuration via GIT_CONFIG_COUNT, GIT_CONFIG_KEY_{n},
GIT_CONFIG_VALUE{n} environment variables. Most of the code complexity
is dealing with the case when these variables are set by the user via
Environment / EnvironmentFiles.

3 months agoMake sure we create the default workspace directory as well
Daan De Meyer [Fri, 18 Apr 2025 12:44:30 +0000 (14:44 +0200)] 
Make sure we create the default workspace directory as well

Fixes #3701

3 months agomkosi-initrd: --kernel-modules-include -> --kernel-modules
Antonio Alvarez Feijoo [Wed, 16 Apr 2025 09:55:55 +0000 (11:55 +0200)] 
mkosi-initrd: --kernel-modules-include -> --kernel-modules

Use the new option name.

3 months agomkosi: Use tools tree by default in repository config
Daan De Meyer [Thu, 17 Apr 2025 10:18:22 +0000 (12:18 +0200)] 
mkosi: Use tools tree by default in repository config

Might as well use a tools tree by default to minimize the number of
packages that have to be installed on the host to build the default
image.

3 months agodnf: Stop messing around with plugins
Daan De Meyer [Thu, 17 Apr 2025 09:52:42 +0000 (11:52 +0200)] 
dnf: Stop messing around with plugins

We disabled plugins by default a long time ago because the
versionlock plugin's configuration from the host was interfering
with image builds. Now that we have completely ownership over /etc,
there shouldn't be a need to disable plugins anymore if we assume
they won't do anything nasty by default without configuration.

3 months agoFix mkosi help
Daan De Meyer [Thu, 17 Apr 2025 09:05:39 +0000 (11:05 +0200)] 
Fix mkosi help

3 months agomkosi-obs: simplify generation of signed UEFI auth files
Dan Streetman [Tue, 15 Apr 2025 23:28:49 +0000 (19:28 -0400)] 
mkosi-obs: simplify generation of signed UEFI auth files

We can use systemd-keyutil to generate the PKCS#7 signature from the
OBS-provided PKCS#1 signature and OBS-provided x509 certificate, instead of the
'kernel-sign-file' script.

Also we can use the ESL files directly, instead of the perl statement that
removes the auth header, as mkosi.postoutput leaves them for us to use.

3 months agoMerge pull request #3661 from septatrix/ssh-runtime
Daan De Meyer [Wed, 16 Apr 2025 11:26:36 +0000 (13:26 +0200)] 
Merge pull request #3661 from septatrix/ssh-runtime

Add new Ssh=runtime option

3 months agoMerge pull request #3682 from DaanDeMeyer/history
Daan De Meyer [Wed, 16 Apr 2025 11:24:39 +0000 (13:24 +0200)] 
Merge pull request #3682 from DaanDeMeyer/history

installer: Make sure package manager state is preserved in the image

3 months agoMerge pull request #3696 from DaanDeMeyer/history-cli
Daan De Meyer [Wed, 16 Apr 2025 10:42:40 +0000 (12:42 +0200)] 
Merge pull request #3696 from DaanDeMeyer/history-cli

Only write CLI arguments to history instead of full config

3 months agoRework version bumping 3696/head
Daan De Meyer [Tue, 15 Apr 2025 18:28:25 +0000 (20:28 +0200)] 
Rework version bumping

Currently, --auto-bump= bumps the version after finishing a build.
Effectively this means the version in mkosi.version doesn't reflect
the actual version of the image which seems weird. Instead, let's
generate the new version upfront so that it's used by the build but
only write it to mkosi.version when we do a successful build.

Additionally, look for a mkosi.bump script and use it if it exists
to generate the new version so we can generate a timestamp as the
version in particleos.

3 months agoOnly write CLI arguments to history instead of full config
Daan De Meyer [Sun, 13 Apr 2025 20:42:55 +0000 (22:42 +0200)] 
Only write CLI arguments to history instead of full config

The huge downside of writing the full config to the history is that
any modifications to config files are ignored until the image is
rebuilt.

If we make the argument that changes to config files are usually
supposed to be permanent rather than ephemeral, it doesn't make sense
to not take them into account when reusing the history. Especially since
the primary purpose of the history is to avoid specifying the same CLI
arguments over and over again without encoding those CLI arguments into
a config file.

So instead of saving the full config to the history and not reparsing
the configuration when reusing the history, let's only save the CLI
arguments to the history and always reparse the configuration, even when
we end up reusing the history.

This keeps the crucial benefit of the history intact (not having to repeat
yourself endlessly) while still making sure any new settings added to the
configuration files are taken into account immediately.

It also simplifies the implementation quite a bit, as we can get away
again with maintaining a single history file instead of two.

Additionally, we opt to completely ignore the history when using the sandbox
verb. The idea here is that the history only applies to the final image (and
subimages). This was already the case as any --tools-tree-xxx CLI options aren't
saved in the history as they are not fields of the Config object.

3 months agoDisallow using --rerun-build-scripts with --force again
Daan De Meyer [Sun, 13 Apr 2025 20:40:16 +0000 (22:40 +0200)] 
Disallow using --rerun-build-scripts with --force again

In the next commit, we're going to move history handling purely into
parse_config(), which means we can't check anymore if we built the
image or not, so let's disallow using --force with --rerun-build-scripts
again as the only way that works is if we can check whether we built the
image or not before writing the history.

3 months agoinstaller: Make sure package manager state is preserved in the image 3682/head
Daan De Meyer [Thu, 10 Apr 2025 20:29:44 +0000 (22:29 +0200)] 
installer: Make sure package manager state is preserved in the image

Package manager state should be preserved in the image as various
local features of the package manager may depend on this data to be
available. For pacman and zypper we already store local state inside
the image. For apt, we achieve this by storing all state in the image
by default except lists which is the repository metadata which we still
don't include in the image. For dnf/dnf5, we make sure the persistdir
points to inside the image.

Note that this state is still subject to removal by CleanPackageMetadata=
if the package manager is not installed or the option is explicitly enabled.

Fixes #3659

3 months agoOnly copy repository metadata from specific subdirs from /var
Daan De Meyer [Wed, 16 Apr 2025 08:16:40 +0000 (10:16 +0200)] 
Only copy repository metadata from specific subdirs from /var

/var usually contains state specific to the local system so it's more
prudent to specify an allowlist of what should be copied rather than a
denylist of what shouldn't be copied.

This doesn't matter so much when using mkosi's own package cache directory
since that is only used when syncing repository metadata and not when actually
installing stuff, but it does matter when PackageCacheDirectory=/var is used since
then we're copying from a state directory in /var that is also used when installing
packages and as such will contain a lot of stuff that we don't want.

3 months agoRename cache_subdirs() to package_subdirs()
Daan De Meyer [Wed, 16 Apr 2025 07:35:41 +0000 (09:35 +0200)] 
Rename cache_subdirs() to package_subdirs()

This method returns subdirs of the cache dir that contain packages
so package_subdirs() seems like a more approriate name.

3 months agoImprove Ssh= documentation 3661/head
Nils K [Tue, 15 Apr 2025 16:47:25 +0000 (18:47 +0200)] 
Improve Ssh= documentation

Let's make the phrasing a bit clearer and easier to digest

Co-authored-by: Jörg Behrmann <behrmann@physik.fu-berlin.de>
3 months agomkosi-obs: do not publish roothash
Luca Boccassi [Tue, 15 Apr 2025 14:22:49 +0000 (15:22 +0100)] 
mkosi-obs: do not publish roothash

importctl confuse it with a detached roothash and try to verify it, but it's
the roothash of the embedded partition, so don't publish it

3 months agomkosi-obs: append certs from mkosi.uefi.db/ to 'db'
Luca Boccassi [Mon, 14 Apr 2025 01:19:14 +0000 (02:19 +0100)] 
mkosi-obs: append certs from mkosi.uefi.db/ to 'db'

Allow appending an arbitrary number of certs to the autoenrolled UEFI
db. Expects list of PEM formatted files. Only implemented for OBS
builds for now.

3 months agoMake sure sync scripts are executable
Daan De Meyer [Tue, 15 Apr 2025 08:12:06 +0000 (10:12 +0200)] 
Make sure sync scripts are executable

Fixes #3689

3 months agoAdd new Ssh=auto and Ssh=runtime options
Septatrix [Mon, 7 Apr 2025 15:33:54 +0000 (17:33 +0200)] 
Add new Ssh=auto and Ssh=runtime options

Fixes #3654

3 months agoRename get_configdir() to finalize_configdir()
Daan De Meyer [Sun, 13 Apr 2025 19:42:24 +0000 (21:42 +0200)] 
Rename get_configdir() to finalize_configdir()

3 months agoGet rid of to_json() methods on Args and Config
Daan De Meyer [Sun, 13 Apr 2025 19:41:47 +0000 (21:41 +0200)] 
Get rid of to_json() methods on Args and Config

Let's reuse dump_json() everywhere instead.

3 months agoSimplify tools tree out of date error
Daan De Meyer [Sat, 12 Apr 2025 07:52:29 +0000 (09:52 +0200)] 
Simplify tools tree out of date error

A tools tree is either not used at all or used for all images, so
no point in mentioning a specific image.

3 months agoFail if --rerun-build-scripts is used and tools is out of date
Daan De Meyer [Sat, 12 Apr 2025 07:49:48 +0000 (09:49 +0200)] 
Fail if --rerun-build-scripts is used and tools is out of date

If --rerun-build-scripts is used, we shouldn't rebuild the tools
tree unless --force is specified as well, so make sure we check for
that specific case.

4 months agomkosi-initrd: add specific configuration for plymouth in Debian
Antonio Alvarez Feijoo [Thu, 10 Apr 2025 08:00:54 +0000 (10:00 +0200)] 
mkosi-initrd: add specific configuration for plymouth in Debian

4 months agoTake shared lock in copy_ephemeral()
Daan De Meyer [Thu, 10 Apr 2025 19:30:25 +0000 (21:30 +0200)] 
Take shared lock in copy_ephemeral()

We don't need an exclusive lock to make this copy, so let's take only
a shared lock.

4 months agoTwo follow ups for #3678
Daan De Meyer [Thu, 10 Apr 2025 17:51:17 +0000 (19:51 +0200)] 
Two follow ups for #3678

4 months agoMerge pull request #3678 from DaanDeMeyer/history
Daan De Meyer [Thu, 10 Apr 2025 17:48:34 +0000 (19:48 +0200)] 
Merge pull request #3678 from DaanDeMeyer/history

4 months agozypper: display debugging output if ARG_DEBUG is set
Antonio Alvarez Feijoo [Thu, 10 Apr 2025 14:39:51 +0000 (16:39 +0200)] 
zypper: display debugging output if ARG_DEBUG is set

4 months agotests: Require genkey to be run once upfront 3678/head
Daan De Meyer [Thu, 10 Apr 2025 14:18:17 +0000 (16:18 +0200)] 
tests: Require genkey to be run once upfront

4 months agotests: Drop unused tools field
Daan De Meyer [Thu, 10 Apr 2025 13:25:51 +0000 (15:25 +0200)] 
tests: Drop unused tools field

4 months agoRework history <=> sandbox integration
Daan De Meyer [Thu, 10 Apr 2025 11:45:39 +0000 (13:45 +0200)] 
Rework history <=> sandbox integration

Until now, we read the tools tree configuration both inside and
outside the sandbox. This is problematic for a few reasons:

- For a number of reasons, the tools tree configuration inside and
outside the sandbox may be different. This is especially true when
the history is used, as when invoking mkosi sandbox and mkosi is
invoked again within the sandbox, we don't know when invoking mkosi
sandbox whether the nested invocation will reuse the history or not.
This can lead to situations where mkosi sandbox thinks the tools tree
is up-to-date whereas mkosi inside the sandbox thinks the tools tree
is out of date, which is a situation that is very hard to resolve for
users.
- Even if we read the tools tree configuration inside the sandbox, there's
no real point to it except maybe for showing the summary. Since the
tools tree has already been built and mounted at that point, we can't
build or use a new tools tree, or clean up an old one.

Let's fix these issues by *not* reading the tools tree configuration
inside the sandbox, neither from configuration not from history. The
one piece of tools tree configuration we do need to pass into the sandbox
is the default tools tree path as that gets included in the history of
the other images so we pass it in via an environment variable
$MKOSI_DEFAULT_TOOLS_TREE_PATH.

As a consequence of this approach, we cannot write the tools tree history
from within the sandbox anymore, so we write it to a separate file from
outside the sandbox instead.

Additionally, we make more commands use the history. Up until now summary and
other verbs did not make use of the history. This doesn't really make sense,
so let's make sure they make use of the history as well. summary in particular
is important as it may be used to query information about the built image after
building it which needs to take the history into account.

We still allow summary to ignore the history by passing --force. Also we
still ignore the history for clean as there are use cases both for having it
use the history and not yet the --force flag already has meaning there.

4 months agoAllow PCR signing settings to be overridden in sub-images
Michael A Cassaniti [Wed, 9 Apr 2025 04:15:50 +0000 (14:15 +1000)] 
Allow PCR signing settings to be overridden in sub-images

A sub-image is usually built from the same base image. That base image may be
used for a rescue image and a primary workstation image. If the rescue image
has PCR signing enabled then it could allow the disk to be automatically
unlocked. This change allows specifying separate PCR signing keys which will
support only the workstation sub-image performing an automatic unlock.

4 months agozypper: do not fail if a package configured to be removed is not found
Antonio Alvarez Feijoo [Wed, 9 Apr 2025 15:13:29 +0000 (17:13 +0200)] 
zypper: do not fail if a package configured to be removed is not found

`dnf` does not fail in this case:

```
‣  Removing 1 packages…
No matches were found for the following plugin name patterns while enabling libdnf plugins: builddep, reflink, versionlock
No matches were found for the following plugin name patterns while disabling libdnf plugins: *
No packages to remove for argument: shadow-utils

Nothing to do.
‣  Removing files…
```

But `zypper` fails by default, breaking the build. Found with mkosi-initrd in
openSUSE, the `shadow` package is not installed when using `WithRecommends=yes`.

```
‣  Removing 2 packages…
Warning: Enforced setting: $releasever=20241001
Reading installed packages...
'shadow' not found in package names. Trying capabilities.
No provider of 'shadow' found.
Resolving package dependencies...

The following package is going to be REMOVED:
  sysuser-shadow

1 package to remove.

Package install size change:
              |         0 B    required by packages that will be installed
    -3.0 KiB  |  -    3.0 KiB  released by packages that will be removed

Backend:  classic_rpmtrans
Continue? [y/n/v/...? shows all options] (y): y
(1/1) Removing: sysuser-shadow-3.3-8.2.noarch ..........................................................................................[done]
Installation has completed with error.
‣ "zypper --installroot=/buildroot --cache-dir=/var/cache/zypp --non-interactive --no-refresh --releasever=20241001 remove --clean-deps shadow sysuser-shadow" returned non-zero exit code 104.
```

This behavior can be changed using the `--ignore-unknown` global option (which
goes before the command).

4 months agoGenerate key-cert pair in config directory (fixes #3655)
Septatrix [Tue, 8 Apr 2025 13:59:30 +0000 (15:59 +0200)] 
Generate key-cert pair in config directory (fixes #3655)

4 months agoDon't use gen_kernel_images() in run_depmod()
Daan De Meyer [Tue, 8 Apr 2025 14:41:29 +0000 (16:41 +0200)] 
Don't use gen_kernel_images() in run_depmod()

We don't actually care about kernel images in this function, so let's
not depend on those being present.

Fixes #3670

4 months agoFix typing due to recent changes in typeshed
Daan De Meyer [Wed, 9 Apr 2025 07:56:52 +0000 (09:56 +0200)] 
Fix typing due to recent changes in typeshed

https://github.com/python/typeshed/pull/13767 narrows the typing for
shutil.copy2() so let's address that by fixing our typing.

4 months agoAdd "plymouth" initrd profile
Antonio Alvarez Feijoo [Fri, 4 Apr 2025 14:25:57 +0000 (16:25 +0200)] 
Add "plymouth" initrd profile

This initrd profile provides a graphical interface at boot (animation and
password prompt).

Closes #3650

4 months agoaction: Drop debug logging
Daan De Meyer [Tue, 8 Apr 2025 15:01:26 +0000 (17:01 +0200)] 
action: Drop debug logging

4 months agoaction: Use inputs to work around github actions empty variables
Daan De Meyer [Tue, 8 Apr 2025 14:35:38 +0000 (16:35 +0200)] 
action: Use inputs to work around github actions empty variables

Even using env doesn't seem to work, so let's try the other workaround
from the issue, using inputs default values to capture the right values
before they become empty.

4 months agoaction: Fix shell debugging
Daan De Meyer [Tue, 8 Apr 2025 14:06:59 +0000 (16:06 +0200)] 
action: Fix shell debugging

4 months agoMerge pull request #3668 from DaanDeMeyer/fix
Daan De Meyer [Tue, 8 Apr 2025 13:46:33 +0000 (15:46 +0200)] 
Merge pull request #3668 from DaanDeMeyer/fix

4 months agoaction: Enable debugging for the git history step 3668/head
Daan De Meyer [Tue, 8 Apr 2025 13:38:08 +0000 (15:38 +0200)] 
action: Enable debugging for the git history step

4 months agoaction: Fix github action repository
Daan De Meyer [Tue, 8 Apr 2025 13:33:46 +0000 (15:33 +0200)] 
action: Fix github action repository

github.action_repository does not contain https://github.com so add
that ourselves.

4 months agoaction: Ensure git history is available
Daan De Meyer [Tue, 8 Apr 2025 12:39:43 +0000 (14:39 +0200)] 
action: Ensure git history is available

Unshallowing the repository only works when the action is used as a
local action within the mkosi repository. If the action is used in any
other github repository, the git history is not available so we cannot
unshallow the repository.

Instead, detect if the git history is available and clone the repository
ourselves if the git history is not available.

4 months agoFix formatting
Daan De Meyer [Tue, 8 Apr 2025 12:17:31 +0000 (14:17 +0200)] 
Fix formatting

4 months agoRequire MinimumVersion= commit sha to be prefixed with commit:
Daan De Meyer [Tue, 8 Apr 2025 11:35:13 +0000 (13:35 +0200)] 
Require MinimumVersion= commit sha to be prefixed with commit:

4 months agoaction: Unshallow repository
Daan De Meyer [Tue, 8 Apr 2025 11:54:04 +0000 (13:54 +0200)] 
action: Unshallow repository

We want the full history so that MinimumVersion= with a git sha
works properly.

4 months agoAllow MinimumVersion to be a git sha
Daan De Meyer [Tue, 8 Apr 2025 09:19:34 +0000 (11:19 +0200)] 
Allow MinimumVersion to be a git sha

In systemd we very often require newer mkosi git commits which means
that setting MinimumVersion=25~devel doesn't work anymore. Let's allow
the MinimumVersion= to be a git sha so that we can enforce the mkosi
version to be new enough.

We skip git commit checks if we're in the sandbox since mkosi will be
a zipapp there and we won't have access to the git repository to do the
check.

4 months agoqemu: Make notify handling code more generic
Daan De Meyer [Mon, 7 Apr 2025 10:53:01 +0000 (12:53 +0200)] 
qemu: Make notify handling code more generic

Let's pass in a queue to the target function of AsyncioThread() to which
it can write messages. Let's also keep track of all sent messages in
AsyncioThread for easy access later and add some utility functions to
process new messages.

We also split out notify() from vsock_notify_handler() and make it non-vsock
specific by passing in the socket as an argument.

4 months agodebian: Remove check if apt exists from install_apt_sources()
Daan De Meyer [Mon, 7 Apr 2025 10:33:22 +0000 (12:33 +0200)] 
debian: Remove check if apt exists from install_apt_sources()

We now install the apt sources before we install apt into the image
so this check can never succeed so let's drop it.

At the same time, create parent directories if needed and make sure
we use the proper modes.

4 months agoFix ToolsTreeRepositories= scope
Daan De Meyer [Mon, 7 Apr 2025 08:00:25 +0000 (10:00 +0200)] 
Fix ToolsTreeRepositories= scope

4 months agoAllow --rerun-build-scripts in combination with none output
Daan De Meyer [Sun, 6 Apr 2025 16:40:30 +0000 (18:40 +0200)] 
Allow --rerun-build-scripts in combination with none output

To make the logic work without being able to check if the output
exists or not, we simply never write the history if --rerun-build-scripts
if specified with the none output format.

4 months agoobs: fix sign-efi-sig-list parameter format
Luca Boccassi [Fri, 4 Apr 2025 23:51:22 +0000 (00:51 +0100)] 
obs: fix sign-efi-sig-list parameter format

It wants a date in the format Y-m-d H:M:S rather than unix seconds.
Also if SOURCE_DATE_EPOCH is not defined, use actual epoch, as the
timestamps must match when creating the signature and when attaching
it

4 months agoDrop ToolsTreeSyncScripts= and ToolsTreePrepareScripts=
Daan De Meyer [Fri, 4 Apr 2025 07:47:59 +0000 (09:47 +0200)] 
Drop ToolsTreeSyncScripts= and ToolsTreePrepareScripts=

These are not in an official release yet, and can be configured via
mkosi.tools.conf now with their regular setting alternatives, so let's
drop these.

4 months agoMerge pull request #3592 from septatrix/persisten-drives
Daan De Meyer [Fri, 4 Apr 2025 07:46:34 +0000 (09:46 +0200)] 
Merge pull request #3592 from septatrix/persisten-drives

4 months agoSet MKOSI_DEBUG instead of DEBUG
Daan De Meyer [Thu, 3 Apr 2025 15:14:37 +0000 (17:14 +0200)] 
Set MKOSI_DEBUG instead of DEBUG

DEBUG is very generic and can picked up by anything, but sometimes
with drastically different meanings to what is supposed to be in the
environment variable value.

For example the xfstests configure script expects DEBUG to contain
compiler options, which makes it break in extremely hard to debug
ways if we set DEBUG ourselves to a boolean value.

Let's namespace this to avoid conflicts.

4 months agoMark scratch disk as nocow 3592/head
Septatrix [Thu, 3 Apr 2025 15:02:19 +0000 (17:02 +0200)] 
Mark scratch disk as nocow

4 months agoInclude machine_or_name in drive filename
Septatrix [Thu, 3 Apr 2025 14:53:01 +0000 (16:53 +0200)] 
Include machine_or_name in drive filename

4 months agoRevert "qemu: Remove unused argument from finalize_drive()"
Septatrix [Tue, 18 Mar 2025 16:59:48 +0000 (17:59 +0100)] 
Revert "qemu: Remove unused argument from finalize_drive()"

This reverts commit 3e850db2bb5b4ad93742b844bb3f74f2c61f8b62.

4 months agoMake Drive= flags more general
Septatrix [Fri, 14 Mar 2025 11:36:43 +0000 (12:36 +0100)] 
Make Drive= flags more general

4 months agoMerge pull request #3646 from aafeijoo-suse/initrd-vconsole-ubuntu
Daan De Meyer [Thu, 3 Apr 2025 07:46:37 +0000 (09:46 +0200)] 
Merge pull request #3646 from aafeijoo-suse/initrd-vconsole-ubuntu

4 months agomkosi-initrd: refactor add_raid_config -> raid_config 3646/head
Antonio Alvarez Feijoo [Thu, 3 Apr 2025 05:55:46 +0000 (07:55 +0200)] 
mkosi-initrd: refactor add_raid_config -> raid_config

4 months agomkosi-initrd: fix vconsole configuration for Ubuntu
Antonio Alvarez Feijoo [Thu, 3 Apr 2025 05:52:34 +0000 (07:52 +0200)] 
mkosi-initrd: fix vconsole configuration for Ubuntu

Ubuntu (and Debian?) installs `/etc/vconsole.conf` as a dangling symlink to
`/etc/default/keyboard`, and that causes the `mkosi-initrd` build to fail.

```
\u2023  Copying in extra file trees\u2026
cp: not writing through dangling symlink '/work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf'
\u2023 "cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents /work/etc/default/keyboard /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf" returned non-zero exit code 1.
bash-5.2# ls -l /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf
lrwxrwxrwx 1 0 0 16 Apr  2 14:49 /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/vconsole.conf -> default/keyboard
bash-5.2# ls -l /work/var/tmp/mkosi-workspace-us4prlhz/root/etc/default/keyboard
ls: cannot access '/work/var/tmp/mkosi-workspace-us4prlhz/root/etc/default/keyboard': No such file or directory
```

4 months agoDon't chdir() to mkosi/ subdirectory
Daan De Meyer [Wed, 2 Apr 2025 12:01:06 +0000 (14:01 +0200)] 
Don't chdir() to mkosi/ subdirectory

Changing the working directory to mkosi/ is not intuitive. We want
to parse configuration from there, but the working directory should
not change (e.g. you don't want mkosi sandbox to execute inside the
mkosi/ subdirectory when invoked in the top level directory).

4 months agomkosi-initrd: copy local vconsole configuration
Antonio Alvarez Feijoo [Wed, 2 Apr 2025 10:02:39 +0000 (12:02 +0200)] 
mkosi-initrd: copy local vconsole configuration

Otherwise it can be very hard to enter a password set on the host using a
keyboard with some specific language layout.

4 months agoMerge pull request #3643 from DaanDeMeyer/subdir
Jörg Behrmann [Wed, 2 Apr 2025 11:12:26 +0000 (13:12 +0200)] 
Merge pull request #3643 from DaanDeMeyer/subdir

Use mkosi/ subdirectory if no configuration exists in cwd

4 months agoUse mkosi/ subdirectory if no configuration exists in cwd 3643/head
Daan De Meyer [Wed, 2 Apr 2025 08:39:27 +0000 (10:39 +0200)] 
Use mkosi/ subdirectory if no configuration exists in cwd

In systemd we've ended up with a large amount of mkosi specific
files and directories in the top level of the repository. Let's allow
moving these to a mkosi/ directory by transparently picking this up.

4 months agobuild(deps): bump github/codeql-action from 3.28.10 to 3.28.13
dependabot[bot] [Tue, 1 Apr 2025 22:17:19 +0000 (22:17 +0000)] 
build(deps): bump github/codeql-action from 3.28.10 to 3.28.13

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.10 to 3.28.13.
- [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/b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d...1b549b9259bda1cb5ddde3b41741a82a2d15a841)

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

Signed-off-by: dependabot[bot] <support@github.com>
4 months agoMerge pull request #3641 from DaanDeMeyer/fix
Daan De Meyer [Tue, 1 Apr 2025 19:36:45 +0000 (21:36 +0200)] 
Merge pull request #3641 from DaanDeMeyer/fix

4 months agoDon't allow configuring distribution, release and mirror in tools tree config 3641/head
Daan De Meyer [Tue, 1 Apr 2025 18:37:52 +0000 (20:37 +0200)] 
Don't allow configuring distribution, release and mirror in tools tree config

config_default_repository_key_check() depends on ToolsTreeDistribution=
to select the right default. If the tools tree distribution is configured
in mkosi.tools.conf, we're unable to select the right default for
RepositoryKeyCheck= for the main image. Until we figure out a decent solution
for this, let's insist that the tools tree distribution is configured via
ToolsTreeDistribution=.

Similarly, selecting the default tools tree mirror depends on the selected
target distribution and mirror, so we insist on configuring the tools tree
mirror and release via ToolsTreeMirror= and ToolsTreeRelease= for now.

4 months agoFixes for config_default_repository_key_check()
Daan De Meyer [Tue, 1 Apr 2025 18:25:47 +0000 (20:25 +0200)] 
Fixes for config_default_repository_key_check()

Currently we assume fetching is not required if the host distribution
is not ubuntu, but this is wrong. If the host distribution is not ubuntu
but a ubuntu tools tree is used to build rpm based or Arch images, then
we still need key fetching.

Additionally, make RepositoryKeyFetch= a universal setting so that the
tools tree can have it enabled without enabling it for the main and subimages.
We then also drop the condition from config_default_repository_key_fetch()
that checks whether we need key fetching to build the tools tree distribution
because this will be determined automatically now when parsing the tools tree
config.

4 months agoFix typo
Daan De Meyer [Tue, 1 Apr 2025 13:33:58 +0000 (15:33 +0200)] 
Fix typo

We should append here since we modified it earlier, not override it.

4 months agoAllow configuring environment variables in tools tree config
Daan De Meyer [Tue, 1 Apr 2025 13:00:56 +0000 (15:00 +0200)] 
Allow configuring environment variables in tools tree config

4 months agoMerge pull request #3638 from DaanDeMeyer/fixes
Daan De Meyer [Tue, 1 Apr 2025 11:12:45 +0000 (13:12 +0200)] 
Merge pull request #3638 from DaanDeMeyer/fixes

Make sure /etc/ and /var/ always exist in sandbox

4 months agomkosi-obs: Only disable History= for main image 3638/head
Daan De Meyer [Tue, 1 Apr 2025 10:32:43 +0000 (12:32 +0200)] 
mkosi-obs: Only disable History= for main image

History= cannot be set anymore for subimages, so only disable it for
the main image.

4 months agoMake sure we chdir() to builtin config path before parsing
Daan De Meyer [Tue, 1 Apr 2025 10:30:19 +0000 (12:30 +0200)] 
Make sure we chdir() to builtin config path before parsing