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 # 开发模块(语言运行时 + 编辑器 + 工具链)
|
│ ├── dev.py # 开发模块(语言运行时 + 编辑器 + 工具链)
|
||||||
│ ├── docker.py # Docker 模块(packages + systemd units)
|
│ ├── docker.py # Docker 模块(packages + systemd units)
|
||||||
│ ├── locale.py # locale 模块(files + on_change hook)
|
│ ├── locale.py # locale 模块(files + on_change hook)
|
||||||
│ ├── wsl.py # WSL 模块(WSL 特定适配)
|
|
||||||
│ └── zsh.py # Zsh 模块(shell + oh-my-zsh + 插件)
|
│ └── zsh.py # Zsh 模块(shell + oh-my-zsh + 插件)
|
||||||
├── system/etc/ # 系统配置文件源 → 部署到 /etc/
|
├── system/etc/ # 系统配置文件源 → 部署到 /etc/
|
||||||
├── home/ # 用户配置文件源 → 部署到 ~/
|
├── home/ # 用户配置文件源 → 部署到 ~/
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ class BaseModule(Module):
|
|||||||
|
|
||||||
def files(self):
|
def files(self):
|
||||||
return {
|
return {
|
||||||
|
"/etc/pacman.conf": File(
|
||||||
|
source_file="./system/etc/pacman.conf",
|
||||||
|
),
|
||||||
"/etc/pacman.d/mirrorlist": File(
|
"/etc/pacman.d/mirrorlist": File(
|
||||||
source_file="./system/etc/pacman.d/mirrorlist",
|
source_file="./system/etc/pacman.d/mirrorlist",
|
||||||
),
|
),
|
||||||
|
|||||||
+12
-12
@@ -1,5 +1,3 @@
|
|||||||
import shlex
|
|
||||||
|
|
||||||
import decman
|
import decman
|
||||||
from decman import File, Module
|
from decman import File, Module
|
||||||
from decman.plugins.pacman import packages as pacman_packages
|
from decman.plugins.pacman import packages as pacman_packages
|
||||||
@@ -46,17 +44,19 @@ class DevModule(Module):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def after_update(self, store):
|
def after_update(self, store):
|
||||||
|
failures: list[str] = []
|
||||||
for pkg in BUN_GLOBAL_PACKAGES:
|
for pkg in BUN_GLOBAL_PACKAGES:
|
||||||
try:
|
try:
|
||||||
decman.prg(
|
decman.prg(["bun", "add", "-g", pkg], user=self.user, mimic_login=True)
|
||||||
["su", "-", self.user, "-c", shlex.join(["bun", "add", "-g", pkg])]
|
except Exception as e:
|
||||||
)
|
failures.append(f"bun: {pkg} ({e})")
|
||||||
except Exception:
|
|
||||||
print(f"警告:安装 {pkg} 失败,跳过")
|
|
||||||
for pkg in GO_INSTALL_PACKAGES:
|
for pkg in GO_INSTALL_PACKAGES:
|
||||||
try:
|
try:
|
||||||
decman.prg(
|
decman.prg(["go", "install", pkg], user=self.user, mimic_login=True)
|
||||||
["su", "-", self.user, "-c", shlex.join(["go", "install", pkg])]
|
except Exception as e:
|
||||||
)
|
failures.append(f"go: {pkg} ({e})")
|
||||||
except Exception:
|
if failures:
|
||||||
print(f"警告:安装 {pkg} 失败,跳过")
|
print(f"\n⚠ {len(failures)} 个全局包安装失败:")
|
||||||
|
for f in failures:
|
||||||
|
print(f" - {f}")
|
||||||
|
print()
|
||||||
|
|||||||
+4
-4
@@ -26,10 +26,10 @@ fi
|
|||||||
|
|
||||||
echo "==> 安装 decman..."
|
echo "==> 安装 decman..."
|
||||||
if ! command -v decman &> /dev/null; then
|
if ! command -v decman &> /dev/null; then
|
||||||
rm -rf /tmp/decman
|
_tmpdir=$(mktemp -d)
|
||||||
git clone https://aur.archlinux.org/decman.git /tmp/decman
|
trap 'rm -rf "$_tmpdir"' EXIT
|
||||||
(cd /tmp/decman && makepkg -si --noconfirm)
|
git clone https://aur.archlinux.org/decman.git "$_tmpdir"
|
||||||
rm -rf /tmp/decman
|
(cd "$_tmpdir" && makepkg -si --noconfirm)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "==> 应用系统配置..."
|
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