This reverts commit d6e40fb7f5.
We do not need this manual patch as it is the part of the code now.
91 lines
3.0 KiB
Bash
Executable File
91 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Root directory = the script's location
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
source ./utils.sh
|
|
|
|
Arch="linux-64"
|
|
OutputPath="$(mktemp -d)"
|
|
Version="$1"
|
|
|
|
PROJ="./v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj"
|
|
dotnet restore "$PROJ"
|
|
sudo rm -rf "$(dirname "$PROJ")/bin/Release/net8.0"
|
|
dotnet publish "${PROJ}" -c Release -r "linux-x64" --self-contained -p:StripSymbols=true -o "$OutputPath"
|
|
PROJ="./v2rayN/AmazTool/AmazTool.csproj"
|
|
dotnet restore "$PROJ"
|
|
sudo rm -rf "$(dirname "$PROJ")/bin/Release/net8.0"
|
|
dotnet publish "${PROJ}" -c Release -r "linux-x64" --self-contained -p:StripSymbols=true -p:PublishTrimmed=true -o "$OutputPath"
|
|
|
|
export RID_DIR="linux-x64"
|
|
download_xray "$OutputPath/bin/xray"
|
|
download_singbox "$OutputPath/bin/sing_box"
|
|
download_geo_assets "$OutputPath"
|
|
|
|
PackagePath="v2rayn-unofficial"
|
|
mkdir -p "${PackagePath}/DEBIAN"
|
|
mkdir -p "${PackagePath}/opt"
|
|
cp -rf "$OutputPath" "${PackagePath}/opt/v2rayN"
|
|
echo "When this file exists, app will not store configs under this folder" >"${PackagePath}/opt/v2rayN/NotStoreConfigHere.txt"
|
|
sudo find "${PackagePath}/opt/v2rayN" -type f -name "*.so" -exec strip {} +
|
|
|
|
if [ "$Arch" = "linux-64" ]; then
|
|
Arch2="amd64"
|
|
else
|
|
Arch2="arm64"
|
|
fi
|
|
|
|
# basic
|
|
cat >"${PackagePath}/DEBIAN/control" <<-EOF
|
|
Package: v2rayn-unofficial
|
|
Version: $Version
|
|
Maintainer: Vlyaii <voronin9032n3@gmail.com>
|
|
Homepage: https://git.vlyaii.ru/voronin9032/v2rayN
|
|
Architecture: $Arch2
|
|
Replaces: v2rayn
|
|
Depends: libc6 (>= 2.34), fontconfig (>= 2.13.1), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 8.32), bash (>= 5.1)
|
|
Breaks: v2rayn
|
|
Conflicts: v2rayn
|
|
Description: A GUI client for Windows and Linux, support Xray core and sing-box-core and others
|
|
EOF
|
|
|
|
cat >"${PackagePath}/DEBIAN/postinst" <<-EOF
|
|
#!/bin/sh
|
|
if [ ! -s /usr/share/applications/v2rayN.desktop ]; then
|
|
cat >/usr/share/applications/v2rayN.desktop<<-END
|
|
[Desktop Entry]
|
|
Name=v2rayN
|
|
Comment=A GUI client for Windows and Linux, support Xray core and sing-box-core and others
|
|
Exec=/opt/v2rayN/v2rayN
|
|
Icon=/opt/v2rayN/v2rayN.png
|
|
Terminal=false
|
|
Type=Application
|
|
Categories=Network;Application;
|
|
END
|
|
fi
|
|
|
|
update-desktop-database
|
|
EOF
|
|
|
|
sudo chmod 0755 "${PackagePath}/DEBIAN/postinst"
|
|
sudo chmod 0755 "${PackagePath}/opt/v2rayN/v2rayN"
|
|
sudo chmod 0755 "${PackagePath}/opt/v2rayN/AmazTool"
|
|
|
|
# Patch
|
|
# set owner to root:root
|
|
sudo chown -R root:root "${PackagePath}"
|
|
# set all directories to 755 (readable & traversable by all users)
|
|
sudo find "${PackagePath}/opt/v2rayN" -type d -exec chmod 755 {} +
|
|
# set all regular files to 644 (readable by all users)
|
|
sudo find "${PackagePath}/opt/v2rayN" -type f -exec chmod 644 {} +
|
|
# ensure main binaries are 755 (executable by all users)
|
|
sudo chmod 755 "${PackagePath}/opt/v2rayN/v2rayN" 2>/dev/null || true
|
|
sudo chmod 755 "${PackagePath}/opt/v2rayN/AmazTool" 2>/dev/null || true
|
|
|
|
# build deb package
|
|
sudo dpkg-deb -Zzstd -z19 --build "$PackagePath"
|
|
sudo mv "${PackagePath}.deb" "v2rayn-unofficial_${Version}_${Arch2}.deb"
|
|
sudo rm -rf "$OutputPath"
|