From 8657c6a7e96df533ee7e1cf4e487af36d0cb9f7a Mon Sep 17 00:00:00 2001 From: Raboneko <119771935+raboneko@users.noreply.github.com> Date: Wed, 23 Apr 2025 06:56:47 -0700 Subject: [PATCH] add: nekoray (#4374) (#4387) * update * Update version * update singbox version * fix: add build-ids --------- Co-authored-by: u Co-authored-by: madonuko (cherry picked from commit 978c9280b511d0a76f5bc9288d679b04b8d0ff0d) Co-authored-by: bunzuhbu --- .../apps/nekoray/Sagernet.SingBox.Version.txt | 1 + anda/apps/nekoray/anda.hcl | 5 + anda/apps/nekoray/nekoray.desktop | 11 +++ anda/apps/nekoray/nekoray.sh | 2 + anda/apps/nekoray/nekoray.spec | 93 +++++++++++++++++++ anda/apps/nekoray/pre.rhai | 5 + anda/apps/nekoray/pre.sh | 9 ++ anda/apps/nekoray/update.rhai | 3 + 8 files changed, 129 insertions(+) create mode 100644 anda/apps/nekoray/Sagernet.SingBox.Version.txt create mode 100644 anda/apps/nekoray/anda.hcl create mode 100644 anda/apps/nekoray/nekoray.desktop create mode 100644 anda/apps/nekoray/nekoray.sh create mode 100644 anda/apps/nekoray/nekoray.spec create mode 100644 anda/apps/nekoray/pre.rhai create mode 100644 anda/apps/nekoray/pre.sh create mode 100644 anda/apps/nekoray/update.rhai diff --git a/anda/apps/nekoray/Sagernet.SingBox.Version.txt b/anda/apps/nekoray/Sagernet.SingBox.Version.txt new file mode 100644 index 0000000000..40faed9aa4 --- /dev/null +++ b/anda/apps/nekoray/Sagernet.SingBox.Version.txt @@ -0,0 +1 @@ +1.11.8 diff --git a/anda/apps/nekoray/anda.hcl b/anda/apps/nekoray/anda.hcl new file mode 100644 index 0000000000..b122b1135d --- /dev/null +++ b/anda/apps/nekoray/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "nekoray.spec" + } +} diff --git a/anda/apps/nekoray/nekoray.desktop b/anda/apps/nekoray/nekoray.desktop new file mode 100644 index 0000000000..5be2046d62 --- /dev/null +++ b/anda/apps/nekoray/nekoray.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Terminal=false +Type=Application +Name=nekoray +Categories=Network; +Comment=Qt based cross-platform GUI proxy configuration manager (backend: sing-box) +Comment[zh_CN]=基于 Qt 的跨平台代理配置管理器 (后端 sing-box) +Keywords=Internet;VPN;Proxy;sing-box; +Exec=/bin/nekoray +Icon=/usr/share/icons/nekoray.ico diff --git a/anda/apps/nekoray/nekoray.sh b/anda/apps/nekoray/nekoray.sh new file mode 100644 index 0000000000..6a41b65f7a --- /dev/null +++ b/anda/apps/nekoray/nekoray.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/lib64/nekoray/nekoray -appdata "${@}" diff --git a/anda/apps/nekoray/nekoray.spec b/anda/apps/nekoray/nekoray.spec new file mode 100644 index 0000000000..cd92bb2e8a --- /dev/null +++ b/anda/apps/nekoray/nekoray.spec @@ -0,0 +1,93 @@ +%global gomodulesmode GO111MODULE=on +Name: nekoray +Version: 4.3.3 +Release: 0%{?autorelease} +Summary: Qt based cross-platform GUI proxy configuration manager (backend: sing-box) +URL: https://github.com/Mahdi-zarei/nekoray +License: GPLv3 + +Source0: https://github.com/Mahdi-zarei/nekoray/archive/refs/tags/%{version}.tar.gz#/nekoray-%{version}.tar.gz +Packager: bunzuhbu +Source1: vendor-%{version}.tar.gz +%define fetch_vendor %{_rpmconfigdir}/rpmuncompress -xv %{SOURCE1} + +Source2: Sagernet.SingBox.Version.txt +%define singbox_version $(cat %{SOURCE2}) + +Source3: %{name}.desktop +Source4: %{name}.sh + +BuildRequires: rpm_macro(cmake) +BuildRequires: rpm_macro(cmake_build) +BuildRequires: rpm_macro(cmake_install) +BuildRequires: cmake +BuildRequires: gcc-c++ +BuildRequires: pkgconfig(protobuf) +BuildRequires: pkgconfig(libcurl) +BuildRequires: cmake(yaml-cpp) +BuildRequires: cmake(ZXing) +BuildRequires: cmake(absl) +BuildRequires: cmake(cpr) +BuildRequires: cmake(Qt6) +BuildRequires: cmake(Qt6Svg) +BuildRequires: cmake(Qt6Linguist) +BuildRequires: cmake(Qt6Charts) +BuildRequires: patchelf +BuildRequires: sed +BuildRequires: golang +BuildRequires: rpm_macro(gobuildflags) +Requires: %{name}-core +%define core nekobox_core + +%package core +Summary: %{summary} + +%description +%{summary} + +%description core +%{summary} + +%prep +%autosetup -p1 -n %{name}-%{version} +sed -i 's~find_package(Protobuf CONFIG REQUIRED)~find_package(Protobuf REQUIRED)~' cmake/myproto.cmake +sed -i 's~add_library(qhotkey 3rdparty/QHotkey/qhotkey.cpp)~add_library(qhotkey STATIC 3rdparty/QHotkey/qhotkey.cpp)~' cmake/QHotkey.cmake +sed -i 's~ImageFormat::BGRA~ImageFormat::BGR~' 3rdparty/ZxingQtReader.hpp +pushd core/server +%{fetch_vendor} +popd + +%build +%cmake +%cmake_build +DEST=$PWD/%{__cmake_builddir}/%{core} +pushd core/server +go build %{gobuildflags} -o $DEST -trimpath -ldflags "-B 0x$(echo "%{name}-%{version}-%{release}-${SOURCE_DATE_EPOCH:-}" | sha1sum | cut -d ' ' -f1) -w -s -X 'github.com/sagernet/sing-box/constant.Version=%{singbox_version}'" -tags "with_clash_api,with_gvisor,with_quic,with_wireguard,with_utls,with_ech,with_dhcp" +popd + +%install +mkdir -p %{buildroot}%{_libdir}/%{name} +mkdir -p %{buildroot}%{_bindir} +mkdir -p %{buildroot}%{_datadir}/applications +mkdir -p %{buildroot}%{_datadir}/icons + +cp %{SOURCE4} %{buildroot}%{_bindir}/%{name} +cp %{SOURCE3} %{buildroot}%{_datadir}/applications/%{name}.desktop +sed -i 's~/bin~%{_bindir}~g;s~/usr/share~%{_datadir}~g;s~nekoray~%{name}~g' %{buildroot}%{_datadir}/applications/%{name}.desktop +sed -i 's~/bin~%{_bindir}~g;s~/lib64~%{_libdir}~g;s~nekoray~%{name}~g' %{buildroot}%{_bindir}/%{name} +cp %{__cmake_builddir}/%{name} %{buildroot}%{_libdir}/%{name}/%{name} +cp %{__cmake_builddir}/%{core} %{buildroot}%{_libdir}/%{name}/%{core} +cp res/nekoray.ico %{buildroot}%{_datadir}/icons/%{name}.ico +patchelf --remove-rpath %{buildroot}%{_libdir}/%{name}/%{name} +patchelf --remove-rpath %{buildroot}%{_libdir}/%{name}/%{core} + +%files +%attr(0755, -, -) %{_bindir}/%{name} +%attr(0755, -, -) %{_libdir}/%{name}/%{name} +%attr(0644, -, -) %{_datadir}/icons/%{name}.ico +%attr(0644, -, -) %{_datadir}/applications/%{name}.desktop + +%files core +%dir %{_libdir}/%{name} +%attr(0755, -, -) %{_libdir}/%{name}/%{core} + diff --git a/anda/apps/nekoray/pre.rhai b/anda/apps/nekoray/pre.rhai new file mode 100644 index 0000000000..8ad379de32 --- /dev/null +++ b/anda/apps/nekoray/pre.rhai @@ -0,0 +1,5 @@ +let sourcedir = "anda/apps/nekoray"; + +sh(`dnf in -y golang rpmdevtools tar rpm-build coreutils`, #{}); +sh(`pushd ${sourcedir}; bash -x pre.sh; popd`, #{}); + diff --git a/anda/apps/nekoray/pre.sh b/anda/apps/nekoray/pre.sh new file mode 100644 index 0000000000..4c07e522b2 --- /dev/null +++ b/anda/apps/nekoray/pre.sh @@ -0,0 +1,9 @@ +export sourcedir="$PWD" +rpmdev-spectool --all --get-files nekoray.spec +version=$(rpmspec --query --queryformat "%{VERSION}\n" nekoray.spec | uniq) + +tar -xzf "nekoray-${version}.tar.gz" +pushd "nekoray-${version}/core/server" + go mod vendor + tar -czf "${sourcedir}/vendor-${version}.tar.gz" vendor +popd diff --git a/anda/apps/nekoray/update.rhai b/anda/apps/nekoray/update.rhai new file mode 100644 index 0000000000..a34cc96916 --- /dev/null +++ b/anda/apps/nekoray/update.rhai @@ -0,0 +1,3 @@ +rpm.version(find(`([\d.]+)-\d+-\d+-\d+`, gh_rawfile("Mahdi-zarei/nekoray", "dev", "nekoray_version.txt"), 1)); + +open_file("anda/apps/nekoray/Sagernet.SingBox.Version.txt", "w").write(gh('sagernet/sing-box'));