systemd / mkosi

💽 Build Bespoke OS Images
https://mkosi.systemd.io/
GNU Lesser General Public License v2.1
1.1k stars 300 forks source link

No support for mixed architectures (32-bit on 64-bit) #2755

Open mcassaniti opened 1 month ago

mcassaniti commented 1 month ago

mkosi commit the issue has been seen with

main

Used host distribution

Ubuntu 24.04 (noble)

Used target distribution

Ubuntu 24.04 (noble)

Linux kernel version used

6.8.0-31-generic

CPU architectures issue was seen on

x86_64

Unexpected behaviour you saw

I added the file apt-extra/var/lib/dpkg/arch with the contents below. This is the equivalent of running dpkg --add-architecture i386 on an amd64 machine. I could not install any i386 based packages.

amd64
i386

Used mkosi config

# Only relevant content shown

[Distribution]
PackageManagerTrees = apt-extra

[Content]
Packages = libc6:i386

mkosi output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libc6:i386
‣ "apt-get -o APT::Architecture=amd64 -o APT::Architectures=amd64 -o APT::Install-Recommends=false -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 Acquire::AllowReleaseInfoChange=true -o Dir::Cache=/var/cache/apt -o Dir::State=/var/lib/apt -o Dir::Log=/var/log/apt -o Dir::State::Status=/buildroot/var/lib/dpkg/status -o Dir::Bin::DPkg=/usr/bin/dpkg -o Debug::NoLocking=true -o DPkg::Options::=--root=/buildroot -o DPkg::Options::=--force-unsafe-io -o DPkg::Options::=--force-architecture -o DPkg::Options::=--force-depends -o DPkg::Options::=--no-debsig -o DPkg::Use-Pty=false -o DPkg::Install::Recursive::Minimum=1000 -o pkgCacheGen::ForceEssential=, install libc6:i386" returned non-zero exit code 100.
mcassaniti commented 1 month ago

The underlying issue is setting -o APT::Architectures=amd64 which overrides the additional file. Is this a case that the project wishes to support?

behrmann commented 1 month ago

That's an edge case. I think only Debian does multilib the way Debian does it.

I don't think we want to set up sources.list for multiple architectures—users needing that can use package manager trees or skeletons. If dropping the -o APT::Architectures= line is enough to fix it or if changing it to only defaulting to debarch and reading the arches from /var/lib/dpkg/arch in the package manager tree or root is enough to fix it and this doesn't interfere with the single arch case, than I think changing that would be fine.

mcassaniti commented 1 month ago

Dropping the option is sufficient with the basic testing I've done but let me do a more thorough test and get back to you.

DaanDeMeyer commented 1 month ago

systemd has a concept of secondary architectures so that i386 is a secondary architecture for x86-64. We could add that as well by adding a secondary() method to he Architecture enum which returns the secondary architecture if there is one and then set APT::Architectures to both the main and secondary architectures.

behrmann commented 1 month ago

I'm not sure we should do this in all cases. I'm not entirely sure how to understand the man page there

The initial default is always the system's native architecture (APT::Architecture), and foreign architectures are added to the default list when they are registered via dpkg --add-architecture.

i.e. whether setting this is equivalent to having done the dpkg --add-architecture. I for one am quite happy to finally getting rid of having multilib systems, so if this would were equivalent to running to dpkg --add-architecture, I'd rather have this be opt in.

mcassaniti commented 3 weeks ago

After poking and prodding I've given up and opted to use a post-install script. This one really should be marked as wont-fix unless you want to test all the bits.