Skip to content

Commit 2c863ce

Browse files
committed
feat: 支持更多 Linux 包管理器 (dnf / pacman)
- 自动检测 apt / dnf / pacman - profiles.json 新增 linux_dnf / linux_pacman 安装命令 - 新增 check_linux_dnf / check_linux_pacman 检测命令 - get_linux_field() 函数动态映射字段名 - install_software() 和 is_installed() 适配多包管理器 - README 更新包管理器表格 - 版本号: v0.32.0
1 parent b8e0a66 commit 2c863ce

3 files changed

Lines changed: 67 additions & 27 deletions

File tree

config/profiles.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@
3232
}
3333
},
3434
"software": {
35-
"chrome": {"name": "Chrome", "desc": "浏览器/Web browser", "win": "winget install Google.Chrome", "mac": "brew install --cask google-chrome", "linux": "sudo apt install -y google-chrome-stable", "check_win": "winget list Google.Chrome", "check_mac": "ls /Applications/Google\\ Chrome.app 2>/dev/null", "check_linux": "which google-chrome-stable 2>/dev/null"},
36-
"edge": {"name": "Edge", "desc": "微软浏览器/Microsoft browser", "win": "winget install Microsoft.Edge", "mac": "brew install --cask microsoft-edge", "linux": "curl -o /tmp/microsoft-edge.deb https://packages.microsoft.com/repos/edge && sudo dpkg -i /tmp/microsoft-edge.deb", "check_win": "winget list Microsoft.Edge", "check_mac": "ls /Applications/Microsoft\\ Edge.app 2>/dev/null", "check_linux": "which microsoft-edge 2>/dev/null"},
37-
"vscode": {"name": "VS Code", "desc": "代码编辑器/Code editor", "win": "winget install Microsoft.VisualStudioCode", "mac": "brew install --cask visual-studio-code", "linux": "sudo snap install --classic code", "check_win": "winget list Microsoft.VisualStudioCode", "check_mac": "ls /Applications/Visual\\ Studio\\ Code.app 2>/dev/null", "check_linux": "which code 2>/dev/null"},
38-
"intellij": {"name": "IntelliJ IDEA", "desc": "JetBrains IDE/JetBrains IDE", "win": "winget install JetBrains.IntelliJIDEA.Community", "mac": "brew install --cask intellij-idea-ce", "linux": "curl -o /tmp/idea.tar.gz https://download.jetbrains.com/product?code=IIC&& sudo tar -xzf /tmp/idea.tar.gz -C /opt", "check_win": "winget list JetBrains.IntelliJIDEA.Community", "check_mac": "ls /Applications/IntelliJ\\ IDEA.app 2>/dev/null", "check_linux": "which idea 2>/dev/null"},
39-
"git": {"name": "Git", "desc": "版本控制/Version control", "win": "winget install Git.Git", "mac": "brew install git", "linux": "sudo apt install -y git", "check_win": "winget list Git.Git", "check_mac": "which git 2>/dev/null", "check_linux": "which git 2>/dev/null"},
40-
"nodejs": {"name": "Node.js", "desc": "JavaScript 运行时/JavaScript runtime", "win": "winget install OpenJS.NodeJS.LTS", "mac": "brew install node", "linux": "curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt install -y nodejs", "check_win": "winget list OpenJS.NodeJS", "check_mac": "which node 2>/dev/null", "check_linux": "which node 2>/dev/null"},
41-
"python": {"name": "Python", "desc": "Python 编程语言/Python programming language", "win": "winget install Python.Python.3.11", "mac": "brew install python@3.11", "linux": "sudo apt install -y python3 python3-pip", "check_win": "winget list Python.Python", "check_mac": "which python3 2>/dev/null", "check_linux": "which python3 2>/dev/null"},
42-
"go": {"name": "Go", "desc": "Go 编程语言/Go programming language", "win": "winget install Golang.Go", "mac": "brew install go", "linux": "sudo apt install -y golang", "check_win": "winget list Golang.Go", "check_mac": "which go 2>/dev/null", "check_linux": "which go 2>/dev/null"},
43-
"docker": {"name": "Docker", "desc": "容器化平台/Containerization platform", "win": "winget install Docker.DockerDesktop", "mac": "brew install --cask docker", "linux": "curl -fsSL https://get.docker.com | sh", "check_win": "winget list Docker.DockerDesktop", "check_mac": "which docker 2>/dev/null", "check_linux": "which docker 2>/dev/null"},
44-
"wps": {"name": "WPS Office", "desc": "办公套件/Office suite", "win": "winget install Kingsoft.WPSOffice", "mac": "brew install --cask wps-office", "linux": "sudo apt install -y wps-office", "check_win": "winget list Kingsoft.WPSOffice", "check_mac": "ls /Applications/WPS\\ Office.app 2>/dev/null", "check_linux": "which wps 2>/dev/null"},
45-
"obsidian": {"name": "Obsidian", "desc": "笔记工具/Note-taking tool", "win": "winget install Obsidian.Obsidian", "mac": "brew install --cask obsidian", "linux": "sudo snap install obsidian --classic", "check_win": "winget list Obsidian.Obsidian", "check_mac": "ls /Applications/Obsidian.app 2>/dev/null", "check_linux": "which obsidian 2>/dev/null"},
46-
"notion": {"name": "Notion", "desc": "协作工具/Collaboration tool", "win": "winget install Notion.Notion", "mac": "brew install --cask notion", "linux": "sudo snap install notion-snap", "check_win": "winget list Notion.Notion", "check_mac": "ls /Applications/Notion.app 2>/dev/null", "check_linux": "which notion 2>/dev/null"},
47-
"cursor": {"name": "Cursor", "desc": "AI 代码编辑器/AI code editor", "win": "winget install Cursor.Cursor", "mac": "brew install --cask cursor", "linux": "curl -o /tmp/cursor.AppImage https://cursor.sh/linux/x64 && chmod +x /tmp/cursor.AppImage", "check_win": "winget list Cursor.Cursor", "check_mac": "ls /Applications/Cursor.app 2>/dev/null", "check_linux": "which cursor 2>/dev/null"},
48-
"ollama": {"name": "Ollama", "desc": "本地 LLM/Local LLM runner", "win": "powershell -Command \"irm https://ollama.ai/install.ps1 | iex\"", "mac": "brew install ollama", "linux": "curl -fsSL https://ollama.ai/install.sh | sh", "check_win": "where ollama 2>nul", "check_mac": "which ollama 2>/dev/null", "check_linux": "which ollama 2>/dev/null"},
49-
"lmstudio": {"name": "LM Studio", "desc": "本地 LLM 客户端/Local LLM client", "win": "winget install LMStudio.LMStudio", "mac": "brew install --cask lm-studio", "linux": "curl -o /tmp/lm-studio.AppImage https://releases.lmstudio.ai/linux/x64/latest", "check_win": "winget list LMStudio.LMStudio", "check_mac": "ls /Applications/LM\\ Studio.app 2>/dev/null", "check_linux": "which lm-studio 2>/dev/null"},
50-
"vlc": {"name": "VLC", "desc": "媒体播放器/Media player", "win": "winget install VideoLAN.VLC", "mac": "brew install --cask vlc", "linux": "sudo apt install -y vlc", "check_win": "winget list VideoLAN.VLC", "check_mac": "ls /Applications/VLC.app 2>/dev/null", "check_linux": "which vlc 2>/dev/null"},
51-
"obs": {"name": "OBS Studio", "desc": "直播录制/Streaming & recording", "win": "winget install OBSProject.OBSStudio", "mac": "brew install --cask obs", "linux": "sudo apt install -y obs-studio", "check_win": "winget list OBSProject.OBSStudio", "check_mac": "ls /Applications/OBS.app 2>/dev/null", "check_linux": "which obs 2>/dev/null"}
35+
"chrome": {"name": "Chrome", "desc": "浏览器/Web browser", "win": "winget install Google.Chrome", "mac": "brew install --cask google-chrome", "linux": "sudo apt install -y google-chrome-stable", "linux_dnf": "sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm", "linux_pacman": "yay -S google-chrome", "check_win": "winget list Google.Chrome", "check_mac": "ls /Applications/Google\\ Chrome.app 2>/dev/null", "check_linux": "which google-chrome-stable 2>/dev/null", "check_linux_dnf": "which google-chrome-stable 2>/dev/null", "check_linux_pacman": "which google-chrome 2>/dev/null"},
36+
"edge": {"name": "Edge", "desc": "微软浏览器/Microsoft browser", "win": "winget install Microsoft.Edge", "mac": "brew install --cask microsoft-edge", "linux": "curl -o /tmp/microsoft-edge.deb https://packages.microsoft.com/repos/edge && sudo dpkg -i /tmp/microsoft-edge.deb", "linux_dnf": "sudo dnf install -y microsoft-edge-stable", "linux_pacman": "yay -S microsoft-edge-stable-bin", "check_win": "winget list Microsoft.Edge", "check_mac": "ls /Applications/Microsoft\\ Edge.app 2>/dev/null", "check_linux": "which microsoft-edge 2>/dev/null", "check_linux_dnf": "which microsoft-edge 2>/dev/null", "check_linux_pacman": "which microsoft-edge 2>/dev/null"},
37+
"vscode": {"name": "VS Code", "desc": "代码编辑器/Code editor", "win": "winget install Microsoft.VisualStudioCode", "mac": "brew install --cask visual-studio-code", "linux": "sudo snap install --classic code", "linux_dnf": "sudo dnf install -y code", "linux_pacman": "sudo pacman -S code", "check_win": "winget list Microsoft.VisualStudioCode", "check_mac": "ls /Applications/Visual\\ Studio\\ Code.app 2>/dev/null", "check_linux": "which code 2>/dev/null", "check_linux_dnf": "which code 2>/dev/null", "check_linux_pacman": "which code 2>/dev/null"},
38+
"intellij": {"name": "IntelliJ IDEA", "desc": "JetBrains IDE/JetBrains IDE", "win": "winget install JetBrains.IntelliJIDEA.Community", "mac": "brew install --cask intellij-idea-ce", "linux": "sudo snap install intellij-idea-community --classic", "linux_dnf": "sudo dnf install -y intellij-idea-community", "linux_pacman": "sudo pacman -S intellij-idea-community-edition", "check_win": "winget list JetBrains.IntelliJIDEA.Community", "check_mac": "ls /Applications/IntelliJ\\ IDEA.app 2>/dev/null", "check_linux": "which idea 2>/dev/null", "check_linux_dnf": "which idea 2>/dev/null", "check_linux_pacman": "which idea 2>/dev/null"},
39+
"git": {"name": "Git", "desc": "版本控制/Version control", "win": "winget install Git.Git", "mac": "brew install git", "linux": "sudo apt install -y git", "linux_dnf": "sudo dnf install -y git", "linux_pacman": "sudo pacman -S git", "check_win": "winget list Git.Git", "check_mac": "which git 2>/dev/null", "check_linux": "which git 2>/dev/null", "check_linux_dnf": "which git 2>/dev/null", "check_linux_pacman": "which git 2>/dev/null"},
40+
"nodejs": {"name": "Node.js", "desc": "JavaScript 运行时/JavaScript runtime", "win": "winget install OpenJS.NodeJS.LTS", "mac": "brew install node", "linux": "curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt install -y nodejs", "linux_dnf": "sudo dnf install -y nodejs", "linux_pacman": "sudo pacman -S nodejs npm", "check_win": "winget list OpenJS.NodeJS", "check_mac": "which node 2>/dev/null", "check_linux": "which node 2>/dev/null", "check_linux_dnf": "which node 2>/dev/null", "check_linux_pacman": "which node 2>/dev/null"},
41+
"python": {"name": "Python", "desc": "Python 编程语言/Python programming language", "win": "winget install Python.Python.3.11", "mac": "brew install python@3.11", "linux": "sudo apt install -y python3 python3-pip", "linux_dnf": "sudo dnf install -y python3 python3-pip", "linux_pacman": "sudo pacman -S python python-pip", "check_win": "winget list Python.Python", "check_mac": "which python3 2>/dev/null", "check_linux": "which python3 2>/dev/null", "check_linux_dnf": "which python3 2>/dev/null", "check_linux_pacman": "which python3 2>/dev/null"},
42+
"go": {"name": "Go", "desc": "Go 编程语言/Go programming language", "win": "winget install Golang.Go", "mac": "brew install go", "linux": "sudo apt install -y golang", "linux_dnf": "sudo dnf install -y golang", "linux_pacman": "sudo pacman -S go", "check_win": "winget list Golang.Go", "check_mac": "which go 2>/dev/null", "check_linux": "which go 2>/dev/null", "check_linux_dnf": "which go 2>/dev/null", "check_linux_pacman": "which go 2>/dev/null"},
43+
"docker": {"name": "Docker", "desc": "容器化平台/Containerization platform", "win": "winget install Docker.DockerDesktop", "mac": "brew install --cask docker", "linux": "curl -fsSL https://get.docker.com | sh", "linux_dnf": "curl -fsSL https://get.docker.com | sh", "linux_pacman": "sudo pacman -S docker && sudo systemctl enable --now docker", "check_win": "winget list Docker.DockerDesktop", "check_mac": "which docker 2>/dev/null", "check_linux": "which docker 2>/dev/null", "check_linux_dnf": "which docker 2>/dev/null", "check_linux_pacman": "which docker 2>/dev/null"},
44+
"wps": {"name": "WPS Office", "desc": "办公套件/Office suite", "win": "winget install Kingsoft.WPSOffice", "mac": "brew install --cask wps-office", "linux": "sudo apt install -y wps-office", "linux_dnf": "sudo dnf install -y wps-office", "linux_pacman": "yay -S wps-office", "check_win": "winget list Kingsoft.WPSOffice", "check_mac": "ls /Applications/WPS\\ Office.app 2>/dev/null", "check_linux": "which wps 2>/dev/null", "check_linux_dnf": "which wps 2>/dev/null", "check_linux_pacman": "which wps 2>/dev/null"},
45+
"obsidian": {"name": "Obsidian", "desc": "笔记工具/Note-taking tool", "win": "winget install Obsidian.Obsidian", "mac": "brew install --cask obsidian", "linux": "sudo snap install obsidian --classic", "linux_dnf": "sudo dnf install -y obsidian", "linux_pacman": "yay -S obsidian", "check_win": "winget list Obsidian.Obsidian", "check_mac": "ls /Applications/Obsidian.app 2>/dev/null", "check_linux": "which obsidian 2>/dev/null", "check_linux_dnf": "which obsidian 2>/dev/null", "check_linux_pacman": "which obsidian 2>/dev/null"},
46+
"notion": {"name": "Notion", "desc": "协作工具/Collaboration tool", "win": "winget install Notion.Notion", "mac": "brew install --cask notion", "linux": "sudo snap install notion-snap", "linux_dnf": "sudo dnf install -y notion-app", "linux_pacman": "yay -S notion-app", "check_win": "winget list Notion.Notion", "check_mac": "ls /Applications/Notion.app 2>/dev/null", "check_linux": "which notion 2>/dev/null", "check_linux_dnf": "which notion 2>/dev/null", "check_linux_pacman": "which notion 2>/dev/null"},
47+
"cursor": {"name": "Cursor", "desc": "AI 代码编辑器/AI code editor", "win": "winget install Cursor.Cursor", "mac": "brew install --cask cursor", "linux": "curl -o /tmp/cursor.AppImage https://cursor.sh/linux/x64 && chmod +x /tmp/cursor.AppImage", "linux_dnf": "curl -o /tmp/cursor.AppImage https://cursor.sh/linux/x64 && chmod +x /tmp/cursor.AppImage", "linux_pacman": "yay -S cursor", "check_win": "winget list Cursor.Cursor", "check_mac": "ls /Applications/Cursor.app 2>/dev/null", "check_linux": "which cursor 2>/dev/null", "check_linux_dnf": "which cursor 2>/dev/null", "check_linux_pacman": "which cursor 2>/dev/null"},
48+
"ollama": {"name": "Ollama", "desc": "本地 LLM/Local LLM runner", "win": "powershell -Command \"irm https://ollama.ai/install.ps1 | iex\"", "mac": "brew install ollama", "linux": "curl -fsSL https://ollama.ai/install.sh | sh", "linux_dnf": "curl -fsSL https://ollama.ai/install.sh | sh", "linux_pacman": "sudo pacman -S ollama", "check_win": "where ollama 2>nul", "check_mac": "which ollama 2>/dev/null", "check_linux": "which ollama 2>/dev/null", "check_linux_dnf": "which ollama 2>/dev/null", "check_linux_pacman": "which ollama 2>/dev/null"},
49+
"lmstudio": {"name": "LM Studio", "desc": "本地 LLM 客户端/Local LLM client", "win": "winget install LMStudio.LMStudio", "mac": "brew install --cask lm-studio", "linux": "curl -o /tmp/lm-studio.AppImage https://releases.lmstudio.ai/linux/x64/latest", "linux_dnf": "curl -o /tmp/lm-studio.AppImage https://releases.lmstudio.ai/linux/x64/latest", "linux_pacman": "yay -S lm-studio", "check_win": "winget list LMStudio.LMStudio", "check_mac": "ls /Applications/LM\\ Studio.app 2>/dev/null", "check_linux": "which lm-studio 2>/dev/null", "check_linux_dnf": "which lm-studio 2>/dev/null", "check_linux_pacman": "which lm-studio 2>/dev/null"},
50+
"vlc": {"name": "VLC", "desc": "媒体播放器/Media player", "win": "winget install VideoLAN.VLC", "mac": "brew install --cask vlc", "linux": "sudo apt install -y vlc", "linux_dnf": "sudo dnf install -y vlc", "linux_pacman": "sudo pacman -S vlc", "check_win": "winget list VideoLAN.VLC", "check_mac": "ls /Applications/VLC.app 2>/dev/null", "check_linux": "which vlc 2>/dev/null", "check_linux_dnf": "which vlc 2>/dev/null", "check_linux_pacman": "which vlc 2>/dev/null"},
51+
"obs": {"name": "OBS Studio", "desc": "直播录制/Streaming & recording", "win": "winget install OBSProject.OBSStudio", "mac": "brew install --cask obs", "linux": "sudo apt install -y obs-studio", "linux_dnf": "sudo dnf install -y obs-studio", "linux_pacman": "sudo pacman -S obs-studio", "check_win": "winget list OBSProject.OBSStudio", "check_mac": "ls /Applications/OBS.app 2>/dev/null", "check_linux": "which obs 2>/dev/null", "check_linux_dnf": "which obs 2>/dev/null", "check_linux_pacman": "which obs 2>/dev/null"}
5252
}
5353
}

