Homebrew安装旧版本qemu
备注
经过不同版本验证,已测试成功:
macOS Big Sur 11.7.10 能够编译安装
qemu-9.0.2
更新的版本需要XCode 15无法在 MacBook Pro 15" Late 2013 所支持的最高 macOS Big Sur 11.7.10 上编译安装
由于 Homebrew 安装qemu 在旧版本macOS上失败(macOS版本过低不支持qemu 10),我尝试安装旧版本qemu
创建本地tap(按照需要提取的软件包名命令git仓库,这里是 QEMU ):
# use $USER variable to mimick userName/repoName structure
# this does not actually create any git repositories
# 1. create a new tap
# brew tap-new $USER/local-<packageName>
brew tap-new $USER/local-qemu
此时输出:
Initialized empty Git repository in /usr/local/Homebrew/Library/Taps/admin/homebrew-local-qemu/.git/
[main (root-commit) 590d9fd] Create admin/local-qemu tap
3 files changed, 107 insertions(+)
create mode 100644 .github/workflows/publish.yml
create mode 100644 .github/workflows/tests.yml
create mode 100644 README.md
==> Created admin/local-qemu
/usr/local/Homebrew/Library/Taps/admin/homebrew-local-qemu
When a pull request making changes to a formula (or formulae) becomes green
(all checks passed), then you can publish the built bottles.
To do so, label your PR as `pr-pull` and the workflow will be triggered.
获取homebrew的formulea:
brew tap homebrew/core --force
备注
我尝试了:
9.2.3 版本,依然要求Clang 15
9.2.1 版本,SHA值和配置不一致,放弃
9.1.1 版本,编译失败
9.0.2 版本,编译安装成功
输出:
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/admin/homebrew-local-qemu, skipping update!
==> Auto-updated Homebrew!
==> Updated Homebrew from 7657b68ce4 to 4.5.0 (97f9837a13).
No changes to formulae or casks.
The 4.5.0 release notes are available on the Homebrew Blog:
https://brew.sh/blog/4.5.0
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 2632075, done.
remote: Counting objects: 100% (512/512), done.
remote: Compressing objects: 100% (159/159), done.
remote: Total 2632075 (delta 479), reused 353 (delta 353), pack-reused 2631563 (from 3)
Receiving objects: 100% (2632075/2632075), 914.56 MiB | 391.00 KiB/s, done.
Resolving deltas: 100% (1951151/1951151), done.
Updating files: 100% (7915/7915), done.
==> Downloading https://formulae.brew.sh/api/formula.jws.json
Tapped 4 commands and 7582 formulae (7,926 files, 1005.6MB).
取出(
extract
)指定版本的软件配置(这里是 QEMU )
# 2. extract into local tap
# brew extract --version=<packageVersion> <packageName> $USER/local-<packageName>
brew extract --version=9.0.2 qemu $USER/local-qemu
输出:
==> Searching repository history
==> Writing formula for qemu at 9.0.2 from revision 4c444ba to:
/usr/local/Homebrew/Library/Taps/admin/homebrew-local-qemu/Formula/qemu@9.0.2.rb
现在就可以按照常规方式进行安装:
# 3. run brew install@version as usual
# brew install <packageName>@<packageVersion>
brew install qemu@9.0.2
出现报错:
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/admin/homebrew-local-qemu, skipping update!
Warning: You are using macOS 11.
We (and Apple) do not provide support for this old version.
This is a Tier 3 configuration:
https://docs.brew.sh/Support-Tiers#tier-3
Do not report any issues to Homebrew/* repositories!
Read the above document instead before opening any issues or PRs.
==> Fetching dependencies for admin/local-qemu/[email protected]: snappy
==> Fetching snappy
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-core/846fde4a3375cd543b7cc8986baada044fe0aaaa/Formu
################################################################################################################ 100.0%
==> Downloading https://github.com/google/snappy/archive/refs/tags/1.2.1.tar.gz
==> Downloading https://github.com/google/snappy/archive/refs/tags/1.2.1.tar.gz
Already downloaded: /Users/admin/Library/Caches/Homebrew/downloads/dded25b5e6de022bc3429f407ef794cefa711f152b397bf4c7610fdc30fcbc3a--snappy-1.2.1.tar.gz
==> Fetching admin/local-qemu/[email protected]
==> Downloading https://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/distributions/1.2/official/FD12FLOPPY.zip
Already downloaded: /Users/admin/Library/Caches/Homebrew/downloads/52fea6f4dc87882ac61241f5f1fe2c1a9d9b4e713f6693b18fd756ad0af832fe--FD12FLOPPY.zip
==> Downloading https://download.qemu.org/qemu-9.2.3.tar.xz
################################################################################################################ 100.0%
==> Installing [email protected] from admin/local-qemu
==> Installing dependencies for admin/local-qemu/[email protected]: snappy
==> Installing admin/local-qemu/[email protected] dependency: snappy
==> Patching
==> cmake -S . -B build/static -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF
Last 15 lines from /Users/admin/Library/Logs/Homebrew/snappy/01.cmake:
-Wno-dev
-DBUILD_TESTING=OFF
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk
CMake Error at CMakeLists.txt:29 (cmake_minimum_required):
Compatibility with CMake < 3.5 has been removed from CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
-- Configuring incomplete, errors occurred!
这里的报错原因是已知的,见 Hoebrew 安装 snappy ,需要手工修订 Homebrew Formulae(公式) 来手工安装 snappy-1.2.2
(已完成),并且修订 qemu
依赖。所以按照前面 extract
出来的指定 qemu@9.2.3.rb
配置文件:
vi /usr/local/Homebrew/Library/Taps/admin/homebrew-local-qemu/Formula/qemu@9.1.2.rb
# 删除掉 depends_on "snappy"
然后再次安装 qemu@9.1.2
9.1.2 版本,编译存在python模块
tomli
报错:
==> ./configure --cc=clang --host-cc=clang --disable-bsd-user --disable-guest-agent --enable-slirp --enable-capstone --
Last 15 lines from /Users/admin/Library/Logs/Homebrew/[email protected]/01.configure:
--disable-sdl
--smbd=/usr/local/sbin/samba-dot-org-smbd
--disable-gtk
--enable-cocoa
Using './build' as the directory for build output
python determined to be '/usr/bin/python3'
python version: Python 3.8.9
mkvenv: Creating non-isolated virtual environment at 'pyvenv'
*** Ouch! ***
found no usable tomli, please install it
Warning: Unable to query GitHub for recent issues on the tap
Validation Failed: [{"message" => "The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.", "resource" => "Search", "field" => "q", "code" => "invalid"}]
我尝试手工创建 Python virtualenv ,然后手工安装发现原来是证书错误导致无法下载:
WARNING: Disabling truststore since ssl support is missing
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/tomli/
...
Could not fetch URL https://pypi.org/simple/tomli/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/tomli/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement tomli (from versions: none)
WARNING: Disabling truststore since ssl support is missing
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
这个问题参考 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available ,我感觉是先安装的python,然后手工完成 Homebrew 安装 openssl ,看起来需要重新安装一次python(获得最新的openssl支持),然后再重新构建 Python virtualenv :
brew reinstall python
果然,在 Homebrew 安装 openssl 之后重新安装一遍 Python ,就能够正常在 Python virtualenv 中使用 pip
安装 tomli
模块了
不过,很奇怪,我发现虽然默认使用的是homebrew的 python 3.13.3(路径优先),但是安装 qemu
的脚本还是找到 /usr/bin/python3
,也就是macOS操纵系统自带的 python 3.8.9 。而且这个 python 3.8.9 创建 pyvenv
环境还是无法安装 tomli
。非常奇怪,我手工使用macOS操作系统自带的 python 3.8.9 来构建virtualenv,安装 tomli
明明是成功的。
我使用 /usr/bin/pip3
在操作系统 全局 安装 tomli
(也就是不创建 Python virtualenv ,直接安装模块):
/usr/bin/pip3
在操作系统 全局 安装 tomli
sudo /usr/bin/pip3 install tomli
OK 这一关过了(不再报 tomli
模块缺失,也确认 9.1.2
版本不再强制要求 clang 15)
编译错误
qemu-9.1.2
编译错误:
...
==> Installing qemu@9.1.2 from admin/local-qemu
==> ./configure --cc=clang --host-cc=clang --disable-bsd-user --disable-guest-agent --enable-slirp --enable-capstone --
==> make V=1 install
Last 15 lines from /Users/admin/Library/Logs/Homebrew/qemu@9.1.2/02.make:
kAudioObjectPropertyElementName
/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:331:5: note: 'kAudioObjectPropertyElementName' declared here
kAudioObjectPropertyElementName = 'lchn',
^
6 errors generated.
...
[1904/6495] clang -m64 -Ilibcommon.a.p -I/usr/local/Cellar/capstone/5.0.6/include/capstone -I/usr/local/Cellar/gnutls/3.8.9/include -I/usr/local/Cellar/nettle/3.10.1/include -I/usr/local/Cellar/libtasn1/4.20.0/include -I/usr/local/Cellar/libidn2/2.3.8/include -I/usr/local/Cellar/p11-kit/0.25.5/include/p11-kit-1 -I/usr/local/Cellar/pixman/0.46.0/include/pixman-1 -I/usr/local/opt/libpng/include/libpng16 -I/usr/local/Cellar/spice-protocol/0.14.5/include/spice-1 -I/usr/local/opt/jpeg-turbo/include -I/usr/local/Cellar/libusb/1.0.28/include/libusb-1.0 -I/usr/local/Cellar/glib/2.84.1/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/ffi -I/usr/local/Cellar/glib/2.84.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.84.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre2/10.45/include -I/usr/local/Cellar/glib/2.84.1/include/gio-unix-2.0 -I/usr/local/opt/zstd/include -I/usr/local/Cellar/libslirp/4.9.0/include/slirp -I/usr/local/Cellar/ncurses/6.5/include/ncursesw -I/usr/local/Cellar/ncurses/6.5/include -I/usr/local/Cellar/libssh/0.11.1/include -fcolor-diagnostics -Wall -Winvalid-pch -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wredundant-decls -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-gnu-variable-sized-type-not-at-end -Wno-initializer-overrides -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -Wno-string-plus-int -Wno-tautological-type-limit-compare -Wno-typedef-redefinition -iquote . -iquote /private/tmp/qemuA9.1.2-20250503-54125-jz3p8e/qemu-9.1.2 -iquote /private/tmp/qemuA9.1.2-20250503-54125-jz3p8e/qemu-9.1.2/include -iquote /private/tmp/qemuA9.1.2-20250503-54125-jz3p8e/qemu-9.1.2/host/include/x86_64 -iquote /private/tmp/qemuA9.1.2-20250503-54125-jz3p8e/qemu-9.1.2/host/include/generic -iquote /private/tmp/qemuA9.1.2-20250503-54125-jz3p8e/qemu-9.1.2/tcg/i386 -mcx16 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -fno-pie -D_DARWIN_C_SOURCE -DNCURSES_WIDECHAR -DNCURSES_WIDECHAR=1 -DSTRUCT_IOVEC_DEFINED -MD -MQ libcommon.a.p/dump_dump.c.o -MF libcommon.a.p/dump_dump.c.o.d -o libcommon.a.p/dump_dump.c.o -c ../dump/dump.c
ninja: build stopped: subcommand failed.
make[1]: *** [run-ninja] Error 1
make: *** [build] Error 2
Warning: Unable to query GitHub for recent issues on the tap
Validation Failed: [{"message" => "The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.", "resource" => "Search", "field" => "q", "code" => "invalid"}]
没有找到解决方法,所以继续回退一个版本:
qemu-9.1.1
同样编译错误
qemu-9.0.2
则编译成功