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

Unable to add packages for other architectures #149

Closed
xobs opened this issue Nov 12, 2017 · 13 comments
Closed

Unable to add packages for other architectures #149

xobs opened this issue Nov 12, 2017 · 13 comments

Comments

@xobs
Copy link

xobs commented Nov 12, 2017

The documentation states that it's possible to create derivative images that include additional packages required for building. For example, libasound2-dev is required to build the asound-dev package. README.md states that it is possible to do this:

FROM japaric/aarch64-unknown-linux-gnu:v0.1.4

RUN dpkg --add-architecture arm64 && \
    apt-get update && \
    apt-get install libfoo:arm64

However this doesn't actually work, because the distribution that is in use doesn't support other architectures:

xobs@nas /d/x/d/cross-build> docker run --rm -it japaric/aarch64-unknown-linux-gnu:v0.1.4 bash
root@a2a1fcfefc05:/# dpkg --add-architecture arm64 && \
>     apt-get update
Ign http://archive.ubuntu.com trusty InRelease
Get:1 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
...
Err http://archive.ubuntu.com trusty-updates/restricted arm64 Packages
  404  Not Found [IP: 91.189.88.149 80]
Err http://archive.ubuntu.com trusty-updates/universe arm64 Packages
  404  Not Found [IP: 91.189.88.149 80]
...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/restricted/binary-arm64/Packages  404  Not Found [IP: 91.189.88.149 80]

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/universe/binary-arm64/Packages  404  Not Found [IP: 91.189.88.149 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.
root@a2a1fcfefc05:/#
@ticky
Copy link

ticky commented Nov 26, 2017

I have just run into this, too. Is there a viable workaround? It seems weird that the documented solution doesn’t actually work!

@ticky
Copy link

ticky commented Nov 28, 2017

Just had another look into this. It looks like a newer version of japaric/aarch64-unknown-linux-gnu would work, as current versions are based on Ubuntu 14.04, however many of the images are still based on 12.04, which doesn’t support multiarch.

Is there a reason the other images are not using 14.04 or newer, at this stage?

@Bobo1239
Copy link
Contributor

@ticky As I understand it: #85

@ticky
Copy link

ticky commented Nov 29, 2017

That’s great, but that should both be documented somewhere and the instructions that say “just use --add-architecture” need a viable alternative for 12.04. Or they simply need updating to 14.04. :)

@spacekookie
Copy link

spacekookie commented May 4, 2018

This isn't just because of the Ubuntu 12.04 containers.

I just build my own version of the armv7 image, based on Ubuntu 14.04 (and 16.04 later) to see if I could add other packages from the armhf architecture but the apt-get update fails after adding the architecture because of broken links to the repository (lots of 404 errors).

So simply bumping the versions won't resolve this issue. And I'm currently actually not sure how Ubuntu does this in general...

@PAStheLoD
Copy link

For Ubuntu the repositories for the ports are located at a different URL (so, not archive.ubuntu.com): http://ports.ubuntu.com/dists/bionic/main/ therefore /etc/apt/sources.list needs to be adapted.

@spacekookie
Copy link

spacekookie commented May 4, 2018

@PAStheLoD True, I forgot to mention in my original comment that it wasn't just that though. When adding the proper sources I get issues like this which sounds like apt can't have libraries of multiple architectures installed at the same time

The following packages have unmet dependencies:
 libudev-dev:armhf : Depends: libacl1:armhf (>= 2.2.51-8) but it is not going to be installed
                     Depends: libblkid1:armhf (>= 2.19.1) but it is not going to be installed
                     Depends: libc6:armhf (>= 2.17) but it is not going to be installed
                     Depends: libgcc1:armhf (>= 1:3.5) but it is not going to be installed
                     Depends: libkmod2:armhf (>= 5~) but it is not going to be installed
                     Depends: libselinux1:armhf (>= 2.0.65) but it is not going to be installed
                     Depends: libudev1:armhf (= 229-4ubuntu4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

When trying to install all the dependencies manually it results in it removing amd64 packages...

(I ended up moving to Debian where it works)

@gdesmott
Copy link
Contributor

gdesmott commented Apr 6, 2020

@spacekookie : I'm facing a similar issue. Can you please share the Docker file you used to build a Debian-based image? thanks :)

@gdesmott
Copy link
Contributor

gdesmott commented Apr 7, 2020

I finally managed to make it work as well using Debian Buster as base for the image. Here is my Docker file for reference:

FROM debian:buster

COPY common.sh /
RUN /common.sh

COPY cmake.sh /
RUN /cmake.sh

COPY xargo.sh /
RUN /xargo.sh

RUN apt-get install -y --no-install-recommends \
    g++-arm-linux-gnueabihf \
    libc6-dev-armhf-cross

COPY qemu.sh /
RUN /qemu.sh arm softmmu

COPY dropbear.sh /
RUN /dropbear.sh

COPY linux-image.sh /
RUN /linux-image.sh armv7

COPY linux-runner /

RUN dpkg --add-architecture armhf && \
    apt-get update && \
    apt-get install -y libgstreamer1.0-dev:armhf libgstreamer-plugins-base1.0-dev:armhf libssl-dev:armhf

ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
    CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER="/linux-runner armv7" \
    CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
    CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
    QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf \
    RUST_TEST_THREADS=1 \
    PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig

Note the PKG_CONFIG_PATH env variable at the end needed so build scripts will actually find the deps.

Building this image require my patch from #403.

May downside here is we have to create an image from scratch and copy all cross docker scripts. Providing updated images based on latest Ubuntu (and ideally latest Debian stable as well) would prevent this: #186

@gdesmott
Copy link
Contributor

gdesmott commented Apr 7, 2020

Note the PKG_CONFIG_PATH env variable at the end needed so build scripts will actually find the deps.

I opened #404 suggesting that we do that in official images to make things easier for users.

@rvolgers
Copy link
Contributor

Some packages do indeed just not work with multi-arch on ubuntu.

One other problem though, as noted, is that packages for other architectures live in another repo on the version of ubuntu used here. That problem was recently fixed however, using this kind of horrible workaround:

3b07a08

bors bot added a commit that referenced this issue Sep 8, 2020
454: Bump README custom-container cross version to incorporate fixes r=therealprof a=theunkn0wn1

The custom dockerfile example in the README targets cross version 0.1.16, [and is known to not actually work as-is](3b07a08).
The fix for this particular issue was released with cross 0.2, thus this PR bumps the cross version.

This became an issue in my use case as I wanted to cross-compile to a raspberry Pi, and needed to install some external libraries not included in the base images, and ran into issues such as #149 and #35 while attempting to follow the recommendation in the readme.

Bumping the cross version to 0.2.x resolved the above issues for me, and this PR is to help other users that may find themselves running into the same issues when following the readme closely.

Co-authored-by: joshua salzedo <joshuasalzedo@gmail.com>
@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented May 27, 2022

I'll be adding examples of this to the wiki including PKG_CONFIG_PATH. but the base for linking to external dependencies and adding external architectures should be provided here.

Note that we internally use debian repositories, so you shouldn't need to rebuild the entire image. See linux-image.sh for how to configure debian repositories to install packages, then restore the old package list. I'll also add this to the Wiki.

@Alexhuszagh
Copy link
Contributor

With #727 we've added the PKG_CONFIG_PATH to all *-linux-gnu images, so adding external packages is now documented and pkg-config support is enabled by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants