Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build custom distribution: NotImplementedError #3313

Closed
MoltenArmor opened this issue Jan 3, 2025 · 4 comments · Fixed by #3326
Closed

Cannot build custom distribution: NotImplementedError #3313

MoltenArmor opened this issue Jan 3, 2025 · 4 comments · Fixed by #3326
Labels

Comments

@MoltenArmor
Copy link

MoltenArmor commented Jan 3, 2025

mkosi commit the issue has been seen with

main

Used host distribution

Fedora 40

Used target distribution

*Any

Linux kernel version used

*Any

CPU architectures issue was seen on

aarch64

Unexpected behaviour you saw

mkosi is installed through pipx on my system.

When invoking mkosi in this way:

~/.local/bin/mkosi -d custom --debug

The debug log says (which is not right):

[root@...]# ~/.local/bin/mkosi -d custom --debug
‣ Loading configuration file /root/aosc/mkosi.conf
‣ Loading configuration file /tmp/tmp7bitztbn/resources/mkosi-initrd/mkosi.conf
‣ Loading configuration file /tmp/tmp7bitztbn/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf
‣ Loading configuration file /tmp/tmp7bitztbn/resources/mkosi-initrd/mkosi.conf.d/10-fedora.conf
‣ Loading configuration file /tmp/tmp7bitztbn/resources/mkosi-initrd/mkosi.conf
‣ Validating certificates and keys
‣ Syncing package manager metadata
......

However, when invoking mkosi in this way:

python3 ~/.local/bin/mkosi -d custom --debug

The debug log says (which is what I expect):

[root@...]# python3 ~/.local/bin/mkosi -d custom --debug
‣ Including configuration file /root/aosc/mkosi.conf
‣ + stat --file-system --format %T /var/tmp
......

I have absolutely no idea why this happens. It might be a problem of pipx or venv?

Used mkosi config

[Include]
Include=

[Distribution]
Distribution=custom

[Content]
Bootable=no

[Output]
Format=directory
@MoltenArmor MoltenArmor added the bug label Jan 3, 2025
@DaanDeMeyer
Copy link
Contributor

Can you double check that this only happens with pipx? We load the mkosi-initrd configuration files to cleanup a previously cached version if needed

@MoltenArmor
Copy link
Author

MoltenArmor commented Jan 3, 2025

Can you double check that this only happens with pipx?

I think I get the issue: I installed an old version of mkosi (v22) with my distribution package manager (dnf), so python3 ~/.local/bin/mkosi in fact runs /usr/bin/mkosi 😢. My usage is incorrect. Under normal circumstances, python3 ~/.local/bin/mkosi should get:

Traceback (most recent call last):
  File "/root/.local/bin/mkosi", line 5, in <module>
    from mkosi.__main__ import main
ModuleNotFoundError: No module named 'mkosi'

We load the mkosi-initrd configuration files to cleanup a previously cached version if needed

However, loading these configurations in my case will cause NotImplementedError, which I think is probably not what we expect to see. This is the full log:

