Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppPkgCreator: New Optional Input: version_key #733

Merged
merged 3 commits into from
Apr 29, 2021

Conversation

primalcurve
Copy link

Adding a feature to allow an alternate version key in Info.plist. The .get method for the dict class allows NoneType arguments without throwing a TypeError exception. So if version_key is unset, it will return None, which will in turn return None on the .get for infoplist, defaulting to CFBundleShortVersionString.

As I will show in further comments/attachments, this will not affect existing recipes.

Glynn Lane added 2 commits April 13, 2021 14:24
Adding a feature to allow an alternate version key in `Info.plist`. The `.get` method for the `dict` class allows NoneType arguments without throwing a TypeError exception. So if `version_key` is unset, it will return `None`, which will in turn return `None` on get `.get` for `infoplist`, defaulting to `CFBundleShortVersionString`.

This will not affect existing recipes.
@primalcurve
Copy link
Author

% git commit -m "Minor verbiage change to message string to allow pre-commit processing"
black....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
[master 8374169] Minor verbiage change to message string to allow pre-commit processing
 1 file changed, 3 insertions(+), 3 deletions(-)

@primalcurve
Copy link
Author

primalcurve commented Apr 13, 2021

In this run I removed the Arguments dictionary from the recipe Property List in order to test to make sure the fallback to CFBundleShortVersionString still functions:

% autopkg run -vvvv <redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe
Processing <redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe...
{'AUTOPKG_VERSION': '2.3.2',
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/primalcurve-recipes/MicrosoftSkype'],
 'verbose': 4}
URLDownloader
{'Input': {'filename': 'MicrosoftSkype.dmg',
           'url': 'https://go.skype.com/mac.download'}}
URLDownloader: No value supplied for prefetch_filename, setting default value of: False
URLDownloader: No value supplied for CHECK_FILESIZE_ONLY, setting default value of: False
URLDownloader: Curl command: ['/usr/bin/curl', '--silent', '--show-error', '--no-buffer', '--dump-header', '-', '--speed-time', '30', '--location', '--url', 'https://go.skype.com/mac.download', '--fail', '--output', '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/tmpdjp_b58y']
URLDownloader: Storing new Last-Modified header: Tue, 02 Mar 2021 13:49:39 GMT
URLDownloader: Storing new ETag header: 0x8D8DD8206620C30
URLDownloader: Downloaded <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
{'Output': {'download_changed': True,
            'etag': '0x8D8DD8206620C30',
            'last_modified': 'Tue, 02 Mar 2021 13:49:39 GMT',
            'pathname': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
            'url_downloader_summary_result': {'data': {'download_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                              'summary_text': 'The following '
                                                              'new items were '
                                                              'downloaded:'}}}
EndOfCheckPhase
{'Input': {}}
{'Output': {}}
CodeSignatureVerifier
{'Input': {'input_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
           'requirement': 'anchor apple generic and identifier '
                          '"com.skype.skype" and (certificate '
                          'leaf[field.1.2.840.113635.100.6.1.9] /* exists */ '
                          'or certificate 1[field.1.2.840.113635.100.6.2.6] /* '
                          'exists */) and certificate '
                          'leaf[field.1.2.840.113635.100.6.1.13] /* exists */ '
                          'and certificate leaf[subject.OU] = AL798K98FX'}}
CodeSignatureVerifier: Mounted disk image <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
CodeSignatureVerifier: Verifying code signature...
CodeSignatureVerifier: Deep verification enabled...
CodeSignatureVerifier: Strict verification not defined. Using codesign defaults...
CodeSignatureVerifier: /private/tmp/dmg.Mq9ftW/Skype.app: valid on disk
CodeSignatureVerifier: /private/tmp/dmg.Mq9ftW/Skype.app: satisfies its Designated Requirement
CodeSignatureVerifier: /private/tmp/dmg.Mq9ftW/Skype.app: explicit requirement satisfied
CodeSignatureVerifier: Signature is valid
{'Output': {}}
AppPkgCreator
{'Input': {}}
AppPkgCreator: Mounted disk image <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
AppPkgCreator: Using path '/private/tmp/dmg.P1buCt/Skype.app' matched from globbed '/private/tmp/dmg.P1buCt/*.app'.
AppPkgCreator: Version: 8.69
AppPkgCreator: BundleID: com.skype.skype
AppPkgCreator: Copied /private/tmp/dmg.P1buCt/Skype.app to <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/payload/Applications/Skype.app
AppPkgCreator: Connecting
AppPkgCreator: Sending packaging request
AppPkgCreator: Disconnecting
AppPkgCreator: Failed to close socket: [Errno 9] Bad file descriptor
{'Output': {'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                                        'pkg_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.pkg',
                                                        'version': '8.69'},
                                               'report_fields': ['identifier',
                                                                 'version',
                                                                 'pkg_path'],
                                               'summary_text': 'The following '
                                                               'packages were '
                                                               'built:'},
            'new_package_request': True,
            'version': '8.69'}}
{'AUTOPKG_VERSION': '2.3.2',
 'CHECK_FILESIZE_ONLY': False,
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/primalcurve-recipes/MicrosoftSkype'],
 'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                             'pkg_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.pkg',
                                             'version': '8.69'},
                                    'report_fields': ['identifier',
                                                      'version',
                                                      'pkg_path'],
                                    'summary_text': 'The following packages '
                                                    'were built:'},
 'bundleid': 'com.skype.skype',
 'download_changed': True,
 'etag': '0x8D8DD8206620C30',
 'filename': 'MicrosoftSkype.dmg',
 'input_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
 'last_modified': 'Tue, 02 Mar 2021 13:49:39 GMT',
 'new_package_request': True,
 'pathname': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
 'pkg_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.pkg',
 'prefetch_filename': False,
 'requirement': 'anchor apple generic and identifier "com.skype.skype" and '
                '(certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists '
                '*/ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists '
                '*/) and certificate leaf[field.1.2.840.113635.100.6.1.13] /* '
                'exists */ and certificate leaf[subject.OU] = AL798K98FX',
 'url': 'https://go.skype.com/mac.download',
 'url_downloader_summary_result': {'data': {'download_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                   'summary_text': 'The following new items '
                                                   'were downloaded:'},
 'verbose': 4,
 'version': '8.69'}
