autopkg / n8felton-recipes

Recipes for Autopkg
28 stars 35 forks source link

Add missing attribute output_variables to YAML custom processor #152

Closed homebysix closed 3 years ago

homebysix commented 3 years ago

The YAML processor is currently failing in AutoPkg version 2.3.1 with the following error:

% autopkg run -vvv YamlTest.recipe
Processing YamlTest.recipe...
WARNING: YamlTest.recipe is missing trust info and FAIL_RECIPES_WITHOUT_TRUST_INFO is not set. Proceeding...
Traceback (most recent call last):
  File "/usr/local/bin/autopkg", line 2758, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/autopkg", line 2754, in main
    return subcommands[verb]["function"](argv)
  File "/usr/local/bin/autopkg", line 2258, in run_recipes
    autopackager.verify(recipe)
  File "/Library/AutoPkg/autopkglib/__init__.py", line 789, in verify
    variables.update(set(processor_class.output_variables.keys()))
AttributeError: type object 'YAML' has no attribute 'output_variables'

The fix is to add an output_variables attribute to the processor, even though the processor won't directly use this attribute.

With this change, the environment variables are set as intended:

% autopkg run -vvv YamlTest.recipe
Processing YamlTest.recipe...
WARNING: YamlTest.recipe is missing trust info and FAIL_RECIPES_WITHOUT_TRUST_INFO is not set. Proceeding...
{'AUTOPKG_VERSION': '2.3.1',
    ...snip...
 'verbose': 3}
YAML
{'Input': {'keys': ['version', 'path'],
           'url': 'https://updates.signal.org/desktop/latest-mac.yml'}}
YAML.py:42: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  releases = yaml.load(response)
{'Output': {}}
{'AUTOPKG_VERSION': '2.3.1',
    ...snip...
 'keys': ['version', 'path'],
 'path': 'signal-desktop-mac-5.16.0.zip',
 'url': 'https://updates.signal.org/desktop/latest-mac.yml',
 'verbose': 3,
 'version': '5.16.0'}
Receipt written to ~/Library/AutoPkg/Cache/local.YamlTest/receipts/YamlTest-receipt-20210904-160330.plist

Here is the simple recipe I used for testing:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Description</key>
    <string>Recipe description</string>
    <key>Identifier</key>
    <string>local.YamlTest</string>
    <key>Input</key>
    <dict>
        <key>NAME</key>
        <string>YamlTest</string>
    </dict>
    <key>MinimumVersion</key>
    <string>1.0</string>
    <key>Process</key>
    <array>
        <dict>
            <key>Arguments</key>
            <dict>
                <key>url</key>
                <string>https://updates.signal.org/desktop/latest-mac.yml</string>
                <key>keys</key>
                <array>
                    <string>version</string>
                    <string>path</string>
                </array>
            </dict>
            <key>Processor</key>
            <string>YAML</string>
        </dict>
    </array>
</dict>
</plist>