Files
omarchycn/bin/omarchy-cn-app-install
T
ZacharyZhang-NYandClaude Fable 5 0812b28527 Detect the missing official repo dbs by core.db, not any db
pacstrap leaves the offline repo's db in the target's sync dir, so
the any-db glob skipped the first-run update path on real installs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
2026-08-25 13:50:11 -04:00

58 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# omarchy:summary=Install a China app from the catalog with source confirmation
# omarchy:args=<app-id> [--yes]
# omarchy:examples=omarchycn app install wechat | omarchycn app install tencent-docs
set -euo pipefail
APPS_JSON="$OMARCHY_PATH/cn/apps.json"
app="${1:?usage: omarchycn app install <app-id> (see: omarchycn app list)}"
yes="${2:-}"
entry=$(jq -e --arg a "$app" '.apps[$a]' "$APPS_JSON") || {
echo "Unknown app: $app (see: omarchycn app list)" >&2
exit 1
}
name=$(jq -r '.name' <<<"$entry")
source_type=$(jq -r '.source' <<<"$entry")
license=$(jq -r '.license' <<<"$entry")
if [[ $license == "proprietary" && $yes != "--yes" ]]; then
pkg=$(jq -r '.package' <<<"$entry")
echo "$name 为专有软件,来源: AUR/$pkg(构建脚本公开,二进制来自厂商)"
if [[ -t 0 ]]; then
gum confirm "确认安装?" || exit 1
else
echo "非交互环境需显式加 --yes 确认专有软件安装" >&2
exit 1
fi
fi
case "$source_type" in
aur)
# Offline installs leave only offline.db in sync; without the official
# repo dbs yay treats repo deps as AUR. Upgrades must go through the
# omarchy-update pipeline (pacman guard).
if [[ ! -f /var/lib/pacman/sync/core.db ]]; then
if [[ ! -t 0 ]]; then
echo "首次安装应用前请先完成一次系统更新: omarchy-update" >&2
exit 1
fi
echo "首次安装应用前需要完成一次系统更新。"
omarchy-update
fi
omarchy-pkg-aur-add "$(jq -r '.package' <<<"$entry")"
;;
webapp)
omarchy-webapp-install "$name" "$(jq -r '.url' <<<"$entry")" "$(jq -r '.icon' <<<"$entry")"
;;
*)
echo "Unknown source type: $source_type" >&2
exit 1
;;
esac
echo "$name 安装完成"