poise-build-essential 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.kitchen.yml +3 -0
  4. data/.travis.yml +60 -0
  5. data/.yardopts +7 -0
  6. data/CHANGELOG.md +5 -0
  7. data/Gemfile +35 -0
  8. data/LICENSE +201 -0
  9. data/README.md +85 -0
  10. data/Rakefile +17 -0
  11. data/chef/attributes/default.rb +21 -0
  12. data/chef/recipes/default.rb +19 -0
  13. data/lib/poise_build_essential.rb +22 -0
  14. data/lib/poise_build_essential/build_essential_providers.rb +49 -0
  15. data/lib/poise_build_essential/build_essential_providers/base.rb +103 -0
  16. data/lib/poise_build_essential/build_essential_providers/debian.rb +41 -0
  17. data/lib/poise_build_essential/build_essential_providers/freebsd.rb +46 -0
  18. data/lib/poise_build_essential/build_essential_providers/mac_os_x.rb +66 -0
  19. data/lib/poise_build_essential/build_essential_providers/omnios.rb +46 -0
  20. data/lib/poise_build_essential/build_essential_providers/rhel.rb +46 -0
  21. data/lib/poise_build_essential/build_essential_providers/smartos.rb +39 -0
  22. data/lib/poise_build_essential/build_essential_providers/solaris.rb +47 -0
  23. data/lib/poise_build_essential/build_essential_providers/suse.rb +43 -0
  24. data/lib/poise_build_essential/build_essential_providers/windows.rb +68 -0
  25. data/lib/poise_build_essential/cheftie.rb +18 -0
  26. data/lib/poise_build_essential/resources.rb +26 -0
  27. data/lib/poise_build_essential/resources/poise_build_essential.rb +48 -0
  28. data/lib/poise_build_essential/version.rb +20 -0
  29. data/poise-build-essential.gemspec +42 -0
  30. data/test/cookbook/attributes/default.rb +17 -0
  31. data/test/cookbook/metadata.rb +18 -0
  32. data/test/cookbook/recipes/default.rb +37 -0
  33. data/test/gemfiles/chef-12.1.gemfile +23 -0
  34. data/test/gemfiles/chef-12.10.gemfile +23 -0
  35. data/test/gemfiles/chef-12.11.gemfile +23 -0
  36. data/test/gemfiles/chef-12.12.gemfile +22 -0
  37. data/test/gemfiles/chef-12.13.gemfile +22 -0
  38. data/test/gemfiles/chef-12.14.gemfile +19 -0
  39. data/test/gemfiles/chef-12.15.gemfile +19 -0
  40. data/test/gemfiles/chef-12.16.gemfile +19 -0
  41. data/test/gemfiles/chef-12.17.gemfile +19 -0
  42. data/test/gemfiles/chef-12.18.gemfile +19 -0
  43. data/test/gemfiles/chef-12.19.gemfile +19 -0
  44. data/test/gemfiles/chef-12.2.gemfile +23 -0
  45. data/test/gemfiles/chef-12.3.gemfile +23 -0
  46. data/test/gemfiles/chef-12.4.gemfile +24 -0
  47. data/test/gemfiles/chef-12.5.gemfile +23 -0
  48. data/test/gemfiles/chef-12.6.gemfile +23 -0
  49. data/test/gemfiles/chef-12.7.gemfile +23 -0
  50. data/test/gemfiles/chef-12.8.gemfile +23 -0
  51. data/test/gemfiles/chef-12.9.gemfile +23 -0
  52. data/test/gemfiles/chef-12.gemfile +19 -0
  53. data/test/gemfiles/master.gemfile +26 -0
  54. data/test/integration/default/serverspec/default_spec.rb +27 -0
  55. data/test/spec/build_essential_providers/debian_spec.rb +49 -0
  56. data/test/spec/build_essential_providers/freebsd_spec.rb +68 -0
  57. data/test/spec/build_essential_providers/mac_os_x_spec.rb +52 -0
  58. data/test/spec/build_essential_providers/omnios_spec.rb +67 -0
  59. data/test/spec/build_essential_providers/rhel_spec.rb +54 -0
  60. data/test/spec/build_essential_providers/smartos_spec.rb +64 -0
  61. data/test/spec/build_essential_providers/solaris_spec.rb +108 -0
  62. data/test/spec/build_essential_providers/suse_spec.rb +54 -0
  63. data/test/spec/recipe_spec.rb +35 -0
  64. data/test/spec/resources/poise_build_essential_spec.rb +49 -0
  65. data/test/spec/spec_helper.rb +19 -0
  66. metadata +210 -0
@@ -0,0 +1,19 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ poise_build_essential 'build_essential' do
18
+ action node['poise-build-essential']['action'].to_sym
19
+ end
@@ -0,0 +1,22 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+
18
+ module PoiseBuildEssential
19
+ autoload :BuildEssentialProviders, 'poise_build_essential/build_essential_providers'
20
+ autoload :Resources, 'poise_build_essential/resources'
21
+ autoload :VERSION, 'poise_build_essential/version'
22
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'chef/platform/provider_priority_map'
18
+
19
+ require 'poise_build_essential/build_essential_providers/debian'
20
+ require 'poise_build_essential/build_essential_providers/freebsd'
21
+ require 'poise_build_essential/build_essential_providers/mac_os_x'
22
+ require 'poise_build_essential/build_essential_providers/omnios'
23
+ require 'poise_build_essential/build_essential_providers/rhel'
24
+ require 'poise_build_essential/build_essential_providers/smartos'
25
+ require 'poise_build_essential/build_essential_providers/solaris'
26
+ require 'poise_build_essential/build_essential_providers/suse'
27
+ # require 'poise_build_essential/build_essential_providers/windows'
28
+
29
+
30
+ module PoiseBuildEssential
31
+ # Inversion providers for the poise_build_essential resource.
32
+ #
33
+ # @since 1.0.0
34
+ module BuildEssentialProviders
35
+ # Set up priority maps
36
+ Chef::Platform::ProviderPriorityMap.instance.priority(:poise_build_essential, [
37
+ PoiseBuildEssential::BuildEssentialProviders::Debian,
38
+ PoiseBuildEssential::BuildEssentialProviders::FreeBSD,
39
+ PoiseBuildEssential::BuildEssentialProviders::MacOSX,
40
+ PoiseBuildEssential::BuildEssentialProviders::OmniOS,
41
+ PoiseBuildEssential::BuildEssentialProviders::RHEL,
42
+ PoiseBuildEssential::BuildEssentialProviders::SmartOS,
43
+ PoiseBuildEssential::BuildEssentialProviders::Solaris,
44
+ PoiseBuildEssential::BuildEssentialProviders::SUSE,
45
+ # PoiseBuildEssential::BuildEssentialProviders::Windows,
46
+ PoiseBuildEssential::BuildEssentialProviders::Base,
47
+ ])
48
+ end
49
+ end
@@ -0,0 +1,103 @@
1
+ #
2
+ # Copyright 2017, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'chef/provider'
18
+ require 'poise'
19
+
20
+
21
+ module PoiseBuildEssential
22
+ module BuildEssentialProviders
23
+ # The provider base class for `poise_build_essential`.
24
+ #
25
+ # @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
26
+ # @provides poise_build_essential
27
+ class Base < Chef::Provider
28
+ include Poise
29
+ provides(:poise_build_essential)
30
+
31
+ # The `install` action for the `poise_build_essential` resource.
32
+ #
33
+ # @return [void]
34
+ def action_install
35
+ notifying_block do
36
+ install_build_essential
37
+ end
38
+ end
39
+
40
+ # The `upgrade` action for the `poise_build_essential` resource.
41
+ #
42
+ # @return [void]
43
+ def action_upgrade
44
+ notifying_block do
45
+ upgrade_build_essential
46
+ end
47
+ end
48
+
49
+ # The `remove` action for the `poise_build_essential` resource.
50
+ #
51
+ # @return [void]
52
+ def action_remove
53
+ notifying_block do
54
+ remove_build_essential
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ # Install C compiler and build tools. Must be implemented by subclasses.
61
+ #
62
+ # @abstract
63
+ def install_build_essential
64
+ unsupported_platform("Unknown platform for poise_build_eseential: #{node['platform']} (#{node['platform_family']})")
65
+ # Return an array so upgrade/remove also work.
66
+ []
67
+ end
68
+
69
+ # Upgrade C compiler and build tools. Must be implemented by subclasses.
70
+ #
71
+ # @abstract
72
+ def upgrade_build_essential
73
+ install_build_essential.tap do |installed|
74
+ Array(installed).each {|r| r.action(:upgrade) }
75
+ end
76
+ end
77
+
78
+ # Uninstall C compiler and build tools. Must be implemented by subclasses.
79
+ #
80
+ # @abstract
81
+ def remove_build_essential
82
+ install_build_essential.tap do |installed|
83
+ Array(installed).each {|r| r.action(:remove) }
84
+ end
85
+ end
86
+
87
+ # Helper method for either warning about an unsupported platform or raising
88
+ # an exception.
89
+ #
90
+ # @api private
91
+ # @param msg [String] Error message to display.
92
+ # @return [void]
93
+ def unsupported_platform(msg)
94
+ if new_resource.allow_unsupported_platform
95
+ Chef::Log.warn(msg)
96
+ else
97
+ raise RuntimeError.new(msg)
98
+ end
99
+ end
100
+
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # Copyright 2008-2017, Chef Software, Inc.
3
+ # Copyright 2017, Noah Kantrowitz
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'poise_build_essential/build_essential_providers/base'
19
+
20
+
21
+ module PoiseBuildEssential
22
+ module BuildEssentialProviders
23
+ # A provider for `poise_build_essential` to install on Debian platforms.
24
+ #
25
+ # @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
26
+ # @provides poise_build_essential
27
+ class Debian < Base
28
+ provides(:poise_build_essential, platform_family: 'debian')
29
+
30
+ private
31
+
32
+ # (see Base#install_build_essential)
33
+ def install_build_essential
34
+ package %w{autoconf binutils-doc bison build-essential flex gettext ncurses-dev}
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
41
+
@@ -0,0 +1,46 @@
1
+ #
2
+ # Copyright 2008-2017, Chef Software, Inc.
3
+ # Copyright 2017, Noah Kantrowitz
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'poise_build_essential/build_essential_providers/base'
19
+
20
+
21
+ module PoiseBuildEssential
22
+ module BuildEssentialProviders
23
+ # A provider for `poise_build_essential` to install on FreeBSD platforms.
24
+ #
25
+ # @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
26
+ # @provides poise_build_essential
27
+ class FreeBSD < Base
28
+ provides(:poise_build_essential, platform_family: 'freebsd')
29
+
30
+ private
31
+
32
+ # (see Base#install_build_essential)
33
+ def install_build_essential
34
+ pkgs = %w{devel/gmake devel/autoconf devel/m4 devel/gettext}
35
+ # Only install gcc on freebsd 9.x - 10 uses clang.
36
+ if node['platform_version'].to_i <= 9
37
+ pkgs << 'lang/gcc49'
38
+ end
39
+ pkgs.map {|name| package name }
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+
46
+
@@ -0,0 +1,66 @@
1
+ #
2
+ # Copyright 2008-2017, Chef Software, Inc.
3
+ # Copyright 2017, Noah Kantrowitz
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'poise_build_essential/build_essential_providers/base'
19
+
20
+
21
+ module PoiseBuildEssential
22
+ module BuildEssentialProviders
23
+ # A provider for `poise_build_essential` to install on macOS platforms.
24
+ #
25
+ # @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
26
+ # @provides poise_build_essential
27
+ class MacOSX < Base
28
+ provides(:poise_build_essential, platform_family: 'mac_os_x')
29
+
30
+ private
31
+
32
+ # (see Base#install_build_essential)
33
+ def install_build_essential
34
+ # This script was graciously borrowed and modified from Tim Sutton's
35
+ # osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh
36
+ execute 'install XCode Command Line tools' do
37
+ command <<-EOH
38
+ # create the placeholder file that's checked by CLI updates' .dist code
39
+ # in Apple's SUS catalog
40
+ touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
41
+ # find the CLI Tools update
42
+ PROD=$(softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n')
43
+ # install it
44
+ softwareupdate -i "$PROD" --verbose
45
+ # Remove the placeholder to prevent perpetual appearance in the update utility
46
+ rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
47
+ EOH
48
+ not_if 'pkgutil --pkgs=com.apple.pkg.CLTools_Executables'
49
+ end
50
+ end
51
+
52
+ # (see Base#upgrade_build_essential)
53
+ def upgrade_build_essential
54
+ # Make upgrade the same as install on Mac.
55
+ install_build_essential
56
+ end
57
+
58
+ # (see Base#remove_build_essential)
59
+ def remove_build_essential
60
+ # Not sure how to do this, ignoring for now.
61
+ raise NotImplementedError
62
+ end
63
+
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Copyright 2008-2017, Chef Software, Inc.
3
+ # Copyright 2017, Noah Kantrowitz
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'poise_build_essential/build_essential_providers/base'
19
+
20
+
21
+ module PoiseBuildEssential
22
+ module BuildEssentialProviders
23
+ # A provider for `poise_build_essential` to install on OmniOS platforms.
24
+ #
25
+ # @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
26
+ # @provides poise_build_essential
27
+ class OmniOS < Base
28
+ provides(:poise_build_essential, platform_family: 'omnios')
29
+
30
+ private
31
+
32
+ # (see Base#install_build_essential)
33
+ def install_build_essential
34
+ # Per OmniOS documentation, the gcc bin dir isn't in the default
35
+ # $PATH, so add it to the running process environment.
36
+ # http://omnios.omniti.com/wiki.php/DevEnv
37
+ ENV['PATH'] = "#{ENV['PATH']}:/opt/gcc-4.7.2/bin"
38
+
39
+ %w{developer/gcc48 developer/object-file developer/linker
40
+ developer/library/lint developer/build/gnu-make system/header
41
+ system/library/math/header-math}.map {|name| package name }
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Copyright 2008-2017, Chef Software, Inc.
3
+ # Copyright 2017, Noah Kantrowitz
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'poise_build_essential/build_essential_providers/base'
19
+
20
+
21
+ module PoiseBuildEssential
22
+ module BuildEssentialProviders
23
+ # A provider for `poise_build_essential` to install on RedHat and Fedora platforms.
24
+ #
25
+ # @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
26
+ # @provides poise_build_essential
27
+ class RHEL < Base
28
+ provides(:poise_build_essential, platform_family: %w{rhel fedora})
29
+
30
+ private
31
+
32
+ # (see Base#install_build_essential)
33
+ def install_build_essential
34
+ pkgs = %w{autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch}
35
+ # Ensure GCC 4 is available on older pre-6 EL
36
+ if node['platform_family'] == 'rhel' && node['platform_version'].to_i < 6
37
+ pkgs += %w{gcc44 gcc44-c++}
38
+ end
39
+ package pkgs
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+
46
+