Receipt written to <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/receipts/MicrosoftSkype.published_version.pkg-receipt-20210413-143129.plist

The following new items were downloaded:
    Download Path                                                                                                                 
    -------------                                                                                                                 
    <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg  

The following packages were built:
    Identifier       Version  Pkg Path                                                                                                        
    ----------       -------  --------                                                                                                        
    com.skype.skype  8.69     <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.pkg  

Since CFBundleShortVersionString in Skype is just 8.69, the recipe processed as expected. This recipe is essentially identical to Skype.pkg.recipe in the main AutoPkg recipes repo.

@primalcurve
Copy link
Author

In this run, I added CFBundleVersion as the version_key so that I could get a complete Version String from the Processor:

        <dict>
            <key>Processor</key>
            <string>AppPkgCreator</string>
            <key>comment</key>
            <string>Using the optional 'version_key' Argument to extract the full version number.</string>
            <key>Arguments</key>
            <dict>
               <key>version_key</key>
               <string>CFBundleVersion</string>
            </dict>
        </dict>
% autopkg run -vvvv <redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe
Processing <redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe...
{'AUTOPKG_VERSION': '2.3.2',
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/primalcurve-recipes/MicrosoftSkype'],
 'verbose': 4}
URLDownloader
{'Input': {'filename': 'MicrosoftSkype.dmg',
           'url': 'https://go.skype.com/mac.download'}}
