mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
4eb5f0eeb6
* Remove Hab pkg deps in favor of OS binaries This removes the runtime dependencies on Hab pkgs and instead modifies the `PATH` environment variable to use the OS binaries where the InSpec Habitat package is installed. It should be noted that this is counter to what Habitat intends in most cases. In general, it is preferable to use only Habitat packages as runtime dependencies to get all the benefits that Habitat provides. We elected not to do this for the InSpec Habitat package since the list of binaries that would need to be installed to support all InSpec resources would be prohibitively expensive (both in disk space and network requirements). If you wish to use Habitat packaged binaries with this package you can use `hab pkg install origin/my-binary --binlink`. Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Modify Habitat install example to use `--binlink` Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Add `core/git` runtime dep (used for fetching) Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
75 lines
1.8 KiB
Bash
75 lines
1.8 KiB
Bash
pkg_name=inspec
|
|
pkg_origin=chef
|
|
pkg_version=$(cat "$PLAN_CONTEXT/../VERSION")
|
|
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."
|
|
pkg_upstream_url=https://www.inspec.io/
|
|
pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>"
|
|
pkg_license=('Apache-2.0')
|
|
pkg_deps=(
|
|
core/coreutils
|
|
core/cacerts
|
|
core/git
|
|
core/ruby
|
|
)
|
|
pkg_build_deps=(
|
|
core/gcc
|
|
core/make
|
|
core/readline
|
|
core/sed
|
|
)
|
|
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 inspec.gemspec
|
|
popd
|
|
}
|
|
|
|
do_install() {
|
|
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname/"
|
|
gem install inspec-*.gem --no-document
|
|
popd
|
|
|
|
wrap_inspec_bin
|
|
}
|
|
|
|
# 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-${pkg_version}/bin/inspec"
|
|
build_line "Adding wrapper $bin to $real_bin"
|
|
cat <<EOF > "$bin"
|
|
#!$(pkg_path_for bash)/bin/bash
|
|
export SSL_CERT_FILE=$(pkg_path_for cacerts)/ssl/cert.pem
|
|
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/ruby)/bin/ruby $real_bin \$@
|
|
EOF
|
|
chmod -v 755 "$bin"
|
|
}
|
|
|
|
do_strip() {
|
|
return 0
|
|
}
|