Create an AppImage executable
This is a trivial example not really utilizing all the benefits of the AppImage format. However, it can serve as a very basic blueprint.
Prerequisites
Install appimagetool
from the latest release
https://github.com/AppImage/AppImageKit/releases/tag/continuous.
Download the appropriate version for your machine.
curl -O -L https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
Make sure that appimagetool
is installed as an
executable that can be used as needed.
sudo install --mode 0755 ./appimagetool-x86_64.AppImage /usr/local/bin/appimagetool
Program
Before dealing with the AppImage create the program that should be
bundled in the image. In this case create a basic C app in a file
named whatever.c
.
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
Compile the application like so. This creates a binary that we can
bundle into an app image. The compiled binary will be output at
/tmp/whatever
.
gcc whatever.c -o /tmp/whatever
AppImage Directory
Create a directory for the AppImage. In this case a directory
called MyApp
. The following files should all be
created in that directory.
Grab a copy of AppRun
for the AppImage
MyApp
directory. Rather than copy and paste the
contents of AppRun
here I suggest using
cURL
or similar in case the contents of
AppRun
change in the future.
curl --output-dir ./MyApp -O -L https://raw.githubusercontent.com/AppImage/AppImageKit/master/resources/AppRun
Make AppRun
executable.
chmod +x ./MyApp/AppRun
Create a file in MyApp
named
MyApp.desktop
like so.
[Desktop Entry]
Name=MyApp
Exec=whatever
Icon=the-icon
Type=Application
Categories=Utility;
Find or create an icon for the AppImage. For example, this open
source image
https://openclipart.org/detail/205221/desktop-computer-with-monitor-on-top. Note that the file name should align with the
Icon
entry in the .desktop
file.
curl --output-dir ./MyApp -o the-icon.svg -L https://openclipart.org/download/205221/desktop-computer-with-monitor-on-top.svg
Install the previously compiled application into our
MyApp
directory at ./usr/bin
.
install -D --mode 0755 --target-directory ./MyApp/usr/bin /tmp/whatever
Generate AppImage file
appimagetool ./MyApp
Run
./MyApp-x86_64.AppImage