autopkg / mosen-recipes

Recipes for osx application update management
MIT License
12 stars 20 forks source link

FirefoxESRPolicies.pkg fails to copy policies.json file #27

Closed haircut closed 6 years ago

haircut commented 6 years ago

In testing the FirefoxESRPolicies.pkg recipe I found that it would fail on the step where the policies.json file is copied to the path within the Firefox.app bundle.

Copier: Copied /private/tmp/dmg.YkeUbA/Firefox.app to /Users/haircut/Library/AutoPkg/Cache/local.pkg.FirefoxESRPoliciesLAC/Firefox/Applications/Firefox.app
{'Output': {}}
Copier
{'Input': {'destination_path': u'/Users/haircut/Library/AutoPkg/Cache/local.pkg.FirefoxESRPoliciesLAC/Firefox/Applications/Firefox.app/Contents/Resources/distribution/policies.json',
           'source_path': u'/Users/haircut/Library/AutoPkg/RecipeOverrides/policies.json'}}
Can't copy /Users/haircut/Library/AutoPkg/RecipeOverrides/policies.json to /Users/haircut/Library/AutoPkg/Cache/local.pkg.FirefoxESRPoliciesLAC/Firefox/Applications/Firefox.app/Contents/Resources/distribution/policies.json: [Errno 2] No such file or directory: u'/Users/haircut/Library/AutoPkg/Cache/local.pkg.FirefoxESRPoliciesLAC/Firefox/Applications/Firefox.app/Contents/Resources/distribution/policies.json'
Failed.

Through some poking I found that the Firefox.app/Contents/Resources/distribution directory does not exist by default when Firefox ESR is downloaded. The Copier processor is not able to create non-existent directories, thus the failure; the destination path does not exist.

To test, I modified the parent recipe (instead of my override) to inject an additional Copier step before the attempt to copy policies.json. This step simply copies an empty distribution directory from the %RECIPE_DIR%.

<dict>
    <key>Arguments</key>
    <dict>
        <key>source_path</key>
        <string>%RECIPE_DIR%/distribution</string>
        <key>destination_path</key>
        <string>%pkgroot%/Applications/Firefox.app/Contents/Resources/distribution</string>
    </dict>
    <key>Processor</key>
    <string>Copier</string>
</dict>
<dict>
    <key>Arguments</key>
    <dict>
        <key>source_path</key>
        <string>%RECIPE_DIR%/%POLICIES_FILENAME%</string>
        <key>destination_path</key>
        <string>%pkgroot%/Applications/Firefox.app/Contents/Resources/distribution/policies.json</string>
    </dict>
    <key>Processor</key>
    <string>Copier</string>
</dict>

This adds the additional requirement of having this "dummy" distribution directory in the %RECIPE_DIR% path.

Perhaps a better solution would be to require that instead of just creating the policies.json file in %RECIPE_DIR%, one must create the full path distribution/policies.json. Then, a single Copier step could correctly copy the distribution directory and its contents to the Firefox app bundle before packaging.

haircut commented 6 years ago

This is fixed in fdbf87c – thanks @mosen 🥇