Class: Mixlib::Install
- Inherits:
-
Object
- Object
- Mixlib::Install
- Defined in:
- lib/mixlib/install.rb,
lib/mixlib/install/util.rb,
lib/mixlib/install/backend.rb,
lib/mixlib/install/options.rb,
lib/mixlib/install/product.rb,
lib/mixlib/install/version.rb,
lib/mixlib/install/generator.rb,
lib/mixlib/install/backend/base.rb,
lib/mixlib/install/artifact_info.rb,
lib/mixlib/install/generator/base.rb,
lib/mixlib/install/backend/bintray.rb,
lib/mixlib/install/generator/bourne.rb,
lib/mixlib/install/script_generator.rb,
lib/mixlib/install/backend/omnitruck.rb,
lib/mixlib/install/backend/artifactory.rb,
lib/mixlib/install/generator/powershell.rb
Defined Under Namespace
Classes: ArtifactInfo, Backend, Generator, Options, Product, ProductMatrix, ScriptGenerator, Util
Constant Summary collapse
- VERSION =
"1.2.2"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.detect_platform ⇒ Object
Returns a Hash containing the platform info options.
-
.detect_platform_ps1 ⇒ Object
Returns the platform_detection.ps1 script.
-
.detect_platform_sh ⇒ Object
Returns the platform_detection.sh script.
-
.install_ps1(context = {}) ⇒ Object
Returns the install.ps1 script Supported context parameters: —————— base_url [String] url pointing to the omnitruck to be queried by the script.
-
.install_sh(context = {}) ⇒ Object
Returns the install.sh script Supported context parameters: —————— base_url [String] url pointing to the omnitruck to be queried by the script.
-
.unified_backend? ⇒ Boolean
Returns if unified_backend feature flag for mixlib-install is enabled.
Instance Method Summary collapse
-
#artifact_info ⇒ Array<ArtifactInfo>, ArtifactInfo
Fetch artifact metadata information.
-
#available_versions ⇒ Array<String>
List available versions.
-
#current_version ⇒ Object
Returns the current version of the installed product.
-
#detect_platform ⇒ Object
Automatically set the platform options.
-
#initialize(options = {}) ⇒ Install
constructor
A new instance of Install.
-
#install_command ⇒ String
Returns an install script for the given options.
-
#root ⇒ String
Returns the base installation directory for the given options.
-
#upgrade_available? ⇒ Boolean
Returns true if an upgradable version is available, false otherwise.
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
32 33 34 |
# File 'lib/mixlib/install.rb', line 32 def @options end |
Class Method Details
.detect_platform ⇒ Object
Returns a Hash containing the platform info options
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/mixlib/install.rb', line 127 def self.detect_platform output = if Gem.win_platform? # For Windows we write the detect platform script and execute the # powershell.exe program with Mixlib::ShellOut Dir.mktmpdir do |d| File.open(File.join(d, "detect_platform.ps1"), "w+") do |f| f.puts self.detect_platform_ps1 end Mixlib::ShellOut.new("powershell.exe -file #{File.join(d, "detect_platform.ps1")}").run_command end else Mixlib::ShellOut.new(self.detect_platform_sh).run_command end platform_info = output.stdout.split { platform: platform_info[0], platform_version: platform_info[1], architecture: platform_info[2], } end |
.detect_platform_ps1 ⇒ Object
Returns the platform_detection.ps1 script
161 162 163 |
# File 'lib/mixlib/install.rb', line 161 def self.detect_platform_ps1 Mixlib::Install::Generator::PowerShell.detect_platform_ps1 end |
.detect_platform_sh ⇒ Object
Returns the platform_detection.sh script
154 155 156 |
# File 'lib/mixlib/install.rb', line 154 def self.detect_platform_sh Mixlib::Install::Generator::Bourne.detect_platform_sh end |
.install_ps1(context = {}) ⇒ Object
Returns the install.ps1 script Supported context parameters:
base_url [String]
url pointing to the omnitruck to be queried by the script.
183 184 185 |
# File 'lib/mixlib/install.rb', line 183 def self.install_ps1(context = {}) Mixlib::Install::Generator::PowerShell.install_ps1(context) end |
.install_sh(context = {}) ⇒ Object
Returns the install.sh script Supported context parameters:
base_url [String]
url pointing to the omnitruck to be queried by the script.
172 173 174 |
# File 'lib/mixlib/install.rb', line 172 def self.install_sh(context = {}) Mixlib::Install::Generator::Bourne.install_sh(context) end |
.unified_backend? ⇒ Boolean
Returns if unified_backend feature flag for mixlib-install is enabled
191 192 193 |
# File 'lib/mixlib/install.rb', line 191 def self.unified_backend? !ENV["MIXLIB_INSTALL_UNIFIED_BACKEND"].nil? end |
Instance Method Details
#artifact_info ⇒ Array<ArtifactInfo>, ArtifactInfo
Fetch artifact metadata information
channel, product name, and product version. channel, product name, product version and platform info
45 46 47 |
# File 'lib/mixlib/install.rb', line 45 def artifact_info Backend.info() end |
#available_versions ⇒ Array<String>
List available versions
product_name and channel.
54 55 56 |
# File 'lib/mixlib/install.rb', line 54 def available_versions Backend.available_versions() end |
#current_version ⇒ Object
Returns the current version of the installed product. Returns nil if the product is not installed.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/mixlib/install.rb', line 86 def current_version # Note that this logic does not work for products other than # chef & chefdk since version-manifest is created under the # install directory which can be different than the product name (e.g. # chef-server -> /opt/opscode). But this is OK for now since # chef & chefdk are the only supported products. version_manifest_file = if .for_ps1? "$env:systemdrive\\opscode\\#{.product_name}\\version-manifest.json" else "/opt/#{.product_name}/version-manifest.json" end if File.exist? version_manifest_file JSON.parse(File.read(version_manifest_file))["build_version"] end end |
#detect_platform ⇒ Object
Automatically set the platform options
119 120 121 122 |
# File 'lib/mixlib/install.rb', line 119 def detect_platform .set_platform_info(self.class.detect_platform) self end |
#install_command ⇒ String
Returns an install script for the given options
63 64 65 |
# File 'lib/mixlib/install.rb', line 63 def install_command Generator.install_command() end |
#root ⇒ String
Returns the base installation directory for the given options
72 73 74 75 76 77 78 79 80 |
# File 'lib/mixlib/install.rb', line 72 def root # This only works for chef and chefdk but they are the only projects # we are supporting as of now. if .for_ps1? "$env:systemdrive\\opscode\\#{.product_name}" else "/opt/#{.product_name}" end end |
#upgrade_available? ⇒ Boolean
Returns true if an upgradable version is available, false otherwise.
106 107 108 109 110 111 112 113 114 |
# File 'lib/mixlib/install.rb', line 106 def upgrade_available? return true if current_version.nil? artifact = artifact_info artifact = artifact.first if artifact.is_a? Array available_ver = Mixlib::Versioning.parse(artifact.version) current_ver = Mixlib::Versioning.parse(current_version) (available_ver > current_ver) end |