URLDownloader: No value supplied for prefetch_filename, setting default value of: False
URLDownloader: No value supplied for CHECK_FILESIZE_ONLY, setting default value of: False
URLDownloader: Curl command: ['/usr/bin/curl', '--silent', '--show-error', '--no-buffer', '--dump-header', '-', '--speed-time', '30', '--location', '--url', 'https://go.skype.com/mac.download', '--fail', '--output', '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/tmpllcq3cym']
URLDownloader: Storing new Last-Modified header: Tue, 02 Mar 2021 13:49:39 GMT
URLDownloader: Storing new ETag header: 0x8D8DD8206620C30
URLDownloader: Downloaded <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
{'Output': {'download_changed': True,
            'etag': '0x8D8DD8206620C30',
            'last_modified': 'Tue, 02 Mar 2021 13:49:39 GMT',
            'pathname': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
            'url_downloader_summary_result': {'data': {'download_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                              'summary_text': 'The following '
                                                              'new items were '
                                                              'downloaded:'}}}
EndOfCheckPhase
{'Input': {}}
{'Output': {}}
CodeSignatureVerifier
{'Input': {'input_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
           'requirement': 'anchor apple generic and identifier '
                          '"com.skype.skype" and (certificate '
                          'leaf[field.1.2.840.113635.100.6.1.9] /* exists */ '
                          'or certificate 1[field.1.2.840.113635.100.6.2.6] /* '
                          'exists */) and certificate '
                          'leaf[field.1.2.840.113635.100.6.1.13] /* exists */ '
                          'and certificate leaf[subject.OU] = AL798K98FX'}}
CodeSignatureVerifier: Mounted disk image <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
CodeSignatureVerifier: Verifying code signature...
CodeSignatureVerifier: Deep verification enabled...
CodeSignatureVerifier: Strict verification not defined. Using codesign defaults...
CodeSignatureVerifier: /private/tmp/dmg.vfE222/Skype.app: valid on disk
CodeSignatureVerifier: /private/tmp/dmg.vfE222/Skype.app: satisfies its Designated Requirement
CodeSignatureVerifier: /private/tmp/dmg.vfE222/Skype.app: explicit requirement satisfied
CodeSignatureVerifier: Signature is valid
{'Output': {}}
AppPkgCreator
{'Input': {'version_key': 'CFBundleVersion'}}
AppPkgCreator: Mounted disk image <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
AppPkgCreator: Using path '/private/tmp/dmg.E4dGdY/Skype.app' matched from globbed '/private/tmp/dmg.E4dGdY/*.app'.
AppPkgCreator: Version: 8.69.0.88
AppPkgCreator: BundleID: com.skype.skype
AppPkgCreator: Copied /private/tmp/dmg.E4dGdY/Skype.app to <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/payload/Applications/Skype.app
AppPkgCreator: Connecting
AppPkgCreator: Sending packaging request
AppPkgCreator: Disconnecting
AppPkgCreator: Failed to close socket: [Errno 9] Bad file descriptor
{'Output': {'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                                        'pkg_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.0.88.pkg',
                                                        'version': '8.69.0.88'},
                                               'report_fields': ['identifier',
                                                                 'version',
                                                                 'pkg_path'],
                                               'summary_text': 'The following '
                                                               'packages were '
                                                               'built:'},
            'new_package_request': True,
            'version': '8.69.0.88'}}
{'AUTOPKG_VERSION': '2.3.2',
 'CHECK_FILESIZE_ONLY': False,
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/primalcurve-recipes/MicrosoftSkype'],
 'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                             'pkg_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.0.88.pkg',
                                             'version': '8.69.0.88'},
                                    'report_fields': ['identifier',
                                                      'version',
                                                      'pkg_path'],
                                    'summary_text': 'The following packages '
                                                    'were built:'},
 'bundleid': 'com.skype.skype',
 'download_changed': True,
 'etag': '0x8D8DD8206620C30',
 'filename': 'MicrosoftSkype.dmg',
 'input_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
 'last_modified': 'Tue, 02 Mar 2021 13:49:39 GMT',
 'new_package_request': True,
 'pathname': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
 'pkg_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.0.88.pkg',
 'prefetch_filename': False,
 'requirement': 'anchor apple generic and identifier "com.skype.skype" and '
                '(certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists '
                '*/ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists '
                '*/) and certificate leaf[field.1.2.840.113635.100.6.1.13] /* '
                'exists */ and certificate leaf[subject.OU] = AL798K98FX',
 'url': 'https://go.skype.com/mac.download',
 'url_downloader_summary_result': {'data': {'download_path': '<redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                   'summary_text': 'The following new items '
                                                   'were downloaded:'},
 'verbose': 4,
 'version': '8.69.0.88',
 'version_key': 'CFBundleVersion'}
