Files
munki/code/client
Paul Cossey 547e297c53 Update pkginfolib.py (#1258)
# Pull Request: Fix incomplete metadata extraction for audio plugins and other bundles

## Problem Summary

The `getiteminfo()` function in `pkginfolib.py` currently provides inconsistent metadata extraction between applications (.app files) and other bundle types (audio plugins like .vst, .component, .aaxplugin, .vst3).

**Current behavior:**
-  **Applications (.app)**: Extract comprehensive metadata including `CFBundleName`, `CFBundleIdentifier`, `CFBundleShortVersionString`, `CFBundleVersion`, and `LSMinimumSystemVersion`
-  **Other bundles**: Only extract `CFBundleShortVersionString` and `CFBundleVersion`

This results in incomplete installs arrays for audio plugins and other bundle types, missing critical metadata for proper tracking and identification.

## Impact

Audio plugin packages (and other non-application bundles) generate installs array entries like this:

**Before (incomplete):**
```xml
<dict>
    <key>CFBundleVersion</key>
    <string>4.5</string>
    <key>path</key>
    <string>/Library/Audio/Plug-Ins/VST/BC Chorus 4 VST(Mono).vst</string>
    <key>type</key>
    <string>bundle</string>
    <key>version_comparison_key</key>
    <string>CFBundleVersion</string>
</dict>
```

**After (complete):**
```xml
<dict>
    <key>CFBundleIdentifier</key>
    <string>com.bluecataudio.bc-chorus-4-vst-mono-</string>
    <key>CFBundleVersion</key>
    <string>4.5</string>
    <key>minosversion</key>
    <string>10.9</string>
    <key>path</key>
    <string>/Library/Audio/Plug-Ins/VST/BC Chorus 4 VST(Mono).vst</string>
    <key>type</key>
    <string>bundle</string>
    <key>version_comparison_key</key>
    <string>CFBundleVersion</string>
</dict>
```

## Root Cause

In the `getiteminfo()` function, the bundle handling section only extracts version-related keys:

```python
# Current problematic code
for key in ['CFBundleShortVersionString', 'CFBundleVersion']:
    if key in plist:
        infodict[key] = plist[key]
```

While the application handling section extracts comprehensive metadata:

```python
# Application code (working correctly)
for key in ['CFBundleName', 'CFBundleIdentifier',
            'CFBundleShortVersionString', 'CFBundleVersion']:
    if key in plist:
        infodict[key] = plist[key]
# Plus LSMinimumSystemVersion handling
```

## Solution

Align bundle metadata extraction with application metadata extraction by expanding the bundle handling section to extract the same keys and minimum OS version information.

## Files Changed

- `code/client/munkilib/pkginfolib.py` - Modified `getiteminfo()` function

## Changes Made

**Modified bundle handling section in `getiteminfo()` function:**

```python
elif (os.path.exists(os.path.join(itempath, 'Contents', 'Info.plist')) or
      os.path.exists(os.path.join(itempath, 'Resources', 'Info.plist'))):
    infodict['type'] = 'bundle'
    infodict['path'] = itempath
    plist = pkgutils.getBundleInfo(itempath)
    # Extract the same keys as applications
    for key in ['CFBundleName', 'CFBundleIdentifier',
                'CFBundleShortVersionString', 'CFBundleVersion']:
        if key in plist:
            infodict[key] = plist[key]
    # Also extract minimum OS version info like applications
    if 'LSMinimumSystemVersion' in plist:
        infodict['minosversion'] = plist['LSMinimumSystemVersion']
    elif 'LSMinimumSystemVersionByArchitecture' in plist:
        # just grab the highest version if more than one is listed
        versions = [item[1] for item in
                    plist['LSMinimumSystemVersionByArchitecture'].items()]
        highest_version = str(max([pkgutils.MunkiLooseVersion(version)
                                   for version in versions]))
        infodict['minosversion'] = highest_version
    elif 'SystemVersionCheck:MinimumSystemVersion' in plist:
        infodict['minosversion'] = \
            plist['SystemVersionCheck:MinimumSystemVersion']
```

## Benefits

1. **Consistent metadata extraction**: All bundle types now get the same comprehensive metadata as applications
2. **Better plugin tracking**: Audio plugins (.vst, .component, .aaxplugin, .vst3) now have unique identifiers
3. **Improved OS compatibility**: Minimum OS version detection for all bundle types
4. **Enhanced debugging**: More metadata available for troubleshooting installs array issues
5. **Future-proof**: Any bundle type with standard Info.plist structure will benefit

## Affected Bundle Types

This fix applies to all bundle types that aren't applications, including:
- Audio Unit Components (`.component`)
- VST Plugins (`.vst`)
- VST3 Plugins (`.vst3`)
- AAX Plugins (`.aaxplugin`)
- Other macOS bundles with Info.plist files

## Testing

Verified with Blue Cat Audio plugins that all plugin formats now extract:
- `CFBundleIdentifier` (when present)
- `CFBundleName` (when present, particularly in AAX plugins)
- `LSMinimumSystemVersion` converted to `minosversion`
- Existing version extraction continues to work
- Some AutoPkg Recipe's that can be used for testing
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20Chorus
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20Flanger
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20Free%20Amp
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20Freeceiver
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20FreqAnalyst
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20Gain%20Suite
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20Phaser
-- https://github.com/autopkg/dataJAR-recipes/tree/master/Blue%20Cat%20Triple%20EQ
2025-08-15 10:34:29 -07:00
..
2025-08-15 10:34:29 -07:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00
2025-01-25 15:35:09 -08:00