Repository navigation
Framework - Add Wine detection weighing system - #40
Conversation
|
Hi @keenanweaver, Thanks again for this new PR :) Well. I'm a little more sceptical about this approach, although I agree it's a clean solution. Initially (a long time ago), I only checked for a Wine entry in the Registry. Then, one day, I came across a strange case where someone had installed Wine on Windows. I'm worried your PR would incorrectly identify that system as Linux in that exact same scenario. That's why I'd feel more confident prompting the user in the rare cases where the OS is ambiguous. Also, having 3 (or 5) independent signals is nice: if they all agree, the result is clear. Otherwise, we can use the majority vote to preselect the most likely answer in the user prompt. So maybe we should simply replace one of the three existing signals with your ntdll check. Which one do you think would make the most sense to replace? -- PS: I don't have a strong opinion on macOS. I hadn't really thought about it, and I didn't even know Wine was available on macOS. I honestly doubt that many of "my" games/installers would work on macOS anyway. Plus, many recipes use an "If Linux, Else" approach. |
|
Thanks for the review! If it helps, I implemented this check into the installers for Silent Hill 2: Enhanced Edition and Freelancer HD Edition several years ago and I haven't heard of any strange behavior as a result of it. Those installers are InnoSetup, so the implementation is different, but the same check is used in those. FL HDE also has /ForceWineOn / /ForceWineOff switches, which would be a nice way to work around any undesired behavior we could put in your installers. I'll look into a 'heuristics' sort of weighing. If a couple of conditions are met, we can definitively say what the OS is. I'm pretty concerned about the Z:\ pathing, because that's not guaranteed to be there in a prefix. A user can easily unmount that letter in the Wine prefix and the check would fail. Very unlikely to happen, but it's possible. As a fallback if anything's too ambiguous, it asks the user what they're using. Which works, and isn't too annoying since it's one dialog box. I think with this change, it could lead to refactoring the installers to have two paths: Windows and Linux, which I think might actually be easier to maintain in the longterm. I'll iterate on it and update the PR. |
Keep the vote, but replace the HKCU\Software\Wine registry check (which can exist on a real Windows install, or WineD3D for Windows) with a check against Wine's ntdll.dll, and use 5 detections: 1. ntdll exports wine_get_version (Windows' ntdll doesn't): 4 points 2. $SYSDIR\winecfg.exe exists (Wine prefix): 1 point 3. /usr exists: 1 point 4. /etc/os-release or /usr/lib/os-release exists: 1 point 5. /proc/version exists (Linux procfs): 1 point ntdll weighs as much as the 4 other detections combined (score out of 8): - 0: "Windows" - 1-2: ask the user, No pre-selected - 3-4: ask the user, Yes pre-selected - 5-8: "Linux" (ntdll + at least 1 other detection) The pre-selected answer is also used as the default in silent mode. Unix paths are checked through Wine's \\?\unix\ prefix instead of Z:\, so they still work when the Z: drive is unmapped or remapped. The result is still memoized, and the DETECT_OS macro is unchanged. Tested with Wine 11.0 (with and without a Z: drive), and through umu-launcher (Steam Linux Runtime 3) with UMU-Proton 10.0-4 and GE-Proton 11-9, including prefixes without winecfg.exe and with Z: pointed to an empty folder: all detected as Linux without a prompt. Assisted-by: Claude Code (Claude Opus 5.5)
23d268c to
f490ab8
Compare
|
Added a weighing system based on feedback. This should work. Meat proxying the LLM below: How OS detection works
Detections
ntdll check: Windows always loads its own
Scoring (out of 8)
Why the registry check was dropped
Expected results
Testing
|
|
Hi @keenanweaver ! I did some more testing, and I haven't found any problems here. Everything works perfectly. Although the previous code was already working quite well, this actually makes the detection more robust, especially by using ntdll.dll and not relying on Z:\* paths 👍 I'm gonna merge that PR today :) Thanks again for your work! |
This changes the Linux detection to check the value of ntdll.dll instead of path-based detection. This is much less fragile. I've only tested on Linux. Detection working as expected:
I'd be glad to make a validation test in CI for this change.
Like the other PR, this one was created with Claude Code.
LLM summary: