refactor(base): 增强配置健壮性与开发体验
- 新增 pacman.conf 管理(Color + ILoveCandy + ParallelDownloads) - dev 模块改用 decman 原生 user/mimic_login 替代手拼 su - - dev 模块异常处理改为收集汇总,不再静默吞掉 - install.sh 改用 mktemp + trap 清理临时目录 - 移除 AGENTS.md 中不存在的 wsl.py 引用
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
│ ├── dev.py # 开发模块(语言运行时 + 编辑器 + 工具链)
|
||||
│ ├── docker.py # Docker 模块(packages + systemd units)
|
||||
│ ├── locale.py # locale 模块(files + on_change hook)
|
||||
│ ├── wsl.py # WSL 模块(WSL 特定适配)
|
||||
│ └── zsh.py # Zsh 模块(shell + oh-my-zsh + 插件)
|
||||
├── system/etc/ # 系统配置文件源 → 部署到 /etc/
|
||||
├── home/ # 用户配置文件源 → 部署到 ~/
|
||||
|
||||
@@ -10,6 +10,9 @@ class BaseModule(Module):
|
||||
|
||||
def files(self):
|
||||
return {
|
||||
"/etc/pacman.conf": File(
|
||||
source_file="./system/etc/pacman.conf",
|
||||
),
|
||||
"/etc/pacman.d/mirrorlist": File(
|
||||
source_file="./system/etc/pacman.d/mirrorlist",
|
||||
),
|
||||
|
||||
+12
-12
@@ -1,5 +1,3 @@
|
||||
import shlex
|
||||
|
||||
import decman
|
||||
from decman import File, Module
|
||||
from decman.plugins.pacman import packages as pacman_packages
|
||||
@@ -46,17 +44,19 @@ class DevModule(Module):
|
||||
}
|
||||
|
||||
def after_update(self, store):
|
||||
failures: list[str] = []
|
||||
for pkg in BUN_GLOBAL_PACKAGES:
|
||||
try:
|
||||
decman.prg(
|
||||
["su", "-", self.user, "-c", shlex.join(["bun", "add", "-g", pkg])]
|
||||
)
|
||||
except Exception:
|
||||
print(f"警告:安装 {pkg} 失败,跳过")
|
||||
decman.prg(["bun", "add", "-g", pkg], user=self.user, mimic_login=True)
|
||||
except Exception as e:
|
||||
failures.append(f"bun: {pkg} ({e})")
|
||||
for pkg in GO_INSTALL_PACKAGES:
|
||||
try:
|
||||
decman.prg(
|
||||
["su", "-", self.user, "-c", shlex.join(["go", "install", pkg])]
|
||||
)
|
||||
except Exception:
|
||||
print(f"警告:安装 {pkg} 失败,跳过")
|
||||
decman.prg(["go", "install", pkg], user=self.user, mimic_login=True)
|
||||
except Exception as e:
|
||||
failures.append(f"go: {pkg} ({e})")
|
||||
if failures:
|
||||
print(f"\n⚠ {len(failures)} 个全局包安装失败:")
|
||||
for f in failures:
|
||||
print(f" - {f}")
|
||||
print()
|
||||
|
||||
+4
-4
@@ -26,10 +26,10 @@ fi
|
||||
|
||||
echo "==> 安装 decman..."
|
||||
if ! command -v decman &> /dev/null; then
|
||||
rm -rf /tmp/decman
|
||||
git clone https://aur.archlinux.org/decman.git /tmp/decman
|
||||
(cd /tmp/decman && makepkg -si --noconfirm)
|
||||
rm -rf /tmp/decman
|
||||
_tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$_tmpdir"' EXIT
|
||||
git clone https://aur.archlinux.org/decman.git "$_tmpdir"
|
||||
(cd "$_tmpdir" && makepkg -si --noconfirm)
|
||||
fi
|
||||
|
||||
echo "==> 应用系统配置..."
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# /etc/pacman.conf
|
||||
#
|
||||
|
||||
[options]
|
||||
HoldPkg = pacman glibc
|
||||
Architecture = auto
|
||||
|
||||
Color
|
||||
ILoveCandy
|
||||
VerbosePkgLists
|
||||
ParallelDownloads = 5
|
||||
|
||||
CheckSpace
|
||||
|
||||
SigLevel = Required DatabaseOptional
|
||||
LocalFileSigLevel = Optional
|
||||
|
||||
[core]
|
||||
Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
[extra]
|
||||
Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
# [multilib]
|
||||
# Include = /etc/pacman.d/mirrorlist
|
||||
Reference in New Issue
Block a user