summaryrefslogtreecommitdiff
path: root/habitat/plan.sh
diff options
context:
space:
mode:
Diffstat (limited to 'habitat/plan.sh')
-rw-r--r--habitat/plan.sh75
1 files changed, 39 insertions, 36 deletions
diff --git a/habitat/plan.sh b/habitat/plan.sh
index 7a797842e2..9c9b5b19c8 100644
--- a/habitat/plan.sh
+++ b/habitat/plan.sh
@@ -7,8 +7,8 @@ pkg_source=nosuchfile.tar.gz
pkg_filename=${pkg_dirname}.tar.gz
pkg_license=('Apache-2.0')
pkg_bin_dirs=(bin)
-pkg_build_deps=(core/make core/gcc core/coreutils core/git)
-pkg_deps=(core/glibc core/ruby core/libxml2 core/libxslt core/libiconv core/xz core/zlib core/bundler core/openssl core/cacerts core/libffi)
+pkg_build_deps=(core/make core/gcc core/git)
+pkg_deps=(core/glibc core/ruby core/libxml2 core/libxslt core/libiconv core/xz core/zlib core/bundler core/openssl core/cacerts core/libffi core/coreutils)
pkg_svc_user=root
do_download() {
@@ -44,7 +44,7 @@ do_build() {
local _libxslt_dir=$(pkg_path_for libxslt)
local _zlib_dir=$(pkg_path_for zlib)
- export GEM_HOME=${pkg_prefix}
+ export GEM_HOME=${pkg_prefix}/bundle
export GEM_PATH=${_bundler_dir}:${GEM_HOME}
export NOKOGIRI_CONFIG="--use-system-libraries --with-zlib-dir=${_zlib_dir} --with-xslt-dir=${_libxslt_dir} --with-xml2-include=${_libxml2_dir}/include/libxml2 --with-xml2-lib=${_libxml2_dir}/lib"
@@ -52,49 +52,52 @@ do_build() {
bundle config --local silence_root_warning 1
- # We need to add tzinfo-data to the Gemfile since we're not in an
- # environment that has this from the OS
- if [[ -z "`grep 'gem .*tzinfo-data.*' Gemfile`" ]]; then
- echo 'gem "tzinfo-data"' >> Gemfile
- fi
-
- bundle install --no-deployment --jobs 2 --retry 5 --path $pkg_prefix
-
- bundle exec 'cd ./chef-config && rake package'
- bundle exec 'rake package'
- mkdir -p gems-suck/gems
- cp pkg/chef-$pkg_version.gem gems-suck/gems
- cp chef-config/pkg/chef-config-$pkg_version.gem gems-suck/gems
- bundle exec gem generate_index -d gems-suck
-
- sed -e "s#gem \"chef\".*#gem \"chef\", source: \"file://$HAB_CACHE_SRC_PATH/$pkg_dirname/gems-suck\"#" -i Gemfile
- sed -e "s#gem \"chef-config\".*#gem \"chef-config\", source: \"file://$HAB_CACHE_SRC_PATH/$pkg_dirname/gems-suck\"#" -i Gemfile
- #bundle config --local local.chef $HAB_CACHE_SRC_PATH/$pkg_dirname/gems-suck
- #bundle config --local local.chef-config $HAB_CACHE_SRC_PATH/$pkg_dirname/gems-suck
-
- bundle install --no-deployment --jobs 2 --retry 5 --path $pkg_prefix
+ pushd chef-config > /dev/null
+ _bundle_install "${pkg_prefix}/bundle"
+ popd > /dev/null
+ _bundle_install "${pkg_prefix}/bundle"
}
do_install() {
-
- mkdir -p $pkg_prefix/bin
-
- bundle exec appbundler $HAB_CACHE_SRC_PATH/$pkg_dirname $pkg_prefix/bin chef
- bundle exec appbundler $HAB_CACHE_SRC_PATH/$pkg_dirname $pkg_prefix/bin ohai
-
- for binstub in ${pkg_prefix}/bin/*; do
- build_line "Setting shebang for ${binstub} to 'ruby'"
- [[ -f $binstub ]] && sed -e "s#/usr/bin/env ruby#$(pkg_path_for ruby)/bin/ruby#" -i $binstub
+ mkdir -p "${pkg_prefix}/chef"
+ for dir in bin chef-config lib chef.gemspec Gemfile Gemfile.lock; do
+ cp -rv "${PLAN_CONTEXT}/../${dir}" "${pkg_prefix}/chef/"
done
+ # This is just generating binstubs with the correct path.
+ # If we generated them on install, bundler thinks our source is in $HAB_CACHE_SOURCE_PATH
+ pushd "$pkg_prefix/chef" > /dev/null
+ _bundle_install \
+ "${pkg_prefix}/bundle" \
+ --local \
+ --quiet \
+ --binstubs "${pkg_prefix}/bin"
+ popd > /dev/null
+
+ fix_interpreter "${pkg_prefix}/bin/*" core/coreutils bin/env
+ fix_interpreter "${pkg_prefix}/bin/*" core/ruby bin/ruby
+}
+
+do_end() {
if [[ `readlink /usr/bin/env` = "$(pkg_path_for coreutils)/bin/env" ]]; then
build_line "Removing the symlink we created for '/usr/bin/env'"
rm /usr/bin/env
fi
}
-# Stubs
-do_strip() {
- return 0
+# Helper function to wrap up some repetitive bundle install flags
+_bundle_install() {
+ local path
+ path="$1"
+ shift
+
+ bundle install ${*:-} \
+ --jobs "$(nproc)" \
+ --without development:test \
+ --path "$path" \
+ --shebang="$(pkg_path_for "core/ruby")/bin/ruby" \
+ --no-clean \
+ --retry 5 \
+ --standalone
}