What I learned by packaging for the AUR
So I started reading some arch wiki pages about PKGBUILDS to have a general idea of how not to mess up badly. The several variables are described. And there are rules like "Packages should never be installed to /usr/local/". I ended up jumping between several pages and demo pkgbuilds to get an idea.
The PKGBUILD is simply a file where you describe some properties of the package plus define build and install operations.
The variables includes package dependencies for making the package and for using the package. This is actually highlighted in the wikis as something that is easy to use incorrectly.
The operations can be a bit confusing as you might be required to "cd" to a directory for them to work. Also the pkgversion variable is actually generated automatically after you build the package with makepkg if you have a proper pkgver() function. The pkgver function can be git aware, using the last tag or commit from the repo.
The automatic install procedure is basically, download git repo, run build(), then run package().
The package() function has a bunch of `install -D -m755 somefile "$pkgdir/usr/bin/somefile"`
A big pain for me was getting git to work. You publish to the aur by using git with your ssh key. After several tries this is the process that worked for me:
- Git clone clone the ssh location - Copy the pkgbuild, .gitignore, and other files you need to that directory - Immediately run: git branch -M master - Then add, commit, and push to master as normal
I made a push.sh file to automate git push and .SRCINFO creation. .SRCINFO is a file that must be generated with "makepkg --printsrcinfo > .SRCINFO" It's a required file used for listing purposes.
I ended up making 4 packages (all software I wrote) since I already had the gist of it. Some packages have different build() steps to download dependencies and what not.
A big thing that happened was that I made changes to my software for packaging to make sense, actual big changes sometimes, it made me rethink a lot of stuff, making the software essentially less complex in a nice way.
I also had to deal with creating some user systemd services, which was almost painless. You just create the service and copy it to /etc/systemd/user/something.service Then tell the user to enable and start the service.
Overall the experience was fun, I know that at least I will be using the packages myself, cool if others use it of course.