net-im/wemeet: fix media-libs/tiff depend
[gentoo-zh.git] / net-proxy / v2rayA / v2rayA-2.0.1-r1.ebuild
blob7e3a03c6fc4583513c1eff75eab0a524286b1feb
1 # Copyright 2022 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
6 inherit systemd go-module desktop xdg
8 DESCRIPTION="web GUI of Project V which supports V2Ray, Xray, SS, SSR, Trojan and Pingtunnel"
9 HOMEPAGE="https://v2raya.org/"
11 SRC_URI="
12 https://github.com/v2rayA/v2rayA/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
14 # maintainer generated vendor
15 # generated with https://github.com/liuyujielol/rei-overlay/blob/main/net-proxy/v2rayA/scripts/v2rayA_vendor_gen.sh
16 SRC_URI+="
17 https://github.com/liuyujielol/vendors/releases/download/${PN}/${P}-yarn_mirror.tar.xz
18 https://github.com/liuyujielol/vendors/releases/download/${PN}/${P}-go-vendor.tar.xz
21 LICENSE="AGPL-3"
22 SLOT="0"
23 KEYWORDS="~amd64"
24 IUSE=""
25 RESTRICT="mirror"
27 DEPEND=""
28 RDEPEND="
29 ${DEPEND}
30 || (
31 >=net-proxy/v2ray-5
32 >=net-proxy/v2ray-bin-5
35 BDEPEND="
36 >=dev-lang/go-1.19:*
37 >=net-libs/nodejs-16
38 sys-apps/yarn
41 src_unpack() {
42 default
44 # go vendor
45 mv -v "${WORKDIR}/vendor" "${S}/service" || die
47 cd "${S}/gui" || die
48 # set yarn-offline-mirror to ${WORKDIR}/yarn_offline_mirror
49 echo "yarn-offline-mirror \"${WORKDIR}/yarn_offline_mirror\"" >> "${S}/gui/.yarnrc" || die
50 addpredict /usr/local
51 yarn install --offline --check-files || die "yarn offline install failed"
54 src_compile() {
55 cd "${S}/gui" || die
56 ## Fix node build error: https://github.com/webpack/webpack/issues/14532#issuecomment-947012063
57 if has_version '>=dev-libs/openssl-3'; then
58 export NODE_OPTIONS=--openssl-legacy-provider
60 OUTPUT_DIR="${S}/service/server/router/web" yarn build || die "yarn build failed"
62 for file in $(find "${S}/service/server/router/web" |grep -v png |grep -v index.html|grep -v .gz)
64 if [ ! -d $file ]; then
65 gzip -9 $file
67 done
69 cd "${S}/service" || die
70 ego build -mod vendor -ldflags "-X github.com/v2rayA/v2rayA/conf.Version=${PV} -s -w" -o v2raya
73 src_install() {
74 dobin "${S}"/service/v2raya
75 # directory for runtime use
76 keepdir "/etc/v2raya"
78 # generate default config
79 cat <<-EOF > "${S}"/v2raya || die
80 # v2raya config example
81 # Everything has defaults so you only need to uncomment things you want to
82 # change
83 EOF
84 ./service/v2raya --report config | sed '1,6d' | fold -s -w 78 | sed -E 's/^([^#].+)/# \1/'\
85 >> "${S}"/v2raya || die
87 # config /etc/default/v2raya
88 insinto "/etc/default"
89 doins "${S}"/v2raya
91 systemd_dounit "${S}"/install/universal/v2raya.service
92 systemd_douserunit "${S}"/install/universal/v2raya-lite.service
94 #thanks to @Universebenzene
95 newinitd "${FILESDIR}/${PN}.initd" v2raya
96 newinitd "${FILESDIR}/${PN}-user.initd" v2raya-user
97 newconfd "${FILESDIR}/${PN}.confd" v2raya
98 newconfd "${FILESDIR}/${PN}-user.confd" v2raya-user
100 newicon -s 512 "${S}"/gui/public/img/icons/android-chrome-512x512.png v2raya.png
101 domenu "${S}"/install/universal/v2raya.desktop
104 pkg_postinst() {
105 xdg_pkg_postinst
107 if has_version '<net-proxy/v2rayA-2.0.0' ; then
108 elog "Starting from net-proxy/v2rayA-2.0.0"
109 elog "Support for v2ray-4 & xray has been dropped"
110 elog "A config migration may be required"