-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPKGBUILD
62 lines (56 loc) · 1.77 KB
/
PKGBUILD
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
# Maintainer: Andrei Costescu <[email protected]>
# shellcheck shell=bash
pkgname=go-motd-git
_pkgname="${pkgname%-git}"
_config_path="etc/${_pkgname}/config.yaml"
pkgver=f07595b
pkgrel=1
pkgdesc="Dynamic MOTD written in Go"
arch=("x86_64")
url="https://github.com/cosandr/go-motd"
license=("MIT")
provides=("${_pkgname}")
conflicts=("${_pkgname}")
optdepends=(
'zfs-utils: ZFS pool status'
'docker: Docker container status'
'hddtemp: Disk temperatures'
'go-check-updates: Pending updates'
'lm_sensors: CPU temperatures'
)
makedepends=("git" "go")
source=("git+$url")
md5sums=("SKIP")
backup=("$_config_path")
pkgver() {
cd "${_pkgname}"
( set -o pipefail
git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
)
}
build() {
cd "${_pkgname}"
go mod vendor
go build -a -ldflags "-X main.defaultCfgPath=/${_config_path}" -o "${_pkgname}"
# Generate default config
./"${_pkgname}" --config /dev/null --dump-config > "default-config.yaml" 2> /dev/null
# Generate systemd unit file
cat > "${_pkgname}".service <<EOF
[Unit]
Description=Go MOTD generator
[Service]
PIDFile=/run/${_pkgname}.pid
ExecReload=/usr/bin/kill -s HUP \$MAINPID
ExecStart=/usr/bin/${_pkgname} --daemon --pid /run/${_pkgname}.pid --output /etc/motd
EOF
}
package() {
cd "${_pkgname}"
install -dm 755 "${pkgdir}/etc/systemd/system"
install -Dm 644 "${_pkgname}".service "${pkgdir}/etc/systemd/system"
install -dm 755 "${pkgdir}/etc/${_pkgname}"
install -Dm 644 "default-config.yaml" "${pkgdir}/${_config_path}"
install -Dm 755 "${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}"
install -Dm 644 LICENSE "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE"
}