dist/quickstart.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,10 @@ is_installed() {
414414
case "$os" in
415415
macos) check_field="check_mac" ;;
416416
windows) check_field="check_win" ;;
417-
linux) check_field="check_linux" ;;
417+
linux)
418+
local linux_field=$(get_linux_field "$PKG_MANAGER")
419+
check_field="check_${linux_field}"
420+
;;
418421
*) return 1 ;;
419422
esac
420423

@@ -644,7 +647,24 @@ check_package_manager() {
644647
case $1 in
645648
windows) command -v winget &>/dev/null && echo "winget" || echo "none" ;;
646649
macos) command -v brew &>/dev/null && echo "brew" || echo "none" ;;
647-
linux) command -v apt &>/dev/null && echo "apt" || echo "none" ;;
650+
linux)
651+
if command -v apt &>/dev/null; then echo "apt"
652+
elif command -v dnf &>/dev/null; then echo "dnf"
653+
elif command -v pacman &>/dev/null; then echo "pacman"
654+
else echo "none"
655+
fi
656+
;;
657+
esac
658+
}
659+
660+
# 获取 Linux 安装命令字段名
661+
get_linux_field() {
662+
local pkg_mgr=$1
663+
case "$pkg_mgr" in
664+
apt) echo "linux" ;;
665+
dnf) echo "linux_dnf" ;;
666+
pacman) echo "linux_pacman" ;;
667+
*) echo "linux" ;;
648668
esac
649669
}
650670

