RedFlag/installer/windows/msi_version.py
Fimeg 765ec4188f publish: carry the Windows product into the projection
The tree adds the installer, service and test paths admitted by this source commit. Nothing else changes about what may cross.

Source-Sha: 3e4a3aa4ce092e9e3f51bc78daf3ddc14d9638f8

Policy-Sha: 3e4a3aa4ce092e9e3f51bc78daf3ddc14d9638f8

Tree-Digest: 89d6fce3828a0e0de0c8eeb41ee6750f4462217e2a04b5190297134d7f4a50c3
2026-09-09 12:47:34 -04:00

24 lines
852 B
Python

#!/usr/bin/env python3
"""Preserve RedFlag's fourth version field in MSI's three-field identity."""
import re
import sys
def product_version(version):
if not re.fullmatch(r"[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\.[0-9]{1,2})?", version):
raise ValueError("expected major.minor.patch[.revision], with revision 0..99")
parts = [int(part) for part in version.split(".")]
major, minor, patch = parts[:3]
revision = parts[3] if len(parts) == 4 else 0
build = patch * 100 + revision
if major > 255 or minor > 255 or build > 65535:
raise ValueError("version exceeds MSI limits (255.255.65535)")
return f"{major}.{minor}.{build}"
if __name__ == "__main__":
try:
print(product_version(sys.argv[1]))
except (ValueError, IndexError) as error:
sys.exit(f"Invalid RedFlag MSI version: {error}")