Receipt written to <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/receipts/MicrosoftSkype.published_version.pkg-receipt-20210413-143245.plist

The following new items were downloaded:
    Download Path                                                                                                                 
    -------------                                                                                                                 
    <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg  

The following packages were built:
    Identifier       Version    Pkg Path                                                                                                             
    ----------       -------    --------                                                                                                             
    com.skype.skype  8.69.0.88  <redacted>/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.69.0.88.pkg  

As you can see, this now shows the full version number in the output.

Comment on lines 110 to 111
infoplist.get(self.env.get("version_key"))
or infoplist["CFBundleShortVersionString"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can combine these lines:

infoplist.get(self.env.get("version_key"), infoplist.get("CFBundleShortVersionString"))

However, this still has a safety risk in that it's possible none of those keys are defined. I would consider something more explicit that informs the admin of a serious problem, which combines your solution and mine:

infoplist.get(self.env.get("version_key"), infoplist.get("CFBundleShortVersionString")) or "0.0.0.0 (FIX ME!)"

If you want to be extra safe, consider adding an additional check at the end that if you don't have a valid result (either None or the "0.0.0.0" idea), throw a ProcessorError, because at that point you'll have a bad version you can't do anything about, and proceeding with it is likely dangerous.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I purposefully left infoplist["CFBundleShortVersionString"] as-is because it will throw a KeyError exception if the default key does not exist. Since this is already inside of a try block, it will throw an exception which will be caught as a ProcessorError.

>>> infoplist = dict()
>>> infoplist["CFBundleShortVersionString"]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    infoplist["CFBundleShortVersionString"]
KeyError: 'CFBundleShortVersionString'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I agree with the code flow, but my point is that it doesn't particularly give the operator a lot of useful information. You and I and people familiar with Python would likely recognize that a key error for this indicates something important is missing, but anyone not fluent in the underlying code here would be confused, as they'd see a traceback without any context or information on what they can do about it.

I'd like to try and make AutoPkg's failure states more meaningful for a wider audience, so ideally you'd capture this error and present a useful indication - i.e. (paraphrasing here) "go yell at the developer because this is really broken and there's nothing we can do to fix it", or "there's no way to get version information from this because it's malformed".

I don't particularly care that much which particular way you solve it, I just want to make the output very explicit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that philosophy. The exception traps I've seen are very broad. Let me put something together and add it to my PR.

Copy link
Contributor

@nmcspadden nmcspadden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left feedback. Good change, and I totally agree with it - just needs another safety net.

* Modified the code so it fails if `version_key` is not found in the Info.plist
* Added `KeyError` exception trap with more verbose output
* Modified description to indicate that it will now fail and not default back to `CFBundleShortVersionString`
@primalcurve
Copy link
Author

I have made some changes per our conversation. It is now specifically trapping KeyError and providing a friendlier error to the user.

@nmcspadden
Copy link
Contributor

Awesome, I like this a lot now. Can you just update the test plan to show that it still works as expected with a regular autopkg run? After that, I'll merge in.

@primalcurve
Copy link
Author

primalcurve commented Apr 29, 2021

Run with version_key unset:

% autopkg run -vvvv ~/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe
Processing <redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe...
{'AUTOPKG_VERSION': '2.3.2',
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype'],
 'verbose': 4}
URLDownloader
{'Input': {'filename': 'MicrosoftSkype.dmg',
           'url': 'https://go.skype.com/mac.download'}}
URLDownloader: No value supplied for prefetch_filename, setting default value of: False
URLDownloader: No value supplied for CHECK_FILESIZE_ONLY, setting default value of: False
URLDownloader: Curl command: ['/usr/bin/curl', '--silent', '--show-error', '--no-buffer', '--dump-header', '-', '--speed-time', '30', '--location', '--url', 'https://go.skype.com/mac.download', '--fail', '--output', '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/tmp5v7978fs']
URLDownloader: Storing new Last-Modified header: Wed, 21 Apr 2021 08:30:51 GMT
URLDownloader: Storing new ETag header: 0x8D9049FC5E85656
URLDownloader: Downloaded <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
{'Output': {'download_changed': True,
            'etag': '0x8D9049FC5E85656',
            'last_modified': 'Wed, 21 Apr 2021 08:30:51 GMT',
            'pathname': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
            'url_downloader_summary_result': {'data': {'download_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                              'summary_text': 'The following '
                                                              'new items were '
                                                              'downloaded:'}}}
EndOfCheckPhase
{'Input': {}}
{'Output': {}}
CodeSignatureVerifier
{'Input': {'input_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
           'requirement': 'anchor apple generic and identifier '
                          '"com.skype.skype" and (certificate '
                          'leaf[field.1.2.840.113635.100.6.1.9] /* exists */ '
                          'or certificate 1[field.1.2.840.113635.100.6.2.6] /* '
                          'exists */) and certificate '
                          'leaf[field.1.2.840.113635.100.6.1.13] /* exists */ '
                          'and certificate leaf[subject.OU] = AL798K98FX'}}
CodeSignatureVerifier: Mounted disk image <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
CodeSignatureVerifier: Verifying code signature...
CodeSignatureVerifier: Deep verification enabled...
CodeSignatureVerifier: Strict verification not defined. Using codesign defaults...
CodeSignatureVerifier: /private/tmp/dmg.qiri0c/Skype.app: valid on disk
CodeSignatureVerifier: /private/tmp/dmg.qiri0c/Skype.app: satisfies its Designated Requirement
CodeSignatureVerifier: /private/tmp/dmg.qiri0c/Skype.app: explicit requirement satisfied
CodeSignatureVerifier: Signature is valid
{'Output': {}}
AppPkgCreator
{'Input': {}}
AppPkgCreator: Mounted disk image <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
AppPkgCreator: Using path '/private/tmp/dmg.XAY5qi/Skype.app' matched from globbed '/private/tmp/dmg.XAY5qi/*.app'.
AppPkgCreator: Version: 8.71
AppPkgCreator: BundleID: com.skype.skype
AppPkgCreator: Copied /private/tmp/dmg.XAY5qi/Skype.app to <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/payload/Applications/Skype.app
AppPkgCreator: Connecting
AppPkgCreator: Sending packaging request
AppPkgCreator: Disconnecting
AppPkgCreator: Failed to close socket: [Errno 9] Bad file descriptor
{'Output': {'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                                        'pkg_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.pkg',
                                                        'version': '8.71'},
                                               'report_fields': ['identifier',
                                                                 'version',
                                                                 'pkg_path'],
                                               'summary_text': 'The following '
                                                               'packages were '
                                                               'built:'},
            'new_package_request': True,
            'version': '8.71'}}
{'AUTOPKG_VERSION': '2.3.2',
 'CHECK_FILESIZE_ONLY': False,
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype'],
 'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                             'pkg_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.pkg',
                                             'version': '8.71'},
                                    'report_fields': ['identifier',
                                                      'version',
                                                      'pkg_path'],
                                    'summary_text': 'The following packages '
                                                    'were built:'},
 'bundleid': 'com.skype.skype',
 'download_changed': True,
 'etag': '0x8D9049FC5E85656',
 'filename': 'MicrosoftSkype.dmg',
 'input_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
 'last_modified': 'Wed, 21 Apr 2021 08:30:51 GMT',
 'new_package_request': True,
 'pathname': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
 'pkg_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.pkg',
 'prefetch_filename': False,
 'requirement': 'anchor apple generic and identifier "com.skype.skype" and '
                '(certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists '
                '*/ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists '
                '*/) and certificate leaf[field.1.2.840.113635.100.6.1.13] /* '
                'exists */ and certificate leaf[subject.OU] = AL798K98FX',
 'url': 'https://go.skype.com/mac.download',
 'url_downloader_summary_result': {'data': {'download_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                   'summary_text': 'The following new items '
                                                   'were downloaded:'},
 'verbose': 4,
 'version': '8.71'}
