Skip to content

Commit

Permalink
cinc-auditor hab plan
Browse files Browse the repository at this point in the history
Signed-off-by: Tensibai Zhaoying <[email protected]>
  • Loading branch information
Tensibai authored and ramereth committed May 12, 2021
1 parent 72fdca7 commit ab107fb
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
pkg_name=inspec
pkg_origin=chef
pkg_name=cinc-auditor
pkg_origin=cinc
pkg_version=$(cat "$PLAN_CONTEXT/../VERSION")
pkg_description="InSpec is an open-source testing framework for infrastructure
pkg_description="Cinc Auditor is the Community build of Inspec by Chef.
Inspec is an open-source testing framework for infrastructure
with a human- and machine-readable language for specifying compliance,
security and policy requirements."
pkg_upstream_url=https://www.inspec.io/
pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>"
pkg_upstream_url=https://www.cinc.sh
pkg_maintainer="The Cinc Maintainers <maintainers@cinc.sh>"
pkg_license=('Apache-2.0')
pkg_deps=(
core/coreutils
Expand Down Expand Up @@ -40,7 +41,7 @@ do_build() {
gem build inspec-core.gemspec
popd
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin"
gem build inspec-bin.gemspec
gem build cinc-auditor-bin.gemspec
popd
}

Expand All @@ -50,7 +51,7 @@ do_install() {
gem install inspec-*.gem --no-document
popd
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin"
gem install inspec-bin*.gem --no-document
gem install cinc-auditor-bin*.gem --no-document
popd

wrap_inspec_bin
Expand All @@ -67,7 +68,7 @@ do_install() {
# Need to wrap the InSpec binary to ensure paths are correct
wrap_inspec_bin() {
local bin="$pkg_prefix/bin/$pkg_name"
local real_bin="$GEM_HOME/gems/inspec-bin-${pkg_version}/bin/inspec"
local real_bin="$GEM_HOME/gems/cinc-auditor-bin-${pkg_version}/bin/cinc-auditor"
build_line "Adding wrapper $bin to $real_bin"
cat <<EOF > "$bin"
#!$(pkg_path_for core/bash)/bin/bash
Expand All @@ -82,7 +83,14 @@ export GEM_PATH="$GEM_PATH"
exec $(pkg_path_for core/ruby26)/bin/ruby $real_bin \$@
EOF
chmod -v 755 "$bin"
cat <<EOF > "$pkg_prefix/bin/cinc-auditor-wrapper"
#!$(pkg_path_for core/bash)/bin/bash
echo "Redirecting to cinc-auditor..."
exec $pkg_prefix/bin/cinc-auditor $@
EOF
ln -s "$pkg_prefix/bin/cinc-auditor-wrapper" "$pkg_prefix/bin/inspec"
chmod -v 755 "$bin" "$pkg_prefix/bin/cinc-auditor-wrapper" "$pkg_prefix/bin/inspec"
}

do_strip() {
Expand Down

0 comments on commit ab107fb

Please sign in to comment.