重写为多协议管理器: 6 协议, CLI + curses TUI, 用户级 systemd

This commit is contained in:
typist committed 2026-11-01 06:38:56 +08:00
1 parent c43ab4a16e
commit 237b958e41
71 files changed
+4599 -1171

No files matched your search

+25 -17
View File
@@ -3,31 +3,39 @@ set -euo pipefail
repo="${SBP_REPO:-justypist/sbp}"
branch="${SBP_BRANCH:-main}"
dest="${SBP_BIN:-$HOME/.local/bin}"
url="https://raw.githubusercontent.com/${repo}/${branch}/sbp"
app_dir="${SBP_APP_DIR:-$HOME/.local/share/sbp/app}"
bin_dir="${SBP_BIN:-$HOME/.local/bin}"
url="https://github.com/${repo}/archive/refs/heads/${branch}.tar.gz"
command -v curl >/dev/null 2>&1 || { echo "error: curl is required" >&2; exit 1; }
command -v tar >/dev/null 2>&1 || { echo "error: tar is required" >&2; exit 1; }
command -v python3 >/dev/null 2>&1 || { echo "error: python3 is required" >&2; exit 1; }
mkdir -p "$dest"
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
curl -fsSL "$url" -o "$tmp"
head -n 1 "$tmp" | grep -q '^#!/usr/bin/env python3' || {
echo "error: unexpected content from $url" >&2
exit 1
}
chmod 755 "$tmp"
mv "$tmp" "$dest/sbp"
trap - EXIT
curl -fsSL "$url" | tar -xz -C "$tmp"
src="$(find "$tmp" -mindepth 1 -maxdepth 1 -type d | head -n 1)"
[ -n "$src" ] && [ -f "$src/sbp" ] || { echo "error: unexpected archive layout from $url" >&2; exit 1; }
[ -f "$src/src/sbp/cli.py" ] || { echo "error: package files missing from $url" >&2; exit 1; }
echo "installed $dest/sbp"
mkdir -p "$(dirname "$app_dir")" "$bin_dir"
rm -rf "$app_dir.new"
mv "$src" "$app_dir.new"
chmod 755 "$app_dir.new/sbp"
if [ -e "$app_dir" ]; then
[ -f "$app_dir/src/sbp/cli.py" ] || { echo "error: refusing to replace $app_dir" >&2; exit 1; }
rm -rf "$app_dir"
fi
mv "$app_dir.new" "$app_dir"
ln -sfn "$app_dir/sbp" "$bin_dir/sbp"
echo "installed $bin_dir/sbp"
case ":$PATH:" in
*":$dest:"*) ;;
*) echo "note: add $dest to PATH, for example: export PATH=\"$dest:\$PATH\"" ;;
*":$bin_dir:"*) ;;
*) echo "note: add $bin_dir to PATH, for example: export PATH=\"$bin_dir:\$PATH\"" ;;
esac
if [ "${1:-}" = "--run" ]; then
exec "$dest/sbp" install "${@:2}"
exec "$bin_dir/sbp" install "${@:2}"
fi