Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
Merge branch 'COOK-584'
Browse files Browse the repository at this point in the history
  • Loading branch information
schisamo committed May 28, 2011
2 parents 6f1d8e6 + 0aa74ad commit 4d7698e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 39 deletions.
29 changes: 24 additions & 5 deletions dmg/README.md
@@ -1,23 +1,35 @@
Description Description
=========== ===========


Lightweight resource and provider to install OS X applications (.app) from dmg files Lightweight resource and provider to install OS X applications (.app) from dmg files.

Changes
=======

## v0.6.0:

- option to install software that is an .mpkg inside a .dmg
- ignore failure on chmod in case mode is already set, or is root owned


Requirements Requirements
============ ============


Platform: Mac OS X ## Platform:

* Mac OS X


Resources and Providers Resources and Providers
======================= =======================


`dmg_package` dmg\_package
------------- ------------


This resource will install a DMG "Package". It will retrieve the DMG from a remote URL, mount it using OS X's `hdid`, copy the application (.app directory) to the specified destination (/Applications), and detach the image using `hdiutil`. The dmg file will be stored in the `Chef::Config[:file_cache_path]`. If you want to install an application that has already been downloaded (not using the `source` parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef: This resource will install a DMG "Package". It will retrieve the DMG from a remote URL, mount it using OS X's `hdid`, copy the application (.app directory) to the specified destination (/Applications), and detach the image using `hdiutil`. The dmg file will be stored in the `Chef::Config[:file_cache_path]`. If you want to install an application that has already been downloaded (not using the `source` parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef:


knife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb knife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb


Optionally, the LWRP can install an "mpkg" package using installer(8).

# Actions: # Actions:


* :install - Installs the application. * :install - Installs the application.
Expand All @@ -28,6 +40,7 @@ This resource will install a DMG "Package". It will retrieve the DMG from a remo
* `source` - remote URL for the dmg to download if specified. Default is nil. * `source` - remote URL for the dmg to download if specified. Default is nil.
* `destination` - directory to copy the .app into. Default is /Applications. * `destination` - directory to copy the .app into. Default is /Applications.
* `checksum` - sha256 checksum of the dmg to download. Default is nil. * `checksum` - sha256 checksum of the dmg to download. Default is nil.
* `type` - type of package, "app" or "mpkg". Default is "app". When using "mpkg", the destination must be /Applications.
* `volumes_dir` - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute. * `volumes_dir` - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute.
* `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces. * `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces.


Expand Down Expand Up @@ -69,6 +82,13 @@ Install MacIrssi to `~/Applications` from the local file downloaded to the cache
action :install action :install
end end


Install Virtualbox to `/Applications` from the .mpkg:

dmg_package "Virtualbox" do
source "http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg"
type "mpkg"
end

To do To do
===== =====


Expand All @@ -82,7 +102,6 @@ Some things that would be nice to have at some point.
* use hdiutil to mount/attach the disk image * use hdiutil to mount/attach the disk image
* automatically detect the `volumes_dir` where the image is attached * automatically detect the `volumes_dir` where the image is attached
* be able to automatically accept license agreements * be able to automatically accept license agreements
* install software that is a .pkg inside a .dmg instead of just .app's


License and Author License and Author
================== ==================
Expand Down
32 changes: 0 additions & 32 deletions dmg/metadata.json

This file was deleted.

2 changes: 1 addition & 1 deletion dmg/metadata.rb
Expand Up @@ -3,5 +3,5 @@
license "Apache 2.0" license "Apache 2.0"
description "LWRP to install OS X applications from dmgs" description "LWRP to install OS X applications from dmgs"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.5.2" version "0.6.0"
supports "mac_os_x" supports "mac_os_x"
9 changes: 8 additions & 1 deletion dmg/providers/package.rb
Expand Up @@ -43,11 +43,18 @@ def load_current_resource
not_if "hdiutil info | grep -q 'image-path.*#{dmg_file}'" not_if "hdiutil info | grep -q 'image-path.*#{dmg_file}'"
end end


execute "cp -r '/Volumes/#{volumes_dir}/#{new_resource.app}.app' '#{new_resource.destination}'" case new_resource.type
when "app"
execute "cp -r '/Volumes/#{volumes_dir}/#{new_resource.app}.app' '#{new_resource.destination}'"
when "mpkg"
execute "sudo installer -pkg /Volumes/#{volumes_dir}/#{new_resource.app}.mpkg -target /"
end

execute "hdiutil detach '/Volumes/#{volumes_dir}'" execute "hdiutil detach '/Volumes/#{volumes_dir}'"


file "#{new_resource.destination}/#{new_resource.app}.app/Contents/MacOS/#{new_resource.app}" do file "#{new_resource.destination}/#{new_resource.app}.app/Contents/MacOS/#{new_resource.app}" do
mode 0755 mode 0755
ignore_failure true
end end


end end
Expand Down
1 change: 1 addition & 0 deletions dmg/resources/package.rb
Expand Up @@ -24,6 +24,7 @@
attribute :checksum, :kind_of => String, :default => nil attribute :checksum, :kind_of => String, :default => nil
attribute :volumes_dir, :kind_of => String, :default => nil attribute :volumes_dir, :kind_of => String, :default => nil
attribute :dmg_name, :kind_of => String, :default => nil attribute :dmg_name, :kind_of => String, :default => nil
attribute :type, :kind_of => String, :default => "app"
attribute :installed, :kind_of => [TrueClass, FalseClass], :default => false attribute :installed, :kind_of => [TrueClass, FalseClass], :default => false


def initialize(name, run_context=nil) def initialize(name, run_context=nil)
Expand Down

0 comments on commit 4d7698e

Please sign in to comment.