summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4d590afc947394196dda13dfd93672fba81f6a0a (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
# Maintainer: Chi_Tang <me@chitang.dev>
# Maintainer: Integral <integral@member.fsf.org>

pkgname=nekoray-git
_pkgname=${pkgname%-git}
pkgver=4.3.2.r30.gf2987f3
pkgrel=2
pkgdesc="Qt based cross-platform GUI proxy configuration manager (backend: sing-box)"
arch=('x86_64' 'aarch64' 'riscv64')
url="https://github.com/Mahdi-zarei/${_pkgname}"
license=('GPL-3.0-or-later')
makedepends=('cmake' 'git' 'go' 'qt6-tools')
depends=('qt6-base' 'qt6-charts' 'protobuf' 'yaml-cpp' 'zxing-cpp' 'abseil-cpp' 'cpr')
optdepends=(
	'sing-geoip-db: geoip database for NekoBox'
	'sing-geosite-db: geosite database for NekoBox'
)
conflicts=("${_pkgname}")
provides=("${_pkgname}")
source=(
	"git+${url}.git"
	${_pkgname}.{sh,desktop}
)
install="${pkgname}.install"
sha512sums=('SKIP'
            'b377f7e8c859ee0b5bc05f89e2dc6c0b8535e740e089e9afe5e5f145c38a05fccbbddfcb6eb8ced9a7478e4d9ccc3cbd3ffb6843c128189c75599c40c87737e8'
            'b0cfd99d7fd038d660af275a5f2fc7f9ebfe63d6751edd6eea66a8c5350f314b6dbc9eddaa5aaed134e97087290630d369b1bdf4ad59d12868c780103b33dbed')

pkgver() {
	git -C "${_pkgname}/" describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
	cd "${_pkgname}/"

	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr

	cmake --build build

	export CGO_CPPFLAGS="${CPPFLAGS}"
	export CGO_CFLAGS="${CFLAGS}"
	export CGO_CXXFLAGS="${CXXFLAGS}"
	export CGO_LDFLAGS="${LDFLAGS}"

	cd core/server
	VERSION_SINGBOX=$(go list -m -f '{{.Version}}' github.com/sagernet/sing-box)
	go build -o ../../build/ \
		-buildmode=pie \
		-trimpath \
		-ldflags "-linkmode=external -w -s -X 'github.com/sagernet/sing-box/constant.Version=${VERSION_SINGBOX}'" \
		-mod=readonly \
		-modcacherw \
		-tags "with_clash_api,with_gvisor,with_quic,with_wireguard,with_utls,with_ech,with_dhcp"
}

package() {
	install -Dm644 "${_pkgname}.desktop" -t "${pkgdir}/usr/share/applications/"
	install -Dm755 "${_pkgname}.sh" "${pkgdir}/usr/bin/${_pkgname}"

	cd "${_pkgname}/"
	install -Dm644 "res/public/nekobox.png" -t "${pkgdir}/usr/share/pixmaps/"
	install -Dm755 build/{${_pkgname},nekobox_core} -t "${pkgdir}/usr/lib/${_pkgname}/"
}