‣ Loading configuration file /root/aosc/mkosi.conf
‣ Loading configuration file /tmp/tmp5a7ujzem/resources/mkosi-initrd/mkosi.conf
‣ Loading configuration file /tmp/tmp5a7ujzem/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf
‣ Loading configuration file /tmp/tmp5a7ujzem/resources/mkosi-initrd/mkosi.conf.d/10-fedora.conf
‣ Loading configuration file /tmp/tmp5a7ujzem/resources/mkosi-initrd/mkosi.conf
‣ Validating certificates and keys
‣ Syncing package manager metadata
‣ Acquiring lock on /root/.cache/mkosi/custom~~arm64/cache/custom
‣ Acquired lock on /root/.cache/mkosi/custom~~arm64/cache/custom
‣ Acquiring lock on /root/.cache/mkosi/custom~~arm64/lib/custom
‣ Acquired lock on /root/.cache/mkosi/custom~~arm64/lib/custom
‣ + rm -rf -- /work/root/.cache/mkosi/mkosi-workspace-qsr8xst0
‣ Copying repository metadata
‣ + cp --recursive --no-dereference --preserve=mode,links,timestamps,ownership,xattr --reflink=auto --copy-contents '/work/root/.cache/mkosi/custom~~arm64/cache/custom' /work/root/.cache/mkosi/mkosi-metadata-7wrd97t5/cache/custom --no-target-directory
‣ + cp --recursive --no-dereference --preserve=mode,links,timestamps,ownership,xattr --reflink=auto --copy-contents '/work/root/.cache/mkosi/custom~~arm64/lib/custom' /work/root/.cache/mkosi/mkosi-metadata-7wrd97t5/lib/custom --no-target-directory
‣ Building default image
‣  Copying in skeleton file trees…
‣ + cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents /work/root/aosc/mkosi.skeleton /work/root/.cache/mkosi/mkosi-workspace-yjd1crgy/root --no-target-directory
‣ + rm -rf -- /work/root/.cache/mkosi/mkosi-workspace-yjd1crgy
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/mkosi/run.py", line 63, in uncaught_exception_handler
    yield
  File "/usr/local/lib/python3.12/site-packages/mkosi/run.py", line 104, in fork_and_wait
    target(*args, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/mkosi/__init__.py", line 4505, in run_build
    build_image(
  File "/usr/local/lib/python3.12/site-packages/mkosi/__init__.py", line 3612, in build_image
    install_distribution(context)
  File "/usr/local/lib/python3.12/site-packages/mkosi/__init__.py", line 210, in install_distribution
    with complete_step(f"Installing {context.config.distribution.pretty_name()}"):
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/mkosi/distributions/__init__.py", line 121, in pretty_name
    return self.installer().pretty_name()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/mkosi/distributions/__init__.py", line 28, in pretty_name
    raise NotImplementedError
NotImplementedError

My expected output is this (built with v22):

[root@...]# /usr/bin/mkosi -d custom --debug --debug-shell --debug-workspace
‣ Including configuration file /root/aosc/mkosi.conf
‣ + stat --file-system --format %T /var/tmp/mkosi-workspaceut6xh3up
‣ + cp --version
‣ + cp --recursive --dereference --preserve=mode,links --reflink=auto --copy-contents /etc/crypto-policies /var/tmp/mkosi-workspaceut6xh3up/pkgmngr/etc/crypto-policies --no-target-directory
‣ Copying in package manager file trees…
‣ + cp --version
‣ + cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents /root/aosc/mkosi.skeleton /var/tmp/mkosi-workspaceut6xh3up/pkgmngr --no-target-directory
‣ Syncing package manager metadata for default image
‣ Acquiring lock on /var/cache/mkosi/custom~~arm64/cache/custom
‣ Acquired lock on /var/cache/mkosi/custom~~arm64/cache/custom
‣ Acquiring lock on /var/cache/mkosi/custom~~arm64/lib/custom
‣ Acquired lock on /var/cache/mkosi/custom~~arm64/lib/custom
‣ + rm -rf -- /var/tmp/mkosi-workspaceut6xh3up
‣ + mount --make-rslave /
‣ + mount --rbind /etc /etc --options ro
‣ + mount --rbind /opt /opt --options ro
‣ + mount --rbind /boot /boot --options ro
‣ + mount --rbind /media /media --options ro
‣ + mount --rbind /usr /usr --options ro
‣ Building default image
‣ + stat --file-system --format %T /var/tmp/mkosi-workspacew7fnzk60
‣ + cp --version
‣ + cp --recursive --dereference --preserve=mode,links --reflink=auto --copy-contents /etc/crypto-policies /var/tmp/mkosi-workspacew7fnzk60/pkgmngr/etc/crypto-policies --no-target-directory
‣  Copying in package manager file trees…
‣ + cp --version
‣ + cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents /root/aosc/mkosi.skeleton /var/tmp/mkosi-workspacew7fnzk60/pkgmngr --no-target-directory
‣ Acquiring lock on /var/cache/mkosi/custom~~arm64/cache/custom
‣ Acquired lock on /var/cache/mkosi/custom~~arm64/cache/custom
‣ + cp --version
‣ + cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents '/var/cache/mkosi/custom~~arm64/cache/custom' /var/tmp/mkosi-workspacew7fnzk60/root/var/cache/custom --keep-directory-symlink --no-target-directory
‣ Acquiring lock on /var/cache/mkosi/custom~~arm64/lib/custom
‣ Acquired lock on /var/cache/mkosi/custom~~arm64/lib/custom
‣ + cp --version
‣ + cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents '/var/cache/mkosi/custom~~arm64/lib/custom' /var/tmp/mkosi-workspacew7fnzk60/root/var/lib/custom --keep-directory-symlink --no-target-directory
‣  Copying in skeleton file trees…
‣ + cp --version
‣ + cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents /root/aosc/mkosi.skeleton /var/tmp/mkosi-workspacew7fnzk60/root --no-target-directory
‣  Installing Custom
‣  Running prepare script /root/aosc/mkosi.prepare.chroot…
‣ + /work/prepare final
This script does nothing.
‣  Generating system users
‣ + systemd-sysusers --root /var/tmp/mkosi-workspacew7fnzk60/root
‣  Generating volatile files
‣ + systemd-tmpfiles --root=/var/tmp/mkosi-workspacew7fnzk60/root --boot --create --remove --exclude-prefix=/tmp --exclude-prefix=/var/tmp --exclude-prefix=/run --exclude-prefix=/proc --exclude-prefix=/sys --exclude-prefix=/dev
/var/tmp/mkosi-workspacew7fnzk60/root/usr/lib/tmpfiles.d/dbus.conf:13: Line references path below legacy directory /var/run/, updating /var/run/dbus/containers → /run/dbus/containers; please update the tmpfiles.d/ drop-in file accordingly.
/var/tmp/mkosi-workspacew7fnzk60/root/usr/lib/tmpfiles.d/var.conf:17: Duplicate line for path "/var/tmp/mkosi-workspacew7fnzk60/root/var/log/lastlog", ignoring.
‣  Applying presets…
‣ + systemctl --root /var/tmp/mkosi-workspacew7fnzk60/root preset-all
‣ + systemctl --root /var/tmp/mkosi-workspacew7fnzk60/root --global preset-all
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/default.target.wants/ssh-agent.service' → '/usr/lib/systemd/user/ssh-agent.service'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/sockets.target.wants/pulseaudio.socket' → '/usr/lib/systemd/user/pulseaudio.socket'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/timers.target.wants/systemd-tmpfiles-clean.timer' → '/usr/lib/systemd/user/systemd-tmpfiles-clean.timer'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/default.target.wants/clash-meta.service' → '/usr/lib/systemd/user/clash-meta.service'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/dbus-org.bluez.obex.service' → '/usr/lib/systemd/user/obex.service'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/basic.target.wants/systemd-tmpfiles-setup.service' → '/usr/lib/systemd/user/systemd-tmpfiles-setup.service'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/default.target.wants/pulseaudio.service' → '/usr/lib/systemd/user/pulseaudio.service'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/sockets.target.wants/p11-kit-server.socket' → '/usr/lib/systemd/user/p11-kit-server.socket'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/default.target.wants/clash-oss.service' → '/usr/lib/systemd/user/clash-oss.service'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/sockets.target.wants/pk-debconf-helper.socket' → '/usr/lib/systemd/user/pk-debconf-helper.socket'.
Created symlink '/var/tmp/mkosi-workspacew7fnzk60/root/etc/systemd/user/default.target.wants/p11-kit-server.service' → '/usr/lib/systemd/user/p11-kit-server.service'.
‣  Generating hardware database
‣ + systemd-hwdb --root /var/tmp/mkosi-workspacew7fnzk60/root --usr --strict update
‣ + cp --version
‣ + cp --recursive --no-dereference --preserve=mode,links,timestamps,ownership,xattr --reflink=auto --copy-contents /var/tmp/mkosi-workspacew7fnzk60/root/var/cache/custom /var/tmp/mkosi-workspacew7fnzk60/package-cache-dir/cache/custom --keep-directory-symlink --no-target-directory
‣ + cp --version
‣ + cp --recursive --no-dereference --preserve=mode,links,timestamps,ownership,xattr --reflink=auto --copy-contents /var/tmp/mkosi-workspacew7fnzk60/root/var/lib/custom /var/tmp/mkosi-workspacew7fnzk60/package-cache-dir/lib/custom --keep-directory-symlink --no-target-directory
‣  /root/aosc/image size is 5.0G.
‣ + rm -rf -- /var/tmp/mkosi-workspacew7fnzk60

Could you please tell me under what conditions would mkosi-initrd configuration be loaded? And is there any way to disable it? I did not find the related code section.

@MoltenArmor MoltenArmor changed the title Different invocation methods result in different configurations loaded Cannot build custom distribution: NotImplementedError Jan 3, 2025
@DaanDeMeyer
Copy link
Contributor

@MoltenArmor The NotImplementedError should be fixed by #3318

@MoltenArmor
Copy link
Author

MoltenArmor commented Jan 4, 2025

@MoltenArmor The NotImplementedError should be fixed by #3318

mkosi does not load mkosi-intird configurations this time, but I still get NotImplementedError:

[root@......]# pipx reinstall mkosi
uninstalled mkosi! ✨ 🌟 ✨
⚠️  Note: mkosi was already on your PATH at /usr/bin/mkosi
  installed package mkosi 24.3, installed using Python 3.12.6
  These apps are now globally available
    - mkosi
    - mkosi-initrd
    - mkosi-sandbox
done! ✨ 🌟 ✨

[root@......]# ~/.local/bin/mkosi -d custom --debug --debug-shell
‣ Loading configuration file /root/aosc/mkosi.conf
‣ Validating certificates and keys
‣ Syncing package manager metadata
‣ Acquiring lock on /root/.cache/mkosi/custom~~arm64/cache/custom
‣ Acquired lock on /root/.cache/mkosi/custom~~arm64/cache/custom
‣ Acquiring lock on /root/.cache/mkosi/custom~~arm64/lib/custom
‣ Acquired lock on /root/.cache/mkosi/custom~~arm64/lib/custom
‣ + rm -rf -- /work/root/.cache/mkosi/mkosi-workspace-w2put89m
‣ Copying repository metadata
‣ + cp --recursive --no-dereference --preserve=mode,links,timestamps,ownership,xattr --reflink=auto --copy-contents '/work/root/.cache/mkosi/custom~~arm64/cache/custom' /work/root/.cache/mkosi/mkosi-metadata-0zykrvfw/cache/custom --no-target-directory
‣ + cp --recursive --no-dereference --preserve=mode,links,timestamps,ownership,xattr --reflink=auto --copy-contents '/work/root/.cache/mkosi/custom~~arm64/lib/custom' /work/root/.cache/mkosi/mkosi-metadata-0zykrvfw/lib/custom --no-target-directory
‣ Building default image
‣  Copying in skeleton file trees…
‣ + cp --recursive --no-dereference --preserve=mode,links --reflink=auto --copy-contents /work/root/aosc/mkosi.skeleton /work/root/.cache/mkosi/mkosi-workspace-yq6l1i7i/root --no-target-directory
‣ + rm -rf -- /work/root/.cache/mkosi/mkosi-workspace-yq6l1i7i
Traceback (most recent call last):
  File "/root/.local/share/pipx/venvs/mkosi/lib64/python3.12/site-packages/mkosi/run.py", line 63, in uncaught_exception_handler
    yield
  File "/root/.local/share/pipx/venvs/mkosi/lib64/python3.12/site-packages/mkosi/run.py", line 104, in fork_and_wait
    target(*args, **kwargs)
  File "/root/.local/share/pipx/venvs/mkosi/lib64/python3.12/site-packages/mkosi/__init__.py", line 4505, in run_build
    build_image(
  File "/root/.local/share/pipx/venvs/mkosi/lib64/python3.12/site-packages/mkosi/__init__.py", line 3612, in build_image
    install_distribution(context)
  File "/root/.local/share/pipx/venvs/mkosi/lib64/python3.12/site-packages/mkosi/__init__.py", line 210, in install_distribution
    with complete_step(f"Installing {context.config.distribution.pretty_name()}"):
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/pipx/venvs/mkosi/lib64/python3.12/site-packages/mkosi/distributions/__init__.py", line 121, in pretty_name
    return self.installer().pretty_name()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/pipx/venvs/mkosi/lib64/python3.12/site-packages/mkosi/distributions/__init__.py", line 28, in pretty_name
    raise NotImplementedError
NotImplementedError
‣ + tput cnorm
‣ + tput smam

Any ideas? @DaanDeMeyer

@DaanDeMeyer DaanDeMeyer linked a pull request Jan 5, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants