A library for interacting with Chef Software Inc's software distribution systems.
Ruby Shell PowerShell HTML HCL
Latest commit c176c75 Dec 6, 2016 @wrightp wrightp v2.1.9
Signed-off-by: Patrick Wright <patrick@chef.io>
Permalink
Failed to load latest commit information.
acceptance
bin Add mixlib-install executable and functional tests Oct 8, 2016
ci
lib/mixlib v2.1.9 Dec 6, 2016
spec
support COOL-629 Honor -download_directory flag in ScriptGenerator Dec 6, 2016
.gitattributes add gitattributes file to force lf line endings on checkout Sep 20, 2016
.gitignore
.rspec
.travis.yml Simplify Travis CI configuration Nov 3, 2016
CHANGELOG.html v2.1.7 Nov 18, 2016
CHANGELOG.md v2.1.9 Dec 6, 2016
CONTRIBUTING.md
Gemfile add env var that forces artifactory as the backend for all channels Jun 30, 2016
LICENSE Add licensing details Jul 14, 2015
PRODUCT_MATRIX.md Update matrix to include harmony test project Oct 3, 2016
README.md
Rakefile
mixlib-install.gemspec

README.md

Build Status

Mixlib::Install

Command Line Usage

$ gem install mixlib-install
# Download latest stable chef for current platform
$ mixlib-install download chef

Run $ mixlib-install help for additional commands and options.

API Usage

Get URL for specific platform and package version

require 'mixlib/install'

options = {
  channel: :current,
  product_name: 'chef',
  product_version: :latest,
  platform: 'mac_os_x',
  platform_version: '10.9',
  architecture: 'x86_64'
}

artifact = Mixlib::Install.new(options).artifact_info
# => #<Mixlib::Install::ArtifactInfo>

artifact.url
# => "https://packages.chef.io/files/current/chef/12.14.90/mac_os_x/10.9/chef-12.14.90-1.dmg"

Get list of artifacts for all platforms given a package version

options = {
  channel: :current,
  product_name: 'chef'
}
# product_version: :latest is the default

artifacts = Mixlib::Install.new(options).artifact_info
# => [#<Mixlib::Install::ArtifactInfo>, ...]

artifacts.first.url
# => => "https://packages.chef.io/files/current/chef/12.14.90/mac_os_x/10.11/chef-12.14.90-1.dmg"

Detect platform information

options = {
  channel: :current,
  product_name: 'chef',
  product_version: :latest
}

artifact = Mixlib::Install.new(options).detect_platform

artifact.platform # => "mac_os_x"
artifact.platform_version # => "10.10"

Use an artifact released for an earlier version of the platform

options = {
  channel: :current,
  product_name: 'chef',
  product_version: :latest,
  platform: 'ubuntu',
  platform_version: '15.04',
  architecture: 'x86_64',
  platform_version_compatibility_mode: true
}

artifact = Mixlib::Install.new(options).artifact_info

artifact.platform # => "ubuntu"
artifact.platform_version # => "14.04"

List the available versions for a product and channel

Instance method

options = {
  channel: :stable,
  product_name: 'chef',
}

Mixlib::Install.new(options).available_versions

# => ["12.13.3", "12.13.7"]

Class method

Mixlib::Install.available_versions("chef", "stable")

# => ["12.13.3", "12.13.7"]

User-Agent Request Headers

By default, all requests made by mixlib-install will include a User-Agent request header as mixlib-install/<version>. Additional User-Agent request headers can be added by setting the user_agent_headers option. When you want to identify a product using mixlib-install as a dependency we recommend the format product/version.

options = {
  channel: :stable,
  product_name: 'chef',
  user_agent_headers: ["my_product/1.2.3", "somethingelse"],
}

Collecting Software Dependencies and License Content

Collecting software dependencies and license content for ArtifactInfo instances requires additional requests to the repository server. By default, collection is disabled. To return data for instance methods software_dependencies and license_content, the include_metadata option must be enabled.

options = {
  channel: :current,
  product_name: 'chef',
  product_version: :latest,
  platform: 'mac_os_x',
  platform_version: '10.9',
  architecture: 'x86_64',
  include_metadata: true,
}

artifact = Mixlib::Install.new(options).artifact_info

artifact.license_content.class
# => String
artifact.software_dependencies.class
# => Hash

# By default, the instance methods return nil

Development

VCR is a tool that helps cache and replay http responses. When these responses change or when you add more tests you might need to update cached responses. Check out spec_helper.rb for instructions on how to do this.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/mixlib-install/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request