diff --git a/bin/kitchen_gem b/bin/kitchen_gem new file mode 100644 index 000000000..7bd3d4592 --- /dev/null +++ b/bin/kitchen_gem @@ -0,0 +1,12 @@ +#!/bin/bash + +# expected to be invoked as kitchen install-gem +export GEM_HOME="/hab/kitchen" +env_version=$KITCHEN_VERSION + +if [[ -z "$env_version" ]]; then +# it will install the latest version if a new version installed unless the version env variable was set + hab pkg exec $origin/$package gem install -- $@ +else + hab pkg exec $origin/$package/$env_version gem install -- $@ +fi \ No newline at end of file diff --git a/habitat/plan.sh b/habitat/plan.sh index d74f0cc15..29239fb3a 100644 --- a/habitat/plan.sh +++ b/habitat/plan.sh @@ -36,7 +36,7 @@ do_unpack() { do_build() { echo $(pkg_path_for $_chef_client_ruby) - export GEM_HOME="$pkg_prefix/vendor/gems" + export GEM_HOME="$pkg_prefix/vendor" build_line "Setting GEM_PATH=$GEM_HOME" export GEM_PATH="$GEM_HOME" @@ -50,6 +50,7 @@ do_build() { } do_install() { + mkdir -p /hab/kitchen export GEM_HOME="$pkg_prefix/vendor/gems" build_line "Setting GEM_PATH=$GEM_HOME" @@ -58,7 +59,7 @@ do_install() { gem install chef-cli wrap_ruby_kitchen wrap_ruby_chef_cli - set_runtime_env "GEM_PATH" "${pkg_prefix}/vendor/gems" + set_runtime_env "GEM_PATH" "${pkg_prefix}/vendor/gems;/hab/kitchen" } wrap_ruby_kitchen() { @@ -95,4 +96,4 @@ EOF do_strip() { return 0 -} +} \ No newline at end of file