@@ -896,7 +916,7 @@ install_software() {
896916
case "$os" in
897917
windows) platform="win" ;;
898918
macos) platform="mac" ;;
899-
linux) platform="linux" ;;
919+
linux) platform=$(get_linux_field "$PKG_MANAGER") ;;
900920
esac
901921

902922
local cmd=$(json_get_software_field "$json_file" "$key" "$platform")
@@ -1068,10 +1088,10 @@ main() {
10681088
log_info "$LANG_DETECTING_SYSTEM"
10691089
local os=$(detect_os)
10701090
local system_info=$(get_system_info)
1071-
local pkg_manager=$(check_package_manager "$os")
1091+
PKG_MANAGER=$(check_package_manager "$os")
10721092

10731093
log_info "$LANG_SYSTEM_INFO: $system_info"
1074-
log_info "$LANG_PACKAGE_MANAGER: $pkg_manager"
1094+
log_info "$LANG_PACKAGE_MANAGER: $PKG_MANAGER"
10751095

10761096
[[ "$os" == "unknown" ]] && log_error "$LANG_UNSUPPORTED_OS" && exit 1
10771097

src/quickstart.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,10 @@ is_installed() {
414414
case "$os" in
415415
macos) check_field="check_mac" ;;
416416
windows) check_field="check_win" ;;
417-
linux) check_field="check_linux" ;;
417+
linux)
418+
local linux_field=$(get_linux_field "$PKG_MANAGER")
419+
check_field="check_${linux_field}"
420+
;;
418421
*) return 1 ;;
419422
esac
420423

