dev-util/android-studio: add 3.1.19
[gentoo-zh.git] / net-proxy / hysteria / hysteria-2.2.2.ebuild
blob05f285cccc0c81b73fb1901963f53bc2e78d6349
1 # Copyright 1999-2023 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/oatiz/gentoo-go-deps/releases/download/${P}/${P}-deps.tar.xz
15 RESTRICT="mirror"
17 LICENSE="MIT"
18 SLOT="0"
19 KEYWORDS="~amd64"
21 GO_CPU_FLAGS_X86="
22 cpu_flags_x86_avx2
23 cpu_flags_x86_fma4
24 cpu_flags_x86_fma3
25 cpu_flags_x86_f16c
26 cpu_flags_x86_avx
27 cpu_flags_x86_sse4_2
28 cpu_flags_x86_sse4_1
29 cpu_flags_x86_ssse3
30 cpu_flags_x86_sse3
33 IUSE="+goamd64 ${GO_CPU_FLAGS_X86[@]}"
35 DEPEND="
36 acct-user/hysteria
37 acct-group/hysteria
38 >=dev-lang/go-1.21.1
40 RDEPEND="${DEPEND}"
42 S="${WORKDIR}/${PN}-app-v${PV}"
44 ego() {
45 set -- go "$@"
46 echo "$@" >&2
47 "$@" || die -n "${*} failed"
50 pkg_setup() {
51 if use goamd64; then
52 GOAMD64_V="v1"
53 if use cpu_flags_x86_sse3 && use cpu_flags_x86_sse4_1 && use cpu_flags_x86_sse4_2 && use cpu_flags_x86_ssse3
54 then
55 GOAMD64_V="v2"
56 if use cpu_flags_x86_avx && use cpu_flags_x86_avx2 && use cpu_flags_x86_f16c && \
57 (use cpu_flags_x86_fma4 || use cpu_flags_x86_fma3)
58 then
59 GOAMD64_V="v3"
62 export GOAMD64="${GOAMD64_V}"
63 einfo "building with GOAMD64=${GOAMD64_V}"
67 src_compile() {
68 local APP_SRC_CMD_PKG="github.com/apernet/hysteria/app/cmd"
69 local APP_DATE
70 APP_DATE=$(LC_ALL=C date -u +'%Y-%m-%dT%H:%M:%SZ' || die)
71 local APP_ARCH="Unknown"
72 if use goamd64; then
73 APP_ARCH="amd64-${GOAMD64}"
76 CGO_ENABLED=1 ego build \
77 -trimpath \
78 -ldflags "-s -w -extldflags \"${LDFLAGS}\" \
79 -X \"${APP_SRC_CMD_PKG}.appVersion=${PV}\" \
80 -X \"${APP_SRC_CMD_PKG}.appDate=${APP_DATE}\" \
81 -X \"${APP_SRC_CMD_PKG}.appType=release\" \
82 -X \"${APP_SRC_CMD_PKG}.appPlatform=linux\" \
83 -X \"${APP_SRC_CMD_PKG}.appArch=${APP_ARCH}\" \
84 " \
85 -o "${PN}" "./app"
88 src_install() {
89 insinto "/etc/${PN}"
90 dobin "${PN}"
92 systemd_dounit "${FILESDIR}/${PN}-server.service"
93 systemd_dounit "${FILESDIR}/${PN}-client.service"
94 newinitd "${FILESDIR}/${PN}-server.initd" "${PN}-server"
95 newinitd "${FILESDIR}/${PN}-client.initd" "${PN}-client"