From 3ae9742abf61a8778acfdd737d51a06bd671afb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Albers?= Date: Thu, 23 Aug 2012 14:29:08 +0200 Subject: [PATCH] Add class homebrew to install Homebrew itself. --- manifests/compiler.pp | 20 ++++++++++++++++++++ manifests/init.pp | 7 +++++++ manifests/install.pp | 42 ++++++++++++++++++++++++++++++++++++++++++ manifests/params.pp | 10 ++++++++++ 4 files changed, 79 insertions(+) create mode 100644 manifests/compiler.pp create mode 100644 manifests/init.pp create mode 100644 manifests/install.pp create mode 100644 manifests/params.pp diff --git a/manifests/compiler.pp b/manifests/compiler.pp new file mode 100644 index 0000000..7a04568 --- /dev/null +++ b/manifests/compiler.pp @@ -0,0 +1,20 @@ +class homebrew::compiler { + if $has_compiler == 'true' { + $package = [ ] + } + elsif versioncmp($macosx_productversion_major, '10.7') < 0 { + warn('Please install the Command Line Tools bundled with XCode manually!') + $package = [ ] + } + else { + notice('Installing Command Line Tools.') + $package = $homebrew::command_line_tools_package + $source = $homebrew::command_line_tools_source + } + + package { $package: + ensure => present, + provider => pkgdmg, + source => $source, + } +} diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..787b211 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,7 @@ +class homebrew( + $command_line_tools_package = $homebrew::params::command_line_tools_package, + $command_line_tools_source = $homebrew::params::command_line_tools_source, + $user = $homebrew::params::user +) inherits homebrew::params { + include homebrew::compiler, homebrew::install +} diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..18f009b --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,42 @@ +class homebrew::install { + $directories = [ '/usr/local', + '/usr/local/bin', + '/usr/local/etc', + '/usr/local/include', + '/usr/local/lib', + '/usr/local/lib/pkgconfig', + '/usr/local/Library', + '/usr/local/sbin', + '/usr/local/share', + '/usr/local/var', + '/usr/local/var/log', + '/usr/local/share/locale', + '/usr/local/share/man', + '/usr/local/share/man/man1', + '/usr/local/share/man/man2', + '/usr/local/share/man/man3', + '/usr/local/share/man/man4', + '/usr/local/share/man/man5', + '/usr/local/share/man/man6', + '/usr/local/share/man/man7', + '/usr/local/share/man/man8', + '/usr/local/share/info', + '/usr/local/share/doc', + '/usr/local/share/aclocal' ] + + file { $directories: + ensure => directory, + owner => $homebrew::user, + group => 'admin', + mode => 0775, + } + + exec { 'install-homebrew': + cwd => '/usr/local', + command => "/usr/bin/su ${homebrew::user} -c '/bin/bash -o pipefail -c \"/usr/bin/curl -skSfL https://github.com/mxcl/homebrew/tarball/master | /usr/bin/tar xz -m --strip 1\"'", + creates => '/usr/local/bin/brew', + logoutput => on_failure, + timeout => 0, + require => File[$directories], + } +} diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..3798249 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,10 @@ +class homebrew::params { + if $operatingsystem != 'Darwin' { + err('This Module works on Mac OS X only!') + fail('Exit') + } + + $command_line_tools_package = 'command_line_tools_for_xcode_os_x_lion_aug_2013.dmg' + $command_line_tools_source = 'http://puppet/command_line_tools_for_xcode_os_x_lion_aug_2013.dmg' + $user = 'root' +}