create-package.md

 1We need to create a new AUR package (or multiple) from scratch.
 2
 3Code style:
 4
 5- Language(s): PKGBUILD is bash; .install (if necessary) is POSIX-sh–compatible
 6  functions
 7- Indent 2 spaces; UTF-8; LF endings; no trailing whitespace
 8- Strings: single quotes for literals; double quotes when expanding vars
 9- Functions: prepare(), build(), check(), package(); only define needed ones
10- No sudo, networking, or user config in build/package functions
11- Use install -Dm755 for binaries; set exact modes explicitly
12- Checksums: keep hashes in sync with sources
13- Keep .SRCINFO in lockstep with PKGBUILD; don't commit build artifacts
14
15During creation, follow this strict workflow. If a planning or todo tool is
16available, fill it out _in detail_ with these steps; you might get interrupted
17and have to pick up where you left off based on that todo/planning tool's
18output.
19
201. List the contents of your current working directory to see what I've already
21   done.
22   - If you see text files, read them.
23   - If you see directories, list their contents.
24     - If by its contents, it seems like the repository of the project we're packaging, ignore it for now.
25   - If there are sub-directories of your current working directory with suffixes like `-bin` or `-git`, we're actually going to be creating _multiple_ AUR packages for the _same_ piece of software.
26     - `-git` packages clone the primary branch (main, master, trunk, etc.) and build and install the software from that source. We do not specify versions for these packages; updpkgsums determines the version and edits the PKGBUILD.
27     - `-bin` packages download the project-built and project-distributed binary and install that.
28     - Packages without a suffix download the nearest thing to a release archive we can find and build/install that source.
29   - There are no sub-directories of your current working directory, we're only creating one package. Look to your current working directory to determine whether we're creating a suffix-less package, or one with `-git` or `-bin`.
302. Ask me for the package name (`provides=`), description (`description=`), and license (`license=()`), _and_ the license path inside the project repo (for `install`ing). Then for each of the non`-git` package types, ask me for its current version and the source URL.
31   - For `-git` packages, you _must_ prefix the source URL with `git+https://...`. Ask me which branch to check out. Include the following function to support versioning.
32     ```bash
33     pkgver() {
34       cd "$pkgname" || exit
35       ( set -o pipefail
36         git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
37         printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
38       )
39     }
40     ```
41   - For `-bin` packages, use `bin-name-$pkgver:https://...` in the source, then `install` `bin-name-$pkgver` as `bin-name`. Additionally, we'll need to obtain the license from the original repository. If the source is GitHub, the raw URL is `https://raw.githubusercontent.com/bmf-san/ggc/refs/tags/{TAG}/LICENSE`. If the source is not GitHub, ask me for the raw URL to the tagged LICENSE file.
423. For each package we're creating, write a new `PKGBUILD` to that directory with the details above. The `Maintainer` comment at the top should be `Amolith <amolith@secluded.site>`. If multiple packages, make sure to include `conflicts=()` so one can't get installed alongside the other. Make sure packages with `-git` or `-bin` use the suffix-less package name in the provides field. Use `b2sums`.
434. Ask me to find and relay the build system/installation methods recommended by the project. This might be `cargo` for Rust projects, `go` for Go, etc.
445. Once I've relayed the project's instructions, adapt those for each of the packages depending on project language and update the PKGBUILDs' `build()`, `check()`, `package()`, etc. functions.
45   - Rust
46     - `-git` and `-bin` are pretty self-explanatory for Rust. For suffix-less packages, download the version crate from cargo's API as a `.crate` file and build it using `cargo`.
47   - Go
48     - To keep all Go modules in the package build environment, use
49       ```
50       prepare() {
51         cd "${pkgname}-${pkgver}"
52         export GOPATH="${srcdir}"
53         go mod download -modcacherw
54       }
55       ```
56     - If the build process bakes in version information, use the following in the build() function.
57       ```
58       go build \
59           -trimpath \
60           -buildmode=pie \
61           -mod=readonly \
62           -modcacherw \
63           -ldflags "-linkmode external -extldflags \"${LDFLAGS}\"" \
64           "$pkgname" main.go # or ./cmd or ...
65       ```
66       If the build process does not bake version info in, use this.
67       ```
68       export CGO_CPPFLAGS="${CPPFLAGS}"
69       export CGO_CFLAGS="${CFLAGS}"
70       export CGO_CXXFLAGS="${CXXFLAGS}"
71       export CGO_LDFLAGS="${LDFLAGS}"
72       export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
73       ```
746. Consider the diagnostics and present _all_ issues to me, whether you think they're relevant or not. Include reasoning why those issues are relevant, or why they're not. We'll work on any genuine issues until they're resolved before proceeding.
757. Update checksums in each package directory with `updpkgsums`
768. Install dependencies and build/install the package(s) by giving _me_ a code block of `makepkg -Ccsi` commands I can copy/paste. If there are multiple packages, include `cd` prior to `makepkg`. We'll work on any issues that arise during this step until they're resolved.
77   - I must run `makepkg` commands because you're prohibited from interacting with it.
789. After I build the packages, run `namcap` on `./package-name-*.pkg.tar.zst` to lint them. Again, report all the issues to me and we'll work on them before continuing.
7910. Generate each package's `.SRCINFO` by, again, giving me a series `makepkg --printsrcinfo > .SRCINFO`. If just one package, no `cd` is necessary. Just `makepkg`.
8011. If the PKGBUILDs and .SRCINFOs are the only files you've created during this session, enter each package directory, then `git add` and `git commit` them. If there are other files you've modified that are tracked by git in those package directory, please show me the diff and ask which you should commit. Create a `.gitignore` in each package repo that lists everything in the dir we have _not_ committed. Use appropriate globbing.
8112. Clean all artefacts with `git clean -fdx`