summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a52a79f10eede2ea30b14b2300eff63d8a361525 (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
# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=gosniff
pkgver=r38.17ac522
pkgrel=1
pkgdesc='A fancy-schmancy tcpdump-esque TUI, programmed in Go'
arch=('x86_64')
url='https://github.com/c-grimshaw/gosniff'
license=('MIT')
depends=('glibc' 'libpcap')
makedepends=('git' 'go')
options=('!lto')
_commit='17ac522a8bb0c0ea3545e06f864f8db476fa5f8e'
source=("$pkgname::git+$url#commit=$_commit")
md5sums=('SKIP')

pkgver() {
  cd "$pkgname"

  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$pkgname"

  # download dependencies
  go mod download
}

build() {
  cd "$pkgname"

  # set Go flags
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"

  go build -v \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags ${LDFLAGS}" \
    .
}

check() {
  cd "$pkgname"

  go test -v ./...
}

package() {
  cd "$pkgname"

  install -vDm755 -t "$pkgdir/usr/bin" gosniff

  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}