Created
August 18, 2016 17:14
-
-
Save pudquick/d64234a093e223e319d2d7a104d4b85e to your computer and use it in GitHub Desktop.
Programmatically access package receipt information using the OS X PrivateFramework PackageKit (same one pkgutil uses) with python and pyobjc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import objc | |
packagekit_bundle = objc.loadBundle('PackageKit', module_globals=globals(), bundle_path='/System/Library/PrivateFrameworks/PackageKit.framework', scan_classes=False) | |
PKReceipt = objc.lookUpClass('PKReceipt') | |
receipts = PKReceipt.receiptsOnVolumeAtPath_('/') | |
first_receipt = receipts[0] | |
# Things you can look up: | |
# installPrefixPath | |
# installProcessName | |
# installDate | |
# packageVersion | |
# packageIdentifier | |
# description | |
# receiptStoragePaths | |
# packageGroups | |
# >>> first_receipt.packageVersion() | |
# u'10.11.4.1.1.1457768702' | |
# Direct access to the BOM for the package receipt | |
# >>> bom = first_receipt._BOM() | |
# >>> e = bom.directoryEnumerator() | |
# >>> e.nextObject() | |
# u'System' | |
# >>> e.nextObject() | |
# u'System/Library' | |
# >>> e.nextObject() | |
# u'System/Library/CoreServices' | |
# >>> e.nextObject() | |
# u'System/Library/CoreServices/SystemVersion.plist' | |
# [...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment