systemd / mkosi

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

Dependency /usr/lib/systemd/ukify is not available for most distros(under 255) #2220

Closed bsdnet closed 11 months ago

bsdnet commented 11 months ago

$ bin/mkosi ‣ Removing output files… ‣ Building default image ‣ Could not find '/usr/lib/systemd/ukify' which is required to build bootable images. ‣ (Bootable=no can be used to create a non-bootable image) [ryx@rockylinux mkosi]$ sudo dnf install mkosi Error: Unable to find a match: mkosi

The way to reproduce is to git clone the latest repo, and follow the instructions to execute mkosi for tag v19 ... 16

DaanDeMeyer commented 11 months ago

You can use ToolsTree=default to have mkosi build an image with ukify and other tools in it which is used to build the final image.

bsdnet commented 11 months ago

Thanks, @DaanDeMeyer

Should ToolsTree=default be the default setting or provide a default mkosi.conf for testing?

Saw the option is added in v17.

In addition, when I tried to build a debian using Rocky Linux, I hit the following:

 $ bin/mkosi
‣ Removing output files…
‣ Removing output files…
‣ Building debian-tools image
‣  Installing Debian
env: ‘apt-get’: No such file or directory
‣ "env APT_CONFIG=/home/rockyuser/.cache/mkosi-workspacexlgwjeqw/apt.conf DEBIAN_FRONTEND=noninteractive DEBCONF_INTERACTIVE_SEEN=true INITRD=No apt-get -o APT::Architecture=amd64 -o APT::Architectures=amd64 -o APT::Immediate-Configure=off -o APT::Get::Assume-Yes=true -o APT::Get::AutomaticRemove=true -o APT::Get::Allow-Change-Held-Packages=true -o APT::Get::Allow-Remove-Essential=true -o APT::Sandbox::User=root -o Dir::Cache=/home/rockyuser/workspace/mkosi/mkosi.cache/tools/apt -o Dir::State=/home/rockyuser/.cache/mkosi-workspacexlgwjeqw/pkgmngr/var/lib/apt -o Dir::State::status=/home/rockyuser/.cache/mkosi-workspacexlgwjeqw/root/var/lib/dpkg/status -o Dir::Etc::trusted=/usr/share/keyrings/debian-archive-keyring.gpg -o Dir::Etc::trustedparts=/usr/share/keyrings -o Dir::Log=/home/rockyuser/.cache/mkosi-workspacexlgwjeqw/pkgmngr/var/log/apt -o Dir::Bin::dpkg=/usr/bin/dpkg -o Debug::NoLocking=true -o DPkg::Options::=--root=/home/rockyuser/.cache/mkosi-workspacexlgwjeqw/root -o DPkg::Options::=--log=/home/rockyuser/.cache/mkosi-workspacexlgwjeqw/pkgmngr/var/log/apt/dpkg.log -o DPkg::Options::=--force-unsafe-io -o DPkg::Options::=--force-architecture -o DPkg::Options::=--force-depends -o Dpkg::Use-Pty=false -o DPkg::Install::Recursive::Minimum=1000 -o pkgCacheGen::ForceEssential=, update" returned non-zero exit code 127.

I can use debootstap to build a bookworm image on the same machine.

Does mkosi require apt-get on the host filesystem?

DaanDeMeyer commented 11 months ago

@bsdnet Yes we require apt-get on the host filesystem to build Debian/Ubuntu images. debootstrap is a poor reimplementation of half of apt so we use apt directly instead. Note that apt is packaged in EPEL 9 so you can just install it on Rocky.

ToolsTree=default should not be the default setting since for example on Arch Linux and Fedora 39 all necessary tools are available already and there's no need for ToolsTree=default.

bsdnet commented 11 months ago

Note that apt is packaged in EPEL 9 so you can just install it on Rocky.

Thanks, let me give it a try when I am back home.

ToolsTree=default should not be the default setting since for example on Arch Linux and Fedora 39 all necessary tools are available already and there's no need for ToolsTree=default.

Depends on how to view this issue, if we consider most OS distributions are still using old systemd, making ToolsTree=default has the following benefits:

As to Arch Linux and Fedora 39, they can package it without ToolsTree=default since they are using latest systemd.

Just some thoughts!

DaanDeMeyer commented 11 months ago

https://github.com/systemd/mkosi/pull/2229 will mention ToolsTree=default in the error message when ukify cannot be found. That should be sufficient to direct users towards ToolsTree=default.

bsdnet commented 11 months ago

I did get the following after running dnf install apt:

‣  Generating hardware database
‣  /home/royyang/workspace/mkosi/mkosi.output/debian-tools size is 978.6M.
‣ Building default image
‣ Could not find 'ukify' which is required to build bootable images.
‣ (Bootable=no can be used to create a non-bootable image)

The command I run bin/mkosi --distribution debian. I added ToolsTree=default into mkosi.conf

devdekunle commented 8 months ago

You can use ToolsTree=default to have mkosi build an image with ukify and other tools in it which is used to build the final image.

