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=(
|
2017-05-17 05:19:14 +00:00
|
|
|
core/busybox-static
|
|
|
|
core/cacerts
|
2016-10-11 21:07:44 +00:00
|
|
|
core/coreutils
|
2017-03-21 21:51:59 +00:00
|
|
|
core/libxml2
|
|
|
|
core/libxslt
|
2016-10-11 21:07:44 +00:00
|
|
|
core/net-tools
|
2017-05-17 05:19:14 +00:00
|
|
|
core/ruby
|
2018-04-27 14:57:13 +00:00
|
|
|
|
|
|
|
# Needed for some InSpec resources
|
|
|
|
core/bind
|
|
|
|
core/curl
|
|
|
|
core/docker
|
2018-05-10 18:49:44 +00:00
|
|
|
core/git
|
2018-04-27 14:57:13 +00:00
|
|
|
core/less
|
|
|
|
core/mysql-client
|
|
|
|
core/netcat
|
|
|
|
core/postgresql
|
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)
|
|
|
|
|
2017-11-14 04:01:51 +00:00
|
|
|
do_prepare() {
|
2018-04-27 14:57:13 +00:00
|
|
|
export GEM_HOME="$pkg_prefix/lib"
|
2017-11-14 04:01:51 +00:00
|
|
|
build_line "Setting GEM_HOME=$GEM_HOME"
|
2018-04-27 14:57:13 +00:00
|
|
|
export GEM_PATH="$GEM_HOME"
|
2017-11-14 04:01:51 +00:00
|
|
|
build_line "Setting GEM_PATH=$GEM_PATH"
|
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"
|
|
|
|
cp -R "$PLAN_CONTEXT"/../ "$HAB_CACHE_SRC_PATH/$pkg_dirname"
|
|
|
|
}
|
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
|
|
|
|
popd
|
|
|
|
}
|
2017-03-21 21:51:59 +00:00
|
|
|
|
2018-04-27 14:57:13 +00:00
|
|
|
do_install() {
|
|
|
|
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/"
|
|
|
|
gem install inspec-*.gem --no-document
|
|
|
|
popd
|
2017-03-21 21:51:59 +00:00
|
|
|
|
2018-04-27 14:57:13 +00:00
|
|
|
wrap_inspec_bin
|
2017-05-17 05:19:14 +00:00
|
|
|
}
|
|
|
|
|
2018-04-27 14:57:13 +00:00
|
|
|
# Need to wrap the InSpec binary to ensure GEM_HOME/GEM_PATH is correct
|
|
|
|
wrap_inspec_bin() {
|
|
|
|
local bin="$pkg_prefix/bin/$pkg_name"
|
|
|
|
local real_bin="$GEM_HOME/gems/inspec-${pkg_version}/bin/inspec"
|
|
|
|
build_line "Adding wrapper $bin to $real_bin"
|
|
|
|
cat <<EOF > "$bin"
|
|
|
|
#!$(pkg_path_for busybox-static)/bin/sh
|
|
|
|
export SSL_CERT_FILE=$(pkg_path_for cacerts)/ssl/cert.pem
|
|
|
|
set -e
|
|
|
|
export GEM_HOME="$GEM_HOME"
|
|
|
|
export GEM_PATH="$GEM_PATH"
|
|
|
|
exec $(pkg_path_for core/ruby)/bin/ruby $real_bin \$@
|
|
|
|
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
|
|
|
}
|