@@ -644,7 +647,24 @@ check_package_manager() {
644647
case $1 in
645648
windows) command -v winget &>/dev/null && echo "winget" || echo "none" ;;
646649
macos) command -v brew &>/dev/null && echo "brew" || echo "none" ;;
647-
linux) command -v apt &>/dev/null && echo "apt" || echo "none" ;;
650+
linux)
651+
if command -v apt &>/dev/null; then echo "apt"
652+
elif command -v dnf &>/dev/null; then echo "dnf"
653+
elif command -v pacman &>/dev/null; then echo "pacman"
654+
else echo "none"
655+
fi
656+
;;
657+
esac
658+
}
659+
660+
# 获取 Linux 安装命令字段名
661+
get_linux_field() {
662+
local pkg_mgr=$1
663+
case "$pkg_mgr" in
664+
apt) echo "linux" ;;
665+
dnf) echo "linux_dnf" ;;
666+
pacman) echo "linux_pacman" ;;
667+
*) echo "linux" ;;
648668
esac
649669
}
650670

@@ -896,7 +916,7 @@ install_software() {
896916
case "$os" in
897917
windows) platform="win" ;;
898918
macos) platform="mac" ;;
899-
linux) platform="linux" ;;
919+
linux) platform=$(get_linux_field "$PKG_MANAGER") ;;
900920
esac
901921

902922
local cmd=$(json_get_software_field "$json_file" "$key" "$platform")
@@ -1068,10 +1088,10 @@ main() {
10681088
log_info "$LANG_DETECTING_SYSTEM"
10691089
local os=$(detect_os)
10701090
local system_info=$(get_system_info)
1071-
local pkg_manager=$(check_package_manager "$os")
1091+
PKG_MANAGER=$(check_package_manager "$os")
10721092

10731093
log_info "$LANG_SYSTEM_INFO: $system_info"
1074-
log_info "$LANG_PACKAGE_MANAGER: $pkg_manager"
1094+
log_info "$LANG_PACKAGE_MANAGER: $PKG_MANAGER"
10751095

10761096
[[ "$os" == "unknown" ]] && log_error "$LANG_UNSUPPORTED_OS" && exit 1
10771097

0 commit comments

Comments
 (0)