Skip to content

Commit 355c9f3

Browse files
committed
Release v3.6: harden Wine updater flow and zip cleanup
1 parent 014c19c commit 355c9f3

6 files changed

Lines changed: 60 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## v3.6
4+
5+
- Wine/Proton updater downloads: runtime Wine detection now biases asset selection toward `release_linux_wine.zip` during `sofbuddy_update download` (non-XP builds).
6+
- Auto-install launch hardening: reverted Wine `/unix` launch path and standardized `winstart` install command to `update_from_zip.cmd` to avoid repeated `Invalid Name` dialogs from `start` wrapper parsing.
7+
- Installer scripts: `update_from_zip.cmd` now prefers non-PowerShell extractors first (`tar`, `7z`, VBScript) and uses PowerShell only as fallback.
8+
- Post-install cleanup: both Windows and Linux/Wine update scripts now delete the extracted zip on successful install to prevent `sof_buddy/update/` accumulation.
9+
310
## v3.5
411

512
- Updater install: `sofbuddy_update_install` now detects Wine (`wine_get_version`) and prefers `sof_buddy/update_from_zip.sh` under Wine/Proton.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.5
1+
3.6

hdr/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
Increment version using: ./increment_version.sh
88
*/
99

10-
#define SOFBUDDY_VERSION "3.5"
10+
#define SOFBUDDY_VERSION "3.6"

rsrc/lin_scripts/update_from_zip.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ fi
4444

4545
echo
4646
echo "Update extraction complete."
47+
echo "Deleting used update zip..."
48+
if rm -f -- "${ZIP_PATH}"; then
49+
echo "Deleted: ${ZIP_PATH}"
50+
else
51+
echo "Warning: could not delete ${ZIP_PATH}"
52+
fi
4753
echo
4854
echo "Searching for old configuration to prune..."
4955
find "${ROOT_DIR}" -type f -name "sofbuddy.cfg" -print -delete 2>/dev/null || true

