summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6e3ac32e198700dc521813d5b7be6fb5f63a25ff (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Maintainer: eNV25 <env252525@gmail.com>

pkgname=('psiphon-console-client' 'psiphon-server')
pkgbase=psiphon-tunnel-core
pkgver=2.0.31
pkgrel=2
pkgdesc="Psiphon Internet censorship circumvention system."
arch=('i686' 'x86_64')
_gomod="github.com/Psiphon-Labs/psiphon-tunnel-core"
url="https://$_gomod"
license=('GPL')
makedepends=('go')
options=(!debug)
source=("$pkgbase-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
install=psiphon.install

export GO111MODULE=off

export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

build() {
	function echorun {
		echo "$@"
		"$@"
	}

	mkdir -vp "$srcdir/go/src/$(dirname "$_gomod")"
	ln -srvf "$srcdir/$pkgbase-$pkgver/" "$srcdir/go/src/$_gomod"

	export GOPATH="$srcdir/go/"

	echorun go build \
		-o bin/psiphon-console-client \
		"$_gomod/ConsoleClient"
	echorun go build \
		-o bin/psiphon-server \
		"$_gomod/Server"
}

package_psiphon-console-client() {
	install -Dm755 "$srcdir/bin/psiphon-console-client" -t "$pkgdir/usr/bin/"
	install -Dm644 /dev/stdin "$pkgdir/usr/lib/systemd/system/psiphon-client.service" <<-'EOF'
		[Unit]
		Description=Psiphon Proxy Client Service

		[Service]
		WorkingDirectory=%E/psiphon/
		ExecStart=/usr/bin/psiphon-console-client -config client.config -formatNotices
		Restart=on-failure

		[Install]
		WantedBy=multi-user.target
	EOF
	install -Dm644 /dev/stdin "$pkgdir/usr/lib/systemd/user/psiphon-client.service" <<-'EOF'
		[Unit]
		Description=Psiphon Proxy Client Service

		[Service]
		WorkingDirectory=%E/psiphon/
		ExecStart=/usr/bin/psiphon-console-client -config client.config -formatNotices
		Restart=on-failure

		[Install]
		WantedBy=default.target
	EOF
}

package_psiphon-server() {
	conflicts=('psiphond')
	provides=('psiphond')
	install -Dm755 "$srcdir/bin/psiphon-server" -t "$pkgdir/usr/bin/"
	ln -srf "$pkgdir/usr/bin/psiphon-server" "$pkgdir/usr/bin/psiphond"
	install -Dm644 /dev/stdin "$pkgdir/usr/lib/systemd/system/psiphon-server.service" <<-'EOF'
		[Unit]
		Description=Psiphon Proxy Server Service

		[Service]
		WorkingDirectory=%E/psiphon/
		ExecStart=/usr/bin/psiphond run
		Restart=on-failure

		[Install]
		WantedBy=multi-user.target
	EOF
	install -Dm644 /dev/stdin "$pkgdir/usr/lib/systemd/user/psiphon-server.service" <<-'EOF'
		[Unit]
		Description=Psiphon Proxy Server Service

		[Service]
		WorkingDirectory=%E/psiphon/
		ExecStart=/usr/bin/psiphond run
		Restart=on-failure

		[Install]
		WantedBy=default.target
	EOF
}

# sums
sha256sums=('75e1680d486d3e797796b0a00ef48abda6b82f70dd14584f8b69452aed7fa64d')