Creating AppImage Binary Manually for Linux from Your App

Contents

What is AppImage?

AppImage is a format for distributing portable software on Linux without needing superuser permissions to install the application. It tries also to allow Linux distribution-agnostic binary software deployment for application developers, also called Upstream packaging. Released first in 2004 under the name klik, it was continuously developed, then renamed in 2011 to PortableLinuxApps and later in 2013 to AppImage.

According to Simon Peter‘s website AppImage.com here are the benefits of using appimage format on Linux:

Easy

The key idea of the AppImage format is one app = one file. Every AppImage contains an app and all the files the app needs to run. In other words, each AppImage has no dependencies other than what is included in the targeted base operating system(s).

Trusted

AppImage format is ideal for upstream packaging, which means that you get the software directly from the original author(s) without any intermediaries, exactly in the way the author(s) intended. And quickly.

Fast

AppImages can be downloaded and run without installation or the need for root rights.

Useful Links

How to Make AppImage Manually?

In this tutorial, we are going to make an AppImage from scratch. For this, I have already written and compiled a program calledDesigners Tools. It is written in Java, however, you do not need JRE or JDK to run this program. I have made it completely 100% executable. All you have to do is just double click on the executable and it will run.

To show the demo, I am putting my app on /home/zunayed/Desktop/zunayed/Documents/sandbox/DesignersTools/ folder. It’s size is 239.1 MB, which is a lot.

Linux App

Now lets make this app as AppImage. We will make it just one file, and user will be able open it just by double clicking it and it can be run on any Linux distribution without any dependencies. And the size will be a lot smaller. Tell me, isn’t that sounds great.

Now to make our AppImage we are renaming our App folder to AppFolder.AppDir. In our case, it’s DesignersTools.AppDir

App Dir

Also, put all of your app contents into AppFolder/usr/bin folder. In our case, it was in DesignersTools folder. Now, it’s in DesignersTools/usr/bin folder.

Folder structure

We will now create 3 files.

  • AppRun
  • your_app_name.desktop
  • An Icon as your_app_name.png
Folder structure

The AppRun file is just a text file it contains following code:

#!/bin/sh
SELF=$(readlink -f "$0")
HERE=${SELF%/*}
export PATH="${HERE}/usr/bin/:${HERE}/usr/sbin/:${HERE}/usr/games/:${HERE}/bin/:${HERE}/sbin/${PATH:+:$PATH}"
export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/:${HERE}/lib32/:${HERE}/lib64/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PYTHONPATH="${HERE}/usr/share/pyshared/${PYTHONPATH:+:$PYTHONPATH}"
export XDG_DATA_DIRS="${HERE}/usr/share/${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
export PERLLIB="${HERE}/usr/share/perl5/:${HERE}/usr/lib/perl5/${PERLLIB:+:$PERLLIB}"
export GSETTINGS_SCHEMA_DIR="${HERE}/usr/share/glib-2.0/schemas/${GSETTINGS_SCHEMA_DIR:+:$GSETTINGS_SCHEMA_DIR}"
export QT_PLUGIN_PATH="${HERE}/usr/lib/qt4/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt4/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt4/plugins/:${HERE}/usr/lib32/qt4/plugins/:${HERE}/usr/lib64/qt4/plugins/:${HERE}/usr/lib/qt5/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt5/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt5/plugins/:${HERE}/usr/lib32/qt5/plugins/:${HERE}/usr/lib64/qt5/plugins/${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}"
EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1)
exec "${EXEC}" "$@"

Also, make sure that, your AppRun file is permitted to executable.

File permission

Now, create/open your_app_name.desktop file with a text editor (in out case DesignersTools.desktop) and write something like this:

[Desktop Entry]
Name=DesignersTools
Exec=DesignersTools
Icon=designerstools
Type=Application
Categories=Utility; 

Also, make sure designerstools.desktop file is executable too.

Just to be clear, our executable file is DesignersTools located at DesignersTools.AppDir/usr/bin/DesignersTools file

We will now download AppImageKit from here https://github.com/AppImage/AppImageKit/releases. I will be using appimagetool-x86_64.AppImage program to make this directory as AppImage file.

Now, go to folder right before DesignersTools.AppDir located. Open this folder in Terminal

cd /home/zunayed/Desktop/zunayed/Documents/sandbox

Now use AppImageKit program to make AppImage of your program

/home/zunayed/opt/appimagetool-x86_64.AppImage DesignersTools.AppDir

Thats it. We have created successfully an AppImage. You can mark that appimage as executable and run it anywhere of Linux distribution just by double clicking it. In our cases, its size is now down to 87.6 MB.

AppImage

Zunayed Hassan

Lives and loves with codes and computer

Leave a Reply

Your email address will not be published. Required fields are marked *