rsrc/win_scripts/update_from_zip.cmd

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ if errorlevel 1 (
5858

5959
echo.
6060
echo Update extraction complete.
61+
echo Deleting used update zip...
62+
del /f /q "!ZIP_PATH!" >nul 2>&1
63+
if exist "!ZIP_PATH!" (
64+
echo Warning: could not delete "!ZIP_PATH!".
65+
) else (
66+
echo Deleted: !ZIP_PATH!
67+
)
6168
echo.
6269
echo Searching for old configuration to prune...
6370
for /r "%ROOT_DIR%" %%F in (sofbuddy.cfg) do (
@@ -75,12 +82,6 @@ exit /b 0
7582
:extract_zip
7683
set "ZIP=%~1"
7784

78-
where powershell.exe >nul 2>&1
79-
if not errorlevel 1 (
80-
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "try { Expand-Archive -LiteralPath '%ZIP%' -DestinationPath '%ROOT_DIR%' -Force; exit 0 } catch { exit 1 }"
81-
if not errorlevel 1 exit /b 0
82-
)
83-
8485
where tar.exe >nul 2>&1
8586
if not errorlevel 1 (
8687
tar -xf "%ZIP%" -C "%ROOT_DIR%"
@@ -96,6 +97,12 @@ if not errorlevel 1 (
9697
call :extract_with_vbscript "%ZIP%"
9798
if not errorlevel 1 exit /b 0
9899

100+
where powershell.exe >nul 2>&1
101+
if not errorlevel 1 (
102+
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "try { Expand-Archive -LiteralPath '%ZIP%' -DestinationPath '%ROOT_DIR%' -Force; exit 0 } catch { exit 1 }"
103+
if not errorlevel 1 exit /b 0
104+
)
105+
99106
exit /b 1
100107

101108
:extract_with_vbscript

src/core/update_command.cpp

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ constexpr const char* kUpdateReleasesUrl = kUpdateReleasesUrlGitHub;
3535
#endif
3636
constexpr const char* kUpdateOutputDir = "sof_buddy/update";
3737
constexpr const char* kUpdateInstallScript = "sof_buddy/update_from_zip.cmd";
38-
constexpr const char* kUpdateInstallScriptWine = "sof_buddy/update_from_zip.sh";
3938
constexpr DWORD kUpdateTimeoutMs = 8000;
4039
constexpr uintptr_t kWinstartRva = 0x0040353C;
4140

@@ -74,6 +73,7 @@ struct ReleaseInfo {
7473
};
7574

7675
bool parse_url(const std::string& url, ParsedUrl& out, std::string& error);
76+
std::wstring utf8_to_wide(const std::string& value);
7777

7878
bool is_regular_file(const char* path) {
7979
if (!path || !path[0]) return false;
@@ -86,6 +86,14 @@ bool is_running_under_wine() {
8686
return ntdll && GetProcAddress(ntdll, "wine_get_version");
8787
}
8888

89+
bool prefer_linux_wine_release_zip() {
90+
#if defined(SOFBUDDY_XP_BUILD)
91+
return false;
92+
#else
93+
return is_running_under_wine();
94+
#endif
95+
}
96+
8997
bool queue_winstart_command(const char* command) {
9098
if (!command || !command[0]) return false;
9199
char** slot = reinterpret_cast<char**>(rvaToAbsExe(reinterpret_cast<void*>(kWinstartRva)));
@@ -598,6 +606,7 @@ int score_release_zip_candidate(const std::string& url) {
598606
const bool is_linux_wine = (name.find("linux") != std::string::npos) ||
599607
(name.find("wine") != std::string::npos);
600608
const bool is_xp = (name.find("xp") != std::string::npos);
609+
const bool prefer_linux_wine = prefer_linux_wine_release_zip();
601610

602611
int score = 0;
603612
if (is_release) score += 400;
@@ -618,9 +627,15 @@ int score_release_zip_candidate(const std::string& url) {
618627
if (is_windows && !is_xp) score -= 400;
619628
if (is_linux_wine) score -= 700;
620629
#else
621-
if (is_windows && !is_xp) score += 1200;
622-
if (is_windows && is_xp) score -= 700;
623-
if (is_linux_wine) score -= 150;
630+
if (prefer_linux_wine) {
631+
if (is_linux_wine) score += 1200;
632+
if (is_windows && !is_xp) score -= 150;
633+
if (is_windows && is_xp) score -= 700;
634+
} else {
635+
if (is_windows && !is_xp) score += 1200;
636+
if (is_windows && is_xp) score -= 700;
637+
if (is_linux_wine) score -= 150;
638+
}
624639
#endif
625640

626641
return score;
@@ -636,12 +651,18 @@ bool zip_matches_build_preference(const std::string& url) {
636651
const bool is_linux_wine = (name.find("linux") != std::string::npos) ||
637652
(name.find("wine") != std::string::npos);
638653
const bool is_xp = (name.find("xp") != std::string::npos);
654+
const bool prefer_linux_wine = prefer_linux_wine_release_zip();
639655

640656
#if defined(SOFBUDDY_XP_BUILD)
641657
if (is_windows && is_xp) return true;
642658
if (is_windows && !is_xp) return false;
643659
if (is_linux_wine) return false;
644660
#else
661+
if (prefer_linux_wine) {
662+
if (is_linux_wine) return true;
663+
if (is_windows && !is_xp) return false;
664+
if (is_windows && is_xp) return false;
665+
}
645666
if (is_windows && !is_xp) return true;
646667
if (is_windows && is_xp) return false;
647668
#endif
@@ -1035,9 +1056,7 @@ void Cmd_SoFBuddy_Update_f(void) {
10351056
void Cmd_SoFBuddy_UpdateInstall_f(void) {
10361057
if (!orig_Cmd_ExecuteString) return;
10371058
const bool wine = is_running_under_wine();
1038-
const char* script = wine ? kUpdateInstallScriptWine : kUpdateInstallScript;
1039-
if (!is_regular_file(script) && wine && is_regular_file(kUpdateInstallScript))
1040-
script = kUpdateInstallScript;
1059+
const char* script = kUpdateInstallScript;
10411060
if (!is_regular_file(script)) {
10421061
set_update_status("install script missing");
10431062
PrintOut(PRINT_BAD, "sofbuddy_update_install: missing %s\n", script);
@@ -1050,18 +1069,12 @@ void Cmd_SoFBuddy_UpdateInstall_f(void) {
10501069
return;
10511070
}
10521071
std::string command;
1053-
if (wine && std::strcmp(script, kUpdateInstallScriptWine) == 0) {
1054-
command = "/unix \"";
1055-
command += script;
1056-
command += "\" \"";
1057-
command += zip_path;
1058-
command += "\"";
1059-
} else {
1060-
command = script;
1061-
command += " \"";
1062-
command += zip_path;
1063-
command += "\"";
1064-
}
1072+
if (wine)
1073+
PrintOut(PRINT_DEV, "sofbuddy_update_install: Wine detected; using %s via winstart\n", script);
1074+
command = script;
1075+
command += " \"";
1076+
command += zip_path;
1077+
command += "\"";
10651078

10661079
if (!queue_winstart_command(command.c_str())) {
10671080
set_update_status("failed to queue install command");

0 commit comments

Comments
 (0)