在macos上查看Command_Line_Tools_for_Xcode版本
env
- macos-15.2
解决
1.查看CLT安装包
➜ openwrt-24.10.0-rc5 pkgutil --packages |grep -i clt
com.apple.pkg.CLTools_SDK_macOS13
com.apple.pkg.CLTools_SDK_macOS12
com.apple.pkg.CLTools_Executables
com.apple.pkg.CLTools_SDK_macOS_LMOS
com.apple.pkg.CLTools_SDK_macOS14
com.apple.pkg.CLTools_SDK_macOS_NMOS
com.apple.pkg.CLTools_SDK_macOS110
com.apple.pkg.CLTools_SwiftBackDeploy
com.apple.pkg.CLTools_macOS_SDK
2.查看CLT当前SDK元信息
➜ openwrt-24.10.0-rc5 pkgutil --pkg-info com.apple.pkg.CLTools_macOS_SDK
package-id: com.apple.pkg.CLTools_macOS_SDK
version: 16.2.0.0.1.1733547573
volume: /
location: /
install-time: 1737255133
3.查看CLT执行元信息
➜ openwrt-24.10.0-rc5 pkgutil --pkg-info com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 16.2.0.0.1.1733547573
volume: /
location: /
install-time: 1737255131
根据元信息,发现CLT版本16.2
pkgutil
查看mac上安装包信息
➜ openwrt-24.10.0-rc5 pkgutil
Usage: pkgutil [OPTIONS] [COMMANDS] ...
Options:
--help Show this usage guide
--verbose, -v Show contextual information and format for easy reading
--force, -f Perform all operations without asking for confirmation
--volume PATH Perform all operations on the specified volume
--edit-pkg PKGID Adjust properties of package PKGID using --learn PATH
--only-files List only files (not directories) in --files listing
--only-dirs List only directories (not files) in --files listing
--regexp Try all PKGID arguments as regular expressions
Receipt Database Commands:
--pkgs, --packages List all currently installed package IDs on --volume //列出当前安装包
--pkgs-plist List all package IDs on --volume in plist format
--pkgs=REGEXP List package IDs on --volume that match REGEXP
--groups List all GROUPIDs on --volume
--groups-plist List all GROUPIDs on --volume in plist format
--group-pkgs GROUPID List all PKGIDs in GROUPID
--files PKGID List files installed by the specified package
--lsbom PKGID List files in the same format as 'lsbom -s'
--pkg-groups PKGID List all GROUPIDs that PKGID is a member of
--export-plist PKGID Print all info about PKGID in plist format
--pkg-info PKGID Show metadata about PKGID //查看包元信息
--pkg-info-plist PKGID Show metadata about PKGID in plist format
--file-info PATH Show metadata known about PATH
--file-info-plist PATH Show metadata known about PATH in plist format
--forget PKGID Discard receipt data for the specified package
--learn PATH Update --edit-pkg PKGID with actual metadata from PATH
File Commands:
--expand PKG DIR Expand the flat package PKG to DIR
--flatten DIR PKG Flatten the files at DIR as PKG
--bom PATH Extract any Bom files from the pkg at PATH into /tmp
--payload-files PATH List the paths archived within the (m)pkg at PATH
--check-signature PATH Validate the signature of the pkg at PATH and print certificate information
pkgutil基本命令
1.列出所有已安装的包
pkgutil --pkgs
2.列出所有匹配某模式的包:
pkgutil --pkgs | grep 模式
3.获取特定包的信息:
pkgutil --pkg-info <包名>
4.列出某个包安装的所有文件:
pkgutil --files <包名>
5.检查某个文件是由哪个包安装的:
pkgutil --file-info <文件路径>
6.验证包的完整性:
pkgutil --check-signature <包名>
7.卸载一个包(谨慎操作,可能会删除系统组件):
sudo pkgutil --forget <包名>
注意:–forget 只是从包数据库中移除包信息,并不会删除文件。要实际删除文件,需要手动操作或使用其他方法