diff --git a/Gemfile b/Gemfile index 66ec1290..687ea4f5 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ gem "rest-client" gem 'rake' gem 'redis' gem 'mixlib-versioning', '~> 1.1.0' -gem 'mixlib-install' +gem 'mixlib-install', '>= 3.11.23' gem 'trashed' group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 54447c2b..ddab2a63 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,7 +98,7 @@ PLATFORMS DEPENDENCIES colorize json - mixlib-install + mixlib-install (>= 3.11.23) mixlib-versioning (~> 1.1.0) pry-byebug rack-test diff --git a/app.rb b/app.rb index 4d94b7df..1b999fa3 100644 --- a/app.rb +++ b/app.rb @@ -32,6 +32,7 @@ require 'chef/version' require 'platform_dsl' +require 'dist' require 'mixlib/versioning' require 'mixlib/install' @@ -114,14 +115,16 @@ class InvalidChannelName < StandardError; end end end - get '/chef/install.msi' do + client = OmnitruckDist::CLIENT_NAME + + get "/#{client}/install.msi" do # default to 32-bit architecture for now - redirect to('/stable/chef/download?p=windows&pv=2008r2&m=i386') + redirect to("/stable/#{client}/download?p=windows&pv=2008r2&m=i386") end get '/install.msi' do # default to 32-bit architecture for now - redirect to('/stable/chef/download?p=windows&pv=2008r2&m=i386') + redirect to("/stable/#{client}/download?p=windows&pv=2008r2&m=i386") end get "/full_:project\\_list" do @@ -258,7 +261,7 @@ class InvalidChannelName < StandardError; end content_type :json JSON.pretty_generate({ - :timestamp => cache.last_modified_for('chef', 'stable') + :timestamp => cache.last_modified_for(client, 'stable') }) end @@ -385,16 +388,7 @@ def get_package_info # Here we map specific project versions that started building # native SLES packages. This is used to determine which projects # need to be remapped to EL before a certain version. - native_sles_project_version = { - "automate" => "0.8.5", - "chef" => "12.21.1", - "angrychef" => "12.21.1", - "chef-server" => "12.14.0", - "chefdk" => "1.3.43", - "inspec" => "1.20.0", - "angry-omnibus-toolchain" => "1.1.66", - "omnibus-toolchain" => "1.1.66", - } + native_sles_project_version = OmnitruckDist::SLES_PROJECT_VERSIONS # Locate native sles version for project if it exists sles_project_version = native_sles_project_version[current_project] diff --git a/lib/chef/cache.rb b/lib/chef/cache.rb index 50bc0c75..a1fe3e80 100644 --- a/lib/chef/cache.rb +++ b/lib/chef/cache.rb @@ -16,7 +16,9 @@ require "redis" require "chef/project_manifest" +require "mixlib/install/dist" require "mixlib/install/product" +require "mixlib/install/product_matrix" class Chef class Cache diff --git a/lib/chef/project_manifest.rb b/lib/chef/project_manifest.rb index 062ab552..1d88bc31 100644 --- a/lib/chef/project_manifest.rb +++ b/lib/chef/project_manifest.rb @@ -1,5 +1,6 @@ require 'yajl' require "mixlib/install" +require "mixlib/install/dist" require "mixlib/install/options" require "mixlib/install/backend/package_router" require 'chef/version' diff --git a/lib/chef/version_resolver.rb b/lib/chef/version_resolver.rb index 05b66f33..03e5bcef 100644 --- a/lib/chef/version_resolver.rb +++ b/lib/chef/version_resolver.rb @@ -1,5 +1,6 @@ require 'chef/version' require 'platform_dsl' +require 'dist' class Chef class VersionResolver @@ -40,7 +41,7 @@ def package_info(platform_string, platform_version_string, machine_string) version = find_target_version_in(version_metadata) if version.nil? - raise InvalidDownloadPath, "Cannot find a valid chef version that matches version constraints: #{friendly_error_msg}" + raise InvalidDownloadPath, "Cannot find a valid #{OmnitruckDist::CLIENT_NAME} version that matches version constraints: #{friendly_error_msg}" end version @@ -107,7 +108,7 @@ def find_raw_metadata_for(target_platform, target_architecture) # first make sure we have some builds available for the given platform if !build_map[core_platform] - raise InvalidDownloadPath, "Cannot find any chef versions for core platform #{core_platform}: #{friendly_error_msg}" + raise InvalidDownloadPath, "Cannot find any #{OmnitruckDist::CLIENT_NAME} versions for core platform #{core_platform}: #{friendly_error_msg}" end # get all the available distro versions @@ -118,13 +119,13 @@ def find_raw_metadata_for(target_platform, target_architecture) distro_versions_available.select! {|v| dsl.new_platform_version(core_platform, v, target_architecture) <= target_platform } if distro_versions_available.length == 0 - raise InvalidDownloadPath, "Cannot find any available chef versions for this platform version #{target_platform.mapped_name} #{target_platform.mapped_version}: #{friendly_error_msg}" + raise InvalidDownloadPath, "Cannot find any available #{OmnitruckDist::CLIENT_NAME} versions for this platform version #{target_platform.mapped_name} #{target_platform.mapped_version}: #{friendly_error_msg}" end # sort the available distro versions from earlier to later: 10.04 then 10.10 etc. distro_versions_available.sort! {|v1,v2| dsl.new_platform_version(core_platform, v1, target_architecture) <=> dsl.new_platform_version(core_platform, v2, target_architecture) } - if project == "chef" + if project == OmnitruckDist::CLIENT_NAME # Windows has the requirement that we not return x86_64 packages from the # stable channel until Chef 12.9+. See the description in project_cache.rb # for more detail. diff --git a/lib/dist.rb b/lib/dist.rb new file mode 100644 index 00000000..8bc47382 --- /dev/null +++ b/lib/dist.rb @@ -0,0 +1,18 @@ +module OmnitruckDist + # This class is not fully implemented, depending it is not recommended! + # Client name + CLIENT_NAME = "chef".freeze + # Here we map specific project versions that started building + # native SLES packages. This is used to determine which projects + # need to be remapped to EL before a certain version. + SLES_PROJECT_VERSIONS = { + "automate" => "0.8.5", + "chef" => "12.21.1", + "angrychef" => "12.21.1", + "chef-server" => "12.14.0", + "chefdk" => "1.3.43", + "inspec" => "1.20.0", + "angry-omnibus-toolchain" => "1.1.66", + "omnibus-toolchain" => "1.1.66", + }.freeze +end