summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 67e56dcd3f0eddcc67a169044587c5c2db477a73 (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
# Maintainer: Julien Virey <julien.virey@gmail.com>

pkgname=privatebin-cli
_binname=privatebin
_bindate=$(date --rfc-3339=date)
pkgver=2.0.2
pkgrel=2
pkgdesc='A powerful CLI for creating and managing PrivateBin pastes with ease'
arch=('x86_64' 'aarch64')
url='https://github.com/gearnode/privatebin'
license=('ISC')
conflicts=("${pkgname}-bin")
makedepends=('go' 'pandoc')
options=(!lto)
install="$pkgname.install"
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('312544308f6727da210f568d387fd629231b6db8c9a58a3a8dfd2596a3d97513')

prepare() {
  cd $_binname-$pkgver
  export GOPATH="${srcdir}"
  go mod download

  # Man
  pandoc --standalone --to man -M footer=$pkgver doc/privatebin.1.md -o privatebin.1
  pandoc --standalone --to man -M footer=$pkgver doc/privatebin-create.1.md -o privatebin-create.1
  pandoc --standalone --to man -M footer=$pkgver doc/privatebin-show.1.md -o privatebin-show.1
  pandoc --standalone --to man -M footer=$pkgver doc/privatebin.conf.5.md -o privatebin.conf.5
}

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

  go build \
    -ldflags "-linkmode external
        -extldflags $LDFLAGS
        -X 'main.version=$pkgver'
        -X 'main.commit=$pkgrel'
        -X 'main.date=$_bindate'" \
    -o $_binname cmd/privatebin/main.go cmd/privatebin/cfg.go
}

package() {
  cd $_binname-$pkgver
  install -Dm755 $_binname "$pkgdir"/usr/bin/$_binname
  install -Dm644 LICENSE.txt -t "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
  install -Dm644 privatebin.1 -t "${pkgdir}"/usr/share/man/man1/
  install -Dm644 privatebin-create.1 -t "${pkgdir}"/usr/share/man/man1/
  install -Dm644 privatebin-show.1 -t "${pkgdir}"/usr/share/man/man1/
  install -Dm644 privatebin.conf.5 -t "${pkgdir}"/usr/share/man/man5/
}