How to create an AppImage to bundle your software

If you are looking how to create an AppImage. This is the right place to find what you want. In this tutorial I will be explaining for you how to build your own AppImage to bundle your software.

How to create an AppImage

1. Introduction: What is an AppImage ?

An AppImage is a self-contained application package that doesn't require installation in order to run. This makes it ideal for distributing applications, especially on Linux where there is no standard package format.

AppImages are essentially just files that contain everything an application needs to run. This includes the application binary or source code, any dependencies, and even an application launcher. To use an AppImage, you simply download it, make it executable, and then run it. No installation required.

AppImages are becoming increasingly popular as a way to distribute Linux applications. They are easy to use and don't require any special permissions to run. This makes them ideal for sharing applications with others, or even just for keeping around on your own computer.

2. AppImage creation requirements

As with any application, there are certain requirements that must be met in order for an AppImage to run. These requirements are as follows:

  • The AppImage must be executable
  • The AppImage must be a single file
  • The AppImage must be contained within a directory
  • The AppImage must be signed with a valid signature

In order to ensure that your AppImage meets these requirements, you can use the AppImageTool. This tool will help you to package your AppImage, as well as sign it with a valid signature.

Once you have created your AppImage, you can then distribute it to your users or customers. They will be able to run it on any Linux distribution that meets the AppImage requirements.

3. How to create your first AppImage to bundle your software

If you're looking to create a new AppImage, there are a few things you'll need to do. First, you'll need to create a basic AppImage skeleton (directories hierarchy). This can be done with a few simple commands. Once you have your skeleton, you'll need to fill it in with your source code or binary file. Finally, you'll need to package your AppImage and test it out.

Step 1 : Downloading the AppImageTool from its official project website.

Launch these commands first:  

mkdir myappimage 

cd myappimage

You can get AppImageTool for your desired CPU architecture here:

https://github.com/AppImage/AppImageKit/releases (download the newest release from Assets section)

In this tutorial I'm using AppImageTool version 13 and CPU architecture (x86_64).

Copy the link from AppImageTool official project website and run:

wget https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage -O appimagetool-x86_64.AppImage

Now, Make it executable with this command:

chmod +x ./appimagetool-x86_64.AppImage

Step 2 : Downloading an AppImage sample (for example: Max Auto Clicker software)

wget https://sourceforge.net/projects/maxautoclicker/files/maxautoclicker_x84_64.AppImage/download -O maxautoclicker.AppImage

make it executable with this command:

chmod +x ./maxautoclicker.AppImage

Step 3 : Creating a skeleton

Is easy, just run the following commands. You should run the AppImageTool with the --appimage-extract parameter and the path to the application maxautoclicker.AppImage as the argument. This will extract the necessary files into a directory (called squashfs-root/).

./maxautoclicker.AppImage  --appimage-extract

You will get this result:

AppImageTool with the --appimage-extract parameter

and this is squashfs-root/ directory tree

squashfs-root/ directory tree

Step 4 : Adding your own files to squashfs-root/ directory

Now, you'll need to fill in your own files (binary, icons, libraries/dependencies if needed, ...).

- Don't remove the file named AppRun in squashfs-root/ directory.

- You should rename the .desktop file from maxautoclicker.desktop to your_software_name.desktop and editing its values (Name, Comment, Exec, Icon, Categories)

maxautoclicker.desktop file content:

[Desktop Entry]
Name=MaxAutoClicker
Comment=Mouse Auto Clicker
Exec=maxautoclicker %u
Terminal=false
Type=Application
StartupNotify=true
Icon=maxautoclicker
Categories=GTK;Utility;

- Next thing to do is editing the file com.blogspot.maxautoclicker.appdata.xml located in squashfs-root/usr/share/metainfo/ directory. then renaming it to org.gnome.your_software_name.appdata.xml

Follow this documentation web page (Metadata Quickstart) and (Upstream Metadata) to get more information about its tags.

com.blogspot.maxautoclicker.appdata.xml file content:

