Tom
Tom

Reputation: 7992

Cross-compiling Alpine Linux packages

I'm trying to rebuild Alpine packages on an x86_64 host for an armhf target. As far as I can tell, the correct way to do this is to clone https://github.com/alpinelinux/aports and run scripts/bootstrap.sh armhf to create a chroot environment that can then be used to cross-compile packages. So far I've:

But the bootstrap script still fails with:

c4a5a8fbf023:~/aports$ scripts/bootstrap.sh armhf
>>> bootstrap-armhf: Building cross-compiler
>>> binutils-armhf: Package is up to date
>>> gcc-armhf: abuild 3.2.0-r0
>>> gcc-armhf: Checking sanity of /home/builder/aports/main/gcc/APKBUILD...
>>> WARNING: gcc-armhf: g++ should not be in makedepends
>>> gcc-armhf: Analyzing dependencies...
ERROR: unsatisfiable constraints:
  .makedepends-gcc-armhf-0:
    masked in: cache
    satisfies: world[.makedepends-gcc-armhf]
  musl (missing):
    required by:
  musl-dev (missing):
    required by:
>>> ERROR: gcc-armhf: all failed
>>> gcc-armhf: Uninstalling dependencies...

musl and musl-dev are packages built for armhf and are in ${HOME}/packages/main/armhf.

Can someone point me to the right magic to get this to work? Is there some documentation on this somewhere that I've missed?

Upvotes: 5

Views: 6572

Answers (4)

ngreen
ngreen

Reputation: 1769

If you have a working abuild environment, the correct answer is the final step in @Golu's answer:

CBUILDROOT=~/sysroot-armhf ~/aports/scripts/bootstrap.sh armhf

I still can't figure out from reading the source code why this works. CBUILDROOT is actually set by the script. It does include a trailing /, which I guess potentially might cause issues. Once the process gets going, setting CBUILDROOT manually stops being necessary. Anyway, this worked for me, which is why I'm leaving a new answer.

Upvotes: 1

Peter
Peter

Reputation: 387

When I ran into this problem, it was because in my eagerness I ran the bootstrap script before setting up my package signing key. This meant that the bootstrap sysroot was not populated with the package signing key because the bootstrapper only copies it over on its initial run, and this led to the error messages shown above. Manually copying the key into ~/sysroot-armhf/etc/apk/keys should fix the problem.

Upvotes: 1

King King
King King

Reputation: 21

abuild-keygen -a -i and install sudo

Upvotes: 1

Golu
Golu

Reputation: 360

Well I had same error but I solved it by doing these steps : 1. abuild-keygen -a and then i saved my key with name mykey and got my keys ( both private and public ) in my current directory. 2. Then just move mykey.pub into /etc/apk/keys 3. Then build your cross compile toolchain by CBUILDROOT=/path/to/buildroot ./scripts/bootstrap.sh armhf and one more thing , don't create your CBUILDROOT directly or manually, just let bootstrap script create it. Let me know if you failed again.

Upvotes: 1

Related Questions