Skip to content

Commit

Permalink
start forking to chocolatey
Browse files Browse the repository at this point in the history
  • Loading branch information
rismoney committed May 13, 2012
1 parent af285ea commit 1c5f52e
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 98 deletions.
12 changes: 6 additions & 6 deletions Modulefile
@@ -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'
10 changes: 5 additions & 5 deletions README
@@ -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’,
}
}
91 changes: 91 additions & 0 deletions lib/puppet/provider/package/chocolatey.rb
@@ -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
87 changes: 0 additions & 87 deletions lib/puppet/provider/package/homebrew.rb

This file was deleted.

0 comments on commit 1c5f52e

Please sign in to comment.