Skip to content

Commit bc36cf8

Browse files
authored
Code Clean (#8586)
1 parent cbdfe2e commit bc36cf8

File tree

1 file changed

+9
-78
lines changed

1 file changed

+9
-78
lines changed

package-rhel.sh

Lines changed: 9 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# == Require Red Hat Enterprise Linux/FedoraLinux/RockyLinux/AlmaLinux/CentOS OR Ubuntu/Debian ==
4+
# ====== Require Red Hat Enterprise Linux/FedoraLinux/RockyLinux/AlmaLinux/CentOS ======
55
if [[ -r /etc/os-release ]]; then
66
. /etc/os-release
77
case "$ID" in
8-
rhel|rocky|almalinux|fedora|centos|ubuntu|debian)
8+
rhel|rocky|almalinux|fedora|centos)
99
echo "[OK] Detected supported system: $NAME $VERSION_ID"
1010
;;
1111
*)
@@ -30,7 +30,7 @@ echo "[INFO] Detected kernel version: $KERNEL_FULL"
3030

3131
if (( KERNEL_MAJOR < MIN_KERNEL_MAJOR )) || { (( KERNEL_MAJOR == MIN_KERNEL_MAJOR )) && (( KERNEL_MINOR < MIN_KERNEL_MINOR )); }; then
3232
echo "[ERROR] Kernel $KERNEL_FULL is too old. Requires Linux >= ${MIN_KERNEL_MAJOR}.${MIN_KERNEL_MINOR}."
33-
echo "Please upgrade your system or use a newer container (e.g. Fedora 42+, RHEL 10+, Debian 13+)."
33+
echo "Please upgrade your system or use a newer container (e.g. Fedora 42+, RHEL 10+)."
3434
exit 1
3535
fi
3636

@@ -80,7 +80,6 @@ host_arch="$(uname -m)"
8080

8181
install_ok=0
8282
case "$ID" in
83-
# ------------------------------ RHEL family (UNCHANGED) ------------------------------
8483
rhel|rocky|almalinux|centos)
8584
if command -v dnf >/dev/null 2>&1; then
8685
sudo dnf -y install dotnet-sdk-8.0 rpm-build rpmdevtools curl unzip tar rsync || \
@@ -92,58 +91,7 @@ case "$ID" in
9291
install_ok=1
9392
fi
9493
;;
95-
# ------------------------------ Ubuntu ----------------------------------------------
96-
ubuntu)
97-
sudo apt-get update
98-
# Ensure 'universe' (Ubuntu) to get 'rpm'
99-
if ! apt-cache policy | grep -q '^500 .*ubuntu.com/ubuntu.* universe'; then
100-
sudo apt-get -y install software-properties-common || true
101-
sudo add-apt-repository -y universe || true
102-
sudo apt-get update
103-
fi
104-
# Base tools + rpm (provides rpmbuild)
105-
sudo apt-get -y install curl unzip tar rsync rpm || true
106-
# Cross-arch binutils so strip matches target arch + objdump for brp scripts
107-
sudo apt-get -y install binutils binutils-x86-64-linux-gnu binutils-aarch64-linux-gnu || true
108-
# rpmbuild presence check
109-
if ! command -v rpmbuild >/dev/null 2>&1; then
110-
echo "[ERROR] 'rpmbuild' not found after installing 'rpm'."
111-
echo " Please ensure the 'rpm' package is available from your repos (universe on Ubuntu)."
112-
exit 1
113-
fi
114-
# .NET SDK 8 (best effort via apt)
115-
if ! command -v dotnet >/dev/null 2>&1; then
116-
sudo apt-get -y install dotnet-sdk-8.0 || true
117-
sudo apt-get -y install dotnet-sdk-8 || true
118-
sudo apt-get -y install dotnet-sdk || true
119-
fi
120-
install_ok=1
121-
;;
122-
# ------------------------------ Debian (KEEP, with local dotnet install) ------------
123-
debian)
124-
sudo apt-get update
125-
# Base tools + rpm (provides rpmbuild on Debian) + objdump/strip
126-
sudo apt-get -y install curl unzip tar rsync rpm binutils || true
127-
# rpmbuild presence check
128-
if ! command -v rpmbuild >/dev/null 2>&1; then
129-
echo "[ERROR] 'rpmbuild' not found after installing 'rpm'."
130-
echo " Please ensure 'rpm' is available from Debian repos."
131-
exit 1
132-
fi
133-
# Try apt for dotnet; fallback to official installer into $HOME/.dotnet
134-
if ! command -v dotnet >/dev/null 2>&1; then
135-
echo "[INFO] 'dotnet' not found. Installing .NET 8 SDK locally to \$HOME/.dotnet ..."
136-
tmp="$(mktemp -d)"; trap '[[ -n "${tmp:-}" ]] && rm -rf "$tmp"' RETURN
137-
curl -fsSL https://dot.net/v1/dotnet-install.sh -o "$tmp/dotnet-install.sh"
138-
bash "$tmp/dotnet-install.sh" --channel 8.0 --install-dir "$HOME/.dotnet"
139-
export PATH="$HOME/.dotnet:$HOME/.dotnet/tools:$PATH"
140-
export DOTNET_ROOT="$HOME/.dotnet"
141-
if ! command -v dotnet >/dev/null 2>&1; then
142-
echo "[ERROR] dotnet installation failed."
143-
exit 1
144-
fi
145-
fi
146-
install_ok=1
94+
*)
14795
;;
14896
esac
14997

