[WIP] PKGBUILD to build and install knot on ArchLinux
archlinux
aur
pkgbuild
1# -*- mode: sh -*-
2
3# Maintainer: Klaus Alexander Seistrup <$(echo 0x1fd+d59decfa=40 | tr 0-9+a-f=x ka-i@p-u.l)>
4
5_pkgname='tangled-knot'
6pkgname="${_pkgname}-git"
7pkgver=1.11.0.alpha.r71.gae0185bd
8pkgrel=2
9pkgdesc='Tangled knot — a code colaboration planform built on the AT protocol (development version)'
10arch=('aarch64' 'x86_64')
11url='https://tangled.org/tangled.org/core'
12license=('MIT') # SPDX-License-Identifier: MIT
13provides=("$_pkgname")
14conflicts=("${provides[@]}")
15makedepends=('git' 'go')
16depends=('git' 'glibc' 'openssh')
17optdepends=(
18 'caddy: webserver for reverse proxy'
19 'nginx: webserver for reverse proxy (alternative)'
20)
21source=(
22 "git+$url"
23 'knotserver.service'
24 'openssh.conf'
25 'tmpfile.conf'
26 'sample-.knot.env'
27 'sample-caddy.conf'
28 'sample-nginx.conf'
29)
30sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')
31install="$_pkgname.install"
32
33pkgver() {
34 cd core
35
36 git describe --long --tags \
37 | sed 's/^v//;s/-rc\d*//;s/\([^-]*-g\)/r\1/;s/-/./g'
38}
39
40prepare() {
41 cd core
42
43 git clean -dfx
44 mkdir -vp build
45 go mod tidy
46}
47
48build() {
49 cd core
50
51 export CGO_ENABLED=1
52 export CGO_CFLAGS="$CFLAGS"
53 export CGO_CXXFLAGS="$CXXFLAGS"
54 export CGO_CPPFLAGS="$CPPFLAGS"
55 export CGO_LDFLAGS="$LDFLAGS"
56
57 _opts=(
58 '-buildmode=pie'
59 '-ldflags=-linkmode=external'
60 '-mod=readonly'
61 '-modcacherw'
62 '-trimpath'
63 )
64 go build "${_opts[@]}" -o build/knot ./cmd/knot
65}
66
67check() {
68 cd core
69
70 : go test ./...
71}
72
73package() {
74 cd core
75
76 install -vDm0755 -t "$pkgdir/usr/bin" \
77 build/knot
78 install -vDm0644 -t "$pkgdir/usr/share/doc/$pkgname" \
79 readme.md docs/*.md
80 install -vDm0644 -t "$pkgdir/usr/share/licenses/$pkgname" \
81 license
82
83 for _dir in doc licenses; do
84 cd "$pkgdir/usr/share/$_dir" && ln -vsr "$pkgname" "$_pkgname"
85 done
86
87 cd "$srcdir"
88
89 install -vDm0644 -t "$pkgdir/usr/lib/systemd/system" knotserver.service
90 install -vDm0644 tmpfile.conf "$pkgdir/usr/lib/tmpfiles.d/$_pkgname.conf"
91 install -vDm0644 openssh.conf "$pkgdir/etc/ssh/sshd_config.d/$_pkgname.conf"
92
93 # Sample configuration files
94 install -vDm0644 -t "$pkgdir/usr/share/doc/$pkgname" sample-*.*
95}
96
97# eof