summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 77c091618c70fb1bb7cbd28194a3b288842c101a (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Maintainer:
# Contributor: Riccardo Berto <riccardo at rcrdbrt dot-symbol com>
# Contributor: Moses Narrow <moe-narrow@use.startmail.com>
# Contributor: Dimitris Kiziridis <ragouel at outlook dot com>
# Contributor: Konrad Tegtmeier <konrad.tegtmeier+aur@gmail.com>
# Contributor: Marcel O'Neil <marcel@marceloneil.com>

## links
# https://www.cockroachlabs.com/docs/stable/install-cockroachdb-linux.html
# https://github.com/cockroachdb/cockroach
# https://www.cockroachlabs.com/docs/releases/

_pkgname=cockroachdb
pkgname="$_pkgname-bin"
pkgver=24.2.4
pkgrel=1
pkgdesc="Cloud-native, distributed SQL database"
url='https://www.cockroachlabs.com'
license=('Apache-2.0' 'BUSL-1.1' 'LicenseRef-CCL')
arch=('x86_64')

depends=('glibc')
makedepends=('chrpath')

conflicts=("$_pkgname=${pkgver}")
provides=("$_pkgname")

options=('!debug')

backup=("etc/default/cockroach")

_pkgsrc="cockroach-v$pkgver.linux-amd64"
_pkgsrc_source="cockroach-$pkgver"
source=(
  "$_pkgname-$pkgver.tar.gz"::"https://binaries.cockroachdb.com/$_pkgsrc.tgz"
  "LICENSE-$pkgver"::"https://github.com/cockroachdb/cockroach/raw/v$pkgver/LICENSE"
  "LICENSE.CCL-$pkgver"::"https://github.com/cockroachdb/cockroach/raw/v$pkgver/licenses/CCL.txt"
)
sha256sums=(
  'fa4a5696f0abd766993d5ded9b6c2cc899701be56afbf6d737baf4841c9e7bc1'
  '0384efdf47789c3548e7eff949c5c2c9c4ee95741f805a39cdb6f02035919889'
  '25ec687608539ef745809b39ed1af6f34520855d74db2a1367f6e6c6adbf43de'
)

build() {
  # generate shell completion
  "$_pkgsrc/cockroach" gen autocomplete bash --out "cockroach.bash"
  "$_pkgsrc/cockroach" gen autocomplete zsh --out "cockroach.zsh"

  # generate man pages
  "$_pkgsrc/cockroach" gen man --path "man"
}

package() {
  local _install_path='usr/lib'

  # binary
  install -Dm755 "$_pkgsrc/cockroach" "$pkgdir/$_install_path/$_pkgname/cockroach"

  # GEOS libraries
  install -Dm644 "$_pkgsrc/lib/libgeos.so" "$pkgdir/$_install_path/$_pkgname/lib/libgeos.so"
  install -Dm644 "$_pkgsrc/lib/libgeos_c.so" "$pkgdir/$_install_path/$_pkgname/lib/libgeos_c.so"
  chrpath -r /usr/lib/cockroachdb "$pkgdir/$_install_path/$_pkgname/lib/libgeos_c.so"

  # script
  install -Dm755 /dev/stdin "$pkgdir/usr/bin/cockroach" << END
#!/usr/bin/env sh
exec /$_install_path/$_pkgname/cockroach "\$@"
END

  # user/group & owned directories
  install -Dm644 /dev/stdin "$pkgdir/usr/lib/sysusers.d/cockroach.conf" << END
u cockroach - "CockroachDB" /var/lib/cockroach
END

  install -Dm644 /dev/stdin "$pkgdir/usr/lib/tmpfiles.d/cockroach.conf" << END
d /etc/cockroach 0755 root cockroach - -
d /var/lib/cockroach 0750 cockroach cockroach - -
END

  # services & runtime
  install -Dm644 /dev/stdin "$pkgdir/usr/lib/systemd/system/cockroach.service" << END
[Unit]
Description=CockroachDB database server
Requires=network-online.target
After=network-online.target

[Service]
User=cockroach
Group=cockroach

EnvironmentFile=-/etc/default/cockroach
ExecStart=/usr/bin/cockroach start --certs-dir /etc/cockroach --store=${COCKROACH_STORE} $COCKROACH_FLAGS
LimitNOFILE=35000

ProtectHome=true
ProtectSystem=full
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
END

  install -Dm644 /dev/stdin "$pkgdir/etc/default/cockroach" << END
COCKROACH_FLAGS="--insecure"
COCKROACH_STORE="path=/var/lib/cockroach"
END

  # man pages
  install -Dm644 "man"/*.1 -t "$pkgdir/usr/share/man/man1/"

  # shell completion
  install -Dm644 cockroach.bash "$pkgdir/usr/share/bash-completion/completions/cockroach"
  install -Dm644 cockroach.zsh "$pkgdir/usr/share/zsh/site-functions/_cockroach"

  # licenses
  install -Dm644 "LICENSE-$pkgver" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 "LICENSE.CCL-$pkgver" "$pkgdir/usr/share/licenses/$pkgname/LICENSE.CCL"
}