Skip to content

Commit

Permalink
Support major.minor.build versions in <sparkle:minimumSystemVersion>
Browse files Browse the repository at this point in the history
Previously much less useful major.minor.servicepack was used, which was
of limited practical applicability and is completely useless since
Windows 10.

To preserve backwards compatiblity, treat low values in the 3rd value of
the tuple as service pack version.
  • Loading branch information
vslavik committed Dec 3, 2024
1 parent f3708c7 commit da4e7e2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Version 0.8.2
-------------

- Support major.minor.build versioning scheme in <sparkle:minimumSystemVersion>;
previously only much less useful major.minor.servicepack was used.
- Added support for gzip/deflate-compressed appcasts.
- Added support for ARM-specific enclosures.
- Fixed handling of multiple enclosures to correctly pick the most-specific
Expand Down
27 changes: 23 additions & 4 deletions src/appcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,40 @@ namespace

// Misc helper functions:

bool is_compatible_with_windows_version(const Appcast &item)
bool is_compatible_with_windows_version(const Appcast &item_)
{
Appcast item(item_);

item.MinOSVersion = "10";

if (item.MinOSVersion.empty())
return true;

OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 };
OSVERSIONINFOEXW osvi = {};
osvi.dwOSVersionInfoSize = sizeof(osvi);

DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);

sscanf(item.MinOSVersion.c_str(), "%lu.%lu.%hu", &osvi.dwMajorVersion,
&osvi.dwMinorVersion, &osvi.wServicePackMajor);
const int parsed = sscanf(item.MinOSVersion.c_str(), "%lu.%lu.%lu",
&osvi.dwMajorVersion, &osvi.dwMinorVersion, &osvi.dwBuildNumber);
if (parsed == 0)
{
// failed to parse version number, ignore the value
return true;
}

// backwards compatibility with WinSparkle < 0.8.2 which used major.minor.sp
// instead of major.minor.build for the version number:
if (parsed == 3 && osvi.dwBuildNumber < 100)
{
osvi.wServicePackMajor = static_cast<WORD>(osvi.dwBuildNumber);
osvi.dwBuildNumber = 0;
}

return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION |
VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
Expand Down

0 comments on commit da4e7e2

Please sign in to comment.