In a previous howto I showed how to build a .deb installer file for a Python program. This would work for the majority of systems with Debian/Ubuntu/Linux Mint etc. However there are many users on Arch Linux or Manjaro, which do not take this .deb installer file. Some Linux computers such as the popular (and currently out of stock 🙁 ) Pinebook laptop, and Pinephone come with Manjaro Linux, which takes Arch packages. Thankfully there is an easy way to add a package to the AUR for these Arch-based devices.
PKGBUILD file and Python
In most of the documentation for PKGBUILD and building an addition to the AUR (Arch User Repository) it is assuming a build of a compiled source of C++ or similar. What about a program that is simply Python – which should run on just about any system without recompiling? With a previously build .deb that is not built for a specific architecture (intel, arm/other), you can use that as a base to copy the files out to the package. In the following example you can see it unzips the content data which you can see within a .deb by opening it with the archive-manager. I based the build for repeaterSTART Arch on an older program that someone built up on AUR. Check this out as an example:
pkgname=repeater-start
pkgver=0.8
pkgrel=1
pkgdesc="Repeater-START (Showing The Amateur Repeaters Tool) is an app to view nearby ham radio repeaters."
arch=('any')
url="http://sourceforge.net/projects/repeater-start/"
options=('!strip')
source=("https://sourceforge.net/projects/$pkgname/files/${pkgname}_${pkgver}_all.deb")
sha256sums=('fef1df7619efc6ed1e574d66bbca90a7862acf0c2fd8f3a2b86759f1791be993')
depends=("python3" "python-gobject" "osm-gps-map" "geoclue")
package() {
tar xvfJ data.tar.xz
mkdir -p $pkgdir/usr/share
cd $srcdir/usr
rm -Rf share/doc
cd $srcdir/usr/share/repeater-START/
cd $srcdir
cp -r usr $pkgdir
chmod -R 755 $pkgdir/usr/bin/repeaterSTART
chmod -R 755 $pkgdir/usr/share/applications/repeaterstart.desktop
chmod -R 755 $pkgdir/usr/share/repeater-START
}
This includes a sha256 you can get with the sha256sum command:
sha256sum <originaldebianinstaller.deb>
to get the sha256 output.
Also note that the package dependency names (“depends” line) of any dependencies (such as Geoclue, osm-gps-map) can be searched by name in the packages repo. “python3” would obviously be needed for any Python-based app, and “python-gobject” is the GObject introspection letting you use and access many Gtk features for windowed applications.
Building
Once the adjustments for copy and chmod are set as above, you can build as described in the documentation with the “makepkg” command run in the same directory as the PKGBUILD file. Also note this needs to be done on the Archlinux/Manjaro device and not within a folder that is in a thumbdrive, FAT partition drive or elsewhere where symlinks won’t work!
Distributing in AUR
Distributing involves the steps outlined in their documentation:
- Create an account on https://aur.archlinux.org/, including the new public key aur.pub after running
ssh-keygen -f ~/.ssh/aur
The aur.pub is the public key to share. - Clone and create your named package with the “git clone ssh://aur@aur.archlinux.org/yournamehere.git”, where “yournamehere” is the LOWER-case name of your package and the same as “pkgname” in the file as entered above. Otherwise it will not work!
- Push git changes to the above, master branch, eg:
git push –set-upstream yournamehere master
After the branch is pushed and set up, it should be findable in the AUR and can be enabled within the options to be added on a Manjaro system by turning on the option and then searching by name in the package installer.