# Copyright 2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # Autogenerated by pycargoebuild 0.15.1 EAPI=8 CRATES=" " declare -A GIT_CRATES=( [clash_verge_service_ipc]='https://github.com/clash-verge-rev/clash-verge-service-ipc;b2a7427d6681c8d3780ab83a73f4dc21da2f22d6;clash-verge-service-ipc-%commit%' [muda]='https://github.com/wonfen/muda;547de49352791653fbdfa785f20f3c7ece8468e2;muda-%commit%' [sysproxy]='https://github.com/clash-verge-rev/sysproxy-rs;89ad876a0942c049ae72e1472f9fc3ed62023c5e;sysproxy-rs-%commit%' [tauri-plugin-mihomo]='https://github.com/clash-verge-rev/tauri-plugin-mihomo;7a03d16f4d39b1bb885b7babe66b9e153e34b615;tauri-plugin-mihomo-%commit%' [tracing-estuary]='https://github.com/Tunglies/tracing-estuary;dbfce033fa4cff8f936f3e7c2282af1277546f3c;tracing-estuary-%commit%' ) RUST_MIN_VER="1.99" inherit cargo desktop dot-a xdg DESCRIPTION="GUI client based on Tauri for tailored proxy experience" HOMEPAGE=" https://www.clashverge.dev https://github.com/clash-verge-rev/clash-verge-rev " # Web dist tarball generated from gentoo-zh-drafts/tauri-web-dist/blob/main/.github/workflows/generator.yml # Crates tarballs generated from gentoo-zh/gentoo-deps/blob/main/.github/workflows/generator.yml DEPS_URI="https://github.com/gentoo-zh/gentoo-deps/releases/download" WEB_URI="https://github.com/gentoo-zh-drafts/tauri-web-dist/releases/download" SRC_URI=" https://github.com/clash-verge-rev/clash-verge-rev/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz ${DEPS_URI}/${P/-rev/}/${P/-rev/}-crates.tar.xz ${WEB_URI}/${P}/${P}-web.tar.xz " # Use macthing commit from git crates SERVICE_COMMIT="b2a7427d6681c8d3780ab83a73f4dc21da2f22d6" SERVICE_P="clash-verge-service-ipc-${SERVICE_COMMIT}" # the service pins its own sysproxy checkout, on the .git URL the app's # GIT_CRATES entry cannot cover SERVICE_SYSPROXY_COMMIT="89ad876a0942c049ae72e1472f9fc3ed62023c5e" SRC_URI+=" ${DEPS_URI}/${SERVICE_P}/${SERVICE_P}-crates.tar.xz https://github.com/clash-verge-rev/sysproxy-rs/archive/${SERVICE_SYSPROXY_COMMIT}.tar.gz -> sysproxy-rs-${SERVICE_SYSPROXY_COMMIT}.tar.gz " SRC_URI+=" ${CARGO_CRATE_URIS}" LICENSE="GPL-3" # Dependent crate licenses LICENSE+=" Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 CC0-1.0 CDLA-Permissive-2.0 GPL-3 ISC MIT MPL-2.0 MPL-2.0 Unicode-3.0 WTFPL-2 ZLIB BZIP2 " SLOT="0" KEYWORDS="~amd64 ~arm64" COMMON_DEPEND=" !net-proxy/clash-verge-rev-bin dev-libs/openssl:0/3 gnome-base/librsvg:2 net-proxy/mihomo net-libs/webkit-gtk:4.1 " RDEPEND=" ${COMMON_DEPEND} dev-libs/libayatana-appindicator " BDEPEND=" ${COMMON_DEPEND} app-misc/jq dev-build/cmake dev-util/patchelf sys-apps/moreutils " PATCHES=( "${FILESDIR}"/${PN}-2.5.7-openrc-detection.patch ) src_prepare() { default pushd "${WORKDIR}/${SERVICE_P}" >/dev/null || die eapply "${FILESDIR}"/${PN}-2.5.7-openrc-installer.patch popd >/dev/null || die # FIXME: tempfile or moreutils? #jq ... "${S}/package.json" > tmp.json && mv tmp.json "${S}/package.json" || die pushd "${T}" >/dev/null || die jq '.bundle.createUpdaterArtifacts = false' "${S}/src-tauri/tauri.conf.json" \ | sponge "${S}/src-tauri/tauri.conf.json" || die popd >/dev/null || die mv -v "${WORKDIR}/dist" "${S}/" || die local sysproxy="${WORKDIR}/sysproxy-rs-${SERVICE_SYSPROXY_COMMIT}" sed -i "s|^sysproxy = { git = .*|sysproxy = { path = \"${sysproxy}\", default-features = false }|" \ "${WORKDIR}/${SERVICE_P}/Cargo.toml" || die # replace upstream's muda crate substitution with ours; the tray-icon # substitution is unused and would make cargo fetch its git source local dep dep=$(grep "^muda" "${ECARGO_HOME}"/config.toml || die) sed -i -e "/\[patch\.crates-io\]/,\$s;^muda.*$;${dep};" \ -e "/\[patch\.crates-io\]/,\${/^tray-icon/d}" Cargo.toml || die } src_compile() { #aws-lc-sys-0.38.0/aws-lc/third_party/jitterentropy/jitterentropy-library/src/jitterentropy-base.c: #The CPU Jitter random number generator must not be compiled with optimizations. #Force use of cmake to auto apply -O0 to related parts export AWS_LC_SYS_CMAKE_BUILDER=1 lto-guarantee-fat # clash-verge-service-ipc pushd "${WORKDIR}/${SERVICE_P}" >/dev/null || die cargo_src_compile --features standalone,client popd >/dev/null || die # FIXME: Can't use $(rust_abi) here, build scripts check for -gnu nonetheless # FIXME: Maybe musl is supported, just name it -gnu and call it a day # NOTE: This list is from https://github.com/clash-verge-rev/clash-verge-rev/blob/dev/scripts/prebuild.mjs einfo "CHOST: ${CHOST}" einfo "CARCH: ${ARCH}" # Taken from gentoo/eclass/rust-toolchain.eclass my_rust_abi() { local CTARGET=${1:-${CHOST}} case ${CTARGET%%*-} in aarch64*gnu) echo aarch64-unknown-linux-gnu;; aarch64*musl) echo aarch64-unknown-linux-gnu;; # -musl changed to -gnu armv7a*h*) echo armv7-unknown-linux-gnueabihf;; i?86*) echo i686-unknown-linux-gnu;; loongarch64*) echo loongarch64-unknown-linux-gnu;; riscv64*gnu) echo riscv64gc-unknown-linux-gnu;; riscv64*musl) echo riscv64gc-unknown-linux-gnu;; # -musl changed to -gnu x86_64*gnu) echo x86_64-unknown-linux-gnu;; x86_64*musl) echo x86_64-unknown-linux-gnu;; # -musl changed to -gnu *) die "Unsupported";; esac } mkdir "${S}"/src-tauri/sidecar || die mkdir "${S}"/src-tauri/resources || die CVR_SERVICE_TARGET="${WORKDIR}/${SERVICE_P}/$(cargo_target_dir)/clash-verge-service" cp -v "${CVR_SERVICE_TARGET}" "${S}/src-tauri/sidecar/clash-verge-service-$(my_rust_abi)" || die cp -v "${CVR_SERVICE_TARGET}"-install "${S}/src-tauri/sidecar/clash-verge-service-install-$(my_rust_abi)" || die cp -v "${CVR_SERVICE_TARGET}"-uninstall "${S}/src-tauri/sidecar/clash-verge-service-uninstall-$(my_rust_abi)" || die # Pretend we have those prebuilt mihomo binaries touch "${S}"/src-tauri/sidecar/verge-mihomo{,-alpha}-"$(my_rust_abi)" || die cd "${S}" || die cargo_src_compile } src_install() { dobin "$(cargo_target_dir)/clash-verge" dobin "$(cargo_target_dir)/clash-verge-service" dobin "$(cargo_target_dir)/clash-verge-service-install" dobin "$(cargo_target_dir)/clash-verge-service-uninstall" for size in 32 128 256; do if [[ "${size}" == 256 ]]; then newicon -s 256 "${S}/src-tauri/icons/128x128@2x.png" clash-verge.png else newicon -s "${size}" "${S}/src-tauri/icons/${size}x${size}.png" clash-verge.png fi done cat <<-EOF > "${S}/clash_verge.desktop" || die [Desktop Entry] Categories=Development; Comment=Clash Verge Rev Exec=clash-verge %u StartupWMClass=clash-verge Icon=clash-verge Name=Clash Verge Terminal=false Type=Application MimeType=x-scheme-handler/clash; EOF domenu "${S}/clash_verge.desktop" dosym -r /usr/bin/mihomo /usr/bin/verge-mihomo dosym -r /usr/bin/mihomo /usr/bin/verge-mihomo-alpha }