summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5a26581852e92c1f4df12bf42448334a9a1d5533 (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
# Maintainer: Luis Aranguren <pizzaman@hotmail.com>
# Contributor: Saleem Rashid <trezor@saleemrashid.com>

_pkgname=trezord
pkgname="${_pkgname}-git"
_gitname="${_pkgname}-go"
pkgver=2.0.33.r6.gdb03d99
pkgrel=1
pkgdesc='Trezor Communication Daemon aka Trezor Bridge (written in Go)'
arch=('x86_64')
url='https://github.com/trezor/trezord-go'
license=('LGPL3')
provides=("${_pkgname}" 'trezor-bridge')
conflicts=("${_pkgname}" 'trezor-bridge-bin')
makedepends=('git' 'go')
options=('!lto')
depends=('trezor-udev')
source=(
    "git+https://github.com/trezor/${_gitname}.git"
    "${_pkgname}.sysusers"
)
sha256sums=('SKIP'
            'efa561a7192a22088d1840278fc742b77f649fb3d949aa2a1d8644c681acd270'
)

_importpath="github.com/trezor/${_gitname}"

prepare() {
    cd "${srcdir}/${_gitname}"
    mkdir -p "${srcdir}/src/$(dirname "${_importpath}")"
    ln -sf -T "${srcdir}/${_gitname}" "${srcdir}/src/${_importpath}"
}

pkgver() {
    cd "${srcdir}/${_gitname}"
    git describe --tags --long | sed \
        -e 's/^v//' \
        -e 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
    cd "${srcdir}/${_gitname}"
    export GOPATH="${srcdir}"
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
    go install \
        -gcflags "all=-trimpath=${srcdir}" \
        -asmflags "all=-trimpath=${srcdir}" \
        -ldflags "-extldflags \"${LDFLAGS}\"" \
        "${_importpath}"
}

package() {
    cd "${srcdir}/${_gitname}"
    install -Dm0755 "${srcdir}/bin/${_gitname}" "${pkgdir}/usr/bin/${_pkgname}"
    install -Dm0644 "${srcdir}/${_pkgname}.sysusers" "${pkgdir}/usr/lib/sysusers.d/${_pkgname}.conf"
    install -Dm0644 release/linux/trezord.service "${pkgdir}/usr/lib/systemd/system/trezord.service"
    install -Dm0644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}