lib/mixlib/install.rb in mixlib-install-0.8.0.alpha.6 vs lib/mixlib/install.rb in mixlib-install-0.8.0.alpha.7
- old
+ new
@@ -76,14 +76,14 @@
# 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 options.for_ps1?
- "$env:systemdrive\\opscode\\#{options.product_name}\\version-manifest.json"
- else
- "/opt/#{options.product_name}/version-manifest.json"
- end
+ "$env:systemdrive\\opscode\\#{options.product_name}\\version-manifest.json"
+ else
+ "/opt/#{options.product_name}/version-manifest.json"
+ end
if File.exist? version_manifest_file
JSON.parse(File.read(version_manifest_file))["build_version"]
end
end
@@ -95,9 +95,48 @@
return true if current_version.nil?
available_ver = Mixlib::Versioning.parse(artifact_info.first.version)
current_ver = Mixlib::Versioning.parse(current_version)
(available_ver > current_ver)
+ end
+
+ #
+ # Automatically set the platform options
+ #
+ def detect_platform
+ options.set_platform_info(self.class.detect_platform)
+ self
+ end
+
+ #
+ # Returns a Hash containing the platform info options
+ #
+ def self.detect_platform
+ platform_info = if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
+ `#{self.detect_platform_ps1}`.split
+ else
+ `#{self.detect_platform_sh}`.split
+ end
+
+ {
+ platform: platform_info[0],
+ platform_version: platform_info[1],
+ architecture: platform_info[2],
+ }
+ end
+
+ #
+ # Returns the platform_detection.sh script
+ #
+ def self.detect_platform_sh
+ Mixlib::Install::Generator::Bourne.detect_platform_sh
+ end
+
+ #
+ # Returns the platform_detection.ps1 script
+ #
+ def self.detect_platform_ps1
+ Mixlib::Install::Generator::PowerShell.detect_platform_ps1
end
#
# Returns the install.sh script
# Supported context parameters: