Commit Graph

49 Commits

Author SHA1 Message Date
Elliot Jordan 41e6d38cc5 Spelling fixes for Munki 7 branch (#1263)
* Fix SidebarViewController.swift file name

* Fix spelling in comments

* Fix spelling in strings and output

* Fix spelling in variables and key names

* One more pass at spelling fixes
2025-08-27 12:27:12 -07:00
Greg Neagle 6ce2321a4a Reduce code duplication in pkginfolib.getiteminfo 2025-08-15 10:34:29 -07:00
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
Greg Neagle 6b4ad647c4 Update copyright dates 2025-01-25 15:35:09 -08:00
Greg Neagle aeac6e96a9 Start consolidating functions that deal with date/times and rely less on undocumented pyObjc conversions 2024-04-12 13:56:11 -07:00
Greg Neagle 2b327569b4 Update copyright dates 2024-01-30 16:14:29 -08:00
Greg Neagle 4d4b759b5c Fomatting tweak 2023-11-20 09:56:34 -08:00
Greg Neagle 3b6aa2173d When creating pkginfo, if an uninstall_script or uninstall_method is specified, also get uninstallable to True. Fixes #950 and #1160. 2023-11-20 09:55:25 -08:00
Greg Neagle bb77913dbf makepkginfo help message tweaks 2023-08-18 09:26:22 -07:00
Nick McSpadden 2d64dcd17a Munkiimport puts supported architecture into pkginfo filename (#1185)
* Munkiimport now puts arch into pkginfo filename
2023-07-24 11:36:39 -07:00
Greg Neagle 767f64b12a Update copyright info 2023-02-22 09:59:22 -08:00
Greg Neagle c262ad35a4 Add minimum_munki_version of 6.2 when using new uninstall_package uninstall method 2023-01-31 15:37:38 -08:00
Greg Neagle 05e40a173d Fix dictionary update error that broke makepkginfo/munkiimport when importing an Adobe pkg 2023-01-20 13:42:31 -08:00
Greg Neagle 13cae46158 Add general support for uninstaller_package to munkiimport/makepkginfo; default to 'normal' Apple package install for Adobe CCP/Admin Console packages 2023-01-18 16:21:10 -08:00
Greg Neagle 929a7e9991 munkiimport: Catch more Exceptions when processesing catalogs 2022-11-01 14:27:11 -07:00
Greg Neagle 1f0dec689e Add more exception catching when reading catalogs in munkiimport 2022-11-01 14:15:41 -07:00
Greg Neagle d29de15e42 makepkginfo and munkiimport now restrict the --arch option to one of 'i386', 'x86_64', 'arm64' 2022-09-13 16:27:13 -07:00
Greg Neagle 9ecf863ffa Enforce the choice of one of ('copy_from_dmg', 'stage_os_installer', 'startosinstall') for --installer-type 2022-09-01 16:00:02 -07:00
Greg Neagle 345956b99e Fix typo in --installer-type help text 2022-09-01 13:35:07 -07:00
Greg Neagle f9d4bef2da Fixes to not reimport an item that is already in the repo 2022-08-29 13:45:43 -07:00
Greg Neagle d3281e9f39 Tweak help text for --installer-type option 2022-08-29 08:54:11 -07:00
Greg Neagle 32c5885b31 Add support for stage_os_installer items to makepkginfo and munkiimport 2022-08-29 08:51:59 -07:00
Greg Neagle 5ee0f5928a Update copyright dates 2022-05-10 16:09:38 -07:00
Greg Neagle 870660c3ac New --arch option for munkiimport and makepkginfo 2021-04-09 13:32:14 -07:00
Greg Neagle 9d3e265cb8 Update copyright dates 2021-02-20 09:05:58 -08:00
Greg Neagle bee2216e8d Remove most subprocess bufsize and open buffering options to instead use defaults. Addresses several RuntimeWarnings when using Python 3.8. 2020-08-06 21:34:43 -07:00
Greg Neagle e161a87952 Update install macos app checks for Big Sur 2020-07-23 16:58:11 -07:00
Greg Neagle 72a0535d0d Update Copyright dates 2020-01-01 08:53:37 -08:00
Greg Neagle a827e6cfd2 Import division from __future__ to make pylint --py3k happier 2019-11-14 10:03:03 -08:00
Greg Neagle aec2ef7014 Raise better exceptions/errors when a filepath given to makepkginfo doesn't exist or can't be read. Addresses #960. 2019-11-14 09:57:00 -08:00
Greg Neagle 3ac475c7c6 Remove no-longer-used sorting function 2019-07-13 07:12:09 -07:00
Greg Neagle cc3da0983c Fix some version sorting issues 2019-06-24 15:49:11 -07:00
Greg Neagle 0dddb5dbd5 Lots of Python 3 compatibility changes for munkilib 2019-06-22 22:19:39 -07:00
Greg Neagle f067961e6e Remove unused plistlib import from munkilib/admin/makecatalogslib.py 2019-05-30 08:57:33 -07:00
Greg Neagle a6d43a2b3c Python 3 compatibility for makecatalogs 2019-05-29 21:19:25 -07:00
Greg Neagle f0e00aefba Fix a typo in a comment 2019-05-26 17:12:17 -07:00
Greg Neagle 4487595fba PyLint cleanups 2019-05-04 07:30:42 -07:00
Greg Neagle df60207145 Add 'from __future__ import absolute_import' to all files to enforce Python3-style imports 2019-05-03 21:34:56 -07:00
Greg Neagle 531d99a01a Convert all print statements to Python3-compatible print functions 2019-05-03 19:47:37 -07:00
Elliot Jordan 2ad27ff411 Align except clauses with PEP 3110 (#933)
This should work for Python 2.6+, including 3.
https://www.python.org/dev/peps/pep-3110/#compatibility-issues
2019-05-03 15:05:13 -07:00
Elliot Jordan d14c4304ea Various typo fixes and spelling corrections (#907)
* Fixed "No Comment" typo in strings files

* Fix "problem updates" typo

* Fix "caught" typo

* Fix "pseudo" typo

* Fix "instantiated" typo

* Fix "explicitly" typo

* Fix "osascript" typo

* Spelling fixes and various other corrections

* Fix two more instances of "Logput"

* Fixed a few remaining spelling issues in python files

* Fix "because" typo

PR also submitted upstream to the Murky project for the same correction.

* Fix name of associated app

* Additional spelling corrections in comments/docstrings
2019-02-14 08:30:43 -08:00
Greg Neagle 918d0b7391 Update copyright dates 2019-01-02 10:31:50 -08:00
Arjen van Bochoven 0bfa5a38b5 Remove .lower() from check_mode() in pkginfolib (#867)
Fix #866
2018-10-03 15:48:55 +02:00
Greg Neagle 1428c40d06 Update copyright notices to include 2018 2018-01-20 08:46:22 -08:00
Greg Neagle f7f7f527b4 makecatalogslib.py: _append_ extra errors to the end of the errors list; _extend_ does the wrong thing :-) 2017-11-27 11:05:03 -08:00
Greg Neagle 833cd18806 Make some functions in munkiimportlib.py less chatty to make them easier to use in other code 2017-11-26 17:32:15 -08:00
Greg Neagle dd6e936e80 munkiimport now calls code in munkilib/admin/makecatalogs.py to rebuild catalogs instead of subprocessing makecatalogs 2017-11-19 17:56:09 -08:00
Greg Neagle 255f5762f5 Move reusable code from makecatalogs into munkilib/admin/makecatalogslb.py 2017-11-19 17:30:22 -08:00
Greg Neagle dbf0c95b9d Move munkiimportlib.py and pkginfolib.py into munkilib/admin 2017-11-19 08:39:22 -08:00