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

[Investigate] support foreign architectures #104

Open
tigarmo opened this issue Jan 26, 2024 · 4 comments
Open

[Investigate] support foreign architectures #104

tigarmo opened this issue Jan 26, 2024 · 4 comments
Labels
Enhancement New feature or request triaged
Milestone

Comments

@tigarmo
Copy link
Collaborator

tigarmo commented Jan 26, 2024

What needs to get done

PR #96 restricted the calls to dpkg --add-architecture to only "compatible" pairs of architectures. This suits a lot of use cases, particularly those that just need to download (but not install) packages from a non-host arch.

Where this breaks is effective cross-compilation; any non-trivial cross-compilation case will require dependencies in the target architecture (like dev versions of shared libraries), and the common idiom of:

build-packages:
  - libxx-dev:arch
stage-packages:
  - libxx:arch

does not work because the installation of libxx-dev:arch fails, because the target arch there has not been added to the system via dpkg --add-architecture.

As #96 explains, the reason we can't just call dpkg --add-architeture non-host-arch is because the official archives list all archs (even those they don't have packages for) and default Apt installations do not restrict the archs in those archives. See /etc/apt/sources.list on my machine:

...
deb http://archive.ubuntu.com/ubuntu jammy-updates universe
...

... so apt update will try to fetch the packages listing for "non-host-arch" from archive.ubuntu.com and fail.

What we need to investigate/prototype is a different strategy: if a package-repo with a non-host arch is added (e.g. adding an armhf repo in an amd64 host), we must call dpkg --add-architecture armhf (or whatever arch), but we must also fix
those sources listings that don't "pin" the arch. In the example above, the new line would read:

...
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-updates universe
...

Here's a series of steps that users are currently doing in host installations to support this scenario:

> dpkg --add-architecture ${ARCH}
> sed -ri "s/^deb /deb [arch=amd64] /g" /etc/apt/sources.list
> apt update
> apt --fix-broken install -y
> apt upgrade -y

... of course, that script only fixes a single file and doesn't do any verification of pre-existing architectures, so the actual commands need to be improved, but the general idea is this.

Why it needs to get done

To make the build system more robust and improve support for cross-compilation.

@tigarmo
Copy link
Collaborator Author

tigarmo commented Jan 29, 2024

Here's the script that Ondrej uses to configure the lxd instance (to then run Snapcraft in destructive mode inside it): https://github.com/kubiko/toolbox/blob/20/glue/bin/snapcraft-lxd-wrapper

@tigarmo
Copy link
Collaborator Author

tigarmo commented Jan 30, 2024

Looks like ubuntu-daily images for noble changed the default sources: instead of the regular file /etc/apt/sources.list, it's now in /etc/apt/sources.list.d/ubuntu.sources in deb822 format:

> cat /etc/apt/sources.list.d/ubuntu.sources
...
# Types: deb deb-src
Types: deb
URIs: http://archive.ubuntu.com/ubuntu
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

## Ubuntu security updates. Aside from URIs and Suites,
## this should mirror your choices in the previous section.
# Types: deb deb-src
Types: deb
URIs: http://security.ubuntu.com/ubuntu
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

@tigarmo
Copy link
Collaborator Author

tigarmo commented Aug 16, 2024

Dilyn mentioned today that this snapcraft project is a good one to use when evaluating a fix: https://github.com/canonical/iot-field-kernel-snap/tree/24-riscv64-nezha
None of that handling of apt sources in the Building section should be necessary.

@lengau lengau added this to the 25.04 milestone Sep 4, 2024
@lengau lengau added the Enhancement New feature or request label Sep 4, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3316.

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

2 participants