@@ -154,7 +102,7 @@ fi
154102

155103
command -v curl >/dev/null
156104

157-
# Root directory = the script's location
105+
# Root directory
158106
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
159107
cd "$SCRIPT_DIR"
160108

@@ -164,14 +112,14 @@ if [[ -f .gitmodules ]]; then
164112
git submodule update --init --recursive || true
165113
fi
166114

167-
# ===== Locate project ================================================================
115+
# Locate project
168116
PROJECT="v2rayN.Desktop/v2rayN.Desktop.csproj"
169117
if [[ ! -f "$PROJECT" ]]; then
170118
PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
171119
fi
172120
[[ -f "$PROJECT" ]] || { echo "v2rayN.Desktop.csproj not found"; exit 1; }
173121

174-
# ===== Resolve GUI version & auto checkout ============================================
122+
# Resolve GUI version & auto checkout
175123
VERSION=""
176124

177125
choose_channel() {
@@ -391,22 +339,6 @@ download_singbox() {
391339
install -Dm755 "$bin" "$outdir/sing-box"
392340
}
393341

394-
# ---- NEW: download_mihomo (REQUIRED in --netcore mode) ----
395-
download_mihomo() {
396-
# Download mihomo into outroot/bin/mihomo/mihomo
397-
local outroot="$1"
398-
local url=""
399-
if [[ "$RID_DIR" == "linux-arm64" ]]; then
400-
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64/bin/mihomo/mihomo"
401-
else
402-
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64/bin/mihomo/mihomo"
403-
fi
404-
echo "[+] Download mihomo: $url"
405-
mkdir -p "$outroot/bin/mihomo"
406-
curl -fL "$url" -o "$outroot/bin/mihomo/mihomo"
407-
chmod +x "$outroot/bin/mihomo/mihomo" || true
408-
}
409-
410342
# Move geo files to a unified path: outroot/bin
411343
unify_geo_layout() {
412344
local outroot="$1"
@@ -491,8 +423,7 @@ download_v2rayn_bundle() {
491423
fi
492424

493425
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
494-
# keep mihomo
495-
# find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 2>/dev/null || true
426+
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 2>/dev/null || true
496427

497428
local nested_dir
498429
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
@@ -603,7 +534,7 @@ build_for_arch() {
603534
fi
604535
download_geo_assets "$WORKDIR/$PKGROOT" || echo "[!] Geo rules download failed (skipped)"
605536
# ---- REQUIRED: always fetch mihomo in netcore mode, per-arch ----
606-
download_mihomo "$WORKDIR/$PKGROOT" || echo "[!] mihomo download failed (skipped)"
537+
# download_mihomo "$WORKDIR/$PKGROOT" || echo "[!] mihomo download failed (skipped)"
607538
fi
608539

609540
# Tarball

0 commit comments

Comments
 (0)