grahampugh-recipes icon indicating copy to clipboard operation
grahampugh-recipes copied to clipboard

ChoicesXMLGenerator should specify undesired choices, not just desired choices

Open homebysix opened this issue 3 years ago • 1 comments

I'd like to be able to use ChoicesXMLGenerator to designate which choices I don't want to install. For example:

<?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"&gt;
<plist version="1.0">
<array>
     <dict>
        <key>choiceIdentifier</key>
        <string>com.corel.pkg.painter2020.zh_TW</string>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>attributeSetting</key>
        <integer>0</integer>
    </dict>
     <dict>
        <key>choiceIdentifier</key>
        <string>com.corel.pkg.painter2020.Japanese</string>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>attributeSetting</key>
        <integer>0</integer>
    </dict>
     <dict>
        <key>choiceIdentifier</key>
        <string>com.corel.pkg.painter2020.German</string>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>attributeSetting</key>
        <integer>0</integer>
    </dict>
     <dict>
        <key>choiceIdentifier</key>
        <string>com.corel.pkg.painter2020.French</string>
        <key>choiceAttribute</key>
        <string>selected</string>
        <key>attributeSetting</key>
        <integer>0</integer>
    </dict>
</array>
</plist>

This will install the default choices, with the exception of the above four components, whose attributeSetting are all set to zero.

To reproduce these choices with ChoicesXMLGenerator, I would need to specify the other components as desired, which to me seems less resilient and more prone to failure if new components are added to subsequent software versions.

  - Processor: com.github.grahampugh.recipes.commonprocessors/ChoicesXMLGenerator
    Arguments:
      choices_pkg_path: "%pkg_path%"
      choices_xml_dest: "%RECIPE_CACHE_DIR%/Scripts/choices.xml"
      desired_choices:
        - com.corel.pkg.painter2020
        - com.corel.pkg.stubhelper.painter2020
        - com.corel.Messages
        - com.corel.CUH
        - com.corel.PCU2
        - com.corel.CUH.update
        - com.corel.LaunchAgents

Ideally, the choices argument would allow eithersetting the attributeSetting to either true (1) or false (0), and would leave at the default if unspecified. A dictionary would work for this, since the choice identifiers should be unique anyway. Like so:

  - Processor: com.github.grahampugh.recipes.commonprocessors/ChoicesXMLGenerator
    Arguments:
      choices_pkg_path: "%pkg_path%"
      choices_xml_dest: "%RECIPE_CACHE_DIR%/Scripts/choices.xml"
      choice_changes:
        com.corel.pkg.painter2020.zh_TW: false
        com.corel.pkg.painter2020.Japanese: false
        com.corel.pkg.painter2020.German: false
        com.corel.pkg.painter2020.French: false

Thanks for considering!

homebysix avatar Nov 09 '21 06:11 homebysix

HI, for some reason I only just saw this. I kind of see your point though I'm not sure I agree that setting the desired choices is less resilient. If some new component is added, I still want my original choices to stand, at least until that new component is evaluated. But then, for the two times I've used this processor, I explicitly want to select desired choices, not deselect some. The dictionary method seems reasonably sensible though. I'll try and look into it.

grahampugh avatar Feb 02 '22 08:02 grahampugh