Permalink
Browse files

start forking to chocolatey

  • Loading branch information...
1 parent af285ea commit 1c5f52ea0f06d109a9c24ba803dbd924f74d66a4 @rismoney rismoney committed May 13, 2012
Showing with 102 additions and 98 deletions.
  1. +6 −6 Modulefile
  2. +5 −5 README
  3. +91 −0 lib/puppet/provider/package/chocolatey.rb
  4. +0 −87 lib/puppet/provider/package/homebrew.rb
View
@@ -1,11 +1,11 @@
-name 'kelseyhightower-homebrew'
+name 'rismoney-chocolatey'
version '0.0.1'
-source 'https://github.com/kelseyhightower/puppet-homebrew'
-author 'kelseyhightower'
+source 'https://github.com/rismoney/puppet-chocolatey'
+author 'rismoeny'
license 'APACHE2'
-summary 'Homebrew package provider'
-description 'Homebrew package provider'
-project_page 'https://github.com/kelseyhightower/puppet-homebrew'
+summary 'Chocolatey package provider'
+description 'Chocolatey package provider'
+project_page 'https://github.com/rismoney/puppet-chocolatey'
## Add dependencies, if any:
# dependency 'username/name', '>= 1.2.0'
View
@@ -1,12 +1,12 @@
-homebrew
+chocolatey
-This is a home brew package provider. Use it like this:
+This is a chocolatey package provider. Use it like this:
- class hightower::packages {
- pkglist = [‘postgresql’, ‘nginx’, ‘git’, ‘tmux’]
+ class rich::packages {
+ pkglist = [‘notepadplusplus’, ‘msysgit’]
package { $pkglist:
ensure => installed,
- provider => ‘homebrew’,
+ provider => ‘chocolatey’,
}
}
@@ -0,0 +1,91 @@
+require 'puppet/provider/package'
+
+Puppet::Type.type(:package).provide(:choc, :parent => Puppet::Provider::Package) do
+ desc "Package management using Chocolatey on Windows"
+
+ confine :operatingsystem => :windows
+
+ has_feature :versionable
+
+ #replace the line below with
+ #commands :brew => "/usr/local/bin/brew"
+ commands :choc => "C:\Chocolatey\chocolateyInstall.cmd"
+
+ # Install packages, known as formulas, using brew.
+ def install
+ should = @resource[:ensure]
+
+ package_name = @resource[:name]
+ case should
+ when true, false, Symbol
+ # pass
+ else
+ package_name += "-#{should}"
+ end
+
+ output = choc(:install, package_name)
+
+ # Fail hard if there is no formula available. commented lines 29-31. need to understand choc output
+ #if output =~ /Error: No available formula/
+ # raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
+ #end
+ end
+
+ # chocolatey doesn't support uninstalls...
+
+ # def uninstall
+ # choc(:uninstall, @resource[:name])
+ # end
+
+ def update
+ self.install
+ end
+
+ # def query
+ # self.class.package_list(:justme => resource[:name])
+ # end
+
+ # def latest
+ # hash = self.class.package_list(:justme => resource[:name])
+ # hash[:ensure]
+ # end
+
+ # def self.package_list(options={})
+ # brew_list_command = [command(:brew), "list", "--versions"]
+
+ # if name = options[:justme]
+ # brew_list_command << name
+ # end
+
+ # begin
+ # list = execute(brew_list_command).lines.map {|line| name_version_split(line) }
+ # rescue Puppet::ExecutionFailure => detail
+ # raise Puppet::Error, "Could not list packages: #{detail}"
+ # end
+
+ # if options[:justme]
+ # return list.shift
+ # else
+ # return list
+ # end
+ # end
+
+ # def self.name_version_split(line)
+ # if line =~ (/^(\S+)\s+(.+)/)
+ # name = $1
+ # version = $2
+ # {
+ # :name => name,
+ # :ensure => version,
+ # :provider => :brew
+ # }
+ # else
+ # Puppet.warning "Could not match #{line}"
+ # nil
+ # end
+ # end
+
+ # def self.instances(justme = false)
+ # package_list.collect { |hash| new(hash) }
+ # end
+# end
@@ -1,87 +0,0 @@
-require 'puppet/provider/package'
-
-Puppet::Type.type(:package).provide(:brew, :parent => Puppet::Provider::Package) do
- desc "Package management using HomeBrew on OS X"
-
- confine :operatingsystem => :darwin
-
- has_feature :versionable
-
- commands :brew => "/usr/local/bin/brew"
-
- # Install packages, known as formulas, using brew.
- def install
- should = @resource[:ensure]
-
- package_name = @resource[:name]
- case should
- when true, false, Symbol
- # pass
- else
- package_name += "-#{should}"
- end
-
- output = brew(:install, package_name)
-
- # Fail hard if there is no formula available.
- if output =~ /Error: No available formula/
- raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
- end
- end
-
- def uninstall
- brew(:uninstall, @resource[:name])
- end
-
- def update
- self.install
- end
-
- def query
- self.class.package_list(:justme => resource[:name])
- end
-
- def latest
- hash = self.class.package_list(:justme => resource[:name])
- hash[:ensure]
- end
-
- def self.package_list(options={})
- brew_list_command = [command(:brew), "list", "--versions"]
-
- if name = options[:justme]
- brew_list_command << name
- end
-
- begin
- list = execute(brew_list_command).lines.map {|line| name_version_split(line) }
- rescue Puppet::ExecutionFailure => detail
- raise Puppet::Error, "Could not list packages: #{detail}"
- end
-
- if options[:justme]
- return list.shift
- else
- return list
- end
- end
-
- def self.name_version_split(line)
- if line =~ (/^(\S+)\s+(.+)/)
- name = $1
- version = $2
- {
- :name => name,
- :ensure => version,
- :provider => :brew
- }
- else
- Puppet.warning "Could not match #{line}"
- nil
- end
- end
-
- def self.instances(justme = false)
- package_list.collect { |hash| new(hash) }
- end
-end

0 comments on commit 1c5f52e

Please sign in to comment.