versioning
napt.versioning.msi
MSI metadata extraction for NAPT.
This module extracts metadata from Windows Installer (MSI) database files, including ProductVersion, ProductName, and architecture (from Template).
Backend Priority:
- Windows: PowerShell COM (Windows Installer COM API, always available)
- Linux/macOS: msiinfo (from the msitools package, must be installed separately)
Installation Requirements:
- Windows: No additional packages required (PowerShell is always available).
- Linux/macOS: Install the msitools package (
apt-get install msitools,dnf install msitools, orbrew install msitools).
Note
This is pure file introspection; no network calls are made. The PowerShell COM backend reads both the Property table (ProductName, ProductVersion) and Summary Information stream (Template/architecture) in a single database open.
MSIMetadata
dataclass
Represents metadata extracted from an MSI file.
Attributes:
| Name | Type | Description |
|---|---|---|
product_name |
str
|
ProductName from MSI Property table (display name). |
product_version |
str
|
ProductVersion from MSI Property table. |
architecture |
Architecture
|
Installer architecture from MSI Template Summary Information property. Always one of "x86", "x64", or "arm64". |
Source code in napt/versioning/msi.py
extract_msi_metadata
Extracts ProductName, ProductVersion, and architecture from an MSI file.
Reads the MSI Property table (ProductName, ProductVersion) and Summary Information stream (Template/architecture) in a single database open. On Windows, uses the PowerShell COM API. On Linux/macOS, requires msitools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
Path to the MSI file. |
required |
Returns:
| Type | Description |
|---|---|
MSIMetadata
|
MSI metadata including product name, version, and architecture. |
Raises:
| Type | Description |
|---|---|
PackagingError
|
If the MSI file does not exist or extraction fails. |
ConfigError
|
If the MSI platform is not supported by Intune. |
NotImplementedError
|
If no extraction backend is available on this system. |
Example
Extract MSI metadata:
Note
ProductName may be empty string if not found in MSI. The build phase validates ProductName and raises ConfigError if empty, because it is required for detection script generation.
Source code in napt/versioning/msi.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
napt.versioning.ordering
Version ordering as managed devices see it.
Whether a release installs over another is decided on the device by
Compare-VersionString in napt/build/templates/_shared_functions.ps1,
which the detection and requirements scripts call. This module mirrors
that function, so that when NAPT calls a release a downgrade it means the
same thing the device will: devices on the other version will not take it.
The mirror is deliberately no smarter than the original. Each . or
- separated segment contributes its leading digits, a segment without
leading digits counts as 0, and missing trailing segments count as 0. A
v prefix or a prerelease tag is therefore not understood on either
side. tests/test_version_ordering.py runs one table of cases through
both implementations to keep them in step.
version_parts
Parses a version string into the numbers a device compares.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
Version string, for example |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
One integer per segment: its leading digits, or 0 when it has none. |
Source code in napt/versioning/ordering.py
compare_versions
Compares two version strings the way a managed device does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left
|
str
|
First version string. |
required |
right
|
str
|
Second version string. |
required |
Returns:
| Type | Description |
|---|---|
int
|
-1 when |
Source code in napt/versioning/ordering.py
is_downgrade
Reports whether a release is lower than the one it would replace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate
|
str
|
Version of the release being considered. |
required |
current
|
str | None
|
Version it would replace, or None when there is none. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when devices on |