diff --git a/habitat/plan.sh b/habitat/plan.sh new file mode 100644 index 00000000..35192cdc --- /dev/null +++ b/habitat/plan.sh @@ -0,0 +1,58 @@ +pkg_name=chef-cli +pkg_origin=chef +pkg_version="5.6.14" +ruby_pkg="core/ruby31" +pkg_deps=(${ruby_pkg} core/coreutils) +pkg_build_deps=( + core/make + core/sed + core/gcc + core/libarchive + ) +pkg_bin_dirs=(bin) +do_setup_environment() { + build_line 'Setting GEM_HOME="$pkg_prefix/lib"' + export GEM_HOME="$pkg_prefix/lib" + + build_line "Setting GEM_PATH=$GEM_HOME" + export GEM_PATH="$GEM_HOME" +} +do_unpack() { + mkdir -pv "$HAB_CACHE_SRC_PATH/$pkg_dirname" + cp -RT "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" +} +do_build() { + pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/" + gem build chef-cli.gemspec + popd +} +do_install() { + pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/" + gem install chef-cli-*.gem --no-document + popd + wrap_ruby_bin +} +wrap_ruby_bin() { + local bin="$pkg_prefix/bin/$pkg_name" + local real_bin="$GEM_HOME/gems/chef-cli-${pkg_version}/bin/chef-cli" + build_line "Adding wrapper $bin to $real_bin" + cat < "$bin" +#!$(pkg_path_for core/bash)/bin/bash +set -e + +# Set binary path that allows InSpec to use non-Hab pkg binaries +export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH" + +# Set Ruby paths defined from 'do_setup_environment()' +export GEM_HOME="$GEM_HOME" +export GEM_PATH="$GEM_PATH" + +exec $(pkg_path_for core/ruby31)/bin/ruby $real_bin \$@ +EOF + chmod -v 755 "$bin" +} + + +do_strip() { + return 0 +} \ No newline at end of file