summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6a465c932d99b9181c13727017568be264b9a9a3 (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
# Maintainer: Sherlock Holo <sherlockya@gmail.com>
_pkgname=camouflage
pkgname=$_pkgname-git
pkgver=2.0.0.r5.gc0dd8e6
pkgrel=1
pkgdesc="a mux websocket over TLS proxy, experimental version"
arch=('x86_64')
license=('MPL')
depends=()
makedepends=('go>=2:1.15' 'git')
url='https://github.com/Sherlock-Holo/camouflage'
source=(
	"git+https://github.com/Sherlock-Holo/camouflage"
    "camouflage.install"
)

provides=(camouflage)
conflicts=(camouflage)

md5sums=('SKIP'
         'd506ec62e984c89ddea0cec157292d42')

backup=(
    'etc/camouflage/example.toml'
)

pkgver() {
    cd $srcdir/$_pkgname
    git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g' | sed 's/^v//g'
}

build() {
	rm -rf "$srcdir/go/src"

	mkdir -p "$srcdir/go/src"

	export GOPATH="$srcdir/go"

    cd "$srcdir/$_pkgname"

    msg2 "Downloading dependencies"
    export GO111MODULE=on
    export CGO_ENABLED=0
    export GOPROXY=https://goproxy.cn,direct
    go mod download

    export GOFLAGS="-trimpath -mod=readonly -modcacherw"

    msg2 "Building binary"

    msg2 "Cleaning residual"
    chmod 777 -R $GOPATH/pkg/mod
    rm -rf $GOPATH/pkg/mod

    go build -v
}

package() {
    mkdir -p $pkgdir/usr/bin
	install -D $srcdir/$_pkgname/camouflage $pkgdir/usr/bin/camouflage

    mkdir -p $pkgdir/etc/camouflage
    install -Dm644 $srcdir/$_pkgname/config/example.toml $pkgdir/etc/camouflage/

	mkdir -p $pkgdir/usr/lib/systemd/system
    install $srcdir/$_pkgname/systemd/camouflage-{client,server}@.service \
    -Dm644 $pkgdir/usr/lib/systemd/system/
}