homebysix / recipe-robot

A kick ass tool for creating AutoPkg recipes.
Apache License 2.0
300 stars 28 forks source link

Recipe downloads zip and calls it dmg instead of download dmg #127

Closed jelockwood closed 6 years ago

jelockwood commented 6 years ago

I have been setting up Munki and related tools for a company and this therefore includes autopkg and AutoPkgr.

I also downloaded Recipe Robot since I was finding that some apps either had no recipes or not ones that did what I wanted. For example there is a recipe for Draw.io but this only downloads a zip file and does not add it or the extracted content.

Using the recipe override option I created my own recipes. Unfortunately even though the generated download recipe looks like it should be downloading the available dmg it actually downloads a zip and saves it with the file extension dmg.

The file is here https://github.com/jgraph/drawio-desktop/releases/

As you can see the first file listed is a zip but there is a dmg listed as well.

How do I get the recipe to only download the dmg.

Since the file is saved as a dmg but is actually a zip the next stage of course fails to mount the 'dmg' therefore the run fails.

jelockwood commented 6 years ago

Right, having just tried using Recipe Robot to build a second recipe for a different project also on GitHub it is now clear what is happening.

If the 'release' in GitHub of a program contains multiple files Recipe Robot generated recipes always pick the very first file and do not pick the real .pkg or real .dmg file.

In the case of Draw.io the first file listed is the .pkg file in the case of the one I just tried of Rocket.Chat+ the first file is a JSON definition and not the .pkg or the .dmg.

Since Recipe Robot is supposed to have built-in knowledge of GitHub repositories this seems like a major failing in the way it parses them. It should have the intelligence to look for something like https://github.com/RocketChat/Rocket.Chat.Electron/releases/tag/*/*.dmg

In this latest case the correct latest file would be https://github.com/RocketChat/Rocket.Chat.Electron/releases/download/2.10.5/rocketchat-2.10.5.dmg and not https://github.com/RocketChat/Rocket.Chat.Electron/releases/download/2.10.5/latest-mac.json which is what it actually downloaded - and then saved as rocketchat-2.10.5.pkg

It is disappointing that after a month the author has not responded to this issue. Hopefully this additional information will be of help.

jelockwood commented 6 years ago

Ok, found an example working recipe for a GitHub package and from that I discovered that changing the generated code from Recipe Robot which was

            <key>Arguments</key>
            <dict>
                <key>github_repo</key>
                <string>%GITHUB_REPO%</string>
            </dict>
            <key>Processor</key>
            <string>GitHubReleasesInfoProvider</string>

to

            <key>Arguments</key>
            <dict>
                <key>asset_regex</key>
                <string>%NAME%-.+\.dmg</string>
                <key>github_repo</key>
                <string>%GITHUB_REPO%</string>
            </dict>
            <key>Processor</key>
            <string>GitHubReleasesInfoProvider</string>

Solves the problem.

homebysix commented 6 years ago

Hi @jelockwood - Your solution is great. Exactly what I would recommend.

You're right that Recipe Robot doesn't try to be smart about which GitHub release to pick. It chooses the first one it finds. It intentionally doesn't try to assume that a particular format (dmg) is better than another format (pkg). That could potentially change if people found it useful.

Another valid workaround would be to download the dmg file, then feed that actual dmg file into Recipe Robot as input. It'll use the download URL saved in the metadata of the file. After the recipes are created, you can go into the download recipe and add GitHubReleasesInfoProvider before URLDownloader with the proper asset_regex and github_repo variables set.

homebysix commented 6 years ago

Check out 4af4df7 — Recipe Robot should now prefer dmg, then zip, then pkg if multiple supported formats are available in a GitHub release feed.

jelockwood commented 6 years ago

I would prefer DMG then pkg then zip, perhaps this should be a user preference with the ability to drag in to the desired order.

Sent from my iPhone

On 17 Mar 2018, at 15:19, Elliot Jordan notifications@github.com wrote:

Check out 4af4df7 — Recipe Robot should now prefer dmg, then zip, then pkg if multiple supported formats are available in a GitHub release feed.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.