36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
root_dir=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
|
vendor_dir="$root_dir/Vendor"
|
|
destination="$vendor_dir/LibXray.xcframework"
|
|
archive_url="https://github.com/XTLS/libXray/releases/download/v26.7.28/libxray-apple-cgo.zip"
|
|
expected_sha256="07f7ed7697277930e1c517755855950f594f41435b0dfc5917a66eea6278aeb9"
|
|
|
|
if [ -d "$destination" ]; then
|
|
echo "LibXray.xcframework 已存在。"
|
|
exit 0
|
|
fi
|
|
|
|
work_dir=$(mktemp -d "${TMPDIR:-/tmp}/ucvl-libxray.XXXXXX")
|
|
trap 'rm -rf "$work_dir"' EXIT INT TERM
|
|
archive_path="$work_dir/libxray-apple-cgo.zip"
|
|
|
|
curl --fail --location --retry 3 --output "$archive_path" "$archive_url"
|
|
actual_sha256=$(shasum -a 256 "$archive_path" | awk '{print tolower($1)}')
|
|
if [ "$actual_sha256" != "$expected_sha256" ]; then
|
|
echo "libXray SHA256 校验失败。" >&2
|
|
exit 1
|
|
fi
|
|
|
|
unzip -q "$archive_path" -d "$work_dir/unpacked"
|
|
framework_path=$(find "$work_dir/unpacked" -type d -name LibXray.xcframework -print -quit)
|
|
if [ -z "$framework_path" ]; then
|
|
echo "官方压缩包中没有 LibXray.xcframework。" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$vendor_dir"
|
|
mv "$framework_path" "$destination"
|
|
echo "已安装并校验 libXray v26.7.28。"
|