starhaven-io/macOSdb

GitHub: starhaven-io/macOSdb

一款用于编目和对比各 macOS 与 Xcode 版本中内置开源组件版本信息的原生应用和命令行工具。

Stars: 6 | Forks: 0

# macOSdb [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/05/f28723072d114808.svg)](https://github.com/starhaven-io/macOSdb/actions/workflows/ci.yml) [![License: AGPL-3.0-only](https://img.shields.io/badge/License-AGPL--3.0--only-blue.svg)](LICENSE) [![Data: CC-BY-4.0](https://img.shields.io/badge/Data-CC--BY--4.0-green.svg)](data/LICENSE) 一款原生 macOS 应用和 CLI 工具,用于编目每个 macOS 和 Xcode 版本中附带的开源组件版本。 macOSdb 会扫描 Apple 的 IPSW 固件文件和 Xcode `.xip` 归档,从系统二进制文件、dyld 共享缓存和 SDK 头文件中提取版本字符串,并记录各项版本的搭载情况。您可以浏览各个版本、对比不同更新之间的组件版本,以及查看每个版本支持的芯片系列和设备。 **网站:** [macosdb.com](https://macosdb.com) ## 跟踪的组件 **文件系统二进制文件:** curl、httpd、LibreSSL、OpenSSH、Ruby、SQLite、vim、zsh **Dyld 共享缓存:** libbz2、libcurl、libexpat、libncurses、libpcap、libsqlite3、libssl、libxml2 **Xcode 工具链:** Apple Clang、cctools、Git、ld、lldb、Swift **SDK 库:** bzip2、expat、libcurl、libedit、libexslt、libffi、libxml2、libxslt、ncurses、sqlite3、zlib ## 安装 需要 macOS 15.0+ 及 Apple Silicon。从源码构建需要 Xcode 26+。 ### Homebrew ``` brew install starhaven-io/tap/macosdb ``` ### App 从 [GitHub Releases](https://github.com/starhaven-io/macOSdb/releases) 下载最新版本,解压后移动到 `/Applications`。该应用内置了 Sparkle 以支持自动更新。 ### 从源码构建 ``` # 构建 CLI swift build -c release # 构建 app xcodebuild build -scheme macOSdb -configuration Release ``` ## CLI 用法 所有命令默认针对 macOS。使用 `--product xcode` 来查询 Xcode 版本。使用 `--json` 获取机器可读的输出。 ``` # List releases macosdb list macosdb list --major 15 macosdb list --product xcode # Show components for a release macosdb show 15.2 macosdb show 15.2 --component curl macosdb show 15.2 --detailed macosdb show 16.2 --product xcode # Compare components between releases macosdb compare 15.1 15.2 macosdb compare 15.1 15.2 --changed macosdb compare 16.1 16.2 --product xcode # Scan an IPSW to produce release JSON macosdb scan ~/Downloads/UniversalMac_15.2_24C101_Restore.ipsw \ --output data/macos/releases --release-date 2024-12-11 --update-index --verbose # Scan an Xcode .xip to produce release JSON macosdb scan ~/Downloads/Xcode_26.4_Apple_silicon.xip \ --output data/xcode/releases --release-date 2026-03-24 --update-index --verbose # Validate archives and create SHA-256 sidecar hashes macosdb validate ~/Downloads/UniversalMac_15.2_24C101_Restore.ipsw macosdb validate --dir /path/to/archive ``` ## 扫描工作原理 扫描器通过一个多阶段的处理流程,从 Apple 的 IPSW 固件镜像中提取组件版本: 1. **提取 IPSW** — 解压 `.ipsw` 文件(它是一个 ZIP 归档) 2. **解析 kernelcache** — 从每个 kernelcache 中提取 Darwin/XNU 版本和芯片系列映射,并使用 BuildManifest.plist 进行设备识别 3. **解密 AEA** — macOS 15+ 使用 Apple Encrypted Archives;扫描器会从 Apple 的服务器获取解密密钥 4. **挂载系统 DMG** — 挂载根文件系统镜像,并扫描二进制文件以获取版本字符串(例如,嵌入在二进制文件中的 `curl --version` 输出) 5. **从 dyld 共享缓存中提取** — 许多库以共享缓存的形式存在,而不是独立的文件;扫描器会解析缓存格式以提取单个 dylib 数据 6. **组装结果** — 将内核信息、文件系统组件和 dyld 缓存组件合并为一个结构化的 `Release` JSON 文件 ## 数据 版本数据以 JSON 文件的形式存储在 `data/` 目录下,按产品类型进行组织: - `data/macos/releases.json` — 所有 macOS 版本的索引(按最新优先排序) - `data/macos/releases/{major}/macOS-{version}-{build}.json` — 包含内核和组件的完整版本数据 - `data/xcode/` — Xcode 版本也采用相同的结构 该数据也通过 REST API 的形式在 [macosdb.com/api/v1/](https://macosdb.com/api/v1/macos/releases.json) 提供服务。 ## 项目结构 ``` Sources/macOSdbKit/ Shared library — models, data provider, scanner pipeline Sources/macosdb/ CLI executable (swift-argument-parser) macOSdbApp/ SwiftUI app (NavigationSplitView, MVVM with @Observable) site/ Astro static site — release browser, compare view, component pages, JSON API, OG image generation, full-text search Tests/ Swift Testing data/ Pre-built release JSON (CC-BY-4.0) scripts/ JSON linting, release note formatting .github/workflows/ CI (build, lint, test), CodeQL, deploy site, release pipeline justfile Task runner for common operations ``` ## 构建 一个 [justfile](https://github.com/casey/just) 提供了常见的构建任务: ``` just build # Build the Swift package just clean # Clean Swift build artifacts just test # Run Swift tests just lint # Run SwiftLint (--strict) just lint-json # Validate JSON data files just typos # Check for typos just audit # Audit GitHub Actions workflows just build-app # Build the app with xcodebuild just test-xcode # Run tests with xcodebuild (matches CI) just check # Run all checks (lint, lint-json, test, audit, site format, site build) ``` ### 网站 `site/` 目录包含一个 [Astro](https://astro.build) 静态网站,已部署至 [macosdb.com](https://macosdb.com): ``` just site-install # Install npm dependencies just site-dev # Start dev server just site-build # Production build just site-preview # Preview the built site just site-format # Format site files with Prettier just site-format-check # Check site formatting ``` ## 致谢 本项目使用 [Claude Code](https://claude.ai/code) 构建。 感谢 [Guilherme Rambo](https://github.com/insidegui) 开发的 [VirtualBuddy](https://github.com/insidegui/VirtualBuddy),正是在为其 macOS 目录贡献代码的过程中,首次激发了我对 IPSW 目录编录的兴趣。 感谢 [Bo Anderson](https://github.com/Bo98) 在 macOS 和 SDK 内部机制方面提供的指导。 macOS 版本数据提取自 Apple 公开提供的 [IPSW 固件镜像](https://support.apple.com/en-us/102662)。Xcode 版本元数据来源于 [Xcode Releases](https://xcodereleases.com)。 设备识别和版本发布元数据来源于 [Apple Support](https://support.apple.com/en-us/102869)、[AppleDB](https://appledb.dev)、[EveryMac](https://everymac.com) 以及 [The Apple Wiki](https://theapplewiki.com)。 Apple、macOS 及相关商标均为 Apple Inc. 的财产。 ## 许可证 本项目基于 [GNU Affero General Public License v3.0](LICENSE) (`AGPL-3.0-only`) 授权。 `data/` 目录中的版本数据单独基于 [CC-BY-4.0](data/LICENSE) 授权。 Copyright (C) 2026 Patrick Linnane
标签:Apple Silicon, Clang, dyld共享缓存, Git, Homebrew, IPSW固件解析, lldb, macOS开发, OpenSSH, SBOM, SDK头文件, SQLite, Swift, VPS部署, Xcode, XIP解压, zsh, 云资产清单, 动态链接库, 原生应用, 固件安全分析, 开源组件, 版本管理, 硬件无关, 系统二进制文件, 系统底座分析, 组件目录, 跌倒检测, 软件分析, 软件物料清单, 逆向工程