summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 42aa82990f6dc4950b446a898909ef3375848304 (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
# Maintainer: DuckSoft <realducksoft@gmail.com>
# Maintainer: mzz2017 <mzz@tuta.io>
pkgname=mmp-go-git
pkgver=20210218.r117.92ace24
pkgrel=1
pkgdesc="Reuse a single port for multiple Shadowsocks AEAD servers"
arch=('x86_64')
url="https://github.com/Qv2ray/mmp-go"
license=('AGPL3')
depends=('git' 'glibc')
makedepends=('go')
provides=('mmp-go')
conflicts=('mmp-go')
source=("$pkgname::git+$url")
sha512sums=('SKIP')

pkgver() {
    cd "$srcdir"/"$pkgname"
    local date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
    local count=$(git rev-list --count HEAD)
    local commit=$(git rev-parse --short HEAD)
    echo "$date.r${count}.$commit"
}

build() {
    cd "$srcdir"/$pkgname
    
    CGO_ENABLED=1 GO111MODULE=on go build -v \
        -buildmode=pie -trimpath \
        -ldflags="-s -w -X github.com/Qv2ray/mmp-go/config.Version=$pkgver -extldflags=-Wl,-z,now,-z,relro" \
        -o mmp-go .
}

package() {
    cd "$srcdir"/$pkgname
    
    # Binary
    install -Dm755 ./mmp-go                    -t "$pkgdir"/usr/bin/
    
    # Documentation
    install -Dm644 ./README.md                 -t "$pkgdir"/usr/share/doc/mmp-go
    install -Dm644 ./systemd/README.md         "$pkgdir"/usr/share/doc/mmp-go/README-systemd.md
    
    # Configuration
    install -Dm644 ./example.json              "$pkgdir"/etc/mmp-go/config.example.json
    
    # Intergration
    install -Dm644 ./systemd/*.{service,timer} -t "$pkgdir"/usr/lib/systemd/system
}