mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-08 13:35:01 +03:00
Update package-rhel.sh (#10537)
* Update package-rhel.sh * Update README.md * Update package-debian.sh * Delete package-rhel-loong.sh * Delete package-rhel-riscv.sh * Delete package-debian-loong.sh * Delete package-debian-riscv.sh * Create package-debian-x86.sh * Create package-rhel-x86.sh * Update build-linux.yml * Update build-linux.yml * Update Directory.Packages.props * Update build-linux.yml * Update package-debian-x86.sh * Update package-rhel-x86.sh * Update package-debian-x86.sh * Update package-debian.sh * Update build-linux.yml * Update package-rhel.sh * Update package-debian.sh * Update package-debian-x86.sh * Update DOTNET_SDK_VERSION in package-rhel-x86.sh --------- Co-authored-by: autorepobot <repo-bot@outlook.com>
This commit is contained in:
+100
-174
@@ -46,7 +46,7 @@ jobs:
|
|||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
deb:
|
deb:
|
||||||
name: build and release deb x64 & arm64
|
name: build and release deb x64 & arm64 & riscv64 & ppc64le & loong64
|
||||||
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||||
runs-on: ubuntu-26.04
|
runs-on: ubuntu-26.04
|
||||||
container: debian:13
|
container: debian:13
|
||||||
@@ -70,8 +70,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p "$GITHUB_WORKSPACE/dist/deb"
|
mkdir -p "$GITHUB_WORKSPACE/dist/deb"
|
||||||
rsync -av "$HOME/debbuild/" "$GITHUB_WORKSPACE/dist/deb/" || true
|
rsync -av "$HOME/debbuild/" "$GITHUB_WORKSPACE/dist/deb/" || true
|
||||||
|
|
||||||
find "$GITHUB_WORKSPACE/dist/deb" -name "v2rayn_*_amd64.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb/v2rayN-linux-64.deb" \; || true
|
find "$GITHUB_WORKSPACE/dist/deb" -name "v2rayn_*_amd64.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb/v2rayN-linux-64.deb" \; || true
|
||||||
find "$GITHUB_WORKSPACE/dist/deb" -name "v2rayn_*_arm64.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb/v2rayN-linux-arm64.deb" \; || true
|
find "$GITHUB_WORKSPACE/dist/deb" -name "v2rayn_*_arm64.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb/v2rayN-linux-arm64.deb" \; || true
|
||||||
|
find "$GITHUB_WORKSPACE/dist/deb" -name "v2rayn_*_riscv64.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb/v2rayN-linux-riscv64.deb" \; || true
|
||||||
|
find "$GITHUB_WORKSPACE/dist/deb" -name "v2rayn_*_ppc64el.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb/v2rayN-linux-ppc64le.deb" \; || true
|
||||||
|
find "$GITHUB_WORKSPACE/dist/deb" -name "v2rayn_*_loong64.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb/v2rayN-linux-loong64.deb" \; || true
|
||||||
|
|
||||||
echo "==== Dist tree ===="
|
echo "==== Dist tree ===="
|
||||||
ls -R "$GITHUB_WORKSPACE/dist/deb" || true
|
ls -R "$GITHUB_WORKSPACE/dist/deb" || true
|
||||||
- name: Upload DEB artifact
|
- name: Upload DEB artifact
|
||||||
@@ -79,7 +84,7 @@ jobs:
|
|||||||
with: { name: release-deb, path: "dist/deb/**/*.deb", if-no-files-found: error }
|
with: { name: release-deb, path: "dist/deb/**/*.deb", if-no-files-found: error }
|
||||||
|
|
||||||
rpm:
|
rpm:
|
||||||
name: build and release rpm x64 & arm64
|
name: build and release rpm x64 & arm64 & riscv64 & ppc64le & loong64
|
||||||
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||||
runs-on: ubuntu-26.04
|
runs-on: ubuntu-26.04
|
||||||
container: registry.access.redhat.com/ubi10/ubi
|
container: registry.access.redhat.com/ubi10/ubi
|
||||||
@@ -129,58 +134,23 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p "$GITHUB_WORKSPACE/dist/rpm"
|
mkdir -p "$GITHUB_WORKSPACE/dist/rpm"
|
||||||
rsync -av "$HOME/rpmbuild/RPMS/" "$GITHUB_WORKSPACE/dist/rpm/" || true
|
rsync -av "$HOME/rpmbuild/RPMS/" "$GITHUB_WORKSPACE/dist/rpm/" || true
|
||||||
find "$GITHUB_WORKSPACE/dist/rpm" -name "v2rayN-*-1*.x86_64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm/v2rayN-linux-rhel-64.rpm" \; || true
|
|
||||||
|
find "$GITHUB_WORKSPACE/dist/rpm" -name "v2rayN-*-1*.x86_64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm/v2rayN-linux-rhel-64.rpm" \; || true
|
||||||
find "$GITHUB_WORKSPACE/dist/rpm" -name "v2rayN-*-1*.aarch64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm/v2rayN-linux-rhel-arm64.rpm" \; || true
|
find "$GITHUB_WORKSPACE/dist/rpm" -name "v2rayN-*-1*.aarch64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm/v2rayN-linux-rhel-arm64.rpm" \; || true
|
||||||
|
find "$GITHUB_WORKSPACE/dist/rpm" -name "v2rayN-*-1*.riscv64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm/v2rayN-linux-rhel-riscv64.rpm" \; || true
|
||||||
|
find "$GITHUB_WORKSPACE/dist/rpm" -name "v2rayN-*-1*.ppc64le.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm/v2rayN-linux-rhel-ppc64le.rpm" \; || true
|
||||||
|
find "$GITHUB_WORKSPACE/dist/rpm" -name "v2rayN-*-1*.loongarch64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm/v2rayN-linux-rhel-loong64.rpm" \; || true
|
||||||
|
|
||||||
echo "==== Dist tree ===="
|
echo "==== Dist tree ===="
|
||||||
ls -R "$GITHUB_WORKSPACE/dist/rpm" || true
|
ls -R "$GITHUB_WORKSPACE/dist/rpm" || true
|
||||||
- name: Upload RPM artifact
|
- name: Upload RPM artifact
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with: { name: release-rpm, path: "dist/rpm/**/*.rpm", if-no-files-found: error }
|
with: { name: release-rpm, path: "dist/rpm/**/*.rpm", if-no-files-found: error }
|
||||||
|
|
||||||
rpm-riscv64:
|
deb-x86:
|
||||||
name: build and release rpm riscv64
|
name: build and release deb x86
|
||||||
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||||
runs-on: ubuntu-24.04-riscv
|
runs-on: ubuntu-26.04
|
||||||
container: rockylinux/rockylinux:10
|
|
||||||
env: { RELEASE_TAG: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}" }
|
|
||||||
steps:
|
|
||||||
- name: Prepare tools (Red Hat)
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
dnf -y makecache
|
|
||||||
dnf -y install sudo git rpm-build rpmdevtools dnf-plugins-core rsync findutils tar gzip unzip which jq
|
|
||||||
- name: Checkout repo (for scripts)
|
|
||||||
shell: bash
|
|
||||||
env: { GITHUB_TOKEN: "${{ github.token }}" }
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
rm -rf ./*
|
|
||||||
git init .
|
|
||||||
git config --global --add safe.directory "$PWD"
|
|
||||||
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
|
||||||
git fetch --depth=1 origin "${GITHUB_SHA}"
|
|
||||||
git checkout FETCH_HEAD
|
|
||||||
git submodule update --init --recursive
|
|
||||||
- name: Ensure script permissions
|
|
||||||
run: chmod 755 package-rhel-riscv.sh
|
|
||||||
- name: Package RPM (RHEL-family)
|
|
||||||
run: ./package-rhel-riscv.sh "${RELEASE_TAG}"
|
|
||||||
- name: Collect RPMs into workspace
|
|
||||||
run: |
|
|
||||||
mkdir -p "$GITHUB_WORKSPACE/dist/rpm-riscv64"
|
|
||||||
rsync -av "$HOME/rpmbuild/RPMS/" "$GITHUB_WORKSPACE/dist/rpm-riscv64/" || true
|
|
||||||
find "$GITHUB_WORKSPACE/dist/rpm-riscv64" -name "*.riscv64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm-riscv64/v2rayN-linux-rhel-riscv64.rpm" \; || true
|
|
||||||
echo "==== Dist tree ===="
|
|
||||||
ls -R "$GITHUB_WORKSPACE/dist/rpm-riscv64" || true
|
|
||||||
- name: Upload RPM artifact
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with: { name: release-rpm-riscv64, path: "dist/rpm-riscv64/**/*.rpm", if-no-files-found: error }
|
|
||||||
|
|
||||||
deb-riscv64:
|
|
||||||
name: build and release deb riscv64
|
|
||||||
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
|
||||||
runs-on: ubuntu-24.04-riscv
|
|
||||||
container: debian:13
|
container: debian:13
|
||||||
env: { RELEASE_TAG: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}" }
|
env: { RELEASE_TAG: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}" }
|
||||||
steps:
|
steps:
|
||||||
@@ -190,162 +160,118 @@ jobs:
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y sudo git rsync findutils tar gzip unzip which curl jq wget file ca-certificates desktop-file-utils xdg-utils fakeroot dpkg-dev gcc make libc6-dev libgcc-s1 libstdc++6 zlib1g libatomic1
|
apt-get install -y sudo git rsync findutils tar gzip unzip which curl jq wget file ca-certificates desktop-file-utils xdg-utils fakeroot dpkg-dev libc6 libgcc-s1 libstdc++6 zlib1g libicu-dev libssl-dev
|
||||||
- name: Checkout repo (for scripts)
|
- name: Checkout repo (for scripts)
|
||||||
shell: bash
|
uses: actions/checkout@v7
|
||||||
env: { GITHUB_TOKEN: "${{ github.token }}" }
|
with: { submodules: 'recursive', fetch-depth: '0' }
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
rm -rf ./*
|
|
||||||
git init .
|
|
||||||
git config --global --add safe.directory "$PWD"
|
|
||||||
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
|
||||||
git fetch --depth=1 origin "${GITHUB_SHA}"
|
|
||||||
git checkout FETCH_HEAD
|
|
||||||
git submodule update --init --recursive
|
|
||||||
- name: Ensure script permissions
|
- name: Ensure script permissions
|
||||||
run: chmod 755 package-debian-riscv.sh
|
run: chmod 755 package-debian-x86.sh
|
||||||
- name: Package DEB (Debian-family)
|
- name: Package DEB x86 (Debian-family)
|
||||||
run: ./package-debian-riscv.sh "${RELEASE_TAG}"
|
run: ./package-debian-x86.sh "${RELEASE_TAG}"
|
||||||
- name: Collect DEBs into workspace
|
- name: Collect x86 DEB into workspace
|
||||||
run: |
|
run: |
|
||||||
mkdir -p "$GITHUB_WORKSPACE/dist/deb-riscv64"
|
mkdir -p "$GITHUB_WORKSPACE/dist/deb-x86"
|
||||||
rsync -av "$HOME/debbuild/" "$GITHUB_WORKSPACE/dist/deb-riscv64/" || true
|
rsync -av "$HOME/debbuild/" "$GITHUB_WORKSPACE/dist/deb-x86/" || true
|
||||||
find "$GITHUB_WORKSPACE/dist/deb-riscv64" -name "*.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb-riscv64/v2rayN-linux-riscv64.deb" \; || true
|
|
||||||
echo "==== Dist tree ===="
|
|
||||||
ls -R "$GITHUB_WORKSPACE/dist/deb-riscv64" || true
|
|
||||||
- name: Upload DEB artifact
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with: { name: release-deb-riscv64, path: "dist/deb-riscv64/**/*.deb", if-no-files-found: error }
|
|
||||||
|
|
||||||
deb-loong64:
|
find "$GITHUB_WORKSPACE/dist/deb-x86" -name "v2rayn_*_i386.deb" \
|
||||||
name: build and release deb loong64
|
-exec mv {} "$GITHUB_WORKSPACE/dist/deb-x86/v2rayN-linux-86.deb" \; || true
|
||||||
|
|
||||||
|
echo "==== Dist tree ===="
|
||||||
|
ls -R "$GITHUB_WORKSPACE/dist/deb-x86" || true
|
||||||
|
- name: Upload x86 DEB artifact
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with: { name: release-deb-x86, path: "dist/deb-x86/**/*.deb", if-no-files-found: error }
|
||||||
|
|
||||||
|
rpm-x86:
|
||||||
|
name: build and release rpm x86
|
||||||
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||||
runs-on: ubuntu-26.04
|
runs-on: ubuntu-26.04
|
||||||
env:
|
container: registry.access.redhat.com/ubi10/ubi
|
||||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
env: { RELEASE_TAG: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}" }
|
||||||
DOCKER_IMAGE: ghcr.io/loong64/debian:trixie
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Prepare tools (Red Hat)
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Setup QEMU
|
|
||||||
uses: docker/setup-qemu-action@v4
|
|
||||||
- name: Package DEB (Debian-family)
|
|
||||||
shell: bash
|
shell: bash
|
||||||
timeout-minutes: 180
|
|
||||||
env: { RELEASE_TAG: "${{ env.RELEASE_TAG }}" }
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
docker run --rm \
|
. /etc/os-release
|
||||||
--privileged \
|
EL_MAJOR="${VERSION_ID%%.*}"
|
||||||
--platform linux/loong64 \
|
echo "EL_MAJOR=${EL_MAJOR}"
|
||||||
--env DEBIAN_FRONTEND=noninteractive \
|
dnf -y makecache || true
|
||||||
--env DOTNET_EnableWriteXorExecute=0 \
|
command -v curl >/dev/null || dnf -y install curl ca-certificates
|
||||||
--volume "${{ github.workspace }}:/root/v2rayN-src" \
|
ARCH="$(uname -m)"
|
||||||
--volume "$HOME/debbuild:/root/debbuild" \
|
case "$ARCH" in x86_64|aarch64) ;; *) echo "Unsupported arch: $ARCH"; exit 1 ;; esac
|
||||||
--workdir /root/v2rayN-src \
|
|
||||||
"$DOCKER_IMAGE" bash -c "
|
|
||||||
apt-get update && \
|
|
||||||
apt-get install -y sudo git rsync findutils tar gzip unzip which curl jq wget file ca-certificates desktop-file-utils xdg-utils fakeroot dpkg-dev gcc make libc6-dev libgcc-s1 libstdc++6 zlib1g libatomic1 && \
|
|
||||||
git config --global --add safe.directory /root/v2rayN-src && \
|
|
||||||
./package-debian-loong.sh ${RELEASE_TAG}"
|
|
||||||
- name: Collect DEBs into workspace
|
|
||||||
run: |
|
|
||||||
mkdir -p "$GITHUB_WORKSPACE/dist/deb-loong64"
|
|
||||||
rsync -av "$HOME/debbuild/" "$GITHUB_WORKSPACE/dist/deb-loong64/" || true
|
|
||||||
find "$GITHUB_WORKSPACE/dist/deb-loong64" -name "*.deb" -exec mv {} "$GITHUB_WORKSPACE/dist/deb-loong64/v2rayN-linux-loong64.deb" \; || true
|
|
||||||
echo "==== Dist tree ===="
|
|
||||||
ls -R "$GITHUB_WORKSPACE/dist/deb-loong64" || true
|
|
||||||
- name: Upload DEB artifact
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with: { name: release-deb-loong64, path: "dist/deb-loong64/**/*.deb", if-no-files-found: error }
|
|
||||||
|
|
||||||
rpm-loong64:
|
install_epel_from_dir() {
|
||||||
name: build and release rpm loong64
|
local base="$1" rpm
|
||||||
if: (github.event_name == 'workflow_dispatch' && inputs.release_tag != '') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
echo "Try: $base"
|
||||||
runs-on: ubuntu-26.04
|
rpm="$({ curl -fsSL "$base/Packages/" 2>/dev/null; curl -fsSL "$base/Packages/e/" 2>/dev/null | sed 's|href="|href="e/|'; } |
|
||||||
env:
|
sed -n 's/.*href="\([^"]*epel-release-[^"]*\.noarch\.rpm\)".*/\1/p' | sort -V | tail -n1)" || true
|
||||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
[[ -n "$rpm" ]] || return 1
|
||||||
DOCKER_IMAGE: ghcr.io/fedora-remix-loongarch/mini-image:f43
|
dnf -y install "$base/Packages/$rpm"
|
||||||
steps:
|
}
|
||||||
- name: Checkout repo
|
|
||||||
|
FEDORA="https://dl.fedoraproject.org/pub/epel/epel-release-latest-${EL_MAJOR}.noarch.rpm"
|
||||||
|
ROCKY="https://dl.rockylinux.org/pub/rocky/${EL_MAJOR}/extras/${ARCH}/os"
|
||||||
|
ALMA="https://repo.almalinux.org/almalinux/${EL_MAJOR}/extras/${ARCH}/os"
|
||||||
|
|
||||||
|
echo "Try Fedora: $FEDORA"
|
||||||
|
curl -fsSLI "$FEDORA" >/dev/null && dnf -y install "$FEDORA" ||
|
||||||
|
install_epel_from_dir "$ROCKY" ||
|
||||||
|
install_epel_from_dir "$ALMA" ||
|
||||||
|
{ echo "EPEL bootstrap failed (Fedora/Rocky/Alma)"; exit 1; }
|
||||||
|
|
||||||
|
dnf -y install sudo git rpm-build rpmdevtools dnf-plugins-core rsync findutils tar gzip unzip which python3
|
||||||
|
dnf repolist | grep -i epel || true
|
||||||
|
|
||||||
|
- name: Checkout repo (for scripts)
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with: { submodules: 'recursive', fetch-depth: '0' }
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
- name: Ensure script permissions
|
||||||
- name: Setup QEMU
|
run: chmod 755 package-rhel-x86.sh
|
||||||
uses: docker/setup-qemu-action@v4
|
|
||||||
- name: Build loong64 RPM
|
- name: Package RPM x86 (RHEL-family)
|
||||||
shell: bash
|
run: ./package-rhel-x86.sh "${RELEASE_TAG}"
|
||||||
timeout-minutes: 180
|
|
||||||
env: { RELEASE_TAG: "${{ env.RELEASE_TAG }}" }
|
- name: Collect x86 RPM into workspace
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
mkdir -p "$GITHUB_WORKSPACE/dist/rpm-x86"
|
||||||
docker run --rm \
|
rsync -av "$HOME/rpmbuild/RPMS/" "$GITHUB_WORKSPACE/dist/rpm-x86/" || true
|
||||||
--privileged \
|
|
||||||
--platform linux/loong64 \
|
find "$GITHUB_WORKSPACE/dist/rpm-x86" -name "v2rayN-*-1*.i686.rpm" \
|
||||||
--env DOTNET_EnableWriteXorExecute=0 \
|
-exec mv {} "$GITHUB_WORKSPACE/dist/rpm-x86/v2rayN-linux-rhel-86.rpm" \; || true
|
||||||
--volume "${{ github.workspace }}:/root/v2rayN-src" \
|
|
||||||
--volume "$HOME/rpmbuild/RPMS:/root/rpmbuild/RPMS" \
|
|
||||||
--workdir /root/v2rayN-src \
|
|
||||||
"$DOCKER_IMAGE" bash -c "
|
|
||||||
dnf -y makecache && \
|
|
||||||
dnf -y install sudo git rpm-build rpmdevtools dnf-plugins-core rsync findutils tar gzip unzip which curl jq file ca-certificates fuse3 && \
|
|
||||||
git config --global --add safe.directory /root/v2rayN-src && \
|
|
||||||
./package-rhel-loong.sh ${RELEASE_TAG}"
|
|
||||||
- name: Collect RPMs into workspace
|
|
||||||
run: |
|
|
||||||
mkdir -p "$GITHUB_WORKSPACE/dist/rpm-loong64"
|
|
||||||
rsync -av "$HOME/rpmbuild/RPMS/" "$GITHUB_WORKSPACE/dist/rpm-loong64/" || true
|
|
||||||
find "$GITHUB_WORKSPACE/dist/rpm-loong64" -name "*.loongarch64.rpm" -exec mv {} "$GITHUB_WORKSPACE/dist/rpm-loong64/v2rayN-linux-rhel-loong64.rpm" \; || true
|
|
||||||
echo "==== Dist tree ===="
|
echo "==== Dist tree ===="
|
||||||
ls -R "$GITHUB_WORKSPACE/dist/rpm-loong64" || true
|
ls -R "$GITHUB_WORKSPACE/dist/rpm-x86" || true
|
||||||
- name: Upload RPM artifact
|
|
||||||
|
- name: Upload x86 RPM artifact
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with: { name: release-rpm-loong64, path: "dist/rpm-loong64/**/*.rpm", if-no-files-found: error }
|
with: { name: release-rpm-x86, path: "dist/rpm-x86/**/*.rpm", if-no-files-found: error }
|
||||||
|
|
||||||
release-deb:
|
release-deb:
|
||||||
name: sign and upload deb x64 arm64
|
name: sign and upload deb x64 arm64 riscv64 ppc64le loong64
|
||||||
needs: deb
|
needs: deb
|
||||||
uses: ./.github/workflows/upload-sign.yml
|
uses: ./.github/workflows/upload-sign.yml
|
||||||
with: { release_tag: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}", artifact_name: release-deb, file_pattern: "*.deb" }
|
with: { release_tag: "${{ inputs.release_tag || github.ref_name }}", artifact_name: release-deb, file_pattern: "*.deb" }
|
||||||
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
||||||
|
|
||||||
release-rpm:
|
release-rpm:
|
||||||
name: sign and upload rpm x64 arm64
|
name: sign and upload rpm x64 arm64 riscv64 ppc64le loong64
|
||||||
needs: rpm
|
needs: rpm
|
||||||
uses: ./.github/workflows/upload-sign.yml
|
uses: ./.github/workflows/upload-sign.yml
|
||||||
with: { release_tag: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}", artifact_name: release-rpm, file_pattern: "*.rpm" }
|
with: { release_tag: "${{ inputs.release_tag || github.ref_name }}", artifact_name: release-rpm, file_pattern: "*.rpm" }
|
||||||
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
||||||
|
|
||||||
release-rpm-riscv64:
|
release-deb-x86:
|
||||||
name: sign and upload rpm riscv64
|
name: sign and upload deb x86
|
||||||
needs: rpm-riscv64
|
needs: deb-x86
|
||||||
uses: ./.github/workflows/upload-sign.yml
|
uses: ./.github/workflows/upload-sign.yml
|
||||||
with: { release_tag: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}", artifact_name: release-rpm-riscv64, file_pattern: "*.rpm" }
|
with: { release_tag: "${{ inputs.release_tag || github.ref_name }}", artifact_name: release-deb-x86, file_pattern: "*.deb" }
|
||||||
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
||||||
|
|
||||||
release-deb-riscv64:
|
release-rpm-x86:
|
||||||
name: sign and upload deb riscv64
|
name: sign and upload rpm x86
|
||||||
needs: deb-riscv64
|
needs: rpm-x86
|
||||||
uses: ./.github/workflows/upload-sign.yml
|
uses: ./.github/workflows/upload-sign.yml
|
||||||
with: { release_tag: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}", artifact_name: release-deb-riscv64, file_pattern: "*.deb" }
|
with: { release_tag: "${{ inputs.release_tag || github.ref_name }}", artifact_name: release-rpm-x86, file_pattern: "*.rpm" }
|
||||||
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
|
||||||
|
|
||||||
release-deb-loong64:
|
|
||||||
name: sign and upload deb loong64
|
|
||||||
needs: deb-loong64
|
|
||||||
uses: ./.github/workflows/upload-sign.yml
|
|
||||||
with: { release_tag: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}", artifact_name: release-deb-loong64, file_pattern: "*.deb" }
|
|
||||||
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
|
||||||
|
|
||||||
release-rpm-loong64:
|
|
||||||
name: sign and upload rpm loong64
|
|
||||||
needs: rpm-loong64
|
|
||||||
uses: ./.github/workflows/upload-sign.yml
|
|
||||||
with: { release_tag: "${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}", artifact_name: release-rpm-loong64, file_pattern: "*.rpm" }
|
|
||||||
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
secrets: { GPG_PRIVATE_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" }
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ Read the Wiki for usage guides and configuration details.
|
|||||||
|
|
||||||
## Supported Platforms / 支持平台
|
## Supported Platforms / 支持平台
|
||||||
|
|
||||||
| Platform / 平台 | x64 | x86 | arm64 | riscv64 | loong64 |
|
| Platform / 平台 | x64 | x86 | arm64 | riscv64 | loong64 | ppc64le |
|
||||||
| --- | --- | --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- | --- | --- |
|
||||||
| Windows | ✅ | ✅ | ✅ | - | - |
|
| Windows | ✅ | ✅ | ✅ | - | - | - |
|
||||||
| Linux | ✅ | - | ✅ | ✅ | ✅ |
|
| Linux | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| macOS | ✅ | - | ✅ | - | - |
|
| macOS | ✅ | - | ✅ | - | - | - |
|
||||||
|
|
||||||
Minimum OS requirements: [Release files introduction](https://github.com/2dust/v2rayN/wiki/Release-files-introduction) / 最低系统要求:[发布文件介绍](https://github.com/2dust/v2rayN/wiki/Release-files-introduction)
|
Minimum OS requirements: [Release files introduction](https://github.com/2dust/v2rayN/wiki/Release-files-introduction) / 最低系统要求:[发布文件介绍](https://github.com/2dust/v2rayN/wiki/Release-files-introduction)
|
||||||
|
|
||||||
|
|||||||
@@ -1,731 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
VERSION_ARG=""
|
|
||||||
WITH_CORE="both"
|
|
||||||
FORCE_NETCORE=0
|
|
||||||
BUILD_FROM=""
|
|
||||||
XRAY_VER="${XRAY_VER:-}"
|
|
||||||
SING_VER="${SING_VER:-}"
|
|
||||||
|
|
||||||
MIN_KERNEL="6.12"
|
|
||||||
PKGROOT="v2rayN-publish"
|
|
||||||
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
|
||||||
OUTPUT_DIR="${HOME}/debbuild"
|
|
||||||
DOTNET_TFM="net10.0"
|
|
||||||
DOTNET_LOONGARCH_VERSION="10.0.111"
|
|
||||||
DOTNET_LOONGARCH_TAG="v10.0.111-loongarch64"
|
|
||||||
DOTNET_LOONGARCH_BASE="https://github.com/loongson/dotnet/releases/download"
|
|
||||||
DOTNET_LOONGARCH_FILE="dotnet-sdk-${DOTNET_LOONGARCH_VERSION}-linux-loongarch64.tar.gz"
|
|
||||||
DOTNET_SDK_URL="${DOTNET_LOONGARCH_BASE}/${DOTNET_LOONGARCH_TAG}/${DOTNET_LOONGARCH_FILE}"
|
|
||||||
|
|
||||||
OS_ID=""
|
|
||||||
OS_NAME=""
|
|
||||||
OS_VERSION_ID=""
|
|
||||||
HOST_ARCH=""
|
|
||||||
SCRIPT_DIR=""
|
|
||||||
PROJECT=""
|
|
||||||
VERSION=""
|
|
||||||
|
|
||||||
declare -a BUILT_DEBS=()
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo "$*" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_args() {
|
|
||||||
local first_arg="${1:-}"
|
|
||||||
|
|
||||||
if [[ -n "$first_arg" && "$first_arg" != --* ]]; then
|
|
||||||
VERSION_ARG="$first_arg"
|
|
||||||
shift || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
|
||||||
--xray-ver) XRAY_VER="${2:-}"; shift 2 ;;
|
|
||||||
--singbox-ver) SING_VER="${2:-}"; shift 2 ;;
|
|
||||||
--netcore) FORCE_NETCORE=1; shift ;;
|
|
||||||
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
|
||||||
*)
|
|
||||||
[[ -n "${VERSION_ARG:-}" ]] || VERSION_ARG="$1"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
|
||||||
die "You cannot specify both an explicit version and --buildfrom at the same time.
|
|
||||||
Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
detect_environment() {
|
|
||||||
local current_kernel=""
|
|
||||||
local lowest=""
|
|
||||||
|
|
||||||
. /etc/os-release
|
|
||||||
|
|
||||||
OS_ID="${ID:-}"
|
|
||||||
OS_NAME="${NAME:-$OS_ID}"
|
|
||||||
OS_VERSION_ID="${VERSION_ID:-}"
|
|
||||||
HOST_ARCH="$(uname -m)"
|
|
||||||
|
|
||||||
case "$OS_ID" in
|
|
||||||
debian)
|
|
||||||
echo "Detected supported system: ${OS_NAME:-$OS_ID} ${OS_VERSION_ID:-}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "Unsupported system: ${OS_NAME:-unknown} (${OS_ID:-unknown}).
|
|
||||||
This script only supports: Debian."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$HOST_ARCH" in
|
|
||||||
loongarch64) ;;
|
|
||||||
*) die "Only supports loongarch64" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
current_kernel="$(uname -r)"
|
|
||||||
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$current_kernel" | sort -V | head -n1)"
|
|
||||||
|
|
||||||
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
|
||||||
echo "[OK] Kernel $current_kernel verified."
|
|
||||||
}
|
|
||||||
|
|
||||||
install_dependencies() {
|
|
||||||
local install_ok=0
|
|
||||||
local tmp_dotnet=""
|
|
||||||
|
|
||||||
mkdir -p "$OUTPUT_DIR"
|
|
||||||
|
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y install \
|
|
||||||
curl unzip tar jq rsync ca-certificates git dpkg-dev fakeroot file \
|
|
||||||
desktop-file-utils xdg-utils wget gcc make pkg-config \
|
|
||||||
libicu-dev libssl-dev libfontconfig1 libfreetype6 zlib1g
|
|
||||||
|
|
||||||
mkdir -p "$HOME/.dotnet"
|
|
||||||
tmp_dotnet="$(mktemp -d)"
|
|
||||||
curl -fL "$DOTNET_SDK_URL" -o "$tmp_dotnet/$DOTNET_LOONGARCH_FILE"
|
|
||||||
tar -C "$HOME/.dotnet" -xzf "$tmp_dotnet/$DOTNET_LOONGARCH_FILE"
|
|
||||||
rm -rf "$tmp_dotnet"
|
|
||||||
|
|
||||||
export PATH="$HOME/.dotnet:$PATH"
|
|
||||||
export DOTNET_ROOT="$HOME/.dotnet"
|
|
||||||
|
|
||||||
dotnet --info >/dev/null 2>&1 && install_ok=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
|
||||||
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
|
||||||
echo "dotnet-loongarch SDK, curl, unzip, tar, rsync, git, gcc, make, dpkg-deb, fakeroot, libicu-dev, libssl-dev"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_workspace() {
|
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
cd "$SCRIPT_DIR"
|
|
||||||
|
|
||||||
if [[ -f .gitmodules ]]; then
|
|
||||||
git submodule sync --recursive || true
|
|
||||||
git submodule update --init --recursive || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
PROJECT="$PROJECT_HINT"
|
|
||||||
[[ -f "$PROJECT" ]] || PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
|
||||||
[[ -f "$PROJECT" ]] || die "v2rayN.Desktop.csproj not found"
|
|
||||||
}
|
|
||||||
|
|
||||||
choose_channel() {
|
|
||||||
local ch="latest"
|
|
||||||
local sel=""
|
|
||||||
|
|
||||||
if [[ -n "${BUILD_FROM:-}" ]]; then
|
|
||||||
case "$BUILD_FROM" in
|
|
||||||
1) echo "latest"; return 0 ;;
|
|
||||||
2) echo "prerelease"; return 0 ;;
|
|
||||||
3) echo "keep"; return 0 ;;
|
|
||||||
*) die "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -t 0 ]]; then
|
|
||||||
echo "[?] Choose v2rayN release channel:" >&2
|
|
||||||
echo " 1) Latest (stable) [default]" >&2
|
|
||||||
echo " 2) Pre-release (preview)" >&2
|
|
||||||
echo " 3) Keep current (do nothing)" >&2
|
|
||||||
printf "Enter 1, 2 or 3 [default 1]: " >&2
|
|
||||||
|
|
||||||
if read -r sel </dev/tty; then
|
|
||||||
case "${sel:-}" in
|
|
||||||
2) ch="prerelease" ;;
|
|
||||||
3) ch="keep" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$ch"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_latest_tag_latest() {
|
|
||||||
curl -fsSL "https://api.github.com/repos/2dust/v2rayN/releases/latest" \
|
|
||||||
| jq -re '.tag_name' \
|
|
||||||
| sed 's/^v//'
|
|
||||||
}
|
|
||||||
|
|
||||||
get_latest_tag_prerelease() {
|
|
||||||
curl -fsSL "https://api.github.com/repos/2dust/v2rayN/releases?per_page=20" \
|
|
||||||
| jq -re 'first(.[] | select(.prerelease == true) | .tag_name)' \
|
|
||||||
| sed 's/^v//'
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_submodules() {
|
|
||||||
if [[ -f .gitmodules ]]; then
|
|
||||||
git submodule sync --recursive || true
|
|
||||||
git submodule update --init --recursive || true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
git_try_checkout() {
|
|
||||||
local want="$1"
|
|
||||||
local ref=""
|
|
||||||
|
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
||||||
git fetch --tags --force --prune --depth=1 || true
|
|
||||||
git rev-parse "refs/tags/${want}" >/dev/null 2>&1 && ref="$want"
|
|
||||||
|
|
||||||
if [[ -n "$ref" ]]; then
|
|
||||||
echo "[OK] Found ref '${ref}', checking out..."
|
|
||||||
git checkout -f "$ref"
|
|
||||||
sync_submodules
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
apply_channel_or_keep() {
|
|
||||||
local ch="$1"
|
|
||||||
local tag=""
|
|
||||||
|
|
||||||
if [[ "$ch" == "keep" ]]; then
|
|
||||||
echo "[*] Keep current repository state (no checkout)."
|
|
||||||
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo '0.0.0+git')"
|
|
||||||
VERSION="${VERSION#v}"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
git remote add upstream https://github.com/2dust/v2rayN || true
|
|
||||||
git fetch upstream
|
|
||||||
|
|
||||||
echo "[*] Resolving ${ch} tag from GitHub releases..."
|
|
||||||
|
|
||||||
case "$ch" in
|
|
||||||
latest) tag="$(get_latest_tag_latest || true)" ;;
|
|
||||||
prerelease) tag="$(get_latest_tag_prerelease || true)" ;;
|
|
||||||
*) die "Failed to resolve latest tag for channel '${ch}'." ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
[[ -n "$tag" ]] || die "Failed to resolve latest tag for channel '${ch}'."
|
|
||||||
|
|
||||||
echo "[*] Latest tag for '${ch}': ${tag}"
|
|
||||||
git_try_checkout "$tag" || die "Failed to checkout '${tag}'."
|
|
||||||
VERSION="${tag#v}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve_version() {
|
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
||||||
if [[ -n "${VERSION_ARG:-}" ]]; then
|
|
||||||
local clean_ver="${VERSION_ARG#v}"
|
|
||||||
|
|
||||||
if git_try_checkout "$clean_ver"; then
|
|
||||||
VERSION="$clean_ver"
|
|
||||||
else
|
|
||||||
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
|
||||||
apply_channel_or_keep "$(choose_channel)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
apply_channel_or_keep "$(choose_channel)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Current directory is not a git repo; proceeding on current tree."
|
|
||||||
VERSION="${VERSION_ARG:-0.0.0}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
VERSION="${VERSION#v}"
|
|
||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
|
||||||
}
|
|
||||||
|
|
||||||
xray_url_for_rid() {
|
|
||||||
local rid="$1"
|
|
||||||
local ver="$2"
|
|
||||||
|
|
||||||
case "$rid" in
|
|
||||||
linux-loongarch64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-loong64.zip" ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
singbox_url_for_rid() {
|
|
||||||
local rid="$1"
|
|
||||||
local ver="$2"
|
|
||||||
|
|
||||||
case "$rid" in
|
|
||||||
linux-loongarch64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-loong64.tar.gz" ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
bundle_url_for_rid() {
|
|
||||||
local rid="$1"
|
|
||||||
|
|
||||||
case "$rid" in
|
|
||||||
linux-loongarch64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-loong64.zip" ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
download_xray() {
|
|
||||||
local outdir="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local ver="${XRAY_VER:-}"
|
|
||||||
local url=""
|
|
||||||
local tmp=""
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest \
|
|
||||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
|
||||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
|
||||||
| head -n1)" || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
|
||||||
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
|
||||||
|
|
||||||
echo "[+] Download xray: $url"
|
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
|
||||||
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
|
||||||
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
|
||||||
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
|
||||||
rm -rf "$tmp"
|
|
||||||
}
|
|
||||||
|
|
||||||
download_singbox() {
|
|
||||||
local outdir="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local ver="${SING_VER:-}"
|
|
||||||
local url=""
|
|
||||||
local tmp=""
|
|
||||||
local bin=""
|
|
||||||
local cronet=""
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
|
||||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
|
||||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
|
||||||
| head -n1)" || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
|
||||||
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
|
||||||
|
|
||||||
echo "[+] Download sing-box: $url"
|
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
|
||||||
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
|
||||||
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
|
||||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
install -m 755 "$bin" "$outdir/sing-box" || { rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
|
||||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
|
||||||
|
|
||||||
rm -rf "$tmp"
|
|
||||||
}
|
|
||||||
|
|
||||||
unify_geo_layout() {
|
|
||||||
local outroot="$1"
|
|
||||||
local n
|
|
||||||
local names=(
|
|
||||||
geosite.dat
|
|
||||||
geoip.dat
|
|
||||||
geoip-only-cn-private.dat
|
|
||||||
Country.mmdb
|
|
||||||
geoip.metadb
|
|
||||||
)
|
|
||||||
|
|
||||||
mkdir -p "$outroot/bin"
|
|
||||||
|
|
||||||
for n in "${names[@]}"; do
|
|
||||||
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
|
||||||
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
download_geo_assets() {
|
|
||||||
local outroot="$1"
|
|
||||||
local bin_dir="$outroot/bin"
|
|
||||||
local srss_dir="$bin_dir/srss"
|
|
||||||
local f=""
|
|
||||||
|
|
||||||
mkdir -p "$bin_dir" "$srss_dir"
|
|
||||||
|
|
||||||
echo "[+] Download Xray Geo to ${bin_dir}"
|
|
||||||
curl -fsSL -o "$bin_dir/geosite.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geosite.dat"
|
|
||||||
curl -fsSL -o "$bin_dir/geoip.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
|
||||||
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
|
||||||
curl -fsSL -o "$bin_dir/Country.mmdb" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
|
||||||
|
|
||||||
echo "[+] Download sing-box rule DB & rule-sets"
|
|
||||||
curl -fsSL -o "$bin_dir/geoip.metadb" "https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb"
|
|
||||||
|
|
||||||
for f in geoip-private.srs geoip-cn.srs geoip-facebook.srs geoip-fastly.srs geoip-google.srs geoip-netflix.srs geoip-telegram.srs geoip-twitter.srs; do
|
|
||||||
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geoip/$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
for f in geosite-cn.srs geosite-gfw.srs geosite-google.srs geosite-greatfire.srs geosite-geolocation-cn.srs geosite-category-ads-all.srs geosite-private.srs; do
|
|
||||||
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geosite/$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
unify_geo_layout "$outroot"
|
|
||||||
}
|
|
||||||
|
|
||||||
populate_assets_zip_mode() {
|
|
||||||
local outroot="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local url=""
|
|
||||||
local tmp=""
|
|
||||||
local nested_dir=""
|
|
||||||
|
|
||||||
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
|
||||||
|
|
||||||
echo "[+] Try v2rayN bundle archive: $url"
|
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
|
||||||
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
|
||||||
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
if [[ -d "$tmp/bin" ]]; then
|
|
||||||
mkdir -p "$outroot/bin"
|
|
||||||
rsync -a "$tmp/bin/" "$outroot/bin/"
|
|
||||||
else
|
|
||||||
rsync -a "$tmp/" "$outroot/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
|
||||||
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 2>/dev/null || true
|
|
||||||
|
|
||||||
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
|
||||||
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
|
||||||
mkdir -p "$outroot/bin"
|
|
||||||
rsync -a "$nested_dir/bin/" "$outroot/bin/"
|
|
||||||
rm -rf "$nested_dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
unify_geo_layout "$outroot"
|
|
||||||
rm -rf "$tmp"
|
|
||||||
|
|
||||||
echo "[+] Bundle extracted to $outroot"
|
|
||||||
}
|
|
||||||
|
|
||||||
populate_assets_netcore_mode() {
|
|
||||||
local outroot="$1"
|
|
||||||
local rid="$2"
|
|
||||||
|
|
||||||
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
|
||||||
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
|
||||||
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
|
||||||
}
|
|
||||||
|
|
||||||
stage_runtime_assets() {
|
|
||||||
local outroot="$1"
|
|
||||||
local rid="$2"
|
|
||||||
|
|
||||||
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
|
||||||
|
|
||||||
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
|
||||||
if populate_assets_zip_mode "$outroot" "$rid"; then
|
|
||||||
echo "[*] Using v2rayN bundle archive."
|
|
||||||
else
|
|
||||||
echo "[*] Bundle failed, fallback to separate core + rules."
|
|
||||||
populate_assets_netcore_mode "$outroot" "$rid"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "[*] --netcore specified: use separate core + rules."
|
|
||||||
populate_assets_netcore_mode "$outroot" "$rid"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
describe_target() {
|
|
||||||
local short="$1"
|
|
||||||
|
|
||||||
case "$short" in
|
|
||||||
loongarch64) printf '%s\n%s\n' "linux-loongarch64" "loong64" ;;
|
|
||||||
*) echo "Unknown arch '$short' (use loongarch64)" >&2; return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
publish_binary() {
|
|
||||||
local rid="$1"
|
|
||||||
|
|
||||||
dotnet clean "$PROJECT" -c Release
|
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
|
||||||
dotnet restore "$PROJECT"
|
|
||||||
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
|
||||||
}
|
|
||||||
|
|
||||||
write_launcher_file() {
|
|
||||||
local stage="$1"
|
|
||||||
|
|
||||||
install -m 755 /dev/stdin "$stage/usr/bin/v2rayn" <<'EOF'
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
DIR="/opt/v2rayN"
|
|
||||||
cd "$DIR"
|
|
||||||
|
|
||||||
if [[ -x "$DIR/v2rayN" ]]; then
|
|
||||||
exec "$DIR/v2rayN" "$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for dll in v2rayN.Desktop.dll v2rayN.dll; do
|
|
||||||
if [[ -f "$DIR/$dll" ]]; then
|
|
||||||
exec /usr/bin/dotnet "$DIR/$dll" "$@"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "v2rayN launcher: no executable found in $DIR" >&2
|
|
||||||
ls -l "$DIR" >&2 || true
|
|
||||||
exit 1
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
write_desktop_file() {
|
|
||||||
local stage="$1"
|
|
||||||
|
|
||||||
install -m 644 /dev/stdin "$stage/usr/share/applications/v2rayn.desktop" <<'EOF'
|
|
||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=v2rayN
|
|
||||||
Comment=v2rayN for Debian GNU Linux
|
|
||||||
Exec=v2rayn
|
|
||||||
Icon=v2rayn
|
|
||||||
Terminal=false
|
|
||||||
Categories=Network;
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
write_maintainer_scripts() {
|
|
||||||
local debian_dir="$1"
|
|
||||||
|
|
||||||
install -m 755 /dev/stdin "$debian_dir/postinst" <<'EOF'
|
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
|
||||||
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
|
||||||
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
install -m 755 /dev/stdin "$debian_dir/postrm" <<'EOF'
|
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
|
||||||
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
|
||||||
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
package_binary() {
|
|
||||||
local short="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local deb_arch="$3"
|
|
||||||
local pubdir=""
|
|
||||||
local workdir=""
|
|
||||||
local stage=""
|
|
||||||
local debian_dir=""
|
|
||||||
local project_dir=""
|
|
||||||
local icon_candidate=""
|
|
||||||
local shlibs_depends=""
|
|
||||||
local extra_depends=""
|
|
||||||
local final_depends=""
|
|
||||||
local multiarch=""
|
|
||||||
local sys_libdir=""
|
|
||||||
local sys_usrlibdir=""
|
|
||||||
local deb_out=""
|
|
||||||
|
|
||||||
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
|
||||||
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
|
||||||
|
|
||||||
workdir="$(mktemp -d)"
|
|
||||||
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
|
||||||
|
|
||||||
stage="$workdir/${PKGROOT}_${VERSION}_${deb_arch}"
|
|
||||||
debian_dir="$stage/DEBIAN"
|
|
||||||
|
|
||||||
mkdir -p "$stage/opt/v2rayN" "$stage/usr/bin" "$stage/usr/share/applications" "$stage/usr/share/icons/hicolor/256x256/apps" "$debian_dir"
|
|
||||||
cp -a "$pubdir/." "$stage/opt/v2rayN/"
|
|
||||||
|
|
||||||
project_dir="$(cd "$(dirname "$PROJECT")" && pwd)"
|
|
||||||
icon_candidate="$project_dir/v2rayN.png"
|
|
||||||
[[ -f "$icon_candidate" ]] && cp "$icon_candidate" "$stage/usr/share/icons/hicolor/256x256/apps/v2rayn.png" || true
|
|
||||||
|
|
||||||
stage_runtime_assets "$stage/opt/v2rayN" "$rid"
|
|
||||||
write_launcher_file "$stage"
|
|
||||||
write_desktop_file "$stage"
|
|
||||||
write_maintainer_scripts "$debian_dir"
|
|
||||||
|
|
||||||
extra_depends="libc6 (>= 2.39), fontconfig (>= 2.15.0), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 9.4), bash (>= 5.2.21), libfreetype6 (>= 2.13)"
|
|
||||||
|
|
||||||
mkdir -p "$workdir/debian"
|
|
||||||
cat > "$workdir/debian/control" <<EOF
|
|
||||||
Source: v2rayn
|
|
||||||
Section: net
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: 2dust <noreply@github.com>
|
|
||||||
Standards-Version: 4.7.0
|
|
||||||
|
|
||||||
Package: v2rayn
|
|
||||||
Architecture: ${deb_arch}
|
|
||||||
Description: v2rayN
|
|
||||||
EOF
|
|
||||||
|
|
||||||
multiarch="$(dpkg-architecture -a"$deb_arch" -qDEB_HOST_MULTIARCH)"
|
|
||||||
sys_libdir="/lib/$multiarch"
|
|
||||||
sys_usrlibdir="/usr/lib/$multiarch"
|
|
||||||
|
|
||||||
: > "$debian_dir/substvars"
|
|
||||||
|
|
||||||
mapfile -t ELF_FILES < <(
|
|
||||||
find "$stage/opt/v2rayN" -type f \( -name "*.so*" -o -perm -111 \) ! -name 'libcoreclrtraceptprovider.so'
|
|
||||||
)
|
|
||||||
|
|
||||||
if [[ "${#ELF_FILES[@]}" -gt 0 ]]; then
|
|
||||||
(
|
|
||||||
cd "$workdir"
|
|
||||||
dpkg-shlibdeps \
|
|
||||||
-l"$stage/opt/v2rayN" \
|
|
||||||
-l"$sys_libdir" \
|
|
||||||
-l"$sys_usrlibdir" \
|
|
||||||
-T"$debian_dir/substvars" \
|
|
||||||
"${ELF_FILES[@]}"
|
|
||||||
) >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
|
||||||
|
|
||||||
if [[ -n "$shlibs_depends" ]]; then
|
|
||||||
shlibs_depends="$(echo "$shlibs_depends" \
|
|
||||||
| sed -E 's/ *\([^)]*\)//g' \
|
|
||||||
| sed -E 's/ *, */, /g' \
|
|
||||||
| sed -E 's/^, *//; s/, *$//')"
|
|
||||||
final_depends="${shlibs_depends}, ${extra_depends}"
|
|
||||||
else
|
|
||||||
final_depends="${extra_depends}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat > "$debian_dir/control" <<EOF
|
|
||||||
Package: v2rayn
|
|
||||||
Version: ${VERSION}
|
|
||||||
Architecture: ${deb_arch}
|
|
||||||
Maintainer: 2dust <noreply@github.com>
|
|
||||||
Homepage: https://github.com/2dust/v2rayN
|
|
||||||
Section: net
|
|
||||||
Priority: optional
|
|
||||||
Depends: ${final_depends}
|
|
||||||
Description: v2rayN (Avalonia) GUI client for Linux
|
|
||||||
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 /
|
|
||||||
Shadowsocks / tuic / WireGuard.
|
|
||||||
EOF
|
|
||||||
|
|
||||||
find "$stage/opt/v2rayN" -type d -exec chmod 0755 {} +
|
|
||||||
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
|
||||||
[[ -f "$stage/opt/v2rayN/v2rayN" ]] && chmod 0755 "$stage/opt/v2rayN/v2rayN" || true
|
|
||||||
|
|
||||||
deb_out="$OUTPUT_DIR/v2rayn_${VERSION}_${deb_arch}.deb"
|
|
||||||
dpkg-deb --root-owner-group --build "$stage" "$deb_out"
|
|
||||||
|
|
||||||
echo "Build done for $short. DEB at:"
|
|
||||||
echo " $deb_out"
|
|
||||||
BUILT_DEBS+=("$deb_out")
|
|
||||||
}
|
|
||||||
|
|
||||||
select_targets() {
|
|
||||||
printf '%s\n' loongarch64
|
|
||||||
}
|
|
||||||
|
|
||||||
build_one_target() {
|
|
||||||
local short="$1"
|
|
||||||
local meta=()
|
|
||||||
local rid=""
|
|
||||||
local deb_arch=""
|
|
||||||
|
|
||||||
mapfile -t meta < <(describe_target "$short") || return 1
|
|
||||||
rid="${meta[0]}"
|
|
||||||
deb_arch="${meta[1]}"
|
|
||||||
|
|
||||||
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
|
||||||
publish_binary "$rid"
|
|
||||||
package_binary "$short" "$rid" "$deb_arch"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_summary() {
|
|
||||||
local pkg=""
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "================ Build Summary ================="
|
|
||||||
if [[ "${#BUILT_DEBS[@]}" -gt 0 ]]; then
|
|
||||||
echo "Output directory: $OUTPUT_DIR"
|
|
||||||
for pkg in "${BUILT_DEBS[@]}"; do
|
|
||||||
echo "$pkg"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "No DEBs detected in summary (check build logs above)."
|
|
||||||
fi
|
|
||||||
echo "==============================================="
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local targets=()
|
|
||||||
local arch=""
|
|
||||||
|
|
||||||
parse_args "$@"
|
|
||||||
detect_environment
|
|
||||||
install_dependencies
|
|
||||||
prepare_workspace
|
|
||||||
resolve_version
|
|
||||||
|
|
||||||
mapfile -t targets < <(select_targets)
|
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
|
||||||
build_one_target "$arch"
|
|
||||||
done
|
|
||||||
|
|
||||||
print_summary
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
Executable → Regular
+220
-64
@@ -8,14 +8,21 @@ BUILD_FROM=""
|
|||||||
XRAY_VER="${XRAY_VER:-}"
|
XRAY_VER="${XRAY_VER:-}"
|
||||||
SING_VER="${SING_VER:-}"
|
SING_VER="${SING_VER:-}"
|
||||||
|
|
||||||
MIN_KERNEL="5.10"
|
MIN_KERNEL="6.12"
|
||||||
PKGROOT="v2rayN-publish"
|
PKGROOT="v2rayN-publish"
|
||||||
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
OUTPUT_DIR="${HOME}/debbuild"
|
OUTPUT_DIR="${HOME}/debbuild"
|
||||||
DOTNET_RISCV_VERSION="10.0.111"
|
|
||||||
DOTNET_RISCV_BASE="https://github.com/xujiegb/dotnet-riscv/releases/download"
|
NUGET_CACHE_DIR=""
|
||||||
DOTNET_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
DOTNET_SDK_DIR=""
|
||||||
DOTNET_SDK_URL="${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}"
|
|
||||||
|
DOTNET_NUPKG_BASE="${DOTNET_NUPKG_BASE:-https://github.com/autorepobot/dotnet-nupkg-prebuild/releases/download}"
|
||||||
|
SKIASHARP_BASE="${SKIASHARP_BASE:-https://github.com/autorepobot/SkiaSharp-ppc64le/releases/download}"
|
||||||
|
SkiaSharp_VERSION="${SkiaSharp_VERSION:-3.119.4}"
|
||||||
|
HarfBuzzSharp_VERSION="${HarfBuzzSharp_VERSION:-8.3.1.5}"
|
||||||
|
|
||||||
|
DOTNET_SDK_VERSION="${DOTNET_SDK_VERSION:-10.0.114}"
|
||||||
|
DOTNET_X86_VERSION="${DOTNET_X86_VERSION:-10.0.114}"
|
||||||
|
|
||||||
OS_ID=""
|
OS_ID=""
|
||||||
OS_NAME=""
|
OS_NAME=""
|
||||||
@@ -24,6 +31,10 @@ HOST_ARCH=""
|
|||||||
SCRIPT_DIR=""
|
SCRIPT_DIR=""
|
||||||
PROJECT=""
|
PROJECT=""
|
||||||
VERSION=""
|
VERSION=""
|
||||||
|
BUILT_ALL=0
|
||||||
|
|
||||||
|
X86_RID="linux-x86"
|
||||||
|
X86_DEB_ARCH="i386"
|
||||||
|
|
||||||
declare -a BUILT_DEBS=()
|
declare -a BUILT_DEBS=()
|
||||||
|
|
||||||
@@ -32,6 +43,13 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_runtime_version() {
|
||||||
|
local sdk_ver="$1"
|
||||||
|
local prefix="${sdk_ver%.*}"
|
||||||
|
local patch="${sdk_ver##*.}"
|
||||||
|
echo "${prefix}.${patch#1}"
|
||||||
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
local first_arg="${1:-}"
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
@@ -82,8 +100,8 @@ This script only supports: Debian."
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "$HOST_ARCH" in
|
case "$HOST_ARCH" in
|
||||||
riscv64) ;;
|
x86_64|aarch64) ;;
|
||||||
*) die "Only supports riscv64" ;;
|
*) die "This script cross-compiles linux-x86 from x86_64 or aarch64 only." ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
current_kernel="$(uname -r)"
|
current_kernel="$(uname -r)"
|
||||||
@@ -91,11 +109,12 @@ This script only supports: Debian."
|
|||||||
|
|
||||||
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
||||||
echo "[OK] Kernel $current_kernel verified."
|
echo "[OK] Kernel $current_kernel verified."
|
||||||
|
echo "[OK] Host architecture: $HOST_ARCH"
|
||||||
|
echo "[OK] Target: $X86_RID (Debian $X86_DEB_ARCH)"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
local install_ok=0
|
local install_ok=0
|
||||||
local tmp_dotnet=""
|
|
||||||
|
|
||||||
mkdir -p "$OUTPUT_DIR"
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
@@ -103,14 +122,21 @@ install_dependencies() {
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get -y install \
|
sudo apt-get -y install \
|
||||||
curl unzip tar jq rsync ca-certificates git dpkg-dev fakeroot file \
|
curl unzip tar jq rsync ca-certificates git dpkg-dev fakeroot file \
|
||||||
desktop-file-utils xdg-utils wget gcc make pkg-config \
|
desktop-file-utils xdg-utils wget python3
|
||||||
libicu-dev libssl-dev libfontconfig1 libfreetype6 zlib1g
|
|
||||||
|
|
||||||
mkdir -p "$HOME/.dotnet"
|
sudo dpkg --add-architecture "$X86_DEB_ARCH" || true
|
||||||
tmp_dotnet="$(mktemp -d)"
|
sudo apt-get update
|
||||||
curl -fL "$DOTNET_SDK_URL" -o "$tmp_dotnet/$DOTNET_RISCV_FILE"
|
sudo apt-get -y install \
|
||||||
tar -C "$HOME/.dotnet" -xzf "$tmp_dotnet/$DOTNET_RISCV_FILE"
|
"libc6:${X86_DEB_ARCH}" \
|
||||||
rm -rf "$tmp_dotnet"
|
"libgcc-s1:${X86_DEB_ARCH}" \
|
||||||
|
"libstdc++6:${X86_DEB_ARCH}" \
|
||||||
|
"zlib1g:${X86_DEB_ARCH}" \
|
||||||
|
"libfontconfig1:${X86_DEB_ARCH}" \
|
||||||
|
"libfreetype6:${X86_DEB_ARCH}"
|
||||||
|
|
||||||
|
wget -q https://dot.net/v1/dotnet-install.sh
|
||||||
|
chmod +x dotnet-install.sh
|
||||||
|
./dotnet-install.sh --version "$DOTNET_SDK_VERSION" --install-dir "$HOME/.dotnet"
|
||||||
|
|
||||||
export PATH="$HOME/.dotnet:$PATH"
|
export PATH="$HOME/.dotnet:$PATH"
|
||||||
export DOTNET_ROOT="$HOME/.dotnet"
|
export DOTNET_ROOT="$HOME/.dotnet"
|
||||||
@@ -120,11 +146,30 @@ install_dependencies() {
|
|||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
||||||
echo "dotnet-riscv SDK, curl, unzip, tar, rsync, git, gcc, make, dpkg-deb, fakeroot, libicu-dev, libssl-dev"
|
echo "dotnet-sdk 10.x, i386 runtime libraries (libc6, libgcc-s1, libstdc++6, zlib1g, libfontconfig1, libfreetype6)"
|
||||||
|
echo "curl, unzip, tar, rsync, git, dpkg-deb, desktop-file-utils, xdg-utils"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_deb_target_arch() {
|
||||||
|
local target_arch="$X86_DEB_ARCH"
|
||||||
|
|
||||||
|
echo "[+] Prepare Debian multiarch environment for $X86_RID: $target_arch"
|
||||||
|
|
||||||
|
sudo dpkg --add-architecture "$target_arch" || true
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install \
|
||||||
|
"libc6:${target_arch}" \
|
||||||
|
"libgcc-s1:${target_arch}" \
|
||||||
|
"libstdc++6:${target_arch}" \
|
||||||
|
"zlib1g:${target_arch}" \
|
||||||
|
"libfontconfig1:${target_arch}" \
|
||||||
|
"libfreetype6:${target_arch}"
|
||||||
|
|
||||||
|
echo "[OK] Debian target libraries prepared for $target_arch"
|
||||||
|
}
|
||||||
|
|
||||||
prepare_workspace() {
|
prepare_workspace() {
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
@@ -257,13 +302,122 @@ resolve_version() {
|
|||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
echo "[*] GUI version resolved as: ${VERSION}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download_nuget_packages() {
|
||||||
|
NUGET_CACHE_DIR="$(mktemp -d)"
|
||||||
|
|
||||||
|
local x86_rt
|
||||||
|
x86_rt="$(get_runtime_version "$DOTNET_X86_VERSION")"
|
||||||
|
|
||||||
|
local urls=(
|
||||||
|
"${DOTNET_NUPKG_BASE}/${x86_rt}/Microsoft.AspNetCore.App.Runtime.linux-x86.${x86_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${x86_rt}/Microsoft.NETCore.App.Host.linux-x86.${x86_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${x86_rt}/Microsoft.NETCore.App.Runtime.linux-x86.${x86_rt}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/SkiaSharp.NativeAssets.Linux.${SkiaSharp_VERSION}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/HarfBuzzSharp.NativeAssets.Linux.${HarfBuzzSharp_VERSION}.nupkg"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "[+] Downloading prebuilt NuGet packages to: $NUGET_CACHE_DIR"
|
||||||
|
local u pkg_name
|
||||||
|
for u in "${urls[@]}"; do
|
||||||
|
pkg_name="${u##*/}"
|
||||||
|
echo " -> $pkg_name"
|
||||||
|
curl -fL "$u" -o "$NUGET_CACHE_DIR/$pkg_name" || {
|
||||||
|
echo "[!] Failed to download $u" >&2
|
||||||
|
rm -rf "$NUGET_CACHE_DIR"
|
||||||
|
NUGET_CACHE_DIR=""
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[OK] Prebuilt NuGet packages ready in $NUGET_CACHE_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_dotnet_sdk() {
|
||||||
|
echo "[+] Using host .NET SDK for cross-target $X86_RID"
|
||||||
|
dotnet --info
|
||||||
|
DOTNET_SDK_DIR="${DOTNET_ROOT:-$(dirname "$(command -v dotnet)")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
patch_x86_sdk() {
|
||||||
|
local sdk_props=""
|
||||||
|
local sdk_version=""
|
||||||
|
|
||||||
|
sdk_version="$(dotnet --version)"
|
||||||
|
sdk_props="$DOTNET_ROOT/sdk/${sdk_version}/Microsoft.NETCoreSdk.BundledVersions.props"
|
||||||
|
|
||||||
|
[[ -f "$sdk_props" ]] || die "SDK props file not found: $sdk_props"
|
||||||
|
|
||||||
|
echo "[+] Patching SDK: $sdk_props"
|
||||||
|
|
||||||
|
python3 - "$sdk_props" <<'PY'
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
path = Path(sys.argv[1])
|
||||||
|
text = path.read_text()
|
||||||
|
old = text
|
||||||
|
|
||||||
|
|
||||||
|
def add_attr_to_known_blocks(text, marker, attr):
|
||||||
|
start = 0
|
||||||
|
while True:
|
||||||
|
start = text.find(marker, start)
|
||||||
|
if start == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
end = text.find('/>', start)
|
||||||
|
if end == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
block = text[start:end]
|
||||||
|
attr_pos = block.find(attr)
|
||||||
|
if attr_pos != -1:
|
||||||
|
value_start = attr_pos + len(attr)
|
||||||
|
value_end = block.find('"', value_start)
|
||||||
|
if value_end != -1:
|
||||||
|
value = block[value_start:value_end]
|
||||||
|
values = value.split(';')
|
||||||
|
if 'linux-x86' not in values:
|
||||||
|
value = value + ';linux-x86'
|
||||||
|
block = block[:value_start] + value + block[value_end:]
|
||||||
|
text = text[:start] + block + text[end:]
|
||||||
|
end = start + len(block)
|
||||||
|
start = end + 2
|
||||||
|
return text
|
||||||
|
|
||||||
|
for framework in ('Microsoft.NETCore.App', 'Microsoft.AspNetCore.App'):
|
||||||
|
text = add_attr_to_known_blocks(
|
||||||
|
text,
|
||||||
|
f'<KnownFrameworkReference Include="{framework}"',
|
||||||
|
'RuntimePackRuntimeIdentifiers="',
|
||||||
|
)
|
||||||
|
|
||||||
|
text = add_attr_to_known_blocks(
|
||||||
|
text,
|
||||||
|
'<KnownAppHostPack',
|
||||||
|
'AppHostRuntimeIdentifiers="',
|
||||||
|
)
|
||||||
|
|
||||||
|
if text == old:
|
||||||
|
raise SystemExit('ERROR: No SDK RuntimePack/AppHost mapping was patched')
|
||||||
|
|
||||||
|
path.write_text(text)
|
||||||
|
PY
|
||||||
|
|
||||||
|
echo "===== Verify RuntimePackRuntimeIdentifiers ====="
|
||||||
|
grep -n 'RuntimePackRuntimeIdentifiers=' "$sdk_props" | grep 'linux-x86'
|
||||||
|
|
||||||
|
echo "===== Verify AppHostRuntimeIdentifiers ====="
|
||||||
|
grep -n 'AppHostRuntimeIdentifiers=' "$sdk_props" | grep 'linux-x86'
|
||||||
|
}
|
||||||
|
|
||||||
xray_url_for_rid() {
|
xray_url_for_rid() {
|
||||||
local rid="$1"
|
local rid="$1"
|
||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-riscv64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-riscv64.zip" ;;
|
linux-x86) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-32.zip" ;;
|
||||||
*) return 1 ;;
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,8 +426,8 @@ singbox_url_for_rid() {
|
|||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-riscv64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-riscv64.tar.gz" ;;
|
linux-x86) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-386.tar.gz" ;;
|
||||||
*) return 1 ;;
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,8 +435,8 @@ bundle_url_for_rid() {
|
|||||||
local rid="$1"
|
local rid="$1"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-riscv64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip" ;;
|
linux-x86) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-86.zip" ;;
|
||||||
*) return 1 ;;
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +457,7 @@ download_xray() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
||||||
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID for upstream Xray: $rid (skipped)"; return 0; }
|
||||||
|
|
||||||
echo "[+] Download xray: $url"
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
@@ -475,27 +629,38 @@ stage_runtime_assets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe_target() {
|
describe_target() {
|
||||||
local short="$1"
|
printf '%s\n%s\n' "$X86_RID" "$X86_DEB_ARCH"
|
||||||
|
|
||||||
case "$short" in
|
|
||||||
riscv64) printf '%s\n%s\n' "linux-riscv64" "riscv64" ;;
|
|
||||||
*) echo "Unknown arch '$short' (use riscv64)" >&2; return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publish_binary() {
|
publish_binary() {
|
||||||
local rid="$1"
|
local rid="$1"
|
||||||
|
|
||||||
|
patch_x86_sdk
|
||||||
dotnet clean "$PROJECT" -c Release
|
dotnet clean "$PROJECT" -c Release
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
dotnet restore "$PROJECT"
|
|
||||||
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
dotnet restore "$PROJECT" \
|
||||||
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json" \
|
||||||
|
-p:SelfContained=true \
|
||||||
|
-p:EnableWindowsTargeting=true \
|
||||||
|
--force-evaluate
|
||||||
|
|
||||||
|
dotnet publish "$PROJECT" \
|
||||||
|
-c Release \
|
||||||
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json" \
|
||||||
|
-p:PublishSingleFile=false \
|
||||||
|
-p:SelfContained=true \
|
||||||
|
--no-restore
|
||||||
}
|
}
|
||||||
|
|
||||||
write_launcher_file() {
|
write_launcher_file() {
|
||||||
local stage="$1"
|
local stage="$1"
|
||||||
|
|
||||||
install -m 755 /dev/stdin "$stage/usr/bin/v2rayn" <<'EOF'
|
install -m 755 /dev/stdin "$stage/usr/bin/v2rayn" <<'EOF_LAUNCHER'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
DIR="/opt/v2rayN"
|
DIR="/opt/v2rayN"
|
||||||
@@ -514,13 +679,13 @@ done
|
|||||||
echo "v2rayN launcher: no executable found in $DIR" >&2
|
echo "v2rayN launcher: no executable found in $DIR" >&2
|
||||||
ls -l "$DIR" >&2 || true
|
ls -l "$DIR" >&2 || true
|
||||||
exit 1
|
exit 1
|
||||||
EOF
|
EOF_LAUNCHER
|
||||||
}
|
}
|
||||||
|
|
||||||
write_desktop_file() {
|
write_desktop_file() {
|
||||||
local stage="$1"
|
local stage="$1"
|
||||||
|
|
||||||
install -m 644 /dev/stdin "$stage/usr/share/applications/v2rayn.desktop" <<'EOF'
|
install -m 644 /dev/stdin "$stage/usr/share/applications/v2rayn.desktop" <<'EOF_DESKTOP'
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=v2rayN
|
Name=v2rayN
|
||||||
@@ -529,13 +694,13 @@ Exec=v2rayn
|
|||||||
Icon=v2rayn
|
Icon=v2rayn
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Categories=Network;
|
Categories=Network;
|
||||||
EOF
|
EOF_DESKTOP
|
||||||
}
|
}
|
||||||
|
|
||||||
write_maintainer_scripts() {
|
write_maintainer_scripts() {
|
||||||
local debian_dir="$1"
|
local debian_dir="$1"
|
||||||
|
|
||||||
install -m 755 /dev/stdin "$debian_dir/postinst" <<'EOF'
|
install -m 755 /dev/stdin "$debian_dir/postinst" <<'EOF_POSTINST'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
@@ -543,9 +708,9 @@ if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
|||||||
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
EOF
|
EOF_POSTINST
|
||||||
|
|
||||||
install -m 755 /dev/stdin "$debian_dir/postrm" <<'EOF'
|
install -m 755 /dev/stdin "$debian_dir/postrm" <<'EOF_POSTRM'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
@@ -553,7 +718,7 @@ if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
|||||||
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
EOF
|
EOF_POSTRM
|
||||||
}
|
}
|
||||||
|
|
||||||
package_binary() {
|
package_binary() {
|
||||||
@@ -595,10 +760,12 @@ package_binary() {
|
|||||||
write_desktop_file "$stage"
|
write_desktop_file "$stage"
|
||||||
write_maintainer_scripts "$debian_dir"
|
write_maintainer_scripts "$debian_dir"
|
||||||
|
|
||||||
extra_depends="libc6 (>= 2.39), fontconfig (>= 2.15.0), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 9.4), bash (>= 5.2.21), libfreetype6 (>= 2.13)"
|
prepare_deb_target_arch
|
||||||
|
|
||||||
|
extra_depends="libc6 (>= 2.36), fontconfig (>= 2.14.1), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 9.1), bash (>= 5.2.15), libfreetype6 (>= 2.12)"
|
||||||
|
|
||||||
mkdir -p "$workdir/debian"
|
mkdir -p "$workdir/debian"
|
||||||
cat > "$workdir/debian/control" <<EOF
|
cat > "$workdir/debian/control" <<EOF_CONTROL
|
||||||
Source: v2rayn
|
Source: v2rayn
|
||||||
Section: net
|
Section: net
|
||||||
Priority: optional
|
Priority: optional
|
||||||
@@ -608,7 +775,7 @@ Standards-Version: 4.7.0
|
|||||||
Package: v2rayn
|
Package: v2rayn
|
||||||
Architecture: ${deb_arch}
|
Architecture: ${deb_arch}
|
||||||
Description: v2rayN
|
Description: v2rayN
|
||||||
EOF
|
EOF_CONTROL
|
||||||
|
|
||||||
multiarch="$(dpkg-architecture -a"$deb_arch" -qDEB_HOST_MULTIARCH)"
|
multiarch="$(dpkg-architecture -a"$deb_arch" -qDEB_HOST_MULTIARCH)"
|
||||||
sys_libdir="/lib/$multiarch"
|
sys_libdir="/lib/$multiarch"
|
||||||
@@ -629,7 +796,7 @@ EOF
|
|||||||
-l"$sys_usrlibdir" \
|
-l"$sys_usrlibdir" \
|
||||||
-T"$debian_dir/substvars" \
|
-T"$debian_dir/substvars" \
|
||||||
"${ELF_FILES[@]}"
|
"${ELF_FILES[@]}"
|
||||||
) >/dev/null 2>&1 || true
|
) || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
||||||
@@ -644,7 +811,7 @@ EOF
|
|||||||
final_depends="${extra_depends}"
|
final_depends="${extra_depends}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > "$debian_dir/control" <<EOF
|
cat > "$debian_dir/control" <<EOF_CONTROL2
|
||||||
Package: v2rayn
|
Package: v2rayn
|
||||||
Version: ${VERSION}
|
Version: ${VERSION}
|
||||||
Architecture: ${deb_arch}
|
Architecture: ${deb_arch}
|
||||||
@@ -656,7 +823,7 @@ Depends: ${final_depends}
|
|||||||
Description: v2rayN (Avalonia) GUI client for Linux
|
Description: v2rayN (Avalonia) GUI client for Linux
|
||||||
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 /
|
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 /
|
||||||
Shadowsocks / tuic / WireGuard.
|
Shadowsocks / tuic / WireGuard.
|
||||||
EOF
|
EOF_CONTROL2
|
||||||
|
|
||||||
find "$stage/opt/v2rayN" -type d -exec chmod 0755 {} +
|
find "$stage/opt/v2rayN" -type d -exec chmod 0755 {} +
|
||||||
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
||||||
@@ -670,21 +837,13 @@ EOF
|
|||||||
BUILT_DEBS+=("$deb_out")
|
BUILT_DEBS+=("$deb_out")
|
||||||
}
|
}
|
||||||
|
|
||||||
select_targets() {
|
|
||||||
printf '%s\n' riscv64
|
|
||||||
}
|
|
||||||
|
|
||||||
build_one_target() {
|
build_one_target() {
|
||||||
local short="$1"
|
local short="x86"
|
||||||
local meta=()
|
local rid="$X86_RID"
|
||||||
local rid=""
|
local deb_arch="$X86_DEB_ARCH"
|
||||||
local deb_arch=""
|
|
||||||
|
|
||||||
mapfile -t meta < <(describe_target "$short") || return 1
|
|
||||||
rid="${meta[0]}"
|
|
||||||
deb_arch="${meta[1]}"
|
|
||||||
|
|
||||||
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
||||||
|
prepare_dotnet_sdk
|
||||||
publish_binary "$rid"
|
publish_binary "$rid"
|
||||||
package_binary "$short" "$rid" "$deb_arch"
|
package_binary "$short" "$rid" "$deb_arch"
|
||||||
}
|
}
|
||||||
@@ -706,20 +865,17 @@ print_summary() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local targets=()
|
|
||||||
local arch=""
|
|
||||||
|
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
detect_environment
|
detect_environment
|
||||||
install_dependencies
|
install_dependencies
|
||||||
prepare_workspace
|
prepare_workspace
|
||||||
resolve_version
|
resolve_version
|
||||||
|
|
||||||
mapfile -t targets < <(select_targets)
|
download_nuget_packages || die "Failed to download prebuilt NuGet packages."
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
build_one_target
|
||||||
build_one_target "$arch"
|
|
||||||
done
|
rm -rf "${NUGET_CACHE_DIR:-}" || true
|
||||||
|
|
||||||
print_summary
|
print_summary
|
||||||
}
|
}
|
||||||
+269
-47
@@ -14,6 +14,30 @@ PKGROOT="v2rayN-publish"
|
|||||||
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
OUTPUT_DIR="${HOME}/debbuild"
|
OUTPUT_DIR="${HOME}/debbuild"
|
||||||
|
|
||||||
|
NUGET_CACHE_DIR=""
|
||||||
|
DOTNET_NUPKG_BASE="${DOTNET_NUPKG_BASE:-https://github.com/autorepobot/dotnet-nupkg-prebuild/releases/download}"
|
||||||
|
SKIASHARP_BASE="${SKIASHARP_BASE:-https://github.com/autorepobot/SkiaSharp-ppc64le/releases/download}"
|
||||||
|
SkiaSharp_VERSION="${SkiaSharp_VERSION:-3.119.4}"
|
||||||
|
HarfBuzzSharp_VERSION="${HarfBuzzSharp_VERSION:-8.3.1.5}"
|
||||||
|
|
||||||
|
DOTNET_SDK_VERSION="${DOTNET_SDK_VERSION:-10.0.114}"
|
||||||
|
|
||||||
|
DOTNET_RISCV_VERSION="${DOTNET_RISCV_VERSION:-10.0.114}"
|
||||||
|
DOTNET_RISCV_BASE="${DOTNET_RISCV_BASE:-https://github.com/autorepobot/dotnet-riscv/releases/download}"
|
||||||
|
DOTNET_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
||||||
|
DOTNET_RISCV_SDK_URL="${DOTNET_RISCV_SDK_URL:-${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}}"
|
||||||
|
|
||||||
|
DOTNET_PPC64LE_VERSION="${DOTNET_PPC64LE_VERSION:-10.0.114}"
|
||||||
|
DOTNET_PPC64LE_BASE="${DOTNET_PPC64LE_BASE:-https://github.com/IBM/dotnet-s390x/releases/download}"
|
||||||
|
DOTNET_PPC64LE_FILE="dotnet-sdk-${DOTNET_PPC64LE_VERSION}-linux-ppc64le.tar.gz"
|
||||||
|
DOTNET_PPC64LE_SDK_URL="${DOTNET_PPC64LE_SDK_URL:-${DOTNET_PPC64LE_BASE}/v${DOTNET_PPC64LE_VERSION}/${DOTNET_PPC64LE_FILE}}"
|
||||||
|
|
||||||
|
DOTNET_LOONGARCH_VERSION="${DOTNET_LOONGARCH_VERSION:-10.0.114}"
|
||||||
|
DOTNET_LOONGARCH_TAG="${DOTNET_LOONGARCH_TAG:-v10.0.114-loongarch64}"
|
||||||
|
DOTNET_LOONGARCH_BASE="${DOTNET_LOONGARCH_BASE:-https://github.com/loongson/dotnet/releases/download}"
|
||||||
|
DOTNET_LOONGARCH_FILE="dotnet-sdk-${DOTNET_LOONGARCH_VERSION}-linux-loongarch64.tar.gz"
|
||||||
|
DOTNET_LOONGARCH_SDK_URL="${DOTNET_LOONGARCH_SDK_URL:-${DOTNET_LOONGARCH_BASE}/${DOTNET_LOONGARCH_TAG}/${DOTNET_LOONGARCH_FILE}}"
|
||||||
|
|
||||||
OS_ID=""
|
OS_ID=""
|
||||||
OS_NAME=""
|
OS_NAME=""
|
||||||
OS_VERSION_ID=""
|
OS_VERSION_ID=""
|
||||||
@@ -21,6 +45,7 @@ HOST_ARCH=""
|
|||||||
SCRIPT_DIR=""
|
SCRIPT_DIR=""
|
||||||
PROJECT=""
|
PROJECT=""
|
||||||
VERSION=""
|
VERSION=""
|
||||||
|
BUILT_ALL=0
|
||||||
|
|
||||||
declare -a BUILT_DEBS=()
|
declare -a BUILT_DEBS=()
|
||||||
|
|
||||||
@@ -29,6 +54,13 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_runtime_version() {
|
||||||
|
local sdk_ver="$1"
|
||||||
|
local prefix="${sdk_ver%.*}"
|
||||||
|
local patch="${sdk_ver##*.}"
|
||||||
|
echo "${prefix}.${patch#1}"
|
||||||
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
local first_arg="${1:-}"
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
@@ -80,8 +112,8 @@ This script only supports: Debian."
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "$HOST_ARCH" in
|
case "$HOST_ARCH" in
|
||||||
x86_64|aarch64) ;;
|
x86_64|aarch64|riscv64|ppc64le|loongarch64) ;;
|
||||||
*) die "Only supports aarch64 / x86_64" ;;
|
*) die "Only supports x86_64 / aarch64 / riscv64 / ppc64le / loongarch64" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
current_kernel="$(uname -r)"
|
current_kernel="$(uname -r)"
|
||||||
@@ -106,26 +138,38 @@ install_dependencies() {
|
|||||||
case "$HOST_ARCH" in
|
case "$HOST_ARCH" in
|
||||||
aarch64) foreign_arch="amd64" ;;
|
aarch64) foreign_arch="amd64" ;;
|
||||||
x86_64) foreign_arch="arm64" ;;
|
x86_64) foreign_arch="arm64" ;;
|
||||||
*) die "Only supports aarch64 / x86_64" ;;
|
riscv64|ppc64le|loongarch64)
|
||||||
|
foreign_arch=""
|
||||||
|
;;
|
||||||
|
*) die "Only supports x86_64 / aarch64 / riscv64 / ppc64le / loongarch64" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
sudo dpkg --add-architecture "$foreign_arch" || true
|
if [[ -n "$foreign_arch" ]]; then
|
||||||
sudo apt-get update
|
sudo dpkg --add-architecture "$foreign_arch" || true
|
||||||
sudo apt-get -y install \
|
sudo apt-get update
|
||||||
"libc6:${foreign_arch}" \
|
sudo apt-get -y install \
|
||||||
"libgcc-s1:${foreign_arch}" \
|
"libc6:${foreign_arch}" \
|
||||||
"libstdc++6:${foreign_arch}" \
|
"libgcc-s1:${foreign_arch}" \
|
||||||
"zlib1g:${foreign_arch}" \
|
"libstdc++6:${foreign_arch}" \
|
||||||
"libfontconfig1:${foreign_arch}"
|
"zlib1g:${foreign_arch}" \
|
||||||
|
"libfontconfig1:${foreign_arch}"
|
||||||
|
fi
|
||||||
|
|
||||||
wget -q https://dot.net/v1/dotnet-install.sh
|
case "$HOST_ARCH" in
|
||||||
chmod +x dotnet-install.sh
|
x86_64|aarch64)
|
||||||
./dotnet-install.sh --channel 10.0.1xx --install-dir "$HOME/.dotnet"
|
wget -q https://dot.net/v1/dotnet-install.sh
|
||||||
|
chmod +x dotnet-install.sh
|
||||||
|
./dotnet-install.sh --version "$DOTNET_SDK_VERSION" --install-dir "$HOME/.dotnet"
|
||||||
|
|
||||||
export PATH="$HOME/.dotnet:$PATH"
|
export PATH="$HOME/.dotnet:$PATH"
|
||||||
export DOTNET_ROOT="$HOME/.dotnet"
|
export DOTNET_ROOT="$HOME/.dotnet"
|
||||||
|
|
||||||
dotnet --info >/dev/null 2>&1 && install_ok=1
|
dotnet --info >/dev/null 2>&1 && install_ok=1
|
||||||
|
;;
|
||||||
|
riscv64|ppc64le|loongarch64)
|
||||||
|
install_ok=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
@@ -135,6 +179,61 @@ install_dependencies() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_deb_target_arch() {
|
||||||
|
local short="$1"
|
||||||
|
local target_arch=""
|
||||||
|
|
||||||
|
case "$HOST_ARCH:$short" in
|
||||||
|
x86_64:ppc64le|aarch64:ppc64le)
|
||||||
|
target_arch="ppc64el"
|
||||||
|
;;
|
||||||
|
x86_64:riscv64|aarch64:riscv64)
|
||||||
|
target_arch="riscv64"
|
||||||
|
;;
|
||||||
|
x86_64:loong64|aarch64:loong64)
|
||||||
|
target_arch="loong64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "[+] Prepare Debian multiarch environment for $short: $target_arch"
|
||||||
|
|
||||||
|
sudo dpkg --add-architecture "$target_arch" || true
|
||||||
|
|
||||||
|
if [[ "$target_arch" == "loong64" ]]; then
|
||||||
|
echo "[+] Add Loong13 Debian Trixie source for loong64"
|
||||||
|
|
||||||
|
cat <<'EOF' | sudo tee /etc/apt/sources.list.d/loong64-loong13.list >/dev/null
|
||||||
|
deb [arch=loong64] http://loong13.debian.net/debian-loong64/ trixie main contrib non-free non-free-firmware
|
||||||
|
deb [arch=loong64] http://loong13.debian.net/debian-loong64-security/ trixie-security main contrib non-free non-free-firmware
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "[+] Install Loong13 archive keyring"
|
||||||
|
|
||||||
|
tmp_keyring="$(mktemp -d)"
|
||||||
|
curl -fL \
|
||||||
|
"http://loong13.debian.net/debian-loong64/pool/main/d/debian-loong64-non-official-archive-keyring/debian-loong64-non-official-archive-keyring_2025.12.22_all.deb" \
|
||||||
|
-o "$tmp_keyring/loong13-keyring.deb"
|
||||||
|
|
||||||
|
sudo dpkg -i "$tmp_keyring/loong13-keyring.deb"
|
||||||
|
rm -rf "$tmp_keyring"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
|
||||||
|
sudo apt-get -y install \
|
||||||
|
"libc6:${target_arch}" \
|
||||||
|
"libgcc-s1:${target_arch}" \
|
||||||
|
"libstdc++6:${target_arch}" \
|
||||||
|
"zlib1g:${target_arch}" \
|
||||||
|
"libfontconfig1:${target_arch}" \
|
||||||
|
"libfreetype6:${target_arch}"
|
||||||
|
|
||||||
|
echo "[OK] Debian target libraries prepared for $target_arch"
|
||||||
|
}
|
||||||
|
|
||||||
prepare_workspace() {
|
prepare_workspace() {
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
@@ -267,14 +366,115 @@ resolve_version() {
|
|||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
echo "[*] GUI version resolved as: ${VERSION}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download_nuget_packages() {
|
||||||
|
NUGET_CACHE_DIR="$(mktemp -d)"
|
||||||
|
|
||||||
|
local riscv_rt ppc64le_rt loong_rt
|
||||||
|
riscv_rt="$(get_runtime_version "$DOTNET_RISCV_VERSION")"
|
||||||
|
ppc64le_rt="$(get_runtime_version "$DOTNET_PPC64LE_VERSION")"
|
||||||
|
loong_rt="$(get_runtime_version "$DOTNET_LOONGARCH_VERSION")"
|
||||||
|
|
||||||
|
local urls=(
|
||||||
|
"${DOTNET_NUPKG_BASE}/${loong_rt}/Microsoft.AspNetCore.App.Runtime.linux-loongarch64.${loong_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${ppc64le_rt}/Microsoft.AspNetCore.App.Runtime.linux-ppc64le.${ppc64le_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${riscv_rt}/Microsoft.AspNetCore.App.Runtime.linux-riscv64.${riscv_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${loong_rt}/Microsoft.NETCore.App.Host.linux-loongarch64.${loong_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${ppc64le_rt}/Microsoft.NETCore.App.Host.linux-ppc64le.${ppc64le_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${riscv_rt}/Microsoft.NETCore.App.Host.linux-riscv64.${riscv_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${loong_rt}/Microsoft.NETCore.App.Runtime.linux-loongarch64.${loong_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${ppc64le_rt}/Microsoft.NETCore.App.Runtime.linux-ppc64le.${ppc64le_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${riscv_rt}/Microsoft.NETCore.App.Runtime.linux-riscv64.${riscv_rt}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/SkiaSharp.NativeAssets.Linux.${SkiaSharp_VERSION}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/HarfBuzzSharp.NativeAssets.Linux.${HarfBuzzSharp_VERSION}.nupkg"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "[+] Downloading prebuilt NuGet packages to: $NUGET_CACHE_DIR"
|
||||||
|
local u pkg_name
|
||||||
|
for u in "${urls[@]}"; do
|
||||||
|
pkg_name="${u##*/}"
|
||||||
|
echo " -> $pkg_name"
|
||||||
|
curl -fL "$u" -o "$NUGET_CACHE_DIR/$pkg_name" || {
|
||||||
|
echo "[!] Failed to download $u" >&2
|
||||||
|
rm -rf "$NUGET_CACHE_DIR"
|
||||||
|
NUGET_CACHE_DIR=""
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[OK] Prebuilt NuGet packages ready in $NUGET_CACHE_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_dotnet_sdk() {
|
||||||
|
local short="$1"
|
||||||
|
local sdk_url=""
|
||||||
|
local sdk_file=""
|
||||||
|
local sdk_dir=""
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
|
case "$HOST_ARCH:$short" in
|
||||||
|
x86_64:x64|aarch64:arm64)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
riscv64:riscv64)
|
||||||
|
sdk_url="$DOTNET_RISCV_SDK_URL"
|
||||||
|
sdk_file="$DOTNET_RISCV_FILE"
|
||||||
|
;;
|
||||||
|
ppc64le:ppc64le)
|
||||||
|
sdk_url="$DOTNET_PPC64LE_SDK_URL"
|
||||||
|
sdk_file="$DOTNET_PPC64LE_FILE"
|
||||||
|
;;
|
||||||
|
loongarch64:loong64)
|
||||||
|
sdk_url="$DOTNET_LOONGARCH_SDK_URL"
|
||||||
|
sdk_file="$DOTNET_LOONGARCH_FILE"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
sdk_dir="$(mktemp -d)"
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
|
||||||
|
echo "[+] Download .NET SDK for $short: $sdk_url"
|
||||||
|
|
||||||
|
curl -fL "$sdk_url" -o "$tmp/$sdk_file" || {
|
||||||
|
rm -rf "$tmp" "$sdk_dir"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
tar -C "$sdk_dir" -xzf "$tmp/$sdk_file" || {
|
||||||
|
rm -rf "$tmp" "$sdk_dir"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
rm -rf "$tmp"
|
||||||
|
|
||||||
|
[[ -x "$sdk_dir/dotnet" ]] || {
|
||||||
|
rm -rf "$sdk_dir"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export DOTNET_ROOT="$sdk_dir"
|
||||||
|
export PATH="$DOTNET_ROOT:$PATH"
|
||||||
|
hash -r
|
||||||
|
|
||||||
|
echo "[OK] .NET SDK for $short extracted to: $sdk_dir"
|
||||||
|
dotnet --info
|
||||||
|
|
||||||
|
DOTNET_SDK_DIR="$sdk_dir"
|
||||||
|
}
|
||||||
|
|
||||||
xray_url_for_rid() {
|
xray_url_for_rid() {
|
||||||
local rid="$1"
|
local rid="$1"
|
||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-x64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip" ;;
|
linux-x64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip" ;;
|
||||||
linux-arm64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip" ;;
|
linux-arm64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip" ;;
|
||||||
*) return 1 ;;
|
linux-riscv64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-riscv64.zip" ;;
|
||||||
|
linux-ppc64le) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-ppc64le.zip" ;;
|
||||||
|
linux-loongarch64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-loong64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,9 +483,12 @@ singbox_url_for_rid() {
|
|||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-x64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz" ;;
|
linux-x64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz" ;;
|
||||||
linux-arm64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz" ;;
|
linux-arm64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz" ;;
|
||||||
*) return 1 ;;
|
linux-riscv64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-riscv64.tar.gz" ;;
|
||||||
|
linux-ppc64le) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-ppc64le.tar.gz" ;;
|
||||||
|
linux-loongarch64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-loong64.tar.gz" ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,9 +496,12 @@ bundle_url_for_rid() {
|
|||||||
local rid="$1"
|
local rid="$1"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-x64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip" ;;
|
linux-x64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip" ;;
|
||||||
linux-arm64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip" ;;
|
linux-arm64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip" ;;
|
||||||
*) return 1 ;;
|
linux-riscv64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip" ;;
|
||||||
|
linux-ppc64le) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-ppc64le.zip" ;;
|
||||||
|
linux-loongarch64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-loong64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +522,7 @@ download_xray() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
||||||
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID for upstream Xray: $rid (skipped)"; return 0; }
|
||||||
|
|
||||||
echo "[+] Download xray: $url"
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
@@ -476,7 +682,7 @@ stage_runtime_assets() {
|
|||||||
|
|
||||||
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
||||||
if populate_assets_zip_mode "$outroot" "$rid"; then
|
if populate_assets_zip_mode "$outroot" "$rid"; then
|
||||||
echo "[*] Using v2rayN bundle bin assets."
|
echo "[*] Using v2rayN bundle archive."
|
||||||
else
|
else
|
||||||
echo "[*] Bundle failed, fallback to separate core + rules."
|
echo "[*] Bundle failed, fallback to separate core + rules."
|
||||||
populate_assets_netcore_mode "$outroot" "$rid"
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
@@ -491,9 +697,12 @@ describe_target() {
|
|||||||
local short="$1"
|
local short="$1"
|
||||||
|
|
||||||
case "$short" in
|
case "$short" in
|
||||||
x64) printf '%s\n%s\n' "linux-x64" "amd64" ;;
|
x64) printf '%s\n%s\n' "linux-x64" "amd64" ;;
|
||||||
arm64) printf '%s\n%s\n' "linux-arm64" "arm64" ;;
|
arm64) printf '%s\n%s\n' "linux-arm64" "arm64" ;;
|
||||||
*) echo "Unknown arch '$short' (use x64|arm64)" >&2; return 1 ;;
|
riscv64) printf '%s\n%s\n' "linux-riscv64" "riscv64" ;;
|
||||||
|
ppc64le) printf '%s\n%s\n' "linux-ppc64le" "ppc64el" ;;
|
||||||
|
loong64) printf '%s\n%s\n' "linux-loongarch64" "loong64" ;;
|
||||||
|
*) echo "Unknown arch '$short' (use x64|arm64|riscv64|ppc64le|loong64)" >&2; return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,8 +711,18 @@ publish_binary() {
|
|||||||
|
|
||||||
dotnet clean "$PROJECT" -c Release
|
dotnet clean "$PROJECT" -c Release
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
dotnet restore "$PROJECT"
|
dotnet restore "$PROJECT" \
|
||||||
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json"
|
||||||
|
dotnet publish "$PROJECT" \
|
||||||
|
-c Release \
|
||||||
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json" \
|
||||||
|
-p:PublishSingleFile=false \
|
||||||
|
-p:SelfContained=true \
|
||||||
|
--no-restore
|
||||||
}
|
}
|
||||||
|
|
||||||
write_launcher_file() {
|
write_launcher_file() {
|
||||||
@@ -609,6 +828,8 @@ package_binary() {
|
|||||||
write_desktop_file "$stage"
|
write_desktop_file "$stage"
|
||||||
write_maintainer_scripts "$debian_dir"
|
write_maintainer_scripts "$debian_dir"
|
||||||
|
|
||||||
|
prepare_deb_target_arch "$short"
|
||||||
|
|
||||||
extra_depends="libc6 (>= 2.39), fontconfig (>= 2.15.0), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 9.4), bash (>= 5.2.21), libfreetype6 (>= 2.13)"
|
extra_depends="libc6 (>= 2.39), fontconfig (>= 2.15.0), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 9.4), bash (>= 5.2.21), libfreetype6 (>= 2.13)"
|
||||||
|
|
||||||
mkdir -p "$workdir/debian"
|
mkdir -p "$workdir/debian"
|
||||||
@@ -643,7 +864,7 @@ EOF
|
|||||||
-l"$sys_usrlibdir" \
|
-l"$sys_usrlibdir" \
|
||||||
-T"$debian_dir/substvars" \
|
-T"$debian_dir/substvars" \
|
||||||
"${ELF_FILES[@]}"
|
"${ELF_FILES[@]}"
|
||||||
) >/dev/null 2>&1 || true
|
) || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
||||||
@@ -676,15 +897,6 @@ EOF
|
|||||||
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
||||||
[[ -f "$stage/opt/v2rayN/v2rayN" ]] && chmod 0755 "$stage/opt/v2rayN/v2rayN" || true
|
[[ -f "$stage/opt/v2rayN/v2rayN" ]] && chmod 0755 "$stage/opt/v2rayN/v2rayN" || true
|
||||||
|
|
||||||
# Core binaries must be executable before installation: ordinary users cannot
|
|
||||||
# chmod the root-owned files installed by dpkg.
|
|
||||||
local core
|
|
||||||
for core in xray/xray sing_box/sing-box mihomo/mihomo; do
|
|
||||||
if [[ -f "$stage/opt/v2rayN/bin/$core" ]]; then
|
|
||||||
chmod 0755 "$stage/opt/v2rayN/bin/$core"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
deb_out="$OUTPUT_DIR/v2rayn_${VERSION}_${deb_arch}.deb"
|
deb_out="$OUTPUT_DIR/v2rayn_${VERSION}_${deb_arch}.deb"
|
||||||
dpkg-deb --root-owner-group --build "$stage" "$deb_out"
|
dpkg-deb --root-owner-group --build "$stage" "$deb_out"
|
||||||
|
|
||||||
@@ -695,9 +907,12 @@ EOF
|
|||||||
|
|
||||||
select_targets() {
|
select_targets() {
|
||||||
case "${ARCH_OVERRIDE:-}" in
|
case "${ARCH_OVERRIDE:-}" in
|
||||||
all) printf '%s\n' x64 arm64 ;;
|
all) printf '%s\n' x64 arm64 riscv64 ppc64le loong64 ;;
|
||||||
x64|amd64) printf '%s\n' x64 ;;
|
x64|amd64) printf '%s\n' x64 ;;
|
||||||
arm64|aarch64) printf '%s\n' arm64 ;;
|
arm64|aarch64) printf '%s\n' arm64 ;;
|
||||||
|
riscv64) printf '%s\n' riscv64 ;;
|
||||||
|
ppc64le|ppc64el) printf '%s\n' ppc64le ;;
|
||||||
|
loong64|loongarch64) printf '%s\n' loong64 ;;
|
||||||
"")
|
"")
|
||||||
case "$HOST_ARCH" in
|
case "$HOST_ARCH" in
|
||||||
x86_64) printf '%s\n' x64 ;;
|
x86_64) printf '%s\n' x64 ;;
|
||||||
@@ -706,7 +921,7 @@ select_targets() {
|
|||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|all." >&2
|
echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|riscv64|ppc64le|loong64|all." >&2
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -723,6 +938,7 @@ build_one_target() {
|
|||||||
deb_arch="${meta[1]}"
|
deb_arch="${meta[1]}"
|
||||||
|
|
||||||
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
||||||
|
prepare_dotnet_sdk "$short" || die "Failed to prepare .NET SDK for $short."
|
||||||
publish_binary "$rid"
|
publish_binary "$rid"
|
||||||
package_binary "$short" "$rid" "$deb_arch"
|
package_binary "$short" "$rid" "$deb_arch"
|
||||||
}
|
}
|
||||||
@@ -753,12 +969,18 @@ main() {
|
|||||||
prepare_workspace
|
prepare_workspace
|
||||||
resolve_version
|
resolve_version
|
||||||
|
|
||||||
|
download_nuget_packages || die "Failed to download prebuilt NuGet packages."
|
||||||
|
|
||||||
mapfile -t targets < <(select_targets)
|
mapfile -t targets < <(select_targets)
|
||||||
|
[[ "${ARCH_OVERRIDE:-}" == "all" ]] && BUILT_ALL=1 || BUILT_ALL=0
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
for arch in "${targets[@]}"; do
|
||||||
build_one_target "$arch"
|
build_one_target "$arch"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
rm -rf "${NUGET_CACHE_DIR:-}" || true
|
||||||
|
rm -rf "${DOTNET_SDK_DIR:-}" || true
|
||||||
|
|
||||||
print_summary
|
print_summary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,698 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
VERSION_ARG=""
|
|
||||||
WITH_CORE="both"
|
|
||||||
FORCE_NETCORE=0
|
|
||||||
BUILD_FROM=""
|
|
||||||
XRAY_VER="${XRAY_VER:-}"
|
|
||||||
SING_VER="${SING_VER:-}"
|
|
||||||
|
|
||||||
MIN_KERNEL="6.12"
|
|
||||||
PKGROOT="v2rayN-publish"
|
|
||||||
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
|
||||||
RPM_TOPDIR="${HOME}/rpmbuild"
|
|
||||||
DOTNET_LOONGARCH_VERSION="10.0.111"
|
|
||||||
DOTNET_LOONGARCH_TAG="v10.0.111-loongarch64"
|
|
||||||
DOTNET_LOONGARCH_BASE="https://github.com/loongson/dotnet/releases/download"
|
|
||||||
DOTNET_LOONGARCH_FILE="dotnet-sdk-${DOTNET_LOONGARCH_VERSION}-linux-loongarch64.tar.gz"
|
|
||||||
DOTNET_SDK_URL="${DOTNET_LOONGARCH_BASE}/${DOTNET_LOONGARCH_TAG}/${DOTNET_LOONGARCH_FILE}"
|
|
||||||
|
|
||||||
OS_ID=""
|
|
||||||
OS_NAME=""
|
|
||||||
OS_VERSION_ID=""
|
|
||||||
HOST_ARCH=""
|
|
||||||
SCRIPT_DIR=""
|
|
||||||
PROJECT=""
|
|
||||||
VERSION=""
|
|
||||||
|
|
||||||
declare -a BUILT_RPMS=()
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo "$*" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_args() {
|
|
||||||
local first_arg="${1:-}"
|
|
||||||
|
|
||||||
if [[ -n "$first_arg" && "$first_arg" != --* ]]; then
|
|
||||||
VERSION_ARG="$first_arg"
|
|
||||||
shift || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case "$1" in
|
|
||||||
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
|
||||||
--xray-ver) XRAY_VER="${2:-}"; shift 2 ;;
|
|
||||||
--singbox-ver) SING_VER="${2:-}"; shift 2 ;;
|
|
||||||
--netcore) FORCE_NETCORE=1; shift ;;
|
|
||||||
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
|
||||||
*)
|
|
||||||
[[ -n "${VERSION_ARG:-}" ]] || VERSION_ARG="$1"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
|
||||||
die "You cannot specify both an explicit version and --buildfrom at the same time.
|
|
||||||
Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
detect_environment() {
|
|
||||||
local current_kernel=""
|
|
||||||
local lowest=""
|
|
||||||
|
|
||||||
. /etc/os-release
|
|
||||||
|
|
||||||
OS_ID="${ID:-}"
|
|
||||||
OS_NAME="${NAME:-$OS_ID}"
|
|
||||||
OS_VERSION_ID="${VERSION_ID:-}"
|
|
||||||
HOST_ARCH="$(uname -m)"
|
|
||||||
|
|
||||||
case "$OS_ID" in
|
|
||||||
rhel|rocky|almalinux|fedora|centos|anolis)
|
|
||||||
echo "Detected supported system: ${OS_NAME:-$OS_ID} ${OS_VERSION_ID:-}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "Unsupported system: ${OS_NAME:-unknown} (${OS_ID:-unknown}).
|
|
||||||
This script only supports: RHEL / Rocky / AlmaLinux / Fedora / CentOS / Anolis OS."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$HOST_ARCH" in
|
|
||||||
loongarch64) ;;
|
|
||||||
*) die "Only supports loongarch64" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
current_kernel="$(uname -r)"
|
|
||||||
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$current_kernel" | sort -V | head -n1)"
|
|
||||||
|
|
||||||
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
|
||||||
echo "[OK] Kernel $current_kernel verified."
|
|
||||||
}
|
|
||||||
|
|
||||||
install_dependencies() {
|
|
||||||
local install_ok=0
|
|
||||||
local tmp_dotnet=""
|
|
||||||
|
|
||||||
if command -v dnf >/dev/null 2>&1; then
|
|
||||||
sudo dnf -y --nogpgcheck install \
|
|
||||||
rpm-build rpmdevtools curl unzip tar jq rsync git python3 \
|
|
||||||
glibc-devel kernel-headers libatomic file ca-certificates libicu \
|
|
||||||
&& install_ok=1
|
|
||||||
|
|
||||||
mkdir -p "$HOME/.dotnet"
|
|
||||||
tmp_dotnet="$(mktemp -d)"
|
|
||||||
curl -fL "$DOTNET_SDK_URL" -o "$tmp_dotnet/$DOTNET_LOONGARCH_FILE"
|
|
||||||
tar -C "$HOME/.dotnet" -xzf "$tmp_dotnet/$DOTNET_LOONGARCH_FILE"
|
|
||||||
rm -rf "$tmp_dotnet"
|
|
||||||
|
|
||||||
export PATH="$HOME/.dotnet:$PATH"
|
|
||||||
export DOTNET_ROOT="$HOME/.dotnet"
|
|
||||||
|
|
||||||
dotnet --info >/dev/null 2>&1 || install_ok=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
|
||||||
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
|
||||||
echo "dotnet-loongarch SDK, curl, unzip, tar, rsync, git, python3, rpm, rpmdevtools, rpm-build (on Red Hat branch)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_workspace() {
|
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
cd "$SCRIPT_DIR"
|
|
||||||
|
|
||||||
if [[ -f .gitmodules ]]; then
|
|
||||||
git submodule sync --recursive || true
|
|
||||||
git submodule update --init --recursive || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
PROJECT="$PROJECT_HINT"
|
|
||||||
[[ -f "$PROJECT" ]] || PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
|
||||||
[[ -f "$PROJECT" ]] || die "v2rayN.Desktop.csproj not found"
|
|
||||||
}
|
|
||||||
|
|
||||||
choose_channel() {
|
|
||||||
local ch="latest"
|
|
||||||
local sel=""
|
|
||||||
|
|
||||||
if [[ -n "${BUILD_FROM:-}" ]]; then
|
|
||||||
case "$BUILD_FROM" in
|
|
||||||
1) echo "latest"; return 0 ;;
|
|
||||||
2) echo "prerelease"; return 0 ;;
|
|
||||||
3) echo "keep"; return 0 ;;
|
|
||||||
*) die "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -t 0 ]]; then
|
|
||||||
echo "[?] Choose v2rayN release channel:" >&2
|
|
||||||
echo " 1) Latest (stable) [default]" >&2
|
|
||||||
echo " 2) Pre-release (preview)" >&2
|
|
||||||
echo " 3) Keep current (do nothing)" >&2
|
|
||||||
printf "Enter 1, 2 or 3 [default 1]: " >&2
|
|
||||||
|
|
||||||
if read -r sel </dev/tty; then
|
|
||||||
case "${sel:-}" in
|
|
||||||
2) ch="prerelease" ;;
|
|
||||||
3) ch="keep" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$ch"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_latest_tag_latest() {
|
|
||||||
curl -fsSL "https://api.github.com/repos/2dust/v2rayN/releases/latest" \
|
|
||||||
| jq -re '.tag_name' \
|
|
||||||
| sed 's/^v//'
|
|
||||||
}
|
|
||||||
|
|
||||||
get_latest_tag_prerelease() {
|
|
||||||
curl -fsSL "https://api.github.com/repos/2dust/v2rayN/releases?per_page=20" \
|
|
||||||
| jq -re 'first(.[] | select(.prerelease == true) | .tag_name)' \
|
|
||||||
| sed 's/^v//'
|
|
||||||
}
|
|
||||||
|
|
||||||
sync_submodules() {
|
|
||||||
if [[ -f .gitmodules ]]; then
|
|
||||||
git submodule sync --recursive || true
|
|
||||||
git submodule update --init --recursive || true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
git_try_checkout() {
|
|
||||||
local want="$1"
|
|
||||||
local ref=""
|
|
||||||
|
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
||||||
git fetch --tags --force --prune --depth=1 || true
|
|
||||||
git rev-parse "refs/tags/${want}" >/dev/null 2>&1 && ref="$want"
|
|
||||||
|
|
||||||
if [[ -n "$ref" ]]; then
|
|
||||||
echo "[OK] Found ref '${ref}', checking out..."
|
|
||||||
git checkout -f "$ref"
|
|
||||||
sync_submodules
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
apply_channel_or_keep() {
|
|
||||||
local ch="$1"
|
|
||||||
local tag=""
|
|
||||||
|
|
||||||
if [[ "$ch" == "keep" ]]; then
|
|
||||||
echo "[*] Keep current repository state (no checkout)."
|
|
||||||
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo '0.0.0+git')"
|
|
||||||
VERSION="${VERSION#v}"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
git remote add upstream https://github.com/2dust/v2rayN || true
|
|
||||||
git fetch upstream
|
|
||||||
|
|
||||||
echo "[*] Resolving ${ch} tag from GitHub releases..."
|
|
||||||
|
|
||||||
case "$ch" in
|
|
||||||
latest) tag="$(get_latest_tag_latest || true)" ;;
|
|
||||||
prerelease) tag="$(get_latest_tag_prerelease || true)" ;;
|
|
||||||
*) die "Failed to resolve latest tag for channel '${ch}'." ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
[[ -n "$tag" ]] || die "Failed to resolve latest tag for channel '${ch}'."
|
|
||||||
|
|
||||||
echo "[*] Latest tag for '${ch}': ${tag}"
|
|
||||||
git_try_checkout "$tag" || die "Failed to checkout '${tag}'."
|
|
||||||
VERSION="${tag#v}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve_version() {
|
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
||||||
if [[ -n "${VERSION_ARG:-}" ]]; then
|
|
||||||
local clean_ver="${VERSION_ARG#v}"
|
|
||||||
|
|
||||||
if git_try_checkout "$clean_ver"; then
|
|
||||||
VERSION="$clean_ver"
|
|
||||||
else
|
|
||||||
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
|
||||||
apply_channel_or_keep "$(choose_channel)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
apply_channel_or_keep "$(choose_channel)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Current directory is not a git repo; proceeding on current tree."
|
|
||||||
VERSION="${VERSION_ARG:-0.0.0}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
VERSION="${VERSION#v}"
|
|
||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
|
||||||
}
|
|
||||||
|
|
||||||
xray_url_for_rid() {
|
|
||||||
local rid="$1"
|
|
||||||
local ver="$2"
|
|
||||||
|
|
||||||
case "$rid" in
|
|
||||||
linux-loongarch64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-loong64.zip" ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
singbox_url_for_rid() {
|
|
||||||
local rid="$1"
|
|
||||||
local ver="$2"
|
|
||||||
|
|
||||||
case "$rid" in
|
|
||||||
linux-loongarch64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-loong64.tar.gz" ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
bundle_url_for_rid() {
|
|
||||||
local rid="$1"
|
|
||||||
|
|
||||||
case "$rid" in
|
|
||||||
linux-loongarch64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-loong64.zip" ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
download_xray() {
|
|
||||||
local outdir="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local ver="${XRAY_VER:-}"
|
|
||||||
local url=""
|
|
||||||
local tmp=""
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest \
|
|
||||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
|
||||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
|
||||||
| head -n1)" || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
|
||||||
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
|
||||||
|
|
||||||
echo "[+] Download xray: $url"
|
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
|
||||||
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
|
||||||
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
|
||||||
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
|
||||||
rm -rf "$tmp"
|
|
||||||
}
|
|
||||||
|
|
||||||
download_singbox() {
|
|
||||||
local outdir="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local ver="${SING_VER:-}"
|
|
||||||
local url=""
|
|
||||||
local tmp=""
|
|
||||||
local bin=""
|
|
||||||
local cronet=""
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
|
||||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
|
||||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
|
||||||
| head -n1)" || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
|
||||||
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
|
||||||
|
|
||||||
echo "[+] Download sing-box: $url"
|
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
|
||||||
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
|
||||||
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
|
||||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
install -m 755 "$bin" "$outdir/sing-box" || { rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
|
||||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
|
||||||
|
|
||||||
rm -rf "$tmp"
|
|
||||||
}
|
|
||||||
|
|
||||||
unify_geo_layout() {
|
|
||||||
local outroot="$1"
|
|
||||||
local n
|
|
||||||
local names=(
|
|
||||||
geosite.dat
|
|
||||||
geoip.dat
|
|
||||||
geoip-only-cn-private.dat
|
|
||||||
Country.mmdb
|
|
||||||
geoip.metadb
|
|
||||||
)
|
|
||||||
|
|
||||||
mkdir -p "$outroot/bin"
|
|
||||||
|
|
||||||
for n in "${names[@]}"; do
|
|
||||||
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
|
||||||
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
download_geo_assets() {
|
|
||||||
local outroot="$1"
|
|
||||||
local bin_dir="$outroot/bin"
|
|
||||||
local srss_dir="$bin_dir/srss"
|
|
||||||
local f=""
|
|
||||||
|
|
||||||
mkdir -p "$bin_dir" "$srss_dir"
|
|
||||||
|
|
||||||
echo "[+] Download Xray Geo to ${bin_dir}"
|
|
||||||
curl -fsSL -o "$bin_dir/geosite.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geosite.dat"
|
|
||||||
curl -fsSL -o "$bin_dir/geoip.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
|
||||||
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
|
||||||
curl -fsSL -o "$bin_dir/Country.mmdb" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
|
||||||
|
|
||||||
echo "[+] Download sing-box rule DB & rule-sets"
|
|
||||||
curl -fsSL -o "$bin_dir/geoip.metadb" "https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb"
|
|
||||||
|
|
||||||
for f in geoip-private.srs geoip-cn.srs geoip-facebook.srs geoip-fastly.srs geoip-google.srs geoip-netflix.srs geoip-telegram.srs geoip-twitter.srs; do
|
|
||||||
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geoip/$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
for f in geosite-cn.srs geosite-gfw.srs geosite-google.srs geosite-greatfire.srs geosite-geolocation-cn.srs geosite-category-ads-all.srs geosite-private.srs; do
|
|
||||||
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geosite/$f"
|
|
||||||
done
|
|
||||||
|
|
||||||
unify_geo_layout "$outroot"
|
|
||||||
}
|
|
||||||
|
|
||||||
populate_assets_zip_mode() {
|
|
||||||
local outroot="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local url=""
|
|
||||||
local tmp=""
|
|
||||||
local nested_dir=""
|
|
||||||
|
|
||||||
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
|
||||||
|
|
||||||
echo "[+] Try v2rayN bundle archive: $url"
|
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
|
||||||
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
|
||||||
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; return 1; }
|
|
||||||
|
|
||||||
if [[ -d "$tmp/bin" ]]; then
|
|
||||||
mkdir -p "$outroot/bin"
|
|
||||||
rsync -a "$tmp/bin/" "$outroot/bin/"
|
|
||||||
else
|
|
||||||
rsync -a "$tmp/" "$outroot/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
|
||||||
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 2>/dev/null || true
|
|
||||||
|
|
||||||
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
|
||||||
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
|
||||||
mkdir -p "$outroot/bin"
|
|
||||||
rsync -a "$nested_dir/bin/" "$outroot/bin/"
|
|
||||||
rm -rf "$nested_dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
unify_geo_layout "$outroot"
|
|
||||||
rm -rf "$tmp"
|
|
||||||
|
|
||||||
echo "[+] Bundle extracted to $outroot"
|
|
||||||
}
|
|
||||||
|
|
||||||
populate_assets_netcore_mode() {
|
|
||||||
local outroot="$1"
|
|
||||||
local rid="$2"
|
|
||||||
|
|
||||||
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
|
||||||
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
|
||||||
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
|
||||||
}
|
|
||||||
|
|
||||||
stage_runtime_assets() {
|
|
||||||
local outroot="$1"
|
|
||||||
local rid="$2"
|
|
||||||
|
|
||||||
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
|
||||||
|
|
||||||
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
|
||||||
if populate_assets_zip_mode "$outroot" "$rid"; then
|
|
||||||
echo "[*] Using v2rayN bundle archive."
|
|
||||||
else
|
|
||||||
echo "[*] Bundle failed, fallback to separate core + rules."
|
|
||||||
populate_assets_netcore_mode "$outroot" "$rid"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "[*] --netcore specified: use separate core + rules."
|
|
||||||
populate_assets_netcore_mode "$outroot" "$rid"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
describe_target() {
|
|
||||||
local short="$1"
|
|
||||||
|
|
||||||
case "$short" in
|
|
||||||
loongarch64) printf '%s\n%s\n%s\n' "linux-loongarch64" "loongarch64" "loongarch64" ;;
|
|
||||||
*) echo "Unknown arch '$short' (use loongarch64)" >&2; return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
publish_binary() {
|
|
||||||
local rid="$1"
|
|
||||||
|
|
||||||
dotnet clean "$PROJECT" -c Release
|
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
|
||||||
dotnet restore "$PROJECT"
|
|
||||||
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
|
||||||
}
|
|
||||||
|
|
||||||
write_spec_file() {
|
|
||||||
local specfile="$1"
|
|
||||||
|
|
||||||
cat > "$specfile" <<'SPEC'
|
|
||||||
%global debug_package %{nil}
|
|
||||||
%undefine _debuginfo_subpackages
|
|
||||||
%undefine _debugsource_packages
|
|
||||||
%global __requires_exclude ^liblttng-ust\.so\..*$
|
|
||||||
|
|
||||||
Name: v2rayN
|
|
||||||
Version: __VERSION__
|
|
||||||
Release: 1%{?dist}
|
|
||||||
Summary: v2rayN (Avalonia) GUI client for Linux
|
|
||||||
License: GPL-3.0-only
|
|
||||||
URL: https://github.com/2dust/v2rayN
|
|
||||||
BugURL: https://github.com/2dust/v2rayN/issues
|
|
||||||
ExclusiveArch: loongarch64
|
|
||||||
Source0: __PKGROOT__.tar.gz
|
|
||||||
|
|
||||||
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
|
||||||
Requires: glibc >= 2.39
|
|
||||||
Requires: fontconfig >= 2.15.0
|
|
||||||
Requires: desktop-file-utils >= 0.26
|
|
||||||
Requires: xdg-utils >= 1.1.3
|
|
||||||
Requires: coreutils >= 9.4
|
|
||||||
Requires: bash >= 5.2.21
|
|
||||||
Requires: freetype >= 2.13
|
|
||||||
|
|
||||||
%description
|
|
||||||
v2rayN Linux for Red Hat Enterprise Linux
|
|
||||||
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 / Shadowsocks / tuic / WireGuard
|
|
||||||
Support Red Hat Enterprise Linux / Fedora Linux / Rocky Linux / AlmaLinux / CentOS / Anolis OS
|
|
||||||
For more information, Please visit our website
|
|
||||||
https://github.com/2dust/v2rayN
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup -q -n __PKGROOT__
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
%install
|
|
||||||
install -dm0755 %{buildroot}/opt/v2rayN
|
|
||||||
cp -a * %{buildroot}/opt/v2rayN/
|
|
||||||
|
|
||||||
find %{buildroot}/opt/v2rayN -type d -exec chmod 0755 {} +
|
|
||||||
find %{buildroot}/opt/v2rayN -type f -exec chmod 0644 {} +
|
|
||||||
[ -f %{buildroot}/opt/v2rayN/v2rayN ] && chmod 0755 %{buildroot}/opt/v2rayN/v2rayN || :
|
|
||||||
|
|
||||||
install -dm0755 %{buildroot}%{_bindir}
|
|
||||||
install -m0755 /dev/stdin %{buildroot}%{_bindir}/v2rayn << 'EOF'
|
|
||||||
#!/usr/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
DIR="/opt/v2rayN"
|
|
||||||
|
|
||||||
if [[ -x "$DIR/v2rayN" ]]; then exec "$DIR/v2rayN" "$@"; fi
|
|
||||||
|
|
||||||
for dll in v2rayN.Desktop.dll v2rayN.dll; do
|
|
||||||
if [[ -f "$DIR/$dll" ]]; then exec /usr/bin/dotnet "$DIR/$dll" "$@"; fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "v2rayN launcher: no executable found in $DIR" >&2
|
|
||||||
ls -l "$DIR" >&2 || true
|
|
||||||
exit 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
install -dm0755 %{buildroot}%{_datadir}/applications
|
|
||||||
install -m0644 /dev/stdin %{buildroot}%{_datadir}/applications/v2rayn.desktop << 'EOF'
|
|
||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=v2rayN
|
|
||||||
Comment=v2rayN for Red Hat Enterprise Linux
|
|
||||||
Exec=v2rayn
|
|
||||||
Icon=v2rayn
|
|
||||||
Terminal=false
|
|
||||||
Categories=Network;
|
|
||||||
EOF
|
|
||||||
|
|
||||||
install -dm0755 %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
|
|
||||||
install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
|
||||||
|
|
||||||
%post
|
|
||||||
/usr/bin/update-desktop-database %{_datadir}/applications >/dev/null 2>&1 || true
|
|
||||||
/usr/bin/gtk-update-icon-cache -f %{_datadir}/icons/hicolor >/dev/null 2>&1 || true
|
|
||||||
|
|
||||||
%postun
|
|
||||||
/usr/bin/update-desktop-database %{_datadir}/applications >/dev/null 2>&1 || true
|
|
||||||
/usr/bin/gtk-update-icon-cache -f %{_datadir}/icons/hicolor >/dev/null 2>&1 || true
|
|
||||||
|
|
||||||
%files
|
|
||||||
%{_bindir}/v2rayn
|
|
||||||
/opt/v2rayN
|
|
||||||
%{_datadir}/applications/v2rayn.desktop
|
|
||||||
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
|
||||||
SPEC
|
|
||||||
|
|
||||||
sed -i "s/__VERSION__/${VERSION}/g" "$specfile"
|
|
||||||
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$specfile"
|
|
||||||
}
|
|
||||||
|
|
||||||
package_binary() {
|
|
||||||
local short="$1"
|
|
||||||
local rid="$2"
|
|
||||||
local rpm_target="$3"
|
|
||||||
local archdir="$4"
|
|
||||||
local pubdir=""
|
|
||||||
local workdir=""
|
|
||||||
local specfile=""
|
|
||||||
local sourcedir=""
|
|
||||||
local specdir=""
|
|
||||||
local project_dir=""
|
|
||||||
local icon_candidate=""
|
|
||||||
local f=""
|
|
||||||
|
|
||||||
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
|
||||||
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
|
||||||
|
|
||||||
workdir="$(mktemp -d)"
|
|
||||||
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
|
||||||
|
|
||||||
mkdir -p "$workdir/$PKGROOT"
|
|
||||||
cp -a "$pubdir/." "$workdir/$PKGROOT/"
|
|
||||||
|
|
||||||
project_dir="$(cd "$(dirname "$PROJECT")" && pwd)"
|
|
||||||
icon_candidate="$project_dir/v2rayN.png"
|
|
||||||
[[ -f "$icon_candidate" ]] || { echo "Required icon not found: $icon_candidate"; return 1; }
|
|
||||||
cp "$icon_candidate" "$workdir/$PKGROOT/v2rayn.png"
|
|
||||||
|
|
||||||
stage_runtime_assets "$workdir/$PKGROOT" "$rid"
|
|
||||||
|
|
||||||
rpmdev-setuptree
|
|
||||||
sourcedir="${RPM_TOPDIR}/SOURCES"
|
|
||||||
specdir="${RPM_TOPDIR}/SPECS"
|
|
||||||
specfile="${specdir}/v2rayN.spec"
|
|
||||||
|
|
||||||
mkdir -p "$sourcedir" "$specdir"
|
|
||||||
tar -C "$workdir" -czf "$sourcedir/$PKGROOT.tar.gz" "$PKGROOT"
|
|
||||||
|
|
||||||
write_spec_file "$specfile"
|
|
||||||
rpmbuild -ba "$specfile" --target "$rpm_target"
|
|
||||||
|
|
||||||
echo "Build done for $short. RPM at:"
|
|
||||||
for f in "${RPM_TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
|
||||||
[[ -e "$f" ]] || continue
|
|
||||||
echo " $f"
|
|
||||||
BUILT_RPMS+=("$f")
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
select_targets() {
|
|
||||||
printf '%s\n' loongarch64
|
|
||||||
}
|
|
||||||
|
|
||||||
build_one_target() {
|
|
||||||
local short="$1"
|
|
||||||
local meta=()
|
|
||||||
local rid=""
|
|
||||||
local rpm_target=""
|
|
||||||
local archdir=""
|
|
||||||
|
|
||||||
mapfile -t meta < <(describe_target "$short") || return 1
|
|
||||||
rid="${meta[0]}"
|
|
||||||
rpm_target="${meta[1]}"
|
|
||||||
archdir="${meta[2]}"
|
|
||||||
|
|
||||||
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
|
||||||
publish_binary "$rid"
|
|
||||||
package_binary "$short" "$rid" "$rpm_target" "$archdir"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_summary() {
|
|
||||||
local rp=""
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "================ Build Summary ================"
|
|
||||||
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
|
||||||
for rp in "${BUILT_RPMS[@]}"; do
|
|
||||||
echo "$rp"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "No RPMs detected in summary (check build logs above)."
|
|
||||||
fi
|
|
||||||
echo "=============================================="
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local targets=()
|
|
||||||
local arch=""
|
|
||||||
|
|
||||||
parse_args "$@"
|
|
||||||
detect_environment
|
|
||||||
install_dependencies
|
|
||||||
prepare_workspace
|
|
||||||
resolve_version
|
|
||||||
|
|
||||||
mapfile -t targets < <(select_targets)
|
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
|
||||||
build_one_target "$arch"
|
|
||||||
done
|
|
||||||
|
|
||||||
print_summary
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
Executable → Regular
+397
-87
@@ -8,14 +8,19 @@ BUILD_FROM=""
|
|||||||
XRAY_VER="${XRAY_VER:-}"
|
XRAY_VER="${XRAY_VER:-}"
|
||||||
SING_VER="${SING_VER:-}"
|
SING_VER="${SING_VER:-}"
|
||||||
|
|
||||||
MIN_KERNEL="5.10"
|
MIN_KERNEL="6.12"
|
||||||
PKGROOT="v2rayN-publish"
|
PKGROOT="v2rayN-publish"
|
||||||
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
RPM_TOPDIR="${HOME}/rpmbuild"
|
RPM_TOPDIR="${HOME}/rpmbuild"
|
||||||
DOTNET_RISCV_VERSION="10.0.111"
|
|
||||||
DOTNET_RISCV_BASE="https://github.com/xujiegb/dotnet-riscv/releases/download"
|
NUGET_CACHE_DIR=""
|
||||||
DOTNET_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
DOTNET_NUPKG_BASE="${DOTNET_NUPKG_BASE:-https://github.com/autorepobot/dotnet-nupkg-prebuild/releases/download}"
|
||||||
DOTNET_SDK_URL="${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}"
|
SKIASHARP_BASE="${SKIASHARP_BASE:-https://github.com/autorepobot/SkiaSharp-ppc64le/releases/download}"
|
||||||
|
SkiaSharp_VERSION="${SkiaSharp_VERSION:-3.119.4}"
|
||||||
|
HarfBuzzSharp_VERSION="${HarfBuzzSharp_VERSION:-8.3.1.5}"
|
||||||
|
|
||||||
|
DOTNET_SDK_VERSION="${DOTNET_SDK_VERSION:-10.0.114}"
|
||||||
|
DOTNET_X86_VERSION="${DOTNET_X86_VERSION:-10.0.114}"
|
||||||
|
|
||||||
OS_ID=""
|
OS_ID=""
|
||||||
OS_NAME=""
|
OS_NAME=""
|
||||||
@@ -24,6 +29,13 @@ HOST_ARCH=""
|
|||||||
SCRIPT_DIR=""
|
SCRIPT_DIR=""
|
||||||
PROJECT=""
|
PROJECT=""
|
||||||
VERSION=""
|
VERSION=""
|
||||||
|
BUILT_ALL=0
|
||||||
|
|
||||||
|
X86_RID="linux-x86"
|
||||||
|
X86_RPM_ARCH="i686"
|
||||||
|
|
||||||
|
RPM_STRIP=""
|
||||||
|
RPM_OBJDUMP=""
|
||||||
|
|
||||||
declare -a BUILT_RPMS=()
|
declare -a BUILT_RPMS=()
|
||||||
|
|
||||||
@@ -32,6 +44,13 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_runtime_version() {
|
||||||
|
local sdk_ver="$1"
|
||||||
|
local prefix="${sdk_ver%.*}"
|
||||||
|
local patch="${sdk_ver##*.}"
|
||||||
|
echo "${prefix}.${patch#1}"
|
||||||
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
local first_arg="${1:-}"
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
@@ -82,8 +101,8 @@ This script only supports: RHEL / Rocky / AlmaLinux / Fedora / CentOS."
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "$HOST_ARCH" in
|
case "$HOST_ARCH" in
|
||||||
riscv64) ;;
|
x86_64|aarch64) ;;
|
||||||
*) die "Only supports riscv64" ;;
|
*) die "This script cross-builds linux-x86/i686 from x86_64 or aarch64 only." ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
current_kernel="$(uname -r)"
|
current_kernel="$(uname -r)"
|
||||||
@@ -91,37 +110,68 @@ This script only supports: RHEL / Rocky / AlmaLinux / Fedora / CentOS."
|
|||||||
|
|
||||||
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
||||||
echo "[OK] Kernel $current_kernel verified."
|
echo "[OK] Kernel $current_kernel verified."
|
||||||
|
echo "[OK] Host architecture: $HOST_ARCH"
|
||||||
|
echo "[OK] Target: $X86_RID (RPM $X86_RPM_ARCH)"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
local install_ok=0
|
local install_ok=0
|
||||||
local tmp_dotnet=""
|
|
||||||
|
|
||||||
if command -v dnf >/dev/null 2>&1; then
|
if command -v dnf >/dev/null 2>&1; then
|
||||||
sudo dnf -y install \
|
sudo dnf -y install \
|
||||||
rpm-build rpmdevtools curl unzip tar jq rsync git python3 \
|
rpm-build rpmdevtools curl unzip tar jq rsync \
|
||||||
glibc-devel kernel-headers libatomic file ca-certificates libicu \
|
python3 binutils wget libicu \
|
||||||
&& install_ok=1
|
&& install_ok=1
|
||||||
|
|
||||||
mkdir -p "$HOME/.dotnet"
|
case "$HOST_ARCH" in
|
||||||
tmp_dotnet="$(mktemp -d)"
|
x86_64|aarch64)
|
||||||
curl -fL "$DOTNET_SDK_URL" -o "$tmp_dotnet/$DOTNET_RISCV_FILE"
|
wget -q https://dot.net/v1/dotnet-install.sh
|
||||||
tar -C "$HOME/.dotnet" -xzf "$tmp_dotnet/$DOTNET_RISCV_FILE"
|
chmod +x dotnet-install.sh
|
||||||
rm -rf "$tmp_dotnet"
|
./dotnet-install.sh --version "$DOTNET_SDK_VERSION" --install-dir "$HOME/.dotnet"
|
||||||
|
|
||||||
export PATH="$HOME/.dotnet:$PATH"
|
export PATH="$HOME/.dotnet:$PATH"
|
||||||
export DOTNET_ROOT="$HOME/.dotnet"
|
export DOTNET_ROOT="$HOME/.dotnet"
|
||||||
|
|
||||||
dotnet --info >/dev/null 2>&1 || install_ok=0
|
dotnet --info >/dev/null 2>&1 && install_ok=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "This script cross-builds linux-x86/i686 from x86_64 or aarch64 only."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
||||||
echo "dotnet-riscv SDK, curl, unzip, tar, rsync, git, python3, rpm, rpmdevtools, rpm-build (on Red Hat branch)"
|
echo "dotnet 10.x, python3, rpm, rpmdevtools, rpm-build, binutils"
|
||||||
|
echo "curl, unzip, tar, rsync, jq, wget"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_cross_rpm_tools() {
|
||||||
|
local target="$1"
|
||||||
|
|
||||||
|
case "$HOST_ARCH:$target" in
|
||||||
|
x86_64:i686|aarch64:i686)
|
||||||
|
echo "[+] Prepare host RPM binutils for $target"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
RPM_STRIP=""
|
||||||
|
RPM_OBJDUMP=""
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
command -v strip >/dev/null 2>&1 || die "strip tool not found"
|
||||||
|
command -v objdump >/dev/null 2>&1 || die "objdump tool not found"
|
||||||
|
|
||||||
|
RPM_STRIP="$(command -v strip)"
|
||||||
|
RPM_OBJDUMP="$(command -v objdump)"
|
||||||
|
|
||||||
|
echo "[OK] RPM strip: $RPM_STRIP"
|
||||||
|
echo "[OK] RPM objdump: $RPM_OBJDUMP"
|
||||||
|
}
|
||||||
|
|
||||||
prepare_workspace() {
|
prepare_workspace() {
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
@@ -254,13 +304,156 @@ resolve_version() {
|
|||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
echo "[*] GUI version resolved as: ${VERSION}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download_nuget_packages() {
|
||||||
|
NUGET_CACHE_DIR="$(mktemp -d)"
|
||||||
|
|
||||||
|
local x86_rt
|
||||||
|
x86_rt="$(get_runtime_version "$DOTNET_X86_VERSION")"
|
||||||
|
|
||||||
|
local urls=(
|
||||||
|
"${DOTNET_NUPKG_BASE}/${x86_rt}/Microsoft.AspNetCore.App.Runtime.linux-x86.${x86_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${x86_rt}/Microsoft.NETCore.App.Host.linux-x86.${x86_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${x86_rt}/Microsoft.NETCore.App.Runtime.linux-x86.${x86_rt}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/SkiaSharp.NativeAssets.Linux.${SkiaSharp_VERSION}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/HarfBuzzSharp.NativeAssets.Linux.${HarfBuzzSharp_VERSION}.nupkg"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "[+] Downloading prebuilt NuGet packages to: $NUGET_CACHE_DIR"
|
||||||
|
local u pkg_name
|
||||||
|
for u in "${urls[@]}"; do
|
||||||
|
pkg_name="${u##*/}"
|
||||||
|
echo " -> $pkg_name"
|
||||||
|
curl -fL "$u" -o "$NUGET_CACHE_DIR/$pkg_name" || {
|
||||||
|
echo "[!] Failed to download $u" >&2
|
||||||
|
rm -rf "$NUGET_CACHE_DIR"
|
||||||
|
NUGET_CACHE_DIR=""
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[OK] Prebuilt NuGet packages ready in $NUGET_CACHE_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_dotnet_sdk() {
|
||||||
|
echo "[+] Using host .NET SDK for cross-target $X86_RID"
|
||||||
|
|
||||||
|
dotnet --info
|
||||||
|
|
||||||
|
if [[ -z "${DOTNET_ROOT:-}" ]]; then
|
||||||
|
local dotnet_bin=""
|
||||||
|
dotnet_bin="$(readlink -f "$(command -v dotnet)")"
|
||||||
|
DOTNET_ROOT="$(dirname "$dotnet_bin")"
|
||||||
|
export DOTNET_ROOT
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[OK] DOTNET_ROOT: $DOTNET_ROOT"
|
||||||
|
}
|
||||||
|
|
||||||
|
patch_x86_sdk() {
|
||||||
|
local sdk_props=""
|
||||||
|
local sdk_version=""
|
||||||
|
local dotnet_root=""
|
||||||
|
|
||||||
|
sdk_version="$(dotnet --version)"
|
||||||
|
|
||||||
|
dotnet_root="${DOTNET_ROOT:-}"
|
||||||
|
if [[ -z "$dotnet_root" ]]; then
|
||||||
|
local dotnet_bin=""
|
||||||
|
dotnet_bin="$(readlink -f "$(command -v dotnet)")"
|
||||||
|
dotnet_root="$(dirname "$dotnet_bin")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sdk_props="$dotnet_root/sdk/${sdk_version}/Microsoft.NETCoreSdk.BundledVersions.props"
|
||||||
|
|
||||||
|
[[ -f "$sdk_props" ]] || die "SDK props file not found: $sdk_props"
|
||||||
|
|
||||||
|
echo "[+] Patching SDK: $sdk_props"
|
||||||
|
|
||||||
|
python3 - "$sdk_props" <<'PY'
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
path = Path(sys.argv[1])
|
||||||
|
text = path.read_text()
|
||||||
|
old = text
|
||||||
|
|
||||||
|
|
||||||
|
def add_attr_to_known_blocks(text, marker, attr):
|
||||||
|
start = 0
|
||||||
|
while True:
|
||||||
|
start = text.find(marker, start)
|
||||||
|
if start == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
end = text.find('/>', start)
|
||||||
|
if end == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
block = text[start:end]
|
||||||
|
attr_pos = block.find(attr)
|
||||||
|
|
||||||
|
if attr_pos != -1:
|
||||||
|
value_start = attr_pos + len(attr)
|
||||||
|
value_end = block.find('"', value_start)
|
||||||
|
|
||||||
|
if value_end != -1:
|
||||||
|
value = block[value_start:value_end]
|
||||||
|
values = value.split(';')
|
||||||
|
|
||||||
|
if 'linux-x86' not in values:
|
||||||
|
value = value + ';linux-x86'
|
||||||
|
block = (
|
||||||
|
block[:value_start]
|
||||||
|
+ value
|
||||||
|
+ block[value_end:]
|
||||||
|
)
|
||||||
|
text = text[:start] + block + text[end:]
|
||||||
|
end = start + len(block)
|
||||||
|
|
||||||
|
start = end + 2
|
||||||
|
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
for framework in ('Microsoft.NETCore.App', 'Microsoft.AspNetCore.App'):
|
||||||
|
text = add_attr_to_known_blocks(
|
||||||
|
text,
|
||||||
|
f'<KnownFrameworkReference Include="{framework}"',
|
||||||
|
'RuntimePackRuntimeIdentifiers="',
|
||||||
|
)
|
||||||
|
|
||||||
|
text = add_attr_to_known_blocks(
|
||||||
|
text,
|
||||||
|
'<KnownAppHostPack',
|
||||||
|
'AppHostRuntimeIdentifiers="',
|
||||||
|
)
|
||||||
|
|
||||||
|
if text == old:
|
||||||
|
raise SystemExit(
|
||||||
|
'ERROR: No SDK RuntimePack/AppHost mapping was patched'
|
||||||
|
)
|
||||||
|
|
||||||
|
path.write_text(text)
|
||||||
|
PY
|
||||||
|
|
||||||
|
echo "===== Verify RuntimePackRuntimeIdentifiers ====="
|
||||||
|
grep -n 'RuntimePackRuntimeIdentifiers=' "$sdk_props" | grep 'linux-x86'
|
||||||
|
|
||||||
|
echo "===== Verify AppHostRuntimeIdentifiers ====="
|
||||||
|
grep -n 'AppHostRuntimeIdentifiers=' "$sdk_props" | grep 'linux-x86'
|
||||||
|
}
|
||||||
|
|
||||||
xray_url_for_rid() {
|
xray_url_for_rid() {
|
||||||
local rid="$1"
|
local rid="$1"
|
||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-riscv64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-riscv64.zip" ;;
|
linux-x86)
|
||||||
*) return 1 ;;
|
echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-32.zip"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,8 +462,12 @@ singbox_url_for_rid() {
|
|||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-riscv64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-riscv64.tar.gz" ;;
|
linux-x86)
|
||||||
*) return 1 ;;
|
echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-386.tar.gz"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,8 +475,12 @@ bundle_url_for_rid() {
|
|||||||
local rid="$1"
|
local rid="$1"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-riscv64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip" ;;
|
linux-x86)
|
||||||
*) return 1 ;;
|
echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-86.zip"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,15 +500,34 @@ download_xray() {
|
|||||||
| head -n1)" || true
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || {
|
||||||
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
echo "[xray] Failed to get version"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
url="$(xray_url_for_rid "$rid" "$ver")" || {
|
||||||
|
echo "[xray] Unsupported RID for upstream Xray: $rid (skipped)"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
echo "[+] Download xray: $url"
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
curl -fL "$url" -o "$tmp/xray.zip" || {
|
||||||
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
rm -rf "$tmp"
|
||||||
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
unzip -q "$tmp/xray.zip" -d "$tmp" || {
|
||||||
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
install -m 755 "$tmp/xray" "$outdir/xray" || {
|
||||||
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,19 +549,40 @@ download_singbox() {
|
|||||||
| head -n1)" || true
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || {
|
||||||
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
echo "[sing-box] Failed to get version"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
url="$(singbox_url_for_rid "$rid" "$ver")" || {
|
||||||
|
echo "[sing-box] Unsupported RID: $rid"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
echo "[+] Download sing-box: $url"
|
echo "[+] Download sing-box: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
curl -fL "$url" -o "$tmp/singbox.tar.gz" || {
|
||||||
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || {
|
||||||
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
||||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
[[ -n "$bin" ]] || {
|
||||||
|
echo "[!] sing-box unpack failed"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
install -m 755 "$bin" "$outdir/sing-box" || { rm -rf "$tmp"; return 1; }
|
install -m 755 "$bin" "$outdir/sing-box" || {
|
||||||
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
||||||
@@ -378,20 +619,44 @@ download_geo_assets() {
|
|||||||
mkdir -p "$bin_dir" "$srss_dir"
|
mkdir -p "$bin_dir" "$srss_dir"
|
||||||
|
|
||||||
echo "[+] Download Xray Geo to ${bin_dir}"
|
echo "[+] Download Xray Geo to ${bin_dir}"
|
||||||
curl -fsSL -o "$bin_dir/geosite.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geosite.dat"
|
curl -fsSL -o "$bin_dir/geosite.dat" \
|
||||||
curl -fsSL -o "$bin_dir/geoip.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
"https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geosite.dat"
|
||||||
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
curl -fsSL -o "$bin_dir/geoip.dat" \
|
||||||
curl -fsSL -o "$bin_dir/Country.mmdb" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
"https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
||||||
|
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" \
|
||||||
|
"https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
||||||
|
curl -fsSL -o "$bin_dir/Country.mmdb" \
|
||||||
|
"https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
||||||
|
|
||||||
echo "[+] Download sing-box rule DB & rule-sets"
|
echo "[+] Download sing-box rule DB & rule-sets"
|
||||||
curl -fsSL -o "$bin_dir/geoip.metadb" "https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb"
|
curl -fsSL -o "$bin_dir/geoip.metadb" \
|
||||||
|
"https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb"
|
||||||
|
|
||||||
for f in geoip-private.srs geoip-cn.srs geoip-facebook.srs geoip-fastly.srs geoip-google.srs geoip-netflix.srs geoip-telegram.srs geoip-twitter.srs; do
|
for f in \
|
||||||
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geoip/$f"
|
geoip-private.srs \
|
||||||
|
geoip-cn.srs \
|
||||||
|
geoip-facebook.srs \
|
||||||
|
geoip-fastly.srs \
|
||||||
|
geoip-google.srs \
|
||||||
|
geoip-netflix.srs \
|
||||||
|
geoip-telegram.srs \
|
||||||
|
geoip-twitter.srs
|
||||||
|
do
|
||||||
|
curl -fsSL -o "$srss_dir/$f" \
|
||||||
|
"https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geoip/$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
for f in geosite-cn.srs geosite-gfw.srs geosite-google.srs geosite-greatfire.srs geosite-geolocation-cn.srs geosite-category-ads-all.srs geosite-private.srs; do
|
for f in \
|
||||||
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geosite/$f"
|
geosite-cn.srs \
|
||||||
|
geosite-gfw.srs \
|
||||||
|
geosite-google.srs \
|
||||||
|
geosite-greatfire.srs \
|
||||||
|
geosite-geolocation-cn.srs \
|
||||||
|
geosite-category-ads-all.srs \
|
||||||
|
geosite-private.srs
|
||||||
|
do
|
||||||
|
curl -fsSL -o "$srss_dir/$f" \
|
||||||
|
"https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geosite/$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
unify_geo_layout "$outroot"
|
unify_geo_layout "$outroot"
|
||||||
@@ -404,13 +669,26 @@ populate_assets_zip_mode() {
|
|||||||
local tmp=""
|
local tmp=""
|
||||||
local nested_dir=""
|
local nested_dir=""
|
||||||
|
|
||||||
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
url="$(bundle_url_for_rid "$rid")" || {
|
||||||
|
echo "[!] Bundle unsupported RID: $rid"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
echo "[+] Try v2rayN bundle archive: $url"
|
echo "[+] Try v2rayN bundle archive: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
|
||||||
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; return 1; }
|
curl -fL "$url" -o "$tmp/v2rayn.zip" || {
|
||||||
|
echo "[!] Bundle download failed"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || {
|
||||||
|
echo "[!] Bundle unzip failed"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
if [[ -d "$tmp/bin" ]]; then
|
if [[ -d "$tmp/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
@@ -423,6 +701,7 @@ populate_assets_zip_mode() {
|
|||||||
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 2>/dev/null || true
|
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 2>/dev/null || true
|
||||||
|
|
||||||
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
||||||
|
|
||||||
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
rsync -a "$nested_dir/bin/" "$outroot/bin/"
|
rsync -a "$nested_dir/bin/" "$outroot/bin/"
|
||||||
@@ -442,14 +721,17 @@ populate_assets_netcore_mode() {
|
|||||||
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
download_xray "$outroot/bin/xray" "$rid" \
|
||||||
|
|| echo "[!] xray download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
download_singbox "$outroot/bin/sing_box" "$rid" \
|
||||||
|
|| echo "[!] sing-box download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
download_geo_assets "$outroot" \
|
||||||
|
|| echo "[!] Geo rules download failed (skipped)"
|
||||||
}
|
}
|
||||||
|
|
||||||
stage_runtime_assets() {
|
stage_runtime_assets() {
|
||||||
@@ -472,21 +754,36 @@ stage_runtime_assets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe_target() {
|
describe_target() {
|
||||||
local short="$1"
|
printf '%s\n%s\n%s\n' \
|
||||||
|
"$X86_RID" \
|
||||||
case "$short" in
|
"$X86_RPM_ARCH" \
|
||||||
riscv64) printf '%s\n%s\n%s\n' "linux-riscv64" "riscv64" "riscv64" ;;
|
"$X86_RPM_ARCH"
|
||||||
*) echo "Unknown arch '$short' (use riscv64)" >&2; return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publish_binary() {
|
publish_binary() {
|
||||||
local rid="$1"
|
local rid="$1"
|
||||||
|
|
||||||
|
patch_x86_sdk
|
||||||
|
|
||||||
dotnet clean "$PROJECT" -c Release
|
dotnet clean "$PROJECT" -c Release
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
dotnet restore "$PROJECT"
|
|
||||||
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
dotnet restore "$PROJECT" \
|
||||||
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json" \
|
||||||
|
-p:SelfContained=true \
|
||||||
|
-p:EnableWindowsTargeting=true \
|
||||||
|
--force-evaluate
|
||||||
|
|
||||||
|
dotnet publish "$PROJECT" \
|
||||||
|
-c Release \
|
||||||
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json" \
|
||||||
|
-p:PublishSingleFile=false \
|
||||||
|
-p:SelfContained=true \
|
||||||
|
--no-restore
|
||||||
}
|
}
|
||||||
|
|
||||||
write_spec_file() {
|
write_spec_file() {
|
||||||
@@ -505,7 +802,7 @@ Summary: v2rayN (Avalonia) GUI client for Linux
|
|||||||
License: GPL-3.0-only
|
License: GPL-3.0-only
|
||||||
URL: https://github.com/2dust/v2rayN
|
URL: https://github.com/2dust/v2rayN
|
||||||
BugURL: https://github.com/2dust/v2rayN/issues
|
BugURL: https://github.com/2dust/v2rayN/issues
|
||||||
ExclusiveArch: riscv64
|
ExclusiveArch: i686
|
||||||
Source0: __PKGROOT__.tar.gz
|
Source0: __PKGROOT__.tar.gz
|
||||||
|
|
||||||
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
||||||
@@ -603,7 +900,10 @@ package_binary() {
|
|||||||
local f=""
|
local f=""
|
||||||
|
|
||||||
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
||||||
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
[[ -d "$pubdir" ]] || {
|
||||||
|
echo "Publish directory not found: $pubdir"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
workdir="$(mktemp -d)"
|
workdir="$(mktemp -d)"
|
||||||
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
||||||
@@ -613,23 +913,41 @@ package_binary() {
|
|||||||
|
|
||||||
project_dir="$(cd "$(dirname "$PROJECT")" && pwd)"
|
project_dir="$(cd "$(dirname "$PROJECT")" && pwd)"
|
||||||
icon_candidate="$project_dir/v2rayN.png"
|
icon_candidate="$project_dir/v2rayN.png"
|
||||||
[[ -f "$icon_candidate" ]] || { echo "Required icon not found: $icon_candidate"; return 1; }
|
|
||||||
|
[[ -f "$icon_candidate" ]] || {
|
||||||
|
echo "Required icon not found: $icon_candidate"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
cp "$icon_candidate" "$workdir/$PKGROOT/v2rayn.png"
|
cp "$icon_candidate" "$workdir/$PKGROOT/v2rayn.png"
|
||||||
|
|
||||||
stage_runtime_assets "$workdir/$PKGROOT" "$rid"
|
stage_runtime_assets "$workdir/$PKGROOT" "$rid"
|
||||||
|
|
||||||
rpmdev-setuptree
|
rpmdev-setuptree
|
||||||
|
|
||||||
sourcedir="${RPM_TOPDIR}/SOURCES"
|
sourcedir="${RPM_TOPDIR}/SOURCES"
|
||||||
specdir="${RPM_TOPDIR}/SPECS"
|
specdir="${RPM_TOPDIR}/SPECS"
|
||||||
specfile="${specdir}/v2rayN.spec"
|
specfile="${specdir}/v2rayN.spec"
|
||||||
|
|
||||||
mkdir -p "$sourcedir" "$specdir"
|
mkdir -p "$sourcedir" "$specdir"
|
||||||
tar -C "$workdir" -czf "$sourcedir/$PKGROOT.tar.gz" "$PKGROOT"
|
|
||||||
|
tar -C "$workdir" \
|
||||||
|
-czf "$sourcedir/$PKGROOT.tar.gz" \
|
||||||
|
"$PKGROOT"
|
||||||
|
|
||||||
write_spec_file "$specfile"
|
write_spec_file "$specfile"
|
||||||
rpmbuild -ba "$specfile" --target "$rpm_target"
|
|
||||||
|
if [[ -n "${RPM_STRIP:-}" ]]; then
|
||||||
|
rpmbuild -ba "$specfile" \
|
||||||
|
--target "$rpm_target" \
|
||||||
|
--define "__strip ${RPM_STRIP}" \
|
||||||
|
--define "__objdump ${RPM_OBJDUMP}"
|
||||||
|
else
|
||||||
|
rpmbuild -ba "$specfile" --target "$rpm_target"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Build done for $short. RPM at:"
|
echo "Build done for $short. RPM at:"
|
||||||
|
|
||||||
for f in "${RPM_TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
for f in "${RPM_TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
||||||
[[ -e "$f" ]] || continue
|
[[ -e "$f" ]] || continue
|
||||||
echo " $f"
|
echo " $f"
|
||||||
@@ -637,23 +955,16 @@ package_binary() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
select_targets() {
|
|
||||||
printf '%s\n' riscv64
|
|
||||||
}
|
|
||||||
|
|
||||||
build_one_target() {
|
build_one_target() {
|
||||||
local short="$1"
|
local short="i686"
|
||||||
local meta=()
|
local rid="$X86_RID"
|
||||||
local rid=""
|
local rpm_target="$X86_RPM_ARCH"
|
||||||
local rpm_target=""
|
local archdir="$X86_RPM_ARCH"
|
||||||
local archdir=""
|
|
||||||
|
|
||||||
mapfile -t meta < <(describe_target "$short") || return 1
|
|
||||||
rid="${meta[0]}"
|
|
||||||
rpm_target="${meta[1]}"
|
|
||||||
archdir="${meta[2]}"
|
|
||||||
|
|
||||||
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
||||||
|
|
||||||
|
prepare_cross_rpm_tools "$short"
|
||||||
|
prepare_dotnet_sdk
|
||||||
publish_binary "$rid"
|
publish_binary "$rid"
|
||||||
package_binary "$short" "$rid" "$rpm_target" "$archdir"
|
package_binary "$short" "$rid" "$rpm_target" "$archdir"
|
||||||
}
|
}
|
||||||
@@ -662,32 +973,31 @@ print_summary() {
|
|||||||
local rp=""
|
local rp=""
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "================ Build Summary ================"
|
echo "================ Build Summary ================="
|
||||||
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
||||||
|
echo "Output directory: ${RPM_TOPDIR}"
|
||||||
for rp in "${BUILT_RPMS[@]}"; do
|
for rp in "${BUILT_RPMS[@]}"; do
|
||||||
echo "$rp"
|
echo "$rp"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "No RPMs detected in summary (check build logs above)."
|
echo "No RPMs detected in summary (check build logs above)."
|
||||||
fi
|
fi
|
||||||
echo "=============================================="
|
echo "==============================================="
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local targets=()
|
|
||||||
local arch=""
|
|
||||||
|
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
detect_environment
|
detect_environment
|
||||||
install_dependencies
|
install_dependencies
|
||||||
prepare_workspace
|
prepare_workspace
|
||||||
resolve_version
|
resolve_version
|
||||||
|
|
||||||
mapfile -t targets < <(select_targets)
|
download_nuget_packages || die \
|
||||||
|
"Failed to download prebuilt NuGet packages."
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
build_one_target
|
||||||
build_one_target "$arch"
|
|
||||||
done
|
rm -rf "${NUGET_CACHE_DIR:-}" || true
|
||||||
|
|
||||||
print_summary
|
print_summary
|
||||||
}
|
}
|
||||||
+262
-25
@@ -14,6 +14,30 @@ PKGROOT="v2rayN-publish"
|
|||||||
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
RPM_TOPDIR="${HOME}/rpmbuild"
|
RPM_TOPDIR="${HOME}/rpmbuild"
|
||||||
|
|
||||||
|
NUGET_CACHE_DIR=""
|
||||||
|
DOTNET_NUPKG_BASE="${DOTNET_NUPKG_BASE:-https://github.com/autorepobot/dotnet-nupkg-prebuild/releases/download}"
|
||||||
|
SKIASHARP_BASE="${SKIASHARP_BASE:-https://github.com/autorepobot/SkiaSharp-ppc64le/releases/download}"
|
||||||
|
SkiaSharp_VERSION="${SkiaSharp_VERSION:-3.119.4}"
|
||||||
|
HarfBuzzSharp_VERSION="${HarfBuzzSharp_VERSION:-8.3.1.5}"
|
||||||
|
|
||||||
|
DOTNET_SDK_VERSION="${DOTNET_SDK_VERSION:-10.0.114}"
|
||||||
|
|
||||||
|
DOTNET_RISCV_VERSION="${DOTNET_RISCV_VERSION:-10.0.114}"
|
||||||
|
DOTNET_RISCV_BASE="${DOTNET_RISCV_BASE:-https://github.com/autorepobot/dotnet-riscv/releases/download}"
|
||||||
|
DOTNET_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
||||||
|
DOTNET_RISCV_SDK_URL="${DOTNET_RISCV_SDK_URL:-${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}}"
|
||||||
|
|
||||||
|
DOTNET_PPC64LE_VERSION="${DOTNET_PPC64LE_VERSION:-10.0.114}"
|
||||||
|
DOTNET_PPC64LE_BASE="${DOTNET_PPC64LE_BASE:-https://github.com/IBM/dotnet-s390x/releases/download}"
|
||||||
|
DOTNET_PPC64LE_FILE="dotnet-sdk-${DOTNET_PPC64LE_VERSION}-linux-ppc64le.tar.gz"
|
||||||
|
DOTNET_PPC64LE_SDK_URL="${DOTNET_PPC64LE_SDK_URL:-${DOTNET_PPC64LE_BASE}/v${DOTNET_PPC64LE_VERSION}/${DOTNET_PPC64LE_FILE}}"
|
||||||
|
|
||||||
|
DOTNET_LOONGARCH_VERSION="${DOTNET_LOONGARCH_VERSION:-10.0.114}"
|
||||||
|
DOTNET_LOONGARCH_TAG="${DOTNET_LOONGARCH_TAG:-v10.0.114-loongarch64}"
|
||||||
|
DOTNET_LOONGARCH_BASE="${DOTNET_LOONGARCH_BASE:-https://github.com/loongson/dotnet/releases/download}"
|
||||||
|
DOTNET_LOONGARCH_FILE="dotnet-sdk-${DOTNET_LOONGARCH_VERSION}-linux-loongarch64.tar.gz"
|
||||||
|
DOTNET_LOONGARCH_SDK_URL="${DOTNET_LOONGARCH_SDK_URL:-${DOTNET_LOONGARCH_BASE}/${DOTNET_LOONGARCH_TAG}/${DOTNET_LOONGARCH_FILE}}"
|
||||||
|
|
||||||
OS_ID=""
|
OS_ID=""
|
||||||
OS_NAME=""
|
OS_NAME=""
|
||||||
OS_VERSION_ID=""
|
OS_VERSION_ID=""
|
||||||
@@ -23,6 +47,9 @@ PROJECT=""
|
|||||||
VERSION=""
|
VERSION=""
|
||||||
BUILT_ALL=0
|
BUILT_ALL=0
|
||||||
|
|
||||||
|
RPM_STRIP=""
|
||||||
|
RPM_OBJDUMP=""
|
||||||
|
|
||||||
declare -a BUILT_RPMS=()
|
declare -a BUILT_RPMS=()
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
@@ -30,6 +57,13 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_runtime_version() {
|
||||||
|
local sdk_ver="$1"
|
||||||
|
local prefix="${sdk_ver%.*}"
|
||||||
|
local patch="${sdk_ver##*.}"
|
||||||
|
echo "${prefix}.${patch#1}"
|
||||||
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
local first_arg="${1:-}"
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
@@ -81,8 +115,8 @@ This script only supports: RHEL / Rocky / AlmaLinux / Fedora / CentOS."
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "$HOST_ARCH" in
|
case "$HOST_ARCH" in
|
||||||
x86_64|aarch64) ;;
|
x86_64|aarch64|riscv64|ppc64le|loongarch64) ;;
|
||||||
*) die "Only supports aarch64 / x86_64" ;;
|
*) die "Only supports x86_64 / aarch64 / riscv64 / ppc64le / loongarch64" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
current_kernel="$(uname -r)"
|
current_kernel="$(uname -r)"
|
||||||
@@ -96,8 +130,31 @@ install_dependencies() {
|
|||||||
local install_ok=0
|
local install_ok=0
|
||||||
|
|
||||||
if command -v dnf >/dev/null 2>&1; then
|
if command -v dnf >/dev/null 2>&1; then
|
||||||
sudo dnf -y install rpm-build rpmdevtools curl unzip tar jq rsync dotnet-sdk-10.0 \
|
sudo dnf -y install \
|
||||||
|
rpm-build rpmdevtools curl unzip tar jq rsync ca-certificates git \
|
||||||
|
desktop-file-utils wget libicu \
|
||||||
&& install_ok=1
|
&& install_ok=1
|
||||||
|
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
x86_64|aarch64)
|
||||||
|
wget -q https://dot.net/v1/dotnet-install.sh
|
||||||
|
chmod +x dotnet-install.sh
|
||||||
|
./dotnet-install.sh \
|
||||||
|
--version "$DOTNET_SDK_VERSION" \
|
||||||
|
--install-dir "$HOME/.dotnet"
|
||||||
|
|
||||||
|
export PATH="$HOME/.dotnet:$PATH"
|
||||||
|
export DOTNET_ROOT="$HOME/.dotnet"
|
||||||
|
|
||||||
|
dotnet --info >/dev/null 2>&1 && install_ok=1
|
||||||
|
;;
|
||||||
|
riscv64|ppc64le|loongarch64)
|
||||||
|
install_ok=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Only supports x86_64 / aarch64 / riscv64 / ppc64le / loongarch64"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
@@ -107,6 +164,48 @@ install_dependencies() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_cross_rpm_tools() {
|
||||||
|
local target="$1"
|
||||||
|
local package=""
|
||||||
|
local strip_tool=""
|
||||||
|
local objdump_tool=""
|
||||||
|
|
||||||
|
case "$HOST_ARCH:$target" in
|
||||||
|
x86_64:ppc64le|aarch64:ppc64le)
|
||||||
|
package="gcc-powerpc64le-linux-gnu"
|
||||||
|
strip_tool="powerpc64le-linux-gnu-strip"
|
||||||
|
objdump_tool="powerpc64le-linux-gnu-objdump"
|
||||||
|
;;
|
||||||
|
x86_64:riscv64|aarch64:riscv64)
|
||||||
|
package="gcc-riscv64-linux-gnu"
|
||||||
|
strip_tool="riscv64-linux-gnu-strip"
|
||||||
|
objdump_tool="riscv64-linux-gnu-objdump"
|
||||||
|
;;
|
||||||
|
x86_64:loong64|aarch64:loong64)
|
||||||
|
package="gcc-loongarch64-linux-gnu"
|
||||||
|
strip_tool="loongarch64-linux-gnu-strip"
|
||||||
|
objdump_tool="loongarch64-linux-gnu-objdump"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
RPM_STRIP=""
|
||||||
|
RPM_OBJDUMP=""
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "[+] Install cross RPM tools for $target: $package"
|
||||||
|
sudo dnf -y install "$package"
|
||||||
|
|
||||||
|
command -v "$strip_tool" >/dev/null 2>&1 || die "Cross strip tool not found: $strip_tool"
|
||||||
|
command -v "$objdump_tool" >/dev/null 2>&1 || die "Cross objdump tool not found: $objdump_tool"
|
||||||
|
|
||||||
|
RPM_STRIP="$(command -v "$strip_tool")"
|
||||||
|
RPM_OBJDUMP="$(command -v "$objdump_tool")"
|
||||||
|
|
||||||
|
echo "[OK] RPM strip: $RPM_STRIP"
|
||||||
|
echo "[OK] RPM objdump: $RPM_OBJDUMP"
|
||||||
|
}
|
||||||
|
|
||||||
prepare_workspace() {
|
prepare_workspace() {
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
@@ -239,14 +338,115 @@ resolve_version() {
|
|||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
echo "[*] GUI version resolved as: ${VERSION}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download_nuget_packages() {
|
||||||
|
NUGET_CACHE_DIR="$(mktemp -d)"
|
||||||
|
|
||||||
|
local riscv_rt ppc64le_rt loong_rt
|
||||||
|
riscv_rt="$(get_runtime_version "$DOTNET_RISCV_VERSION")"
|
||||||
|
ppc64le_rt="$(get_runtime_version "$DOTNET_PPC64LE_VERSION")"
|
||||||
|
loong_rt="$(get_runtime_version "$DOTNET_LOONGARCH_VERSION")"
|
||||||
|
|
||||||
|
local urls=(
|
||||||
|
"${DOTNET_NUPKG_BASE}/${loong_rt}/Microsoft.AspNetCore.App.Runtime.linux-loongarch64.${loong_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${ppc64le_rt}/Microsoft.AspNetCore.App.Runtime.linux-ppc64le.${ppc64le_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${riscv_rt}/Microsoft.AspNetCore.App.Runtime.linux-riscv64.${riscv_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${loong_rt}/Microsoft.NETCore.App.Host.linux-loongarch64.${loong_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${ppc64le_rt}/Microsoft.NETCore.App.Host.linux-ppc64le.${ppc64le_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${riscv_rt}/Microsoft.NETCore.App.Host.linux-riscv64.${riscv_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${loong_rt}/Microsoft.NETCore.App.Runtime.linux-loongarch64.${loong_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${ppc64le_rt}/Microsoft.NETCore.App.Runtime.linux-ppc64le.${ppc64le_rt}.nupkg"
|
||||||
|
"${DOTNET_NUPKG_BASE}/${riscv_rt}/Microsoft.NETCore.App.Runtime.linux-riscv64.${riscv_rt}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/SkiaSharp.NativeAssets.Linux.${SkiaSharp_VERSION}.nupkg"
|
||||||
|
"${SKIASHARP_BASE}/v${SkiaSharp_VERSION}/HarfBuzzSharp.NativeAssets.Linux.${HarfBuzzSharp_VERSION}.nupkg"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "[+] Downloading prebuilt NuGet packages to: $NUGET_CACHE_DIR"
|
||||||
|
local u pkg_name
|
||||||
|
for u in "${urls[@]}"; do
|
||||||
|
pkg_name="${u##*/}"
|
||||||
|
echo " -> $pkg_name"
|
||||||
|
curl -fL "$u" -o "$NUGET_CACHE_DIR/$pkg_name" || {
|
||||||
|
echo "[!] Failed to download $u" >&2
|
||||||
|
rm -rf "$NUGET_CACHE_DIR"
|
||||||
|
NUGET_CACHE_DIR=""
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[OK] Prebuilt NuGet packages ready in $NUGET_CACHE_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_dotnet_sdk() {
|
||||||
|
local short="$1"
|
||||||
|
local sdk_url=""
|
||||||
|
local sdk_file=""
|
||||||
|
local sdk_dir=""
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
|
case "$HOST_ARCH:$short" in
|
||||||
|
x86_64:x64|aarch64:arm64)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
riscv64:riscv64)
|
||||||
|
sdk_url="$DOTNET_RISCV_SDK_URL"
|
||||||
|
sdk_file="$DOTNET_RISCV_FILE"
|
||||||
|
;;
|
||||||
|
ppc64le:ppc64le)
|
||||||
|
sdk_url="$DOTNET_PPC64LE_SDK_URL"
|
||||||
|
sdk_file="$DOTNET_PPC64LE_FILE"
|
||||||
|
;;
|
||||||
|
loongarch64:loong64)
|
||||||
|
sdk_url="$DOTNET_LOONGARCH_SDK_URL"
|
||||||
|
sdk_file="$DOTNET_LOONGARCH_FILE"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
sdk_dir="$(mktemp -d)"
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
|
||||||
|
echo "[+] Download .NET SDK for $short: $sdk_url"
|
||||||
|
|
||||||
|
curl -fL "$sdk_url" -o "$tmp/$sdk_file" || {
|
||||||
|
rm -rf "$tmp" "$sdk_dir"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
tar -C "$sdk_dir" -xzf "$tmp/$sdk_file" || {
|
||||||
|
rm -rf "$tmp" "$sdk_dir"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
rm -rf "$tmp"
|
||||||
|
|
||||||
|
[[ -x "$sdk_dir/dotnet" ]] || {
|
||||||
|
rm -rf "$sdk_dir"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export DOTNET_ROOT="$sdk_dir"
|
||||||
|
export PATH="$DOTNET_ROOT:$PATH"
|
||||||
|
hash -r
|
||||||
|
|
||||||
|
echo "[OK] .NET SDK for $short extracted to: $sdk_dir"
|
||||||
|
dotnet --info
|
||||||
|
|
||||||
|
DOTNET_SDK_DIR="$sdk_dir"
|
||||||
|
}
|
||||||
|
|
||||||
xray_url_for_rid() {
|
xray_url_for_rid() {
|
||||||
local rid="$1"
|
local rid="$1"
|
||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-x64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip" ;;
|
linux-x64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip" ;;
|
||||||
linux-arm64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip" ;;
|
linux-arm64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip" ;;
|
||||||
*) return 1 ;;
|
linux-riscv64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-riscv64.zip" ;;
|
||||||
|
linux-ppc64le) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-ppc64le.zip" ;;
|
||||||
|
linux-loongarch64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-loong64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,9 +455,12 @@ singbox_url_for_rid() {
|
|||||||
local ver="$2"
|
local ver="$2"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-x64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz" ;;
|
linux-x64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz" ;;
|
||||||
linux-arm64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz" ;;
|
linux-arm64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz" ;;
|
||||||
*) return 1 ;;
|
linux-riscv64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-riscv64.tar.gz" ;;
|
||||||
|
linux-ppc64le) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-ppc64le.tar.gz" ;;
|
||||||
|
linux-loongarch64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-loong64.tar.gz" ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,9 +468,12 @@ bundle_url_for_rid() {
|
|||||||
local rid="$1"
|
local rid="$1"
|
||||||
|
|
||||||
case "$rid" in
|
case "$rid" in
|
||||||
linux-x64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip" ;;
|
linux-x64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip" ;;
|
||||||
linux-arm64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip" ;;
|
linux-arm64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip" ;;
|
||||||
*) return 1 ;;
|
linux-riscv64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip" ;;
|
||||||
|
linux-ppc64le) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-ppc64le.zip" ;;
|
||||||
|
linux-loongarch64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-loong64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +494,7 @@ download_xray() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
||||||
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID for upstream Xray: $rid (skipped)"; return 0; }
|
||||||
|
|
||||||
echo "[+] Download xray: $url"
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
@@ -463,9 +669,12 @@ describe_target() {
|
|||||||
local short="$1"
|
local short="$1"
|
||||||
|
|
||||||
case "$short" in
|
case "$short" in
|
||||||
x64) printf '%s\n%s\n%s\n' "linux-x64" "x86_64" "x86_64" ;;
|
x64) printf '%s\n%s\n%s\n' "linux-x64" "x86_64" "x86_64" ;;
|
||||||
arm64) printf '%s\n%s\n%s\n' "linux-arm64" "aarch64" "aarch64" ;;
|
arm64) printf '%s\n%s\n%s\n' "linux-arm64" "aarch64" "aarch64" ;;
|
||||||
*) echo "Unknown arch '$short' (use x64|arm64)" >&2; return 1 ;;
|
riscv64) printf '%s\n%s\n%s\n' "linux-riscv64" "riscv64" "riscv64" ;;
|
||||||
|
ppc64le) printf '%s\n%s\n%s\n' "linux-ppc64le" "ppc64le" "ppc64le" ;;
|
||||||
|
loong64) printf '%s\n%s\n%s\n' "linux-loongarch64" "loongarch64" "loongarch64" ;;
|
||||||
|
*) echo "Unknown arch '$short' (use x64|arm64|riscv64|ppc64le|loong64)" >&2; return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,8 +683,18 @@ publish_binary() {
|
|||||||
|
|
||||||
dotnet clean "$PROJECT" -c Release
|
dotnet clean "$PROJECT" -c Release
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
dotnet restore "$PROJECT"
|
dotnet restore "$PROJECT" \
|
||||||
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json"
|
||||||
|
dotnet publish "$PROJECT" \
|
||||||
|
-c Release \
|
||||||
|
-r "$rid" \
|
||||||
|
--source "$NUGET_CACHE_DIR" \
|
||||||
|
--source "https://api.nuget.org/v3/index.json" \
|
||||||
|
-p:PublishSingleFile=false \
|
||||||
|
-p:SelfContained=true \
|
||||||
|
--no-restore
|
||||||
}
|
}
|
||||||
|
|
||||||
write_spec_file() {
|
write_spec_file() {
|
||||||
@@ -494,7 +713,7 @@ Summary: v2rayN (Avalonia) GUI client for Linux
|
|||||||
License: GPL-3.0-only
|
License: GPL-3.0-only
|
||||||
URL: https://github.com/2dust/v2rayN
|
URL: https://github.com/2dust/v2rayN
|
||||||
BugURL: https://github.com/2dust/v2rayN/issues
|
BugURL: https://github.com/2dust/v2rayN/issues
|
||||||
ExclusiveArch: aarch64 x86_64
|
ExclusiveArch: aarch64 x86_64 riscv64 ppc64le loongarch64
|
||||||
Source0: __PKGROOT__.tar.gz
|
Source0: __PKGROOT__.tar.gz
|
||||||
|
|
||||||
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
||||||
@@ -616,7 +835,15 @@ package_binary() {
|
|||||||
tar -C "$workdir" -czf "$sourcedir/$PKGROOT.tar.gz" "$PKGROOT"
|
tar -C "$workdir" -czf "$sourcedir/$PKGROOT.tar.gz" "$PKGROOT"
|
||||||
|
|
||||||
write_spec_file "$specfile"
|
write_spec_file "$specfile"
|
||||||
rpmbuild -ba "$specfile" --target "$rpm_target"
|
|
||||||
|
if [[ -n "${RPM_STRIP:-}" ]]; then
|
||||||
|
rpmbuild -ba "$specfile" \
|
||||||
|
--target "$rpm_target" \
|
||||||
|
--define "__strip ${RPM_STRIP}" \
|
||||||
|
--define "__objdump ${RPM_OBJDUMP}"
|
||||||
|
else
|
||||||
|
rpmbuild -ba "$specfile" --target "$rpm_target"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Build done for $short. RPM at:"
|
echo "Build done for $short. RPM at:"
|
||||||
for f in "${RPM_TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
for f in "${RPM_TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
||||||
@@ -628,9 +855,12 @@ package_binary() {
|
|||||||
|
|
||||||
select_targets() {
|
select_targets() {
|
||||||
case "${ARCH_OVERRIDE:-}" in
|
case "${ARCH_OVERRIDE:-}" in
|
||||||
all) printf '%s\n' x64 arm64 ;;
|
all) printf '%s\n' x64 arm64 riscv64 ppc64le loong64 ;;
|
||||||
x64|amd64) printf '%s\n' x64 ;;
|
x64|amd64) printf '%s\n' x64 ;;
|
||||||
arm64|aarch64) printf '%s\n' arm64 ;;
|
arm64|aarch64) printf '%s\n' arm64 ;;
|
||||||
|
riscv64) printf '%s\n' riscv64 ;;
|
||||||
|
ppc64le|ppc64el) printf '%s\n' ppc64le ;;
|
||||||
|
loong64|loongarch64) printf '%s\n' loong64 ;;
|
||||||
"")
|
"")
|
||||||
case "$HOST_ARCH" in
|
case "$HOST_ARCH" in
|
||||||
x86_64) printf '%s\n' x64 ;;
|
x86_64) printf '%s\n' x64 ;;
|
||||||
@@ -639,7 +869,7 @@ select_targets() {
|
|||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|all." >&2
|
echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|riscv64|ppc64le|loong64|all." >&2
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -658,6 +888,8 @@ build_one_target() {
|
|||||||
archdir="${meta[2]}"
|
archdir="${meta[2]}"
|
||||||
|
|
||||||
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
||||||
|
prepare_cross_rpm_tools "$short"
|
||||||
|
prepare_dotnet_sdk "$short" || die "Failed to prepare .NET SDK for $short."
|
||||||
publish_binary "$rid"
|
publish_binary "$rid"
|
||||||
package_binary "$short" "$rid" "$rpm_target" "$archdir"
|
package_binary "$short" "$rid" "$rpm_target" "$archdir"
|
||||||
}
|
}
|
||||||
@@ -666,7 +898,7 @@ print_summary() {
|
|||||||
if [[ "$BUILT_ALL" -eq 1 ]]; then
|
if [[ "$BUILT_ALL" -eq 1 ]]; then
|
||||||
local rp=""
|
local rp=""
|
||||||
echo ""
|
echo ""
|
||||||
echo "================ Build Summary (both architectures) ================"
|
echo "================ Build Summary (all architectures) ================"
|
||||||
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
||||||
for rp in "${BUILT_RPMS[@]}"; do
|
for rp in "${BUILT_RPMS[@]}"; do
|
||||||
echo "$rp"
|
echo "$rp"
|
||||||
@@ -688,6 +920,8 @@ main() {
|
|||||||
prepare_workspace
|
prepare_workspace
|
||||||
resolve_version
|
resolve_version
|
||||||
|
|
||||||
|
download_nuget_packages || die "Failed to download prebuilt NuGet packages."
|
||||||
|
|
||||||
mapfile -t targets < <(select_targets)
|
mapfile -t targets < <(select_targets)
|
||||||
[[ "${ARCH_OVERRIDE:-}" == "all" ]] && BUILT_ALL=1 || BUILT_ALL=0
|
[[ "${ARCH_OVERRIDE:-}" == "all" ]] && BUILT_ALL=1 || BUILT_ALL=0
|
||||||
|
|
||||||
@@ -695,6 +929,9 @@ main() {
|
|||||||
build_one_target "$arch"
|
build_one_target "$arch"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
rm -rf "${NUGET_CACHE_DIR:-}" || true
|
||||||
|
rm -rf "${DOTNET_SDK_DIR:-}" || true
|
||||||
|
|
||||||
print_summary
|
print_summary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,5 +31,6 @@
|
|||||||
<PackageVersion Include="YamlDotNet" Version="18.1.0" />
|
<PackageVersion Include="YamlDotNet" Version="18.1.0" />
|
||||||
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.22" />
|
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.22" />
|
||||||
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.119.4" />
|
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.119.4" />
|
||||||
|
<PackageVersion Include="HarfBuzzSharp.NativeAssets.Linux" Version="8.3.1.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user