summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d8fb567e67fe24515fc71edfca563cf8d3337c0e (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
79
80
81
82
83
84
85
86
87
88
# Maintainer: Christian Pfeiffer <cpfeiffer@live.de>
# Contributor: Jason Papakostas <vithos@gmail.com>
# Contributor: Sean Enck <enckse@gmail.com>

pkgname=ergochat
_upstream_pkgname=ergo
pkgver=2.14.0
pkgrel=1
pkgdesc="A modern IRC server written in Go"
arch=('i686' 'pentium4' 'x86_64' 'arm' 'armv7h' 'armv6h' 'aarch64')
url="https://github.com/ergochat/ergo"
license=('MIT')
install=install
depends=('glibc')
optdepends=('ergochat-ldap: LDAP authentication support')
makedepends=('go' 'git')
source=("git+$url#tag=v$pkgver"
    "config.patch"
    "systemd-service-unit.patch"
    "ergochat.sysusers"
    "ergochat.tmpfiles")
sha256sums=('SKIP'
            '94ea647a7557002817d077d280e69a95ebce8a94d0806d84e623e44572edf0d2'
            'cba63567bbd989c22242d25c8c9dd23a82caded310fbddc1532e551d5adea708'
            '1912d91aff30318dfafedbdf6c786f096ff897962736bd960acf7130859cdff2'
            '3fbd033a9a7c92859f6e26005db2ddeddda3816b0e735f7772f10c4da4df0266')
backup=("etc/oragono.conf" "etc/$pkgname.conf" "etc/$pkgname/ircd.yaml")
replaces=("oragono")
conflicts=("oragono")
provides=("oragono")

prepare() {
    cd "$srcdir/$_upstream_pkgname" || exit
    patch --backup <../config.patch

    cd "$srcdir/$_upstream_pkgname/distrib/systemd" || exit
    patch --backup <../../../systemd-service-unit.patch
}

build() {
    GOPATH=$(pwd)/..
    export GOPATH
    cd "${srcdir}/$_upstream_pkgname" || exit

    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
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    go build \
        -trimpath \
        -buildmode=pie \
        -mod=vendor \
        -modcacherw \
        -ldflags "-X main.commit=${GIT_COMMIT} -compressdwarf=false -linkmode external -extldflags \"${LDFLAGS}\"" \
        -v \
        .

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

check() {
    GOPATH=$(pwd)/..
    export GOPATH
    cd "${srcdir}/$_upstream_pkgname" || exit

    go test ./...
}

package() {
    install -Dm644 "$srcdir/$pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
    install -Dm644 "$srcdir/$pkgname.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf"

    cd "$srcdir/$_upstream_pkgname" || exit
    install -Dm644 "distrib/systemd/$_upstream_pkgname.service" "$pkgdir/usr/lib/systemd/system/$pkgname.service"
    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 $_upstream_pkgname "$pkgdir/usr/bin/$pkgname"
    install -Dm644 default.yaml "$pkgdir/etc/$pkgname/ircd.yaml"
    install -Dm644 $_upstream_pkgname.motd "$pkgdir/usr/share/$pkgname/default.motd"
}