Building AUR Packages
Background
So two pieces of background:
- The Today I Learned tag will be what I use for things I literally just learned. Likely, it'll be things I learned in the last couple weeks rather than the last couple days, but TIL sounds much better. As such, I may very well be wrong or at least very incomplete. Since it's something I'm just learning I would extra appreciate any new insights on the matter (respectfully given of course).
- I run a lot of different operating systems (more on that another time). On my laptop, I run Manjaro an Arch-based distro with some (mostly) reasonable defaults. The reason I run it is that my current window manager of choice is i3 and the community i3 spin comes with most of the config I want without having to write it myself.
What I learned
While hanging out on the Joplin forum, I saw that another Arch user was having issues getting the thing to install via AUR. Having recently had similar problems getting the thing to build in Docker, I decided to help out.
The intention was not to actually submit a PR to submit the PKGBUILD, but I did anyway and it got merged! Unfortunately, there's still issues with it for some users due to an invalid (or at least weird) .SRCINFO file.
If you (like me) had no idea what the heck this file was for here's what the Arch Wiki has to say about it:
.SRCINFOfiles contain package metadata in a simple, unambiguous format, so that tools such as the AUR's Web back-end or AUR helpers may retrieve a package's metadata without parsing the PKGBUILD directly.
It works for me, though so I went to find out why and it turns out that pamac (the AUR helper on Manjaro) will frequently regenerate a valid PKGBUILD and is quite forgiving, but some AUR helpers (yay in particular) are not quite as accepting.
The code from pamac (reproduced below) that will regenerate a .SRCINFO file if it's out of date. There's likely code elsewhere that is also just deals with multiple pkgbase sections rather than failing, though I didn't look hard enough to find the exact section.
pamac code:
bool regenerate_srcinfo_real (string pkgname, Cancellable? cancellable) {
string pkgdir_name;
if (config.aur_build_dir == "/var/tmp") {
pkgdir_name = Path.build_path ("/", config.aur_build_dir, "pamac-build-%s".printf (Environment.get_user_name ()), pkgname);
} else {
pkgdir_name = Path.build_path ("/", config.aur_build_dir, "pamac-build", pkgname);
}
var srcinfo = File.new_for_path (Path.build_path ("/", pkgdir_name, ".SRCINFO"));
var pkgbuild = File.new_for_path (Path.build_path ("/", pkgdir_name, "PKGBUILD"));
if (srcinfo.query_exists ()) {
// check if PKGBUILD was modified after .SRCINFO
try {
FileInfo info = srcinfo.query_info ("time::modified", 0);
DateTime srcinfo_time = info.get_modification_date_time ();
info = pkgbuild.query_info ("time::modified", 0);
DateTime pkgbuild_time = info.get_modification_date_time ();
if (srcinfo_time.compare (pkgbuild_time) == 1) {
// no need to regenerate
return true;
}
} catch (Error e) {
critical ("%s\n", e.message);
}
}
// ..This is the much less lenient line of code from the package yay uses to parse .SRCINFO files:
case "pkgbase":
if psr.srcinfo.Pkgbase != "" {
return fmt.Errorf("key \"%s\" can not occur after pkgbase or pkgname", key)
}
pkgbase.Pkgbase = value
return nilLooking at the Arch Wiki (because I've got no idea where this is better documented), it seems to be implied that you can only have one pkgbase line per file (emphasis mine):
The following fields may appear only once in each .SRCINFO file, in the pkgbase section:
Solution?
Open another PR which will hopefully get merged and help these guys out.