summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6bad70957bc7ac235d6dd7f323501a9a75e70fa5 (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
# Maintainer: Luis Martinez <luis dot martinez at disroot dot org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=blocky
pkgver=0.19
pkgrel=1
pkgdesc="Fast and lightweight DNS proxy as ad-blocker"
arch=('x86_64' 'armv6h' 'armv7h' 'aarch64')
url="https://github.com/0xERR0R/blocky"
license=('Apache')
depends=('glibc')
makedepends=('go')
backup=('etc/blocky.yml')
install=blocky.install
options=('!lto')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
        'blocky.service'
        'blocky.sysusers'
        'blocky.yml')
sha256sums=('25aa341a836ded4f2c60eb7e3a578d8723148c327c297fdc572c342f8fc79c41'
            '21a56bc11ad08186b0f6d3394106500c8e662662fe9af5bed56d788fc3c91ebb'
            '8ef3cfa71ee8d2ad427dc5d83df7967a6b3e6e1dfafaec8cb4520e7269c2471b'
            'b2240a9a3a0d732920c481b3d6c80c8d78d7f8153129c8cdf33851c9b16e6e39')

prepare() {
    cd "$pkgname-$pkgver"
    mkdir -p build
    go mod download
}

build() {
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"

    cd "$pkgname-$pkgver"
    ## make build overrides our GOFLAGS
    local _BUILDTIME="$(date '+%Y%m%d-%H%M%S')"
    local _govar="${url#https://}/util"
    go build -o build \
        -ldflags "-linkmode=external -extldflags ${LDFLAGS} -X $_govar.Version=$pkgver -X $_govar.BuildTime=$_BUILDTIME"
}

check() {
    cd "$pkgname-$pkgver"
    go test ./...
}

package() {
    install -Dm644 blocky.sysusers "$pkgdir/usr/lib/sysusers.d/blocky.conf"
    install -Dm644 blocky.service -t "$pkgdir/usr/lib/systemd/system/"
    install -Dm644 blocky.yml -t "$pkgdir/etc/"
    cd "$pkgname-$pkgver"
    install -D build/blocky -t "$pkgdir/usr/bin/"
    install -Dm644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}

# vim:set ts=4 sw=4 et: