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

Installing pcscd library with arm-unknown-linux-gnueabihf DockerFile #1076

Closed
Iskers opened this issue Oct 14, 2022 · 6 comments
Closed

Installing pcscd library with arm-unknown-linux-gnueabihf DockerFile #1076

Iskers opened this issue Oct 14, 2022 · 6 comments

Comments

@Iskers
Copy link

Iskers commented Oct 14, 2022

I'm trying to use cross with Docker to develop for Raspberry Pi. I have created a Dockerfile in order to recreate the enviroment but am not able to install the needed Rust library.

FROM rustembedded/cross:arm-unknown-linux-gnueabihf

RUN apt-get update
RUN dpkg --add-architecture armhf && \
    apt-get update

RUN apt-get install --assume-yes zlib1g:armhf
RUN apt-get install --assume-yes pcscd:armhf libpcsclite-dev:armhf 

When installing pcscd i get the error:

#10 9.531 Setting up python2.7-minimal:armhf (2.7.17-1\~18.04ubuntu1.8) ...
#10 9.572 /usr/bin/python2.7: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
#10 9.573 dpkg: error processing package python2.7-minimal:armhf (--configure):
#10 9.573  installed python2.7-minimal:armhf package post-installation script subprocess returned error exit status 127
#10 9.573 dpkg: dependency problems prevent configuration of python2.7:armhf:
#10 9.573  python2.7:armhf depends on python2.7-minimal (= 2.7.17-1~18.04ubuntu1.8); however:
#10 9.573   Package python2.7-minimal:armhf is not configured yet.
#10 9.573
#10 9.573 dpkg: error processing package python2.7:armhf (--configure):
#10 9.573  dependency problems - leaving unconfigured
#10 9.573 Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
#10 9.606 Errors were encountered while processing:
#10 9.606  python2.7-minimal:armhf
#10 9.606  python2.7:armhf
#10 9.629 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
executor failed running [/bin/sh -c apt-get install --assume-yes python2.7:armhf]: exit code: 100

@Alexhuszagh
Copy link
Contributor

So there is a solution here it seems:

LD_PRELOAD=/lib/arm-linux-gnueabihf/libz.so.1 apt-get install --assume-yes pcscd:armhf libpcsclite-dev:armhf

This will correctly fail to preload the ARM zlib library on the apt-get step, but then succeed on the python2.7 configuration and then the install of these dependent libraries. It might also be possible to add it to the pkg-config path or also create a symlink.

A side note, the image you're using is out-of-date by over a year. You should be using ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:main, not rustembedded/cross:arm-unknown-linux-gnueabihf. Those images are old and unsupported.

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Oct 14, 2022

arm-unknown-linux-gnueabihf-specific

NOTE: You're probably going to run into #1017, since the Debian repositories generally are built against ARMv7-a and not an ARMv6 architecture:

$ readelf -a /usr/lib/arm-linux-gnueabihf/libpcsclite.so.1.0.0
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6

This will give you illegal instructions on your RPi 0 or RPi W. You will have to build those dependencies from source. It seems like #1018 was not enough in this case.

More General

There's a better solution: add the --no-install-recommends flag to apt-get install:

FROM ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:main
# useful in case anything wants an interactive prompt
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN dpkg --add-architecture armhf && \
    apt-get update

RUN apt-get install --assume-yes zlib1g:armhf --no-install-recommends
RUN apt-get install --assume-yes pcscd:armhf libpcsclite-dev:armhf --no-install-recommends

I'll document this on the wiki.

@Alexhuszagh Alexhuszagh changed the title Installing pcscd library with arm-unknown-linux-gnueabihf DockerFile Deny List for ARMv6 HF Targets not Working Oct 14, 2022
@Alexhuszagh Alexhuszagh changed the title Deny List for ARMv6 HF Targets not Working Installing pcscd library with arm-unknown-linux-gnueabihf DockerFile Oct 14, 2022
@Alexhuszagh
Copy link
Contributor

Closing since the wiki has been updated and I've confirmed the deny lists are working for the latest images. This means that all armhf architecture packages will not have installation candidates for the arm-unknown-linux-gnueabihf target.

$ docker pull ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:main
$ docker run -it --rm ghcr.io/cross-rs/arm-unknown-linux-gnueabihf:main bash
$ dpkg --add-architecture armhf && apt-get update && apt-get install --assume-yes zlib1g:armhf
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package zlib1g:armhf is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  zlib1g zlib1g:i386

E: Package 'zlib1g:armhf' has no installation candidate
$ cat /etc/apt/preferences.d/all-packages
Package: *:armhf
Pin: release *
Pin-Priority: -1

@kingosticks
Copy link
Contributor

kingosticks commented Feb 23, 2023

Sorry to bring this old issue back up and I'm not 100% sure about this, but isn't it reasonable to want to install Debian/Ubuntu's armhf (v7) -dev packages into a (v6) arm-unknown-linux-gnueabihf container for use in builds? If so, is there a way to override the deny list?

@Emilgardis
Copy link
Member

removing /etc/apt/preferences.d/all-packages will remove the "deny"

@kingosticks
Copy link
Contributor

Super, thanks!

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

No branches or pull requests

4 participants