A better PKGBUILD template for AppImage packages

Posted on November 16, 2019

Presented here is a template for creating an Arch Linux desktop package from an AppImage. This improves on my last post How to Create a PKGBUILD for a AppImage binary which had the problem of not installing a .desktop file so the application can be started easily from GUI.

The Template

# Maintainer: My name <myemail@domain.me>


pkgdesc="Description of my project"
depends=('zlib' 'hicolor-icon-theme')

prepare() {
    chmod +x "${_appimage}"
    ./"${_appimage}" --appimage-extract

build() {
    # Adjust .desktop so it will work outside of AppImage container
    sed -i -E "s|Exec=AppRun|Exec=env DESKTOPINTEGRATION=false /usr/bin/${_pkgname}|"\
    # Fix permissions; .AppImage permissions are 700 for all directories
    chmod -R a-x+rX squashfs-root/usr

package() {
    # AppImage
    install -Dm755 "${srcdir}/${_appimage}" "${pkgdir}/opt/${pkgname}/${pkgname}.AppImage"
    install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/opt/${pkgname}/LICENSE"

    # Desktop file
    install -Dm644 "${srcdir}/squashfs-root/${_pkgname}.desktop"\

    # Icon images
    install -dm755 "${pkgdir}/usr/share/"
    cp -a "${srcdir}/squashfs-root/usr/share/icons" "${pkgdir}/usr/share/"

    # Symlink executable
    install -dm755 "${pkgdir}/usr/bin"
    ln -s "/opt/${pkgname}/${pkgname}.AppImage" "${pkgdir}/usr/bin/${_pkgname}"

    # Symlink license
    install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}/"
    ln -s "/opt/$pkgname/LICENSE" "$pkgdir/usr/share/licenses/$pkgname"


After looking at a few other AppImage PKGBUILDs I realized some authors already had a solution for .desktop files. Their solution is:

  1. Extract AppImage
  2. Modify the .desktop so it works outside of the AppImage binary
  3. Package the .desktop file and icon images

These steps work well, but I was still faced with a nagging popup which prompted to add a .desktop file again! Fortunately, there seems to be a way to suppress the popup with the environment variable DESKTOPINTEGRATION, as I found by poking around in an AppImage I was trying to package. Keep in mind, not all AppImages have this popup problem, so the DESKTOPINTEGRATION variable might be unnecessary.


Thank you to Igor Moura and Frederik “Freso” S. Olesen for their AppImage examples.

Modified: November 17, 2019 - 07:18:13 PM