在 Docker 容器中指定 Wine 的默认 Windows 版本

在 Docker 容器中指定 Wine 的默认 Windows 版本

我想使用我的python项目构建windows二进制文件Py安装程序葡萄酒通过Docker。 我在用engineervix/pyinstaller-windows,我从中分叉出来cdrx/pyinstaller-windows使用更新的 Ubuntu LTS 映像(18.04/20.04)以及更新的 Python 版本和其他软件。

在里面Dockerfile,我已经winetricks -q win10,并且构建日志似乎表明这是成功的:

...
...

------------------------------------------------------
Using winetricks 20200412-next - sha256sum: 6f57ead2f28148ef7d801b1c0dbf10cf327d22b2fcbe0f742dd1579097f66635 with wine-5.0.2 and WINEARCH=win64
Executing w_do_call win10
Executing mkdir -p /
------------------------------------------------------
warning: You are using a 64-bit WINEPREFIX. Note that many verbs only install 32-bit versions of packages. If you encounter problems, please retest in a clean 32-bit WINEPREFIX before reporting a bug.
------------------------------------------------------
Executing load_win10
The operation completed successfully
Setting Windows version to win10
Executing wine regedit /S C:\windows\Temp\set-winver.reg
Executing wine64 regedit /S C:\windows\Temp\set-winver.reg
------------------------------------------------------
warning: Running /usr/bin/wineserver -w. This will hang until all wine processes in prefix=/wine terminate
------------------------------------------------------

...
...

[91m+ echo assoc .py=PythonScript
[0m
Microsoft Windows 10.0.10240
C:\Python37>
.py
=
PythonScript
C:\Python37>
[91m+ [0m
[91mwine[0m
[91m cmd[0m
[91m
[0m
[91m+ [0m
[91mecho[0m
[91m ftype PythonScript=c:\Python37\python.exe "%1" %*[0m
[91m
[0m
Microsoft Windows 10.0.10240
C:\Python37>
PythonScript
=
c:\Python37\python.exe "%1" %*
C:\Python37>

...
...

但是,当使用 Docker Image 时,我从 PyInstaller 日志中获得以下内容:

...
...

pyinstaller --clean -F --windowed --upx-dir=upx build_win.spec
170 INFO: PyInstaller: 4.0
170 INFO: Python: 3.7.9
171 INFO: Platform: Windows-7-6.1.7601
335 INFO: UPX is available.
336 INFO: Removing temporary files and cleaning cache in C:\users\root\Application Data\pyinstaller
365 INFO: checking Tree
366 INFO: Building Tree because Tree-00.toc is non existent
366 INFO: Building Tree Tree-00.toc
368 INFO: Extending PYTHONPATH with paths

...
...

来自winetricks源代码中,我看到 Wine 的默认 Windows 版本是 Windows 7。这意味着以某种方式设置 Windows 版本winetricks -q win10不起作用,或者至少 Windows 版本没有在 Docker 容器中“持久保存”。可能存在什么问题?我该如何解决?我知道winecfg可用于修改windows默认版本,但它似乎是一个图形实用程序,如官方网站

Winecfg 是 Wine 的 GUI 配置工具,旨在使生活比编辑注册表更轻松一些。

答案1

在 docker 中使用 wine 做任何事情时,等待 wineserver 完成是比较安全的做法。wineserver 在后台启动,负责协调诸如将数据刷新到存储库之类的事情,但完成后主命令。

RUN winecfg -v win10 && wineserver -w

相关内容