Skip to content

Commit

Permalink
Community distribution fixes
Browse files Browse the repository at this point in the history
This applies some fixes which were introduced in [1] that help support community
distributions better. Some other fixes include:

- Ensure we pull in mixlib-install >= 3.11.23 which includes the patches
  introduced in [1]
- Create dist.rb file for renaming chef to something else and also set the SLES
  project versions to other names

[1] chef/mixlib-install#292

Signed-off-by: Lance Albertson <lance@osuosl.org>
  • Loading branch information
ramereth committed Mar 14, 2020
1 parent 92b38cc commit 02b2eb7
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ PLATFORMS
DEPENDENCIES
colorize
json
mixlib-install
mixlib-install (>= 3.11.23)
mixlib-versioning (~> 1.1.0)
pry-byebug
rack-test
Expand Down
22 changes: 8 additions & 14 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

require 'chef/version'
require 'platform_dsl'
require 'dist'
require 'mixlib/versioning'
require 'mixlib/install'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions lib/chef/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/chef/project_manifest.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
9 changes: 5 additions & 4 deletions lib/chef/version_resolver.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'chef/version'
require 'platform_dsl'
require 'dist'

class Chef
class VersionResolver
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions lib/dist.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 02b2eb7

Please sign in to comment.