Hello @DaanDeMeyer good morning. Please I am also having challenges with this #32020 while trying to set up mkosi. That's when I run sudo mkosi boot in the SystemD project repo. While searching for solutions I came across this issue. I wrote the ToolsTree=default in the mkonsi.conf file. And tried again but I still encountered the same error when trying to generate the image. I don't know if I did it right. I'm trying to set it up because I'm trying to run the integration tests of test/TEST-26-SYSTEMCTL. I'd like to ask if I absolutely need to have mkosi set up before I can do that sir.

devdekunle commented 8 months ago

‣ Generating unified kernel image for kernel version 6.8.0-11-generic /usr/lib/systemd/ukify: 1: exec: /usr/lib/systemd/ukify: not found ‣ "/usr/lib/systemd/ukify --cmdline @/home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/cmdline --os-release @/home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/usr/lib/os-release --stub /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/usr/lib/systemd/boot/efi/linuxx64.efi.stub --output /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/boot/EFI/Linux/ubuntu-6.8.0-11-generic.efi --efi-arch x64 --uname 6.8.0-11-generic --sign-kernel --signtool sbsign --secureboot-private-key /home/adekunle/systemd/mkosi.key --secureboot-certificate /home/adekunle/systemd/mkosi.crt --pcr-private-key /home/adekunle/systemd/mkosi.key --pcr-banks sha1,sha256 build --linux /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/usr/lib/modules/6.8.0-11-generic/vmlinuz --initrd /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/microcode.initrd --initrd /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/initrd --initrd /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/kernel-modules-6.8.0-11-generic.initrd" returned non-zero exit code 127. This is the error I get while setting up

DaanDeMeyer commented 8 months ago

@devdekunle Unfortunately this is not sufficient information for me to be able to help out. I need the full logs with --debug and I need the mkosi version that you're using, as well as any local configuration changes that you've made.

devdekunle commented 8 months ago

Thank you very much sir @DaanDeMeyer for your response. Please how can I show you the log. should I run sudo mkosi boot --debug and copy and paste the logs here? And I use mkosi v21 and the only change I've made to the mkosi.conf file is adding the ToolsTree=default

DaanDeMeyer commented 8 months ago

Put the logs in a github gist (https://gist.github.com/) and paste the link here. Please make sure you're using the latest version from git.

devdekunle commented 8 months ago

Put the logs in a github gist (https://gist.github.com/) and paste the link here. Please make sure you're using the latest version from git.

Thank you very much for your time and assistance @DaanDeMeyer. I am doing that now

devdekunle commented 8 months ago

Hello @DaanDeMeyer, https://gist.github.com/devdekunle/9fecce0145d43021baa0cd3c56c58bda This is the link to the github gist page. The mkosi_output.log contains the log from running sudo mkosi --debug boot in the systemd local repo and also the mkosi.conf file in the mkosi repo on my local machine. I have not made any changes to it. this is mkosi version 22. Please let me give you a little background to why i want to use mkosi. I opened a PR to add an option --by-slice to systemctl list-units command which prints the units slice tree structure. So i added a test coverage in test/units/testsuites-26.sh. but each time i try to run all the tests using sudo test/run-integration-tests.sh there are errors which say qemu binary not found and also that i the build directory needs to be confugured with -Dinstall-test=true. I have done reconfigured several times but it still gives the same errors. So i found out that the test/TEST-??-... subdirectories all have a make file which decribes an OS image and the test script to run. That is why i want to set up mkosi and run the tests in the environment with systemd-nspawn. Thank you for your time sir.

devdekunle commented 8 months ago

‣ Generating unified kernel image for kernel version 6.8.0-11-generic /usr/lib/systemd/ukify: 1: exec: /usr/lib/systemd/ukify: not found ‣ "/usr/lib/systemd/ukify --cmdline @/home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/cmdline --os-release @/home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/usr/lib/os-release --stub /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/usr/lib/systemd/boot/efi/linuxx64.efi.stub --output /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/boot/EFI/Linux/ubuntu-6.8.0-11-generic.efi --efi-arch x64 --uname 6.8.0-11-generic --sign-kernel --signtool sbsign --secureboot-private-key /home/adekunle/systemd/mkosi.key --secureboot-certificate /home/adekunle/systemd/mkosi.crt --pcr-private-key /home/adekunle/systemd/mkosi.key --pcr-banks sha1,sha256 build --linux /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/root/usr/lib/modules/6.8.0-11-generic/vmlinuz --initrd /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/microcode.initrd --initrd /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/initrd --initrd /home/adekunle/.cache/mkosi/mkosi-workspace0guekfhd/kernel-modules-6.8.0-11-generic.initrd" returned non-zero exit code 127. Earlier this is the error i was getting. But now it is different. I think it's encountering a new error before getting to that stage. Thank you once again @DaanDeMeyer

DaanDeMeyer commented 8 months ago

@devdekunle Please try setting Distribution=debian in the config file, ubuntu isn't working properly at the moment.

devdekunle commented 8 months ago

Okay thank you very much for your response @DaanDeMeyer I'll do that and give you feedback. I really appreciate.

devdekunle commented 8 months ago

@devdekunle Please try setting Distribution=debian in the config file, ubuntu isn't working properly at the moment.

Hello @DaanDeMeyer. Thank you very much. I added this to mkosi.conf file in the forked systemd repo and it worked. Thank you once again. I really appreciate your time and assistance.