summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1ef684b66d6f544b09a5645bd00ee4f6e758b1ef (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
# Maintainer: Jiri Tyr <jiri.tyr@gmail.com>

_pkg='tempreader'
_gopkg="github.com/jtyr/$_pkg"

pkgname="$_pkg-git"
pkgver=r5.73ebe52
pkgrel=2
pkgdesc='RESTful API to read data from DS18B20 temperature sensors.'
url="https://github.com/jtyr/tempreader"
arch=('any')
license=('MIT')
conflicts=('tempreader')
makedepends=('go')


pkgver() {
    cd "$srcdir/src/$_gopkg"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}


prepare() {
    msg2 'Fetching Go package'
    GOPATH="$srcdir" go get -u -d "$_gopkg"
}


build() {
    msg2 'Building binary'
    GOPATH="$srcdir" go build -o "bin/$_pkg" -trimpath -ldflags='-s -w' "$_gopkg"
}


package() {
    msg2 'Installing files'
    install -Dm755 "$srcdir/bin/$_pkg" -t "$pkgdir/usr/bin"
    install -Dm644 "$srcdir/src/$_gopkg/"/{LICENSE,README.md} -t "$pkgdir/usr/share/doc/$_pkg"
    install -Dm644 "$srcdir/src/$_gopkg/contrib/$_pkg.service" "$pkgdir/usr/lib/systemd/system/$_pkg.service"
    install -Dm644 "$srcdir/src/$_gopkg/contrib/$_pkg.default" "$pkgdir/etc/default/$_pkg"
}