Cannot install qemu-user-static in build for R-pi2


#1

I’m trying to install the qemu-arm-static package, using the resin/raspberrypi2-debian:latest base image. I know that’s a pretty weird idea, but I have a binary compiled for x86 that I don’t have the source code to recompile for ARM. So I need to emulate x86 on my Raspberry-pi, and this is the cleanest way I can find to do that.

Here’s the error I’m getting:

 unable to make backup link of `./usr/bin/qemu-arm-static' before installing new version: Invalid cross-device link```

My first guess is that the builder is emulated, and that'w why the build fails- it's protecting the qemu-arm-static file.  Any suggestions for working around this?  The native ARM builder was deprecated, right?

#2

hey @ashmastaflash ,
Yeah thats a pretty weird issue to have, indeed the builds on our builders are qemu emulated, so thats very lightly your issue. We did indeed deprecate the native ARM builders because they ended up being very unstable and more head ache than they were worth. I don’t really have a good idea of how to work around your issue currently. Out of interest what is the x86 binary you need?


#3

@ashmastaflash checked this out, one possible solution is to manually add the qemu-*-static binaries. An example I put together takes a static compiled i386 binary (used a simple go example), and call it on a Raspberry Pi: here’s the repo, will add Readme in a bit.

It basically comes down to:

RUN apt-get update && \
    apt-get -o dir::cache::archives="/tmp/" -d install qemu-user-static && \
    cd /tmp/ && \
    ls -la && \
    mkdir data && \
    dpkg-deb -x qemu-user-static*.deb data && \
    cp data/usr/bin/qemu-i386-static /usr/bin/ && \
    cd / && rm -rf /tmp/* && apt-get clean && rm -rf /var/lib/apt/lists/*

then adding your binary file somewhere, and call qemu-i386-static <executable> in your project, I think.

Very rough, but should work to some level (works for me in the hello world case). Would love to hear the results!


#4

Thanks @imrehg! I’ll give it a shot ASAP and let you know how it goes