<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
  <id>org.gnome.maxautoclicker</id>
  <metadata_license>FSFAP</metadata_license>
  <project_license>LicenseRef-proprietary=https://github.com/mautosoft/maxautoclicker/releases/download/v1.5.8/mxac_license.txt</project_license>
  <name>maxautoclicker</name>
  <summary>Emulate and automate your mouse clicks</summary>
  <description>
    <p>
      Max Auto Clicker is a tool that lets you emulate and automate your mouse clicks.
      This wonderful mouse tool will help you of repeated clicks tasks in idles video
      games that needs auto clicking tasks.
    </p>
    <p>
      This auto clicker can also be used in desktop environment in repeated clicks 
      tasks, for example: auto-refreshing browser.
    </p>
    <p>
      For more features and updates visit Max Auto Clicker homepage.
    </p>
  </description>
<launchable type="desktop-id">maxautoclicker.desktop</launchable>
  <url type="homepage">https://sourceforge.net/projects/maxautoclicker</url>
  <project_group>AppImage</project_group>
  <provides>
    <binary>maxautoclicker</binary>
  </provides>
  <releases>
    <release version="1.5.7" date="2022-05-11">
      <description>
        <p>add more features + Fixes issues</p>
      </description>
    </release>
  </releases>

Step 5 : Building AppImage for your software

When done with your own files, done with editing appimagetool.appdata.xml file and .desktop file. Its time to build your first AppImage for your software.

Run the AppImageTool with the generate parameter and the path to the directory(squashfs-root/) containing the application as the argument. This will create the .AppImage file for your software.

./appimagetool-x86_64.AppImage squashfs-root/ your_software_name.AppImage generate

You will get  this result :

brahim@brahim-desktop:~/myappimage$ ./appimagetool-x86_64.AppImage squashfs-root/ maxautoclicker.AppImage  generate 
appimagetool, continuous build (commit 8bbf694), build <local dev build> built on 2020-12-31 11:48:33 UTC
Using architecture x86_64
/home/brahim/myappimage/squashfs-root should be packaged as maxautoclicker.AppImage
WARNING: AppStream upstream metadata is missing, please consider creating it
         in usr/share/metainfo/maxautoclicker.appdata.xml
         Please see https://www.freedesktop.org/software/appstream/docs/chap-Quickstart.html#sect-Quickstart-DesktopApps
         for more information or use the generator at http://output.jsbin.com/qoqukof.
Generating squashfs...
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on maxautoclicker.AppImage, block size 131072.
[=================================================================|] 34/34 100%

Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
compressed data, compressed metadata, compressed fragments,
compressed xattrs, compressed ids
duplicates are removed
Filesystem size 1052.46 Kbytes (1.03 Mbytes)
34.62% of uncompressed filesystem size (3039.94 Kbytes)
Inode table size 387 bytes (0.38 Kbytes)
43.10% of uncompressed inode table size (898 bytes)
Directory table size 319 bytes (0.31 Kbytes)
52.30% of uncompressed directory table size (610 bytes)
Number of duplicate files found 1
Number of inodes 25
Number of files 11
Number of fragments 1
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 14
Number of ids (unique uids + gids) 1
Number of uids 1
root (0)
Number of gids 1
root (0)
Embedding ELF...
Marking the AppImage as executable...
Embedding MD5 digest
Success

Please consider submitting your AppImage to AppImageHub, the crowd-sourced
central directory of available AppImages, by opening a pull request
at https://github.com/AppImage/appimage.github.io

Step 6 : Copy the AppImage file to the desired location and make it executable

chmod +x  your_software_name.AppImage

cp   your_software_name.AppImage /home/brahim/Desktop

Step 7 : Run the AppImage file to launch the application

This done by double clicking on it or launch it in terminal with this command:

./your_software_name.AppImage

4. The pros and cons of using Appimage

If you're looking for a new application to try, you may have come across Appimage. Appimage is a packaging format that allows applications to be run on multiple Linux distributions. While this may sound great, there are some potential drawbacks to using Appimage.

One of the biggest advantages of Appimage is that it makes it easy to run applications on multiple Linux distributions. Appimage bundles all of the necessary dependencies into a single file, which makes it much easier to install and run applications on different distributions. This is a great benefit for users who want to try new applications without having to worry about compatibility issues.

However, there are some potential downsides to using Appimage. One issue is that Appimage bundles can be quite large, which can take up a lot of disk space. Additionally, Appimage bundles are often not as well-optimized as native packages.

Popular posts from this blog

Linux Mint : 26 Reasons Why I Use It And You Should Too

SEO Services Primelis Company: Rank Fast in Google