From e8cbd17f40efad105d2af3f9d14779ab1a0dcf2c Mon Sep 17 00:00:00 2001 From: Tensibai Zhaoying Date: Mon, 28 Sep 2020 14:54:16 +0000 Subject: [PATCH] Add linux path, variabilize script_generator and install Signed-off-by: Tensibai Zhaoying --- lib/mixlib/install.rb | 5 +++-- lib/mixlib/install/dist.rb | 2 ++ lib/mixlib/install/script_generator.rb | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/mixlib/install.rb b/lib/mixlib/install.rb index fbb21933..12be49db 100644 --- a/lib/mixlib/install.rb +++ b/lib/mixlib/install.rb @@ -25,6 +25,7 @@ require_relative "install/generator" require_relative "install/generator/bourne" require_relative "install/generator/powershell" +require_relative "install/dist" module Mixlib class Install @@ -119,7 +120,7 @@ def root # This only works for chef and chefdk but they are the only projects # we are supporting as of now. if options.for_ps1? - "$env:systemdrive\\opscode\\#{options.product_name}" + "$env:systemdrive\\#{Mixlib::Install::Dist::WINDOWS_INSTALL_DIR}\\#{options.product_name}" else "/opt/#{options.product_name}" end @@ -136,7 +137,7 @@ def current_version # 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" + "$env:systemdrive\\#{Mixlib::Install::Dist::WINDOWS_INSTALL_DIR}\\#{options.product_name}\\version-manifest.json" else "/opt/#{options.product_name}/version-manifest.json" end diff --git a/lib/mixlib/install/dist.rb b/lib/mixlib/install/dist.rb index 221ae4cb..57916a24 100644 --- a/lib/mixlib/install/dist.rb +++ b/lib/mixlib/install/dist.rb @@ -24,6 +24,8 @@ class Dist MACOS_VOLUME = "chef_software".freeze # Windows install directory name WINDOWS_INSTALL_DIR = "opscode".freeze + # Linux install directory name + LINUX_INSTALL_DIR = "/opt" end end end diff --git a/lib/mixlib/install/script_generator.rb b/lib/mixlib/install/script_generator.rb index 7acd71f3..567ba992 100644 --- a/lib/mixlib/install/script_generator.rb +++ b/lib/mixlib/install/script_generator.rb @@ -19,6 +19,7 @@ require_relative "util" require_relative "generator/powershell" +require_relative "dist" require "cgi" module Mixlib @@ -83,9 +84,9 @@ def initialize(version, powershell = false, opts = {}) @sudo_command = "sudo -E" @root = if powershell - "$env:systemdrive\\opscode\\chef" + "$env:systemdrive\\#{Mixlib::Install::Dist::WINDOWS_INSTALL_DIR}\\#{Mixlib::Install::Dist::DEFAULT_PRODUCT}" else - "/opt/chef" + "#{Mixlib::Install::Dist::LINUX_INSTALL_DIR}/#{Mixlib::Install::Dist::DEFAULT_PRODUCT}" end parse_opts(opts)