summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b01ec89da3f9523a6ee6fc2ea74a9a9965492d6b (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
# Maintainer: devome <evinedeng@hotmail.com>

pkgname="webhookd"
pkgver=1.20.1
pkgrel=1
pkgdesc="A very simple webhook server launching scripts."
arch=('i686' 'pentium4' 'x86_64' 'arm' 'armv7h' 'armv6h' 'aarch64' 'riscv64')
url="https://github.com/ncarlier/${pkgname}"
license=("MIT")
makedepends=("git" "go")
backup=("etc/default/${pkgname}")
source=("${pkgname}::git+${url}.git#tag=v${pkgver}"
        "${pkgname}.service"
        "${pkgname}.user.service")
sha256sums=('f9689036fd4b010be1124ed381cbacd354c768490020a145904080ac6fb96728'
            'b24d5dfc84bf7b1cceea963b96de3085b6ed079c8f99c56225d8125c791d3543'
            '714e9e219b51af192208500b6936f748ad86a5ec79d5e5683cab1e81fbeae09c')

build() {
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    cd "${pkgname}"

    local git_commit=$(git rev-list -1 HEAD --abbrev-commit)
    local build_time="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
    local ldflags=" \
        -s -w \
        -X ${url/https:\/\//}/pkg/version.Version=v${pkgver} \
        -X ${url/https:\/\//}/pkg/version.GitCommit=${git_commit} \
        -X ${url/https:\/\//}/pkg/version.Built=${build_time} \
        -extldflags '${LDFLAGS}'
    "
    go build \
        -tags osusergo,netgo \
        -trimpath \
        -ldflags="$ldflags" \
        -o "${pkgname}"
}

package() {
    install -Dm755 "${pkgname}/${pkgname}"                 "${pkgdir}/usr/bin/${pkgname}"
    install -Dm644 "${pkgname}/LICENSE"                    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -Dm644 "${pkgname}.service"                    "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
    install -Dm644 "${pkgname}.user.service"               "${pkgdir}/usr/lib/systemd/user/${pkgname}.service"
    install -Dm644 "${pkgname}/etc/default/${pkgname}.env" "${pkgdir}/etc/default/${pkgname}"
    install -Dm644 "${pkgname}"/{README.md,scripts/*.sh,scripts/examples/*} -t "${pkgdir}/usr/share/doc/${pkgname}"
}