net-proxy/hysteria: add 2.6.0, drop 2.5.2
[gentoo-zh.git] / net-proxy / hysteria / hysteria-2.6.0.ebuild
blobe84a3a7a1447fdd761145d398e91f12abd2584f2
1 # Copyright 1999-2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
5 inherit go-module systemd
7 DESCRIPTION="A powerful, lightning fast and censorship resistant proxy."
8 HOMEPAGE="https://github.com/apernet/hysteria"
10 SRC_URI="
11         https://github.com/apernet/${PN}/archive/refs/tags/app/v${PV}.tar.gz -> ${P}.tar.gz
12         https://github.com/peeweep/gentoo-go-deps/releases/download/${P}/${P}-deps.tar.xz
15 S="${WORKDIR}/${PN}-app-v${PV}"
16 LICENSE="MIT"
17 SLOT="0"
18 KEYWORDS="~amd64"
20 GO_CPU_FLAGS_X86="
21         cpu_flags_x86_avx2
22         cpu_flags_x86_fma4
23         cpu_flags_x86_fma3
24         cpu_flags_x86_f16c
25         cpu_flags_x86_avx
26         cpu_flags_x86_sse4_2
27         cpu_flags_x86_sse4_1
28         cpu_flags_x86_ssse3
29         cpu_flags_x86_sse3
32 IUSE="+goamd64 ${GO_CPU_FLAGS_X86[@]}"
34 DEPEND="
35         acct-user/hysteria
36         acct-group/hysteria
37         >=dev-lang/go-1.21.1
39 RDEPEND="${DEPEND}"
41 ego() {
42         set -- go "$@"
43         echo "$@" >&2
44         "$@" || die -n "${*} failed"
47 pkg_setup() {
48         if use goamd64; then
49                 GOAMD64_V="v1"
50                 if use cpu_flags_x86_sse3 && use cpu_flags_x86_sse4_1 && use cpu_flags_x86_sse4_2 && use cpu_flags_x86_ssse3
51                 then
52                         GOAMD64_V="v2"
53                         if use cpu_flags_x86_avx && use cpu_flags_x86_avx2 && use cpu_flags_x86_f16c && \
54                                         (use cpu_flags_x86_fma4 || use cpu_flags_x86_fma3)
55                         then
56                                 GOAMD64_V="v3"
57                         fi
58                 fi
59                 export GOAMD64="${GOAMD64_V}"
60                 einfo "building with GOAMD64=${GOAMD64_V}"
61         fi
64 src_compile() {
65         local APP_SRC_CMD_PKG="github.com/apernet/hysteria/app/cmd"
66         local APP_DATE
67         APP_DATE=$(LC_ALL=C date -u +'%Y-%m-%dT%H:%M:%SZ' || die)
68         local APP_ARCH="Unknown"
69         if use goamd64; then
70                 APP_ARCH="amd64-${GOAMD64}"
71         fi
73         CGO_ENABLED=1 ego build \
74                                   -trimpath \
75                                   -ldflags "-s -w -extldflags \"${LDFLAGS}\" \
76                                   -X \"${APP_SRC_CMD_PKG}.appVersion=${PV}\" \
77                                   -X \"${APP_SRC_CMD_PKG}.appDate=${APP_DATE}\" \
78                                   -X \"${APP_SRC_CMD_PKG}.appType=release\" \
79                                   -X \"${APP_SRC_CMD_PKG}.appPlatform=linux\" \
80                                   -X \"${APP_SRC_CMD_PKG}.appArch=${APP_ARCH}\" \
81                                   " \
82                                   -o "${PN}" "./app"
85 src_install() {
86         insinto "/etc/${PN}"
87         dobin "${PN}"
89         systemd_dounit "${FILESDIR}/${PN}-server.service"
90         systemd_dounit "${FILESDIR}/${PN}-client.service"
91         newinitd "${FILESDIR}/${PN}-server.initd" "${PN}-server"
92         newinitd "${FILESDIR}/${PN}-client.initd" "${PN}-client"