This document provides best practices on creation of PKGBUILD desktop packages from AppImage.
Package naming
Please use $_name-appimage (where $_name is the upstream project name).
Template
PKGBUILD
# Maintainer: My name <myemail at domain dot me>
_pkgname=my-project
pkgname="${_pkgname}"-appimage
pkgver=0.0.1
pkgrel=1
pkgdesc="Description of my project"
arch=('x86_64')
url="https://github.com/user/repo/"
license=('custom:Unlicense')
depends=('zlib' 'fuse2')
options=(!strip)
_appimage="${pkgname}-${pkgver}.AppImage"
source_x86_64=("${_appimage}::https://github.com/user/repo/releases/download/${pkgver}/${_pkgname}.${pkgver}.AppImage"
"https://raw.githubusercontent.com/user/repo/${pkgver}/LICENSE"
)
noextract=("${_appimage}")
sha256sums_x86_64=('0000000000000000000000000000000000000000000000000000000000000000'
'0000000000000000000000000000000000000000000000000000000000000000')
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}|"\
"squashfs-root/${_pkgname}.desktop"
# 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"\
"${pkgdir}/usr/share/applications/${_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"
}