Skip to content
Ismael Barros² edited this page Mar 9, 2016 · 8 revisions

This is a possible way to get started experimenting with AppImages. Just download an AppImage, and start breaking it:

Taking it apart

The best way to start making AppImages is by understanding them, and just like learning how a radio works, everything starts by getting an AppImage and taking it apart.

An AppImage is just an .iso file with an executable header. Just like any other .iso file, you can explore its contents with a couple of tools:

You can just mount it somewhere with good ol' mount (root permission needed)

$ sudo mount -o loop Xonotic\ 0.7.0-r1-archlinux-x86.run /mnt/mount
[sudo] password for raziel: 
mount: /dev/loop0 is write-protected, mounting read-only
$ ls /mnt/mount 
AppRun  AppRun.desktop  AppRun.png  usr  util.sh
$ sudo umount /mnt/mount

Or using other fancy mount tools like fuseiso (root permission not needed)

$ fuseiso -p Xonotic\ 0.7.0-r1-archlinux-x86.run mountpoint
$ ls mountpoint/
AppRun  AppRun.desktop  AppRun.png  usr  util.sh
$ fusermount -u mountpoint

Or you can use bsdtar

$ bsdtar -tf Game\ Dev\ Tycoon\ \(demo\)\ 1.3.9-r2-x86.run
.
./usr
./usr/greenheartgames
./usr/lib
./usr/lib/nss
./AppRun
./AppRun.png
./.DirIcon
./AppRun.desktop
(...)
./usr/lib/nss/libsoftokn3.so
./usr/lib/nss/libfreebl3.so
./usr/lib/nss/libnssckbi.so

Or you can use 7z (it may fail with some packages)

$ 7z l Game\ Dev\ Tycoon\ \(demo\)\ 1.3.9-r2-x86.run 

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF8,Utf16=on,HugeFiles=on,4 CPUs)

Listing archive: Game Dev Tycoon (demo) 1.3.9-r2-x86.run

--
Path = Game Dev Tycoon (demo) 1.3.9-r2-x86.run
Type = Iso
Comment = 
Volume: ISOIMAGE
VolumeSet: ISOIMAGE
Preparer: XORRISO-0.4.8 2010.01.25.120001, LIBISOBURN-0.4.8, LIBISOFS-0.6.26, LIBBURN-0.7.6
Created = 2014-03-01 21:01:18
Modified = 2014-03-01 21:01:18

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2014-03-01 21:01:18 .....         4617         4617  .DirIcon
2014-03-01 21:01:18 .....          777          777  AppRun
2014-03-01 21:01:18 .....          417          417  AppRun.desktop
(...)
2014-03-01 21:01:18 .....          899          899  usr/lib/nss/libsoftokn3.chk
2014-03-01 21:01:18 .....       117157       117157  usr/lib/nss/libsoftokn3.so
2014-03-01 21:01:18 .....         1348         1348  util.sh
------------------- ----- ------------ ------------  ------------------------
                              69572668     69572668  23 files, 4 folders

Or you can use these new fancy UI tools

$ 7zFM l Game\ Dev\ Tycoon\ \(demo\)\ 1.3.9-r2-x86.run

Or use a custom script, available on the repos, which mainly uses fuseiso to mount the AppImage in a temporal directory, and copy its contents to a new directory. This is the recommended way if you want to modify the AppImage and re-package it.

$ unpackAppImage Xonotic\ 0.7.0-r1-archlinux-x86.run        
Unpacking "Xonotic 0.7.0-r1-archlinux-x86.run" on "Xonotic 0.7.0-r1-archlinux-x86.AppDir"...
‘/tmp/tmp.nB5lXBHZYN_unpackAppImage/AppRun’ -> ‘Xonotic 0.7.0-r1-archlinux-x86.AppDir/AppRun’
‘/tmp/tmp.nB5lXBHZYN_unpackAppImage/AppRun.desktop’ -> ‘Xonotic 0.7.0-r1-archlinux-    x86.AppDir/AppRun.desktop’
‘/tmp/tmp.nB5lXBHZYN_unpackAppImage/AppRun.png’ -> ‘Xonotic 0.7.0-r1-archlinux-x86.AppDir/AppRun.png’
(...)
‘/tmp/tmp.nB5lXBHZYN_unpackAppImage/util.sh’ -> ‘Xonotic 0.7.0-r1-archlinux-x86.AppDir/util.sh’
fusermount: entry for /tmp/tmp.nB5lXBHZYN_unpackAppImage not found in /etc/mtab
$ ls Xonotic\ 0.7.0-r1-archlinux-x86.AppDir/
AppRun  AppRun.desktop  AppRun.png  usr  util.sh

Dissecting it

Inside an AppDir, you'll find mainly three things

  • A bash script named AppRun. This is what's run when you launch the AppImage.
  • A .desktop, named for example AppRun.desktop. This contains some metadata regarding your application. The only mandatory fields are:
  • Name=Something Something Awesome Game 1.0-r1: Specifies the AppImage name
  • Exec=AppRun: Specifies the runnable script
  • Icon=AppRun.png: Specifies the icon file

Let's focus on the AppRun. It's the script you need to tweak in order to run your application. This is the place to setup config dirs, load libraries, etc. You can test your AppDir before packing it into an AppImage, by running this script with ./AppRun. If this fails, your AppImage will fail. If this works, your AppImage will likely work. If it doesn't, it may be because whatever you're running inside your AppRun is trying to write inside the AppImage. Remember: An AppImage is read only, so all writes must happen outside. If the application insists on writing inside the AppImage, there are tricks you can use (like symlinking resources from a writable location to the AppImage, or using an unionfs)

Playing with it

The AppRun script will probably setup the environment in a certain way and run some other file inside the AppDir. You can add your files to the AppDir, and make the AppRun script run them. It may work. It may not. It may need some further tweaking.

For example, taking a Dosbox AppImage or a node-webkit and changing the game inside will likely work, but doing the same with Wine will likely not, because Wine apps are usually difficult to package. Classic Windows applications like to write inside the application directory, so you'll need to rock some black magic in order to redirect the writes, and also many of Windows applications need custom winetricks to work. Furthermore, Wine is huge, so Wine-based AppImages usually come with a trimmed-down version of Wine, only with the libraries each particular application uses. If you substitute the application, it will likely use other libraries, so it'll fail to run, although in this case you can substitute the Wine setup with a complete Wine, and trim it again for the new application.