name: maintaining-aur-packages description: Creates and updates AUR packages following Arch packaging standards. Use when creating new AUR packages, updating existing AUR PKGBUILDs, bumping package versions, or when the user mentions AUR, PKGBUILD, makepkg, pacman packaging, or Arch Linux packages. user-invocable: true license: LicenseRef-MutuaL-1.2 metadata: author: Amolith amolith@secluded.site
Code style
- PKGBUILD is bash;
.installfiles are POSIX-sh–compatible functions - Indent 2 spaces; UTF-8; LF endings; no trailing whitespace
- Single quotes for literals; double quotes when expanding variables
- Quote variables:
"$pkgdir","$srcdir", and all paths - Prefix custom PKGBUILD variables with
_to avoid collisions with makepkg internals - Arrays:
arch,license,provides,conflictsuse( ... )syntax arch=('x86_64')for compiled packages;arch=('any')for arch-independent oneslicense=()must use SPDX identifiers- Functions:
prepare(),build(),check(),package(); only define the ones needed - No
sudo, networking, or user config inbuild/packagefunctions - Use
install -Dm755for binaries; set exact modes explicitly - Keep checksums in sync with sources
- Keep
.SRCINFOin lockstep with PKGBUILD; never commit build artifacts
Package types
When the working directory contains subdirectories with these suffixes, we're maintaining multiple packages for the same software:
- suffix-less: Downloads a release archive, builds, and installs from source
-bin: Downloads the project's pre-built binary and installs it-git: Clones the primary branch and builds from source; version is determined byupdpkgsums, not specified manually
If no subdirectories exist, we're maintaining a single package. The current directory name indicates which type.
Constraints
- You cannot interactively authenticate to execute
makepkgin a way that requires escalation. You do the non-privileged work (build withmakepkg -Cf, lint withnamcap, generate.SRCINFO), then give the user a single copyablemakepkg -csicommand. - Use
updpkgsumsfor checksums - Use
namcapto lint built.pkg.tar.zstfiles - Use
b2sumsfor all packages.
Creating packages
Follow this strict workflow. If a planning or todo tool is available, fill it out in detail; the session might get interrupted and need to resume.
-
List the contents of the current working directory.
- Read any text files present.
- List subdirectory contents (ignore what looks like the upstream project repo).
- Subdirectories with
-binor-gitsuffixes mean multiple packages for the same software.
-
Ask for: package name (
provides=), description (pkgdesc=), license (license=()), and the license path inside the project repo (forinstalling). For each non--gitpackage, ask for the current version and source URL.-gitpackages: Use"$pkgname::git+https://...#branch=BRANCH"as the source entry (the$pkgname::prefix ensures makepkg clones into a directory matching$pkgname; the#branch=fragment selects the branch). Addgittomakedepends. Useb2sums=('SKIP')— VCS sources have no static content to checksum. Include this versioning function:pkgver() { cd "$pkgname" || exit ( set -o pipefail git describe --long --abbrev=7 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' || printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)" ) }-binpackages: Usebin-name-$pkgver::https://...insource, theninstallbin-name-$pkgverasbin-name. Obtain the license from the original repo. For GitHub sources, the raw URL ishttps://raw.githubusercontent.com/USER/REPO/refs/tags/{TAG}/LICENSE. For non-GitHub sources, ask for the raw tagged LICENSE URL.
-
Write a
PKGBUILDfor each package. Set the# Maintainer:comment at the top to the user's email address. If you don't know it, ask. If multiple packages, includeconflicts=()as appropriate so they can't coexist. Packages with-gitor-binsuffixes use versioned provides:provides=("pkgname=${pkgver}"). Useb2sums(except-gitsources, which use'SKIP'). -
Find or ask the user to find and relay the build system/installation methods recommended by the project (e.g.
cargofor Rust,gofor Go). -
Adapt those instructions for each package's
build(),check(),package(), etc. See build-patterns.md for language-specific templates. -
Present all diagnostics, whether seemingly relevant or not, with reasoning for each. Resolve genuine issues before proceeding. Some issues are expected for AUR packages.
-
Update checksums with
updpkgsumsin each package directory. -
Run
makepkg -Cfyourself. Work through any build issues. -
Run
namcapon./package-name-*.pkg.tar.zst. Report all issues with reasoning. -
Give the user a copyable
makepkg -csicommand (withcdif multiple packages). This handles deps, rebuild, and installation in one step. -
Run
makepkg --printsrcinfo > .SRCINFO(withcdif multiple packages). -
If only PKGBUILDs and
.SRCINFOs were created, enter each package directory andgit add+git committhem. If other tracked files were modified, show the diff and ask which to commit. Create a.gitignorein each repo listing everything not committed, using appropriate globs. -
Clean all artifacts with
git clean -fdx.
Updating packages
Follow this strict workflow.
-
List the contents of the current working directory.
- Read any text files present.
- List subdirectory contents (ignore what looks like the upstream project repo).
- Subdirectories with
-binor-gitsuffixes mean multiple packages.
-
We're upgrading to version
$VERSION. Read the PKGBUILD(s), then edit the version number for non--gitpackages. -
Update checksums with
updpkgsums. -
Present all diagnostics with reasoning. Resolve genuine issues before proceeding.
-
Run
makepkg -Cf. Work through any build issues. -
Run
namcapon./package-name-*.pkg.tar.zst. Report all issues with reasoning. -
Give the user a copyable
makepkg -csicommand (withcdif multiple packages). -
Run
makepkg --printsrcinfo > .SRCINFO(withcdif multiple packages). -
If only
PKGBUILDand.SRCINFOwere modified,git addandgit committhem. If other tracked files were modified, show the diff and ask which to commit. -
Clean all artifacts with
git clean -fdx.
If anything other than pkgver is edited during the update, re-run shellcheck and namcap as appropriate.