~bigbes/sr-ht-spec

ref: 5bb0bb134d608263da3197df9fb4f1d8a3fe42db sr-ht-spec/APKBUILD -rw-r--r-- 4.1 KiB
5bb0bb13 — Eugene Blikh graph: serve /query on the anonymous router with a bearer credential 2 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Maintainer: bigbes <bigbes@gmail.com>
#
# Built by builds.sr.ht (.build.yml) and published to our own apk repo at
# repo.bigb.es/alpine/v3.22/bigbes. The srht deployment installs it from there
# instead of cloning and compiling this repo inside its Dockerfile.
#
# pkgver is READ FROM THE ENVIRONMENT, not rewritten in place. CI's `version`
# task exports PKGVER from one `git describe`: a tag becomes `0.2.0`, a tag plus
# commits becomes `0.2.0_git7` (which sorts AFTER the release in Alpine's
# comparison), and a repository with no tags at all falls back to
# `0.0.<commit count>`. The literal below is what a local `abuild` that was
# handed no PKGVER honestly builds.
#
# The earlier arrangement had CI `sed` that literal here before abuild ran, and
# it cannot stand: Go records vcs.modified in every binary compiled inside a
# repository and reads that flag from `git status --porcelain`, so a CI task
# that rewrites a tracked file in the checkout stamps every packaged binary
# dirty for the life of the apk. Measured on go1.26.5.
pkgname=spec.sr.ht
pkgver="${PKGVER:-0.0.0}"
pkgrel=0
pkgdesc="Reviewable document storage for humans and agents"
url="https://sourcecraft.dev/bigbes/sr-ht-spec"
arch="x86_64"
license="MIT"
# !check      — the suites are run by the `test` task of .build.yml, against the
#               Postgres that manifest brings up, and they run BEFORE this
#               package is built. Letting abuild run them again would repeat the
#               work with SPECSRHT_TEST_PG unset, i.e. with every database suite
#               skipping — 67 tests of db/, service/ and cmd/specsrht-migrate/,
#               measured. That task's DSN guard is what makes this line true; a
#               pipeline without it packages code nothing tested.
# !tracedeps  — CGO_ENABLED=0, so the binaries are static
options="!check !tracedeps"

source=""
builddir="$startdir"

build() {
	cd "$builddir"
	# abuild redirects GOCACHE into $tmpdir (wiped after packaging), and an
	# upstream typo makes GOMODCACHE follow GOCACHE's value rather than its
	# own. Re-pin both to the stable home locations here — after abuild's own
	# exports — so CI's cache_restore/cache_save tasks see them survive.
	export GOCACHE="$HOME/.cache/go-build"
	export GOMODCACHE="$HOME/go/pkg/mod"
	# CSS strictly before the binaries: web/ go:embed-s static/, so a
	# stylesheet built afterwards would never make it into the binary. The
	# shared scss partials are assembled by CI at ASSETS/scss (no apk ships
	# them).
	make css ASSETS=/usr/share/sourcehut
	# The stylesheet has to exist before the compiler runs and nothing else
	# says so: `go build` succeeds perfectly well with an unstyled static/,
	# because //go:embed takes the directory and not the file, and the first
	# sign of trouble would be an unstyled page in production. `make install`
	# runs this too; here it fails the build before anything is staged.
	make check-css
	# -modcacherw matters beyond convenience: without it the module cache is
	# extracted read-only, and the CI cache tarball made from it can't be
	# unpacked on the next build (mkdir into 0555 dirs fails).
	CGO_ENABLED=0 make build GOFLAGS="-trimpath -modcacherw"
}

package() {
	cd "$builddir"
	# This Makefile honours DESTDIR; ASSETS must stay the real runtime path so
	# migrations and schema land where specsrht-migrate resolves them. Static
	# assets are not installed at all — they are inside the binary, embedded by
	# web/templates.go.
	#
	# `install-files` and not `install`, because this function must not compile.
	# abuild runs package() in a FRESH abuild process under fakeroot, which
	# re-sources this file and never calls build(): nothing build() exported
	# reaches here, the Go cache pins above included, so `make install` — whose
	# .PHONY binary targets always rerun — relinked both binaries from a cold
	# cache and shipped a SECOND binary that nothing in this pipeline had
	# tested. `install -Dm755 specsrht` on a missing file is a fatal error
	# naming it, so a package() reached without a build() says so.
	make install-files DESTDIR="$pkgdir" PREFIX=/usr \
		ASSETS=/usr/share/sourcehut
}