AppImageKit icon indicating copy to clipboard operation
AppImageKit copied to clipboard

Unable to run appimagetool on a docker arm environment

Open teras opened this issue 4 years ago • 9 comments

Hello

I am trying to run the ci version of the appimagetool for arm32v7 and arm32v8 on docker, using the official debian:stable and centos images.

Specifically I've tried to run, with no luck :

  • appimagetool-aarch64.AppImage on arm64v8/centos and arm64v8/debian:stable
  • appimagetool-armhf.AppImage on arm32v7/centos and arm32v7/debian:stable

The exact command I am trying to run is appimagetoo.*.AppImage --appimage-extract

The error I get is this:

bash: ./appimagetool-armhf.AppImage: cannot execute binary file: Exec format error

or

bash: ./appimagetool-aarch64.AppImage: cannot execute binary file: Exec format error

I have also checked the downloaded file with the file command and I got this message

appimagetool-aarch64.AppImage: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=b0fb5c0d824dce460722a3c8da347f6053115800, stripped

I have checked these docker files with other applications and my own (nim) projects and they work just fine. So where is the problem?

teras avatar Jun 12 '20 16:06 teras

Are you running those on an actual ARM device or on a regular computer? Obviously, on a non-ARM machine it won't run unless binfmt_misc is set up together with qemu-user[-static].

TheAssassin avatar Jun 12 '20 16:06 TheAssassin

I run these docker files on a regular computer and these docker images work with all other arm executables I tried, except appimage.

teras avatar Jun 12 '20 16:06 teras

There's no guarantees made any of these files works on a non-native machine. We don't have time to support such a use case either.

If you need to cross-build, you can use a native appimagetool release with an ARM runtime.

TheAssassin avatar Jun 12 '20 16:06 TheAssassin

It's understandable.

Is there anywhere documentation on how to do this? I searched on the site but didn't have any real luck.

teras avatar Jun 12 '20 16:06 teras

Oh, thinking about it, this could be a simple magic bytes issue... Mind to remove them (sed -i s|AI\x02|\x00\x00\x00| my.AppImage is good enough for simple ones) and then try again? Edit: it's a well-known problem actually that the AppImage magic bytes, which are in a very bad location in type 2, make qemu refuse to run AppImages.

In general, download a runtime, e.g., https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-armhf.AppImage, get your native appimagetool, and add e.g., --runtime-file appimagetool-armhf.

TheAssassin avatar Jun 12 '20 16:06 TheAssassin

Indeed removing the magic bytes, solved this problem. Now this problem appears:

Read of e_ident from /proc/self/exe failed: Bad file descriptor
Failed to get fs offset for /proc/self/exe

EDIT: I tried with the provided runtimes and it works fine. Although I managed to "solve my problem", the original reported issue still remains :) From my point of view, I am already covered.

teras avatar Jun 12 '20 17:06 teras

Oh, thinking about it, this could be a simple magic bytes issue... Mind to remove them (sed -i s|AI\x02|\x00\x00\x00| my.AppImage is good enough for simple ones) and then try again?

I had the same problem as OP. Using sed worked for me!

On Manjaro, I have qemu-user-static-binfmt 7.2.0-3 installed. I'm using the qemu static bins from https://github.com/multiarch/qemu-user-static, and I'm using an Ubuntu bionic container.

andy5995 avatar Mar 04 '23 11:03 andy5995