Deploying Binaries to other Linux Distros using Appimage

Brandon Rozek

October 19, 2020

One way to distribute to different Linux distributions is to compile the source under each of them and distribute it separately. This can be a pain to manage if you target multiple distributions and multiple versions of those distributions. Instead, let’s take a look at AppImage. This allows us to package up our binaries and shared libraries under one file which we can distribute.

AppImage Architecture Diagram


It works by packaging up the application in a SquashFS which is then mounted during runtime using FUSE. The project recommends that the AppImage is packaged on an older system, like an Ubuntu LTS or CentOS. Newer systems are often backwards compatible but not the other way around. Let’s get started!

Setting up the AppImage

Let’s create an AppImage based on the application Gqrx. The following structure will be common for all binary distribution packages:

      # Config files
      # Shared libraries

The AppRun executable comes from the AppImage Releases Page. While you’re there, you should also download appimagetool as we’ll be using that soon.

The .desktop file needs to be a valid Linux Desktop Icon. Make sure to define the Categories field, the appimagetool complained when I didn’t.

Copy over gqrx over to the AppDir:

export gqrx_loc=$(which gqrx)
cp $gqrx_loc gqrx.AppDir/usr/bin/

Finding Needed Shared Libraries

This part is the most time consuming of this whole process. Most of the shared libraries that the application depends on needs to be added to the usr/lib folder. Except for the lowest level libraries.

Let’s first take a look at all the libraries we need:

export all_libraries=$(ldd $gqrx_loc | awk '{ print $1 }')
echo $all_libraries

Then let’s grab the excludelist from AppImage:


Now let’s filter our library output to take away the lowest level libraries:

export filtered_libraries=$(echo $all_libraries | grep -vwf excludelist)
echo $filtered_libraries

Finally, let’s save the locations of these libraries to library_locations.txt

ldd $gqrx_loc | grep $filtered_libraries | awk '{ print $3 }' > library_locations.txt
cat library_locations.txt

Copy over all the libraries

xargs -a library_locations.txt -L 1 -I @ cp @ gqrx.AppDir/usr/lib/

If there are any libraries that you need get dynamically injected during runtime, you will have to copy those over as well.

Creating the AppImage

Finally we can use the appimagetool command to create the AppImage:

./appimagetool-x86_64.AppImage gqrx.AppDir/

Which will generate a gqrx-appimage-x86_64.AppImage file.

Now for the moment of true, copy that file over to another Linux distribution and see if it executes appropriately. If it complains about shared libraries missing, then you should go back to the previous system and add that library in.

If it complains about Illegal instructions, then there is probably either a low level library that needs to be removed, or the CPU instruction set between the two computers differ.