2016-10-11 21:07:44 +00:00
|
|
|
pkg_name=inspec
|
|
|
|
pkg_origin=chef
|
2017-11-14 04:01:51 +00:00
|
|
|
pkg_version=$(cat "$PLAN_CONTEXT/../VERSION")
|
2016-10-11 21:07:44 +00:00
|
|
|
pkg_description="InSpec is an open-source testing framework for infrastructure
|
|
|
|
with a human- and machine-readable language for specifying compliance,
|
|
|
|
security and policy requirements."
|
2017-05-17 05:19:14 +00:00
|
|
|
pkg_upstream_url=https://www.inspec.io/
|
2016-10-11 21:07:44 +00:00
|
|
|
pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>"
|
|
|
|
pkg_license=('Apache-2.0')
|
|
|
|
pkg_deps=(
|
|
|
|
core/coreutils
|
2018-05-10 18:49:44 +00:00
|
|
|
core/git
|
2022-02-23 23:51:38 +00:00
|
|
|
core/ruby27
|
2018-12-20 18:29:51 +00:00
|
|
|
core/bash
|
2016-10-11 21:07:44 +00:00
|
|
|
)
|
|
|
|
pkg_build_deps=(
|
|
|
|
core/gcc
|
|
|
|
core/make
|
|
|
|
core/readline
|
2017-05-17 05:19:14 +00:00
|
|
|
core/sed
|
2016-10-11 21:07:44 +00:00
|
|
|
)
|
|
|
|
pkg_bin_dirs=(bin)
|
|
|
|
|
2018-12-06 15:16:56 +00:00
|
|
|
do_setup_environment() {
|
|
|
|
build_line 'Setting GEM_HOME="$pkg_prefix/lib"'
|
2018-04-27 14:57:13 +00:00
|
|
|
export GEM_HOME="$pkg_prefix/lib"
|
2018-12-06 15:16:56 +00:00
|
|
|
|
|
|
|
build_line "Setting GEM_PATH=$GEM_HOME"
|
2018-04-27 14:57:13 +00:00
|
|
|
export GEM_PATH="$GEM_HOME"
|
2016-10-11 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
2018-04-27 14:57:13 +00:00
|
|
|
do_unpack() {
|
|
|
|
mkdir -pv "$HAB_CACHE_SRC_PATH/$pkg_dirname"
|
2018-07-20 16:59:15 +00:00
|
|
|
cp -RT "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/"
|
2018-04-27 14:57:13 +00:00
|
|
|
}
|
2017-03-21 21:51:59 +00:00
|
|
|
|
2018-04-27 14:57:13 +00:00
|
|
|
do_build() {
|
|
|
|
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/"
|
|
|
|
gem build inspec.gemspec
|
2020-01-30 23:58:27 +00:00
|
|
|
gem build inspec-core.gemspec
|
2018-04-27 14:57:13 +00:00
|
|
|
popd
|
2019-04-26 17:34:08 +00:00
|
|
|
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin"
|
|
|
|
gem build inspec-bin.gemspec
|
|
|
|
popd
|
2018-04-27 14:57:13 +00:00
|
|
|
}
|
2017-03-21 21:51:59 +00:00
|
|
|
|
2018-04-27 14:57:13 +00:00
|
|
|
do_install() {
|
2019-04-26 17:34:08 +00:00
|
|
|
# MUST install inspec first because inspec-bin depends on it via gemspec
|
2018-04-27 14:57:13 +00:00
|
|
|
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/"
|
|
|
|
gem install inspec-*.gem --no-document
|
|
|
|
popd
|
2019-04-26 17:34:08 +00:00
|
|
|
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin"
|
|
|
|
gem install inspec-bin*.gem --no-document
|
|
|
|
popd
|
2017-03-21 21:51:59 +00:00
|
|
|
|
2018-04-27 14:57:13 +00:00
|
|
|
wrap_inspec_bin
|
2019-01-18 16:50:13 +00:00
|
|
|
|
2020-11-05 02:40:45 +00:00
|
|
|
# ed25519 ssh key support done here as its a native gem we can't put in the gemspec
|
|
|
|
# for omnibus we also install this as part of the package
|
|
|
|
gem install ed25519 bcrypt_pbkdf --no-document
|
|
|
|
|
2019-01-18 16:50:13 +00:00
|
|
|
# Certain gems (timeliness) are getting installed with world writable files
|
|
|
|
# This is removing write bits for group and other.
|
|
|
|
find "$GEM_HOME" -xdev -perm -0002 -type f -print 2>/dev/null | xargs -I '{}' chmod go-w '{}'
|
2017-05-17 05:19:14 +00:00
|
|
|
}
|
|
|
|
|
2018-12-06 15:16:56 +00:00
|
|
|
# Need to wrap the InSpec binary to ensure paths are correct
|
2018-04-27 14:57:13 +00:00
|
|
|
wrap_inspec_bin() {
|
|
|
|
local bin="$pkg_prefix/bin/$pkg_name"
|
2019-04-26 17:34:08 +00:00
|
|
|
local real_bin="$GEM_HOME/gems/inspec-bin-${pkg_version}/bin/inspec"
|
2018-04-27 14:57:13 +00:00
|
|
|
build_line "Adding wrapper $bin to $real_bin"
|
|
|
|
cat <<EOF > "$bin"
|
2018-12-20 18:29:51 +00:00
|
|
|
#!$(pkg_path_for core/bash)/bin/bash
|
2018-04-27 14:57:13 +00:00
|
|
|
set -e
|
2018-12-06 15:16:56 +00:00
|
|
|
|
|
|
|
# Set binary path that allows InSpec to use non-Hab pkg binaries
|
2020-07-17 10:05:35 +00:00
|
|
|
export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH"
|
2018-12-06 15:16:56 +00:00
|
|
|
|
|
|
|
# Set Ruby paths defined from 'do_setup_environment()'
|
2018-04-27 14:57:13 +00:00
|
|
|
export GEM_HOME="$GEM_HOME"
|
|
|
|
export GEM_PATH="$GEM_PATH"
|
2018-12-06 15:16:56 +00:00
|
|
|
|
2022-02-28 00:29:37 +00:00
|
|
|
exec $(pkg_path_for core/ruby27)/bin/ruby $real_bin \$@
|
2018-04-27 14:57:13 +00:00
|
|
|
EOF
|
|
|
|
chmod -v 755 "$bin"
|
2016-10-11 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
2017-05-17 05:19:14 +00:00
|
|
|
do_strip() {
|
|
|
|
return 0
|
2016-10-11 21:07:44 +00:00
|
|
|
}
|