Skip to content

Commit

Permalink
Added plan.sh file
Browse files Browse the repository at this point in the history
Signed-off-by: nitin sanghi <[email protected]>
  • Loading branch information
sanghinitin committed Aug 29, 2024
1 parent 73eed54 commit 6f738ca
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF > "$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
}

0 comments on commit 6f738ca

Please sign in to comment.