Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-1421

appdmg prematurely filters for sources ending in .dmg

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: PUP 3.3.1
    • Fix Version/s: PUP 3.5.0
    • Component/s: Types and Providers
    • Labels:
      None
    • Environment:

      Mac OS 10.9, using Puppet 3.3.1 via boxen/our-boxen

    • Template:
    • Story Points:
      1
    • Sprint:
      Week 2014-1-8 to 2014-1-15, Week 2014-1-15 to 2014-1-21, Week 2014-1-22 to 2014-1-29

      Description

      Problem

      The following package resource:

      package { 'Toggl':
        provider => 'appdmg',
        source   => 'https://www.toggl.com/api/v8/installer?app=td&platform=darwin&channel=stable'
      }
      

      Fails with:

      Error: Could not set 'present' on ensure: private method `fail' called for Puppet::Type::Package::ProviderAppdmg:Class at [manifest line]
      

      Root Cause

      In lib/puppet/provider/package/appdmg.rb the installpkgdmg method starts out by validating that the source ends with .dmg:

        def self.installpkgdmg(source, name)
          unless source =~ /\.dmg$/i
            self.fail "Mac OS X PKG DMG's must specify a source string ending in .dmg"
          end
          # ... proceeds with downloading the source
      

      In the example above Toggl has a download URL which is an abstraction to redirect to the latest version:

      https://www.toggl.com/api/v8/installer?app=td&platform=darwin&channel=stable
      

      Redirects to the latest version, which is currently:

      https://55aa37393ef0d1f9fb76-e65c36a55026053efe5868c3826f43f1.ssl.cf1.rackcdn.com/TogglDesktop_2013-10-17-13-05-57.dmg
      

      Incidentally the download is curled to whatever "name" is, and "name" is what is ultimately mounted (and this will mount without the .dmg extension). With the validation commented out:

      Debug: Executing '/usr/bin/curl -o /tmp/d20140112-38340-1k8oyhr/Toggl -C - -k -L -s --url https://www.toggl.com/api/v8/installer?app=td&platform=darwin&channel=stable'
      Debug: Success: curl transfered [Toggl]
      Debug: Executing '/usr/bin/hdiutil mount -plist -nobrowse -readonly -mountrandom /tmp /tmp/d20140112-38340-1k8oyhr/Toggl'
      Debug: Executing '/usr/bin/ditto --rsrc /private/tmp/dmg.fJGJa8/TogglDesktop.app /Applications/TogglDesktop.app'
      Debug: Executing '/usr/bin/hdiutil eject /private/tmp/dmg.fJGJa8'
      Notice: /Stage[main]/Toggl/Package[Toggl]/ensure: created
      

      This issue was discovered in 3.3.1, but appdmg.rb hasn't changed significantly since then (as of 3.4.2).

      I will submit a PR with the fix.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbj74 Jonathan Webb
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Zendesk Support