Receipt written to <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/receipts/MicrosoftSkype.published_version.pkg-receipt-20210429-114640.plist

The following new items were downloaded:
    Download Path                                                                                                                 
    -------------                                                                                                                 
    <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg  

The following packages were built:
    Identifier       Version  Pkg Path                                                                                                        
    ----------       -------  --------                                                                                                        
    com.skype.skype  8.71     <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.pkg  

@primalcurve
Copy link
Author

Run with custom key:

% autopkg run -vvvv ~/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe
Processing <redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe...
{'AUTOPKG_VERSION': '2.3.2',
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype'],
 'verbose': 4}
URLDownloader
{'Input': {'filename': 'MicrosoftSkype.dmg',
           'url': 'https://go.skype.com/mac.download'}}
URLDownloader: No value supplied for prefetch_filename, setting default value of: False
URLDownloader: No value supplied for CHECK_FILESIZE_ONLY, setting default value of: False
URLDownloader: Curl command: ['/usr/bin/curl', '--silent', '--show-error', '--no-buffer', '--dump-header', '-', '--speed-time', '30', '--location', '--url', 'https://go.skype.com/mac.download', '--fail', '--output', '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/tmp79zzq4ur', '--header', 'If-None-Match: 0x8D8DD8206620C30', '--header', 'If-Modified-Since: Tue, 02 Mar 2021 13:49:39 GMT']
URLDownloader: Storing new Last-Modified header: Wed, 21 Apr 2021 08:30:51 GMT
URLDownloader: Storing new ETag header: 0x8D9049FC5E85656
URLDownloader: Downloaded <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
{'Output': {'download_changed': True,
            'etag': '0x8D9049FC5E85656',
            'last_modified': 'Wed, 21 Apr 2021 08:30:51 GMT',
            'pathname': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
            'url_downloader_summary_result': {'data': {'download_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                              'summary_text': 'The following '
                                                              'new items were '
                                                              'downloaded:'}}}
EndOfCheckPhase
{'Input': {}}
{'Output': {}}
CodeSignatureVerifier
{'Input': {'input_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
           'requirement': 'anchor apple generic and identifier '
                          '"com.skype.skype" and (certificate '
                          'leaf[field.1.2.840.113635.100.6.1.9] /* exists */ '
                          'or certificate 1[field.1.2.840.113635.100.6.2.6] /* '
                          'exists */) and certificate '
                          'leaf[field.1.2.840.113635.100.6.1.13] /* exists */ '
                          'and certificate leaf[subject.OU] = AL798K98FX'}}
CodeSignatureVerifier: Mounted disk image <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
CodeSignatureVerifier: Verifying code signature...
CodeSignatureVerifier: Deep verification enabled...
CodeSignatureVerifier: Strict verification not defined. Using codesign defaults...
CodeSignatureVerifier: /private/tmp/dmg.jKRaid/Skype.app: valid on disk
CodeSignatureVerifier: /private/tmp/dmg.jKRaid/Skype.app: satisfies its Designated Requirement
CodeSignatureVerifier: /private/tmp/dmg.jKRaid/Skype.app: explicit requirement satisfied
CodeSignatureVerifier: Signature is valid
{'Output': {}}
AppPkgCreator
{'Input': {'version_key': 'CFBundleVersion'}}
AppPkgCreator: Mounted disk image <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
AppPkgCreator: Using path '/private/tmp/dmg.cRqC7I/Skype.app' matched from globbed '/private/tmp/dmg.cRqC7I/*.app'.
AppPkgCreator: Version: 8.71.0.45
AppPkgCreator: BundleID: com.skype.skype
AppPkgCreator: Copied /private/tmp/dmg.cRqC7I/Skype.app to <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/payload/Applications/Skype.app
AppPkgCreator: Connecting
AppPkgCreator: Sending packaging request
AppPkgCreator: Disconnecting
AppPkgCreator: Failed to close socket: [Errno 9] Bad file descriptor
{'Output': {'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                                        'pkg_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.0.45.pkg',
                                                        'version': '8.71.0.45'},
                                               'report_fields': ['identifier',
                                                                 'version',
                                                                 'pkg_path'],
                                               'summary_text': 'The following '
                                                               'packages were '
                                                               'built:'},
            'new_package_request': True,
            'version': '8.71.0.45'}}
{'AUTOPKG_VERSION': '2.3.2',
 'CHECK_FILESIZE_ONLY': False,
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype'],
 'app_pkg_creator_summary_result': {'data': {'identifier': 'com.skype.skype',
                                             'pkg_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.0.45.pkg',
                                             'version': '8.71.0.45'},
                                    'report_fields': ['identifier',
                                                      'version',
                                                      'pkg_path'],
                                    'summary_text': 'The following packages '
                                                    'were built:'},
 'bundleid': 'com.skype.skype',
 'download_changed': True,
 'etag': '0x8D9049FC5E85656',
 'filename': 'MicrosoftSkype.dmg',
 'input_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
 'last_modified': 'Wed, 21 Apr 2021 08:30:51 GMT',
 'new_package_request': True,
 'pathname': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
 'pkg_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.0.45.pkg',
 'prefetch_filename': False,
 'requirement': 'anchor apple generic and identifier "com.skype.skype" and '
                '(certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists '
                '*/ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists '
                '*/) and certificate leaf[field.1.2.840.113635.100.6.1.13] /* '
                'exists */ and certificate leaf[subject.OU] = AL798K98FX',
 'url': 'https://go.skype.com/mac.download',
 'url_downloader_summary_result': {'data': {'download_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                   'summary_text': 'The following new items '
                                                   'were downloaded:'},
 'verbose': 4,
 'version': '8.71.0.45',
 'version_key': 'CFBundleVersion'}
Receipt written to <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/receipts/MicrosoftSkype.published_version.pkg-receipt-20210429-114327.plist

The following new items were downloaded:
    Download Path
    -------------
    <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg

The following packages were built:
    Identifier       Version    Pkg Path
    ----------       -------    --------
    com.skype.skype  8.71.0.45  <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/Skype-8.71.0.45.pkg
    ```

@primalcurve
Copy link
Author

Run with a purposefully invalid key:

        <dict>
            <key>Processor</key>
            <string>AppPkgCreator</string>
            <key>comment</key>
            <string>Using the optional 'version_key' Argument to extract the full version number.</string>
            <key>Arguments</key>
            <dict>
               <key>version_key</key>
               <string>INVALID_KEY</string>
            </dict>
        </dict>
% autopkg run -vvvv ~/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe
Processing <redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe...
WARNING: <redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe is missing trust info and FAIL_RECIPES_WITHOUT_TRUST_INFO is not set. Proceeding...
{'AUTOPKG_VERSION': '2.3.2',
 'DOWNLOAD_URL': 'https://go.skype.com/mac.download',
 'NAME': 'MicrosoftSkype',
 'PARENT_RECIPES': ['<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes/Skype/Skype.download.recipe'],
 'RECIPE_CACHE_DIR': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype',
 'RECIPE_DIR': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype',
 'RECIPE_OVERRIDE_DIRS': ['~/Library/AutoPkg/RecipeOverrides'],
 'RECIPE_PATH': '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe',
 'RECIPE_REPOS': {'<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes': {'URL': 'https://github.com/autopkg/recipes'},
                  '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes': {'URL': 'https://github.com/autopkg/rtrouton-recipes'}},
 'RECIPE_SEARCH_DIRS': ['.',
                        '~/Library/AutoPkg/Recipes',
                        '/Library/AutoPkg/Recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.recipes',
                        '<redacted>/Library/AutoPkg/RecipeRepos/com.github.autopkg.rtrouton-recipes',
                        '<redacted>/gitlab/primalcurve-recipes/MicrosoftSkype'],
 'verbose': 4}
URLDownloader
{'Input': {'filename': 'MicrosoftSkype.dmg',
           'url': 'https://go.skype.com/mac.download'}}
URLDownloader: No value supplied for prefetch_filename, setting default value of: False
URLDownloader: No value supplied for CHECK_FILESIZE_ONLY, setting default value of: False
URLDownloader: Curl command: ['/usr/bin/curl', '--silent', '--show-error', '--no-buffer', '--dump-header', '-', '--speed-time', '30', '--location', '--url', 'https://go.skype.com/mac.download', '--fail', '--output', '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/tmp2w5ivu0l']
URLDownloader: Storing new Last-Modified header: Wed, 21 Apr 2021 08:30:51 GMT
URLDownloader: Storing new ETag header: 0x8D9049FC5E85656
URLDownloader: Downloaded <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
{'Output': {'download_changed': True,
            'etag': '0x8D9049FC5E85656',
            'last_modified': 'Wed, 21 Apr 2021 08:30:51 GMT',
            'pathname': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg',
            'url_downloader_summary_result': {'data': {'download_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg'},
                                              'summary_text': 'The following '
                                                              'new items were '
                                                              'downloaded:'}}}
EndOfCheckPhase
{'Input': {}}
{'Output': {}}
CodeSignatureVerifier
{'Input': {'input_path': '<redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg/Skype.app',
           'requirement': 'anchor apple generic and identifier '
                          '"com.skype.skype" and (certificate '
                          'leaf[field.1.2.840.113635.100.6.1.9] /* exists */ '
                          'or certificate 1[field.1.2.840.113635.100.6.2.6] /* '
                          'exists */) and certificate '
                          'leaf[field.1.2.840.113635.100.6.1.13] /* exists */ '
                          'and certificate leaf[subject.OU] = AL798K98FX'}}
CodeSignatureVerifier: Mounted disk image <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
CodeSignatureVerifier: Verifying code signature...
CodeSignatureVerifier: Deep verification enabled...
CodeSignatureVerifier: Strict verification not defined. Using codesign defaults...
CodeSignatureVerifier: /private/tmp/dmg.WU7ec4/Skype.app: valid on disk
CodeSignatureVerifier: /private/tmp/dmg.WU7ec4/Skype.app: satisfies its Designated Requirement
CodeSignatureVerifier: /private/tmp/dmg.WU7ec4/Skype.app: explicit requirement satisfied
CodeSignatureVerifier: Signature is valid
{'Output': {}}
AppPkgCreator
{'Input': {'version_key': 'INVALID_KEY'}}
AppPkgCreator: Mounted disk image <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg
AppPkgCreator: Using path '/private/tmp/dmg.ZJz81s/Skype.app' matched from globbed '/private/tmp/dmg.ZJz81s/*.app'.
Traceback (most recent call last):
  File "<redacted>/gitlab/autopkg/Code/autopkglib/AppPkgCreator.py", line 111, in package_app
    self.env["version"] = infoplist[version_key]
KeyError: 'INVALID_KEY'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<redacted>/gitlab/autopkg/Code/autopkglib/__init__.py", line 840, in process
    self.env = processor.process()
  File "<redacted>/gitlab/autopkg/Code/autopkglib/__init__.py", line 626, in process
    self.main()
  File "<redacted>/gitlab/autopkg/Code/autopkglib/AppPkgCreator.py", line 256, in main
    self.package_app(matched_app_path)
  File "<redacted>/gitlab/autopkg/Code/autopkglib/AppPkgCreator.py", line 116, in package_app
    f"The key '{version_key}' does not exist in the App "
autopkglib.ProcessorError: The key 'INVALID_KEY' does not exist in the App Bundle's Info.plist! (/private/tmp/dmg.ZJz81s/Skype.app/Contents/Info.plist) Please check the recipe and try again.
  File "<redacted>/gitlab/autopkg/Code/autopkglib/__init__.py", line 840, in process
    self.env = processor.process()
The key 'INVALID_KEY' does not exist in the App Bundle's Info.plist! (/private/tmp/dmg.ZJz81s/Skype.app/Contents/Info.plist) Please check the recipe and try again.
Failed.
Receipt written to <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/receipts/MicrosoftSkype.published_version.pkg-receipt-20210429-115119.plist

The following recipes failed:
    <redacted>/gitlab/primalcurve-recipes/MicrosoftSkype/MicrosoftSkype.published_version.pkg.recipe
        Error in com.github.primalcurve.pkg.published_version.MicrosoftSkype: Processor: AppPkgCreator: Error: The key 'INVALID_KEY' does not exist in the App Bundle's Info.plist! (/private/tmp/dmg.ZJz81s/Skype.app/Contents/Info.plist) Please check the recipe and try again.

The following new items were downloaded:
    Download Path
    -------------
    <redacted>/Library/AutoPkg/Cache/com.github.primalcurve.pkg.published_version.MicrosoftSkype/downloads/MicrosoftSkype.dmg

@nmcspadden
Copy link
Contributor

Awesome, thank you!

@nmcspadden nmcspadden merged commit bead79e into autopkg:master Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants