summaryrefslogtreecommitdiff
path: root/ergo/PKGBUILD
blob: c2e63526005d1f68204a6a4e0a18d69efa42420c (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Maintainer: Deposite Pirate <dpirate at metalpunks dot info>
#
# Upstream: https://git.metalpunks.info/arch-ports

pkgname=ergo
pkgver=2.10.0
pkgrel=1
pkgdesc="A modern IRC server written in Go"
arch=('x86_64')
url="https://github.com/ergochat/ergo"
license=('MIT')
install=ergo.install
depends=('glibc')
makedepends=('go' 'git')
source=("git+$url#tag=v$pkgver"
				"ergo-paths.patch"
        "ergo.service"
        "ergo.sysusers"
        "ergo.tmpfiles")
sha256sums=('SKIP'
            '824b6618d0377c50645ff75cf1f3ad903e217476738728bc57102fd26ca766c8'
            'e668371b2505832cc7f762f0f3b9f9503692f89882735b67eec05f7819cc19f7'
            '1930c0e32093b32ff7c05fe8548c20a90846acea08b62aab3194c1be7240a756'
            '1bc9acdd7fc1fb8251a0165a19d6f4383069e522827535b9c1f717de5495cb29')
backup=('etc/ergo.conf')
replaces=('oragono')
conflicts=('oragono')
provides=('oragono')

prepare() {
  cd "${srcdir}/${pkgname}"
  
	# Fix paths
	patch -p1 -i ../ergo-paths.patch
}

build() {
  export GOPATH=$(pwd)/..
  cd "${srcdir}/${pkgname}"

  GIT_COMMIT="$(git rev-parse HEAD 2> /dev/null)"

  # flags from https://wiki.archlinux.org/index.php/Go_package_guidelines
  # to address issues namcap warns about:
  #   ergo W: ELF file ('usr/bin/ergo') lacks FULL RELRO, check LDFLAGS.
  #   ergo W: ELF file ('usr/bin/ergo') lacks PIE.
  # related: https://bugs.archlinux.org/task/60928
  go build \
      -trimpath \
      -buildmode=pie \
      -ldflags "-X main.commit=${GIT_COMMIT} -linkmode external -extldflags \"${LDFLAGS}\"" \
      -v \
      .

  rm languages/README.md
  rm -rf languages/example
}

check() {
  export GOPATH=$(pwd)/..
  cd "${srcdir}/${pkgname}"

  go test ./...
}

package() {
  install -Dm644 ergo.service "${pkgdir}/usr/lib/systemd/system/ergo.service"
  install -Dm644 "${srcdir}/ergo.sysusers" "${pkgdir}/usr/lib/sysusers.d/ergo.conf"
  install -Dm644 "${srcdir}/ergo.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/ergo.conf"

  cd "${srcdir}/${pkgname}"
  install -Dm755 -d "${pkgdir}/usr/share/${pkgname}/i18n"
  cp languages/* "${pkgdir}/usr/share/${pkgname}/i18n/"
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm755 ergo "${pkgdir}/usr/bin/ergo"
  install -Dm644 default.yaml "${pkgdir}/etc/ergo.conf"
  install -Dm644 ergo.motd "${pkgdir}/usr/share/${pkgname}/default.motd"
}