From b01e2793534ad77182d6b68c756234131d609dc2 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 15 Jan 2017 10:25:34 +0100 Subject: [PATCH] applying `build_deps` fix as described in willdurand/puppet-composer#44 --- README.md | 25 ++++++++++++++ manifests/init.pp | 6 ++++ manifests/install.pp | 53 +++++++++++++++++------------ manifests/install/download.pp | 2 -- spec/defines/nodejs_install_spec.rb | 13 +++++++ 5 files changed, 75 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 4436f7d..21fefce 100644 --- a/README.md +++ b/README.md @@ -223,6 +223,31 @@ This would install the package ``webpack`` into ``/target/directory`` with versi } ``` +### Omitting package build + +As discussed in [willdurand/composer#44](https://github.com/willdurand/puppet-composer/issues/44) each module should get a `build_deps` parameter which can be used in edge cases in order to turn the package setup of this module off: + +``` puppet +class { '::nodejs': + build_deps => false, +} + +::nodejs::install { 'nodejs-foo': + build_deps => false, +} +``` + +In this case you'll need to take care of the following packages: + +- `tar` +- `ruby` +- `wget` +- `semver` (GEM used by ruby) +- `make` +- `gcc` +- `git` +- `curl` + ### Proxy When your puppet agent is behind a web proxy, export the `http_proxy` environment variable: diff --git a/manifests/init.pp b/manifests/init.pp index 6b71564..61b1485 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,6 +20,9 @@ # [*python_package*] # Python package name, defaults to python # +# [*build_deps*] +# Whether or not to build packages. +# # == Example: # # include nodejs @@ -35,8 +38,10 @@ $make_install = true, $node_path = '/usr/local/node/node-default/lib/node_modules', $python_package = 'python', + $build_deps = true, ) { validate_string($node_path) + validate_bool($build_deps) nodejs::install { "nodejs-${version}": version => $version, @@ -44,6 +49,7 @@ with_npm => $with_npm, make_install => $make_install, python_package => $python_package, + build_deps => true, } $node_version = $version ? { diff --git a/manifests/install.pp b/manifests/install.pp index dd742f0..fb7943a 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -20,6 +20,9 @@ # [*python_package*] # Python package name, defaults to python # +# [*build_deps*] +# Whether or not to build deps. +# # == Example: # # class { 'nodejs': @@ -37,6 +40,7 @@ $with_npm = true, $make_install = true, $python_package = 'python', + $build_deps = true, ) { include nodejs::params @@ -53,33 +57,36 @@ default => $target_dir } - if !defined(Package['curl']) { - package {'curl': - ensure => installed + if $build_deps { + ensure_packages(['wget']) + if !defined(Package['curl']) { + package {'curl': + ensure => installed + } } - } - if !defined(Package['tar']) { - package {'tar': - ensure => installed + if !defined(Package['tar']) { + package {'tar': + ensure => installed + } } - } - if !defined(Package['git']) { - package {'git': - ensure => installed + if !defined(Package['git']) { + package {'git': + ensure => installed + } } - } - if !defined(Package['ruby']){ - package { 'ruby': - ensure => installed, - before => Package['semver'], + if !defined(Package['ruby']){ + package { 'ruby': + ensure => installed, + before => Package['semver'], + } } } $node_unpack_folder = "${::nodejs::params::install_dir}/node-${node_version}" - if !defined(Package['semver']){ + if ($build_deps and !defined(Package['semver'])) { package { 'semver': ensure => installed, provider => gem, @@ -168,13 +175,15 @@ if $make_install { - if $::osfamily == 'Suse'{ - package { 'patterns-openSUSE-minimal_base-conflicts-12.3-7.10.1.x86_64': - ensure => 'absent' + if $build_deps { + if $::osfamily == 'Suse'{ + package { 'patterns-openSUSE-minimal_base-conflicts-12.3-7.10.1.x86_64': + ensure => 'absent' + } } - } - ensure_packages([ $python_package, $gplusplus_package, 'make' ]) + ensure_packages([ $python_package, $gplusplus_package, 'make' ]) + } exec { "nodejs-make-install-${node_version}": command => "./configure --prefix=${node_unpack_folder} && make && make install", diff --git a/manifests/install/download.pp b/manifests/install/download.pp index 5fc5e0f..266a155 100644 --- a/manifests/install/download.pp +++ b/manifests/install/download.pp @@ -24,8 +24,6 @@ validate_string($destination) validate_string($source) - ensure_packages(['wget']) - if $caller_module_name != $module_name { warning('::nodejs::install::download is not meant for public use!') } diff --git a/spec/defines/nodejs_install_spec.rb b/spec/defines/nodejs_install_spec.rb index 26e7ec7..09e242e 100644 --- a/spec/defines/nodejs_install_spec.rb +++ b/spec/defines/nodejs_install_spec.rb @@ -211,6 +211,19 @@ )} end + describe 'omit package build' do + let(:params) {{ + :build_deps => false, + }} + + it { should_not contain_package('semver') } + it { should_not contain_package('ruby') } + it { should_not contain_package('git') } + it { should_not contain_package('tar') } + it { should_not contain_pacakge('wget') } + it { should_not contain_package('make') } + end + describe 'uninstall' do describe 'any instance' do let(:params) {{