@@ -10,7 +10,7 @@ if [[ -r /etc/os-release ]]; then
1010 ;;
1111 * )
1212 echo " [ERROR] Unsupported system: $NAME ($ID )."
13- echo " This script only supports Red Hat Enterprise Linux/RockyLinux/AlmaLinux/CentOS or Ubuntu/Debian ."
13+ echo " This script only supports Red Hat Enterprise Linux/RockyLinux/AlmaLinux/CentOS."
1414 exit 1
1515 ;;
1616 esac
@@ -483,20 +483,11 @@ build_for_arch() {
483483 trap ' [[ -n "${WORKDIR:-}" ]] && rm -rf "$WORKDIR"' RETURN
484484
485485 # rpmbuild topdir selection
486- local TOPDIR SPECDIR SOURCEDIR USE_TOPDIR_DEFINE
487- if [[ " $ID " =~ ^(rhel| rocky| almalinux| centos)$ ]]; then
488- rpmdev-setuptree
489- TOPDIR=" ${HOME} /rpmbuild"
490- SPECDIR=" ${TOPDIR} /SPECS"
491- SOURCEDIR=" ${TOPDIR} /SOURCES"
492- USE_TOPDIR_DEFINE=0
493- else
494- TOPDIR=" ${WORKDIR} /rpmbuild"
495- SPECDIR=" ${TOPDIR} /SPECS}"
496- SOURCEDIR=" ${TOPDIR} /SOURCES"
497- mkdir -p " ${SPECDIR} " " ${SOURCEDIR} " " ${TOPDIR} /BUILD" " ${TOPDIR} /RPMS" " ${TOPDIR} /SRPMS"
498- USE_TOPDIR_DEFINE=1
499- fi
486+ local TOPDIR SPECDIR SOURCEDIR
487+ rpmdev-setuptree
488+ TOPDIR=" ${HOME} /rpmbuild"
489+ SPECDIR=" ${TOPDIR} /SPECS"
490+ SOURCEDIR=" ${TOPDIR} /SOURCES"
500491
501492 # Stage publish content
502493 mkdir -p " $WORKDIR /$PKGROOT "
@@ -533,8 +524,6 @@ build_for_arch() {
533524 download_singbox " $WORKDIR /$PKGROOT /bin/sing_box" || echo " [!] sing-box download failed (skipped)"
534525 fi
535526 download_geo_assets " $WORKDIR /$PKGROOT " || echo " [!] Geo rules download failed (skipped)"
536- # ---- REQUIRED: always fetch mihomo in netcore mode, per-arch ----
537- # download_mihomo "$WORKDIR/$PKGROOT" || echo "[!] mihomo download failed (skipped)"
538527 fi
539528
540529 # Tarball
@@ -588,6 +577,12 @@ https://github.com/2dust/v2rayN
588577install -dm0755 %{buildroot}/opt/v2rayN
589578cp -a * %{buildroot}/opt/v2rayN/
590579
580+ install -dm0755 %{buildroot}%{_sysconfdir}/sudoers.d
581+ cat > %{buildroot}%{_sysconfdir}/sudoers.d/v2rayn-mihomo-deny << 'EOF'
582+ ALL ALL=(ALL) !/home/*/.local/share/v2rayN/bin/mihomo/mihomo
583+ EOF
584+ chmod 0440 %{buildroot}%{_sysconfdir}/sudoers.d/v2rayn-mihomo-deny
585+
591586# Launcher (prefer native ELF first, then DLL fallback)
592587install -dm0755 %{buildroot}%{_bindir}
593588cat > %{buildroot}%{_bindir}/v2rayn << 'EOF'
641636/opt/v2rayN
642637%{_datadir}/applications/v2rayn.desktop
643638%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
639+ %config(noreplace) /etc/sudoers.d/v2rayn-mihomo-deny
644640SPEC
645641
646642 # Autostart injection (inside %install) and %files entry
@@ -680,35 +676,8 @@ SPEC
680676 sed -i " s/__VERSION__/${VERSION} /g" " $SPECFILE "
681677 sed -i " s/__PKGROOT__/${PKGROOT} /g" " $SPECFILE "
682678
683- # ----- Select proper 'strip' per target arch on Ubuntu only (cross-binutils) -----
684- # NOTE: We define only __strip to point to the target-arch strip.
685- # DO NOT override __brp_strip (it must stay the brp script path).
686- local STRIP_ARGS=()
687- if [[ " $ID " == " ubuntu" ]]; then
688- local STRIP_BIN=" "
689- if [[ " $short " == " x64" ]]; then
690- STRIP_BIN=" /usr/bin/x86_64-linux-gnu-strip"
691- else
692- STRIP_BIN=" /usr/bin/aarch64-linux-gnu-strip"
693- fi
694- if [[ -x " $STRIP_BIN " ]]; then
695- STRIP_ARGS=( --define " __strip $STRIP_BIN " )
696- fi
697- fi
698-
699679 # Build RPM for this arch (force rpm --target to match compile arch)
700- if [[ " $USE_TOPDIR_DEFINE " -eq 1 ]]; then
701- rpmbuild -ba " $SPECFILE " --define " _topdir $TOPDIR " --target " $rpm_target " " ${STRIP_ARGS[@]} "
702- else
703- rpmbuild -ba " $SPECFILE " --target " $rpm_target " " ${STRIP_ARGS[@]} "
704- fi
705-
706- # Copy temporary rpmbuild to ~/rpmbuild on Debian/Ubuntu path
707- if [[ " $USE_TOPDIR_DEFINE " -eq 1 ]]; then
708- mkdir -p " $HOME /rpmbuild"
709- rsync -a " $TOPDIR " / " $HOME /rpmbuild" /
710- TOPDIR=" $HOME /rpmbuild"
711- fi
680+ rpmbuild -ba " $SPECFILE " --target " $rpm_target "
712681
713682 echo " Build done for $short . RPM at:"
714683 local f
0 commit comments