systemd / mkosi

💽 Build Bespoke OS Images
https://mkosi.systemd.io/
1.19k stars 324 forks source link

Add a mkosi.init script to run before configuration files parsing happens #3176

Open davide125 opened 1 week ago

davide125 commented 1 week ago

mkosi commit the issue has been seen with

main

Used host distribution

Fedora Linux 41

Used target distribution

Fedora Linux 41

Linux kernel version used

No response

CPU architectures issue was seen on

None

Unexpected behaviour you saw

I'd like to have a mkosi.init script to run at the very beginning (before config parsing/validation) in order to create/initialize the contents of things like PackageDirectories and ExtraSearchPaths. The specific usecase I have in mind is building systemd as part of the mkosi build, and including the systemd packages into the image built by mkosi. My attempt at that involved cloning systemd in the mkosi directory, and then adding a mkosi.sync with mkosi --directory=systemd --release=41 -t none to build it. However, this runs too late, and mkosi ends up failing because the build directory doesn't exist yet.

Used mkosi config

[Distribution]
Distribution=fedora
Release=41

[Content]
PackageDirectories=systemd/build/mkosi.builddir/%d~%r~%a

[Host]
ExtraSearchPaths=systemd/build/mkosi.builddir/%d~%r~%a

mkosi output

‣ systemd/build/mkosi.builddir/fedora~41~x86-64 does not exist
davide125 commented 1 week ago

Obviously, a workaround for this is manually running mkdir systemd/build/mkosi.builddir/fedora~41~x86-64 before attempting to build, but that's an additional manual step I'd like to avoid if possible.