You are not logged in.

#1 2020-11-25 23:20:27

antoyo
Member
Registered: 2012-08-16
Posts: 37

Install packages from a different architecture with pacman

Hi.
I want to cross-compile to ARM an application requiring some libraries.
I wonder if it is possible to use pacman (or another tool) to install ARM packages on an Arch amd64.
I guess the packages would need to be installed in a different location to avoid conflicts.

How do people usually do that in ArchLinux?
Thank.s

Offline

#2 2020-11-25 23:29:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Install packages from a different architecture with pacman

Packages and pacman's abilities aren't particularly relevant here: in fact pacman could easily install a package built for another architecture, but no compiled content in that package could run.

But I'm not understanding the motivation: why are you cross compiling for ARM if you want to install that on your machine?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2020-11-26 12:28:00

antoyo
Member
Registered: 2012-08-16
Posts: 37

Re: Install packages from a different architecture with pacman

The idea here is to avoid compiling on a machine with less CPU/RAM resources.

Installing the libraries but not running them is still useful, because that would allow me to link the program on my amd64 machine (which is more powerful) and then, I can copy the program on my ARM machine and run it there.

Using pacman here would be interesting because it would fetch all the dependencies for me.

Offline

#4 2020-11-26 14:18:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Install packages from a different architecture with pacman

Ah, so you don't actually want to install the packages to use them, you're just asking about building for ARM when there are dependencies to what you are building.  That is really quite a different question.  While I don't have experience with it, this is what distcc is really for, and your use case is explicitly covered in the wiki:

https://wiki.archlinux.org/index.php/Di … olunteers)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2020-11-26 22:25:30

antoyo
Member
Registered: 2012-08-16
Posts: 37

Re: Install packages from a different architecture with pacman

That seems pretty involved. Am I missing something or that requires setting some distributed system?

I just want to compile everything on my x86_86 without having to coordinate with my ARM device.

Offline

#6 2020-11-26 23:02:48

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: Install packages from a different architecture with pacman

There's https://www.archlinux.org/packages/comm … x-gnu-gcc/ but if you eg. wanted to link Qt, installing the package of archlinuxarm would conflict w/ the actual Qt installation (same goes for boost, libX11, … everything)
You'd have to copy the shared objects (and headers) somewhere else and reference those locations as include and library paths to gcc.
Since that's super annoying and easily runs out of control, you want to use distcc for everything other than a glorified "hello world".

Offline

#7 2020-11-27 02:18:21

antoyo
Member
Registered: 2012-08-16
Posts: 37

Re: Install packages from a different architecture with pacman

In the end, I was able to create a pacman config file to install ARM packages in a different directory. This helps avoid the package conflict issue.

Here are the instructions:

cp /etc/pacman.conf arm_pacman.conf

Edit arm_pacman.conf with the following options:

RootDir     = /opt/ArchARM
DBPath      = /opt/ArchARM/var/lib/pacman/
CacheDir    = /opt/ArchARM/var/cache/pacman/pkg/
GPGDir      = /opt/ArchARM/etc/pacman.d/gnupg/
HookDir     = /opt/ArchARM/etc/pacman.d/hooks/
Architecture = aarch64

# For each repo:
Include = ./mirrorlist

mirrorlist contains:

Server = http://nj.us.mirror.archlinuxarm.org/$arch/$repo

Initialize the pacman database and install the ARM packages

yay -S archlinuxarm-keyring
sudo pacstrap -M -C arm_pacman.conf /opt/ArchARM <packages>
Questions

My questions are:

  • Is there a better way to import the GPG key (archlinux-keyring being not installed in my root at /opt/ArchARM might means that there's no simpler way)? (fixed with pacstrap and installing the ARM keyring)

  • Is it normal to get errors about execv call when installing packages that way? (that works anyway even with those errors)

  • Did I forget some settings which would make the above mess up with the pacman files (database, cache, …) of my system?

  • Is there any tool that would do the above steps automatically? (pacstrap does exactly that)

Thanks for your help.

Former instructions:

sudo mkdir -p /opt/ArchARM/var/lib/pacman/local
sudo mkdir /opt/ArchARM/var/lib/pacman/sync

Import the key for the ARM repo:

gpg --recv 77193F152BDBE6A6
gpg --export 77193F152BDBE6A6 > arm_pacman_key

Initialize the pacman database:

sudo pacman-key --init --config arm_pacman.conf
sudo pacman-key --config arm_pacman.conf --add arm_pacman_key
sudo pacman-db-upgrade --root /opt/ArchARM/ --dbpath /opt/ArchARM/var/lib/pacman/

Trust the key:

sudo pacman-key --config arm_pacman.conf --edit-key 68B3537F39A313B3E574D06777193F152BDBE6A6

Install the packages:

sudo pacman -S --config arm_pacman.conf <package>

Last edited by antoyo (2020-11-27 19:57:00)

Offline

#8 2023-06-04 11:36:17

spaceone
Member
Registered: 2010-06-24
Posts: 8

Re: Install packages from a different architecture with pacman

I recently have the same endeavour and info from antoyo help me a lot.

After that many years, I guess answering questions is somewhat to late, but to at least contribute, here are my 2 cents.

antoyo wrote:

My questions are:

  • Is it normal to get errors about execv call when installing packages that way? (that works anyway even with those errors)

Pacman or certain packages have also post install activities, where certain binaries are used. If you are on a different architecture, then those binaries cannot be executed at all, which will make installation incomplete.
To overcome this, you definitely need an emulator, like qemu https://wiki.archlinux.org/title/QEMU#C … rom_x86_64.

With qemu/binfmt you can then also chroot into the aarch64 environment, however I noticed as a normal user (needed for yay for example) I couldn't use sudo with error:

sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

In that case some flags need to be changed in /usr/lib/binfmt.d/qemu-aarch64-static.conf, namely OC should be added at the end of the line (by default I had PF).

:qemu-aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64-static:PFOC

Courtesy to https://en.wikipedia.org/wiki/Binfmt_misc

Offline

Board footer

Powered by FluxBB