summaryrefslogtreecommitdiff
path: root/habitat/plan.sh
diff options
context:
space:
mode:
authorAdam Jacob <adam@chef.io>2016-12-21 09:58:31 -0800
committerAdam Jacob <adam@chef.io>2016-12-21 09:58:31 -0800
commit3efafd0be5ea54fc89de6d147106ffa1eedb395d (patch)
tree94aa2d3ce839e8b25ef7b209f8e04bef440d954d /habitat/plan.sh
parent03c3c222b1246b537e2121ec35330e685afee66a (diff)
downloadchef-3efafd0be5ea54fc89de6d147106ffa1eedb395d.tar.gz
Initial habitat planadamhjk/habitat
This is a simple initial habitat plan. It creates a chef-client service, which uses chef-solo to run cookbooks that are located in the default cache location. To build it yourself: * Install habitat * `hab studio build` You'll wind up with a habitat artifact in `results`. Signed-off-by: Adam Jacob <adam@chef.io>
Diffstat (limited to 'habitat/plan.sh')
-rw-r--r--habitat/plan.sh98
1 files changed, 98 insertions, 0 deletions
diff --git a/habitat/plan.sh b/habitat/plan.sh
new file mode 100644
index 0000000000..32c5943217
--- /dev/null
+++ b/habitat/plan.sh
@@ -0,0 +1,98 @@
+pkg_name=chef-client
+pkg_origin=chef
+pkg_maintainer="The Chef Maintainers <humans@chef.io>"
+pkg_description="The Chef Client"
+pkg_version=$(cat ../VERSION)
+pkg_source=nosuchfile.tar.gz
+pkg_license=('Apache-2.0')
+pkg_bin_dirs=(bin)
+pkg_build_deps=(core/make core/gcc core/coreutils core/rsync 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_svc_user=root
+
+do_prepare() {
+ export OPENSSL_LIB_DIR=$(pkg_path_for openssl)/lib
+ export OPENSSL_INCLUDE_DIR=$(pkg_path_for openssl)/include
+ export SSL_CERT_FILE=$(pkg_path_for cacerts)/ssl/cert.pem
+
+ build_line "Setting link for /usr/bin/env to 'coreutils'"
+ [[ ! -f /usr/bin/env ]] && ln -s $(pkg_path_for coreutils)/bin/env /usr/bin/env
+
+ rsync -vaP --delete --exclude habitat --exclude results --exclude .git --exclude Gemfile.lock $PLAN_CONTEXT/../ $HAB_CACHE_SRC_PATH/$pkg_dirname
+ return 0
+}
+
+do_build() {
+ export CPPFLAGS="${CPPFLAGS} ${CFLAGS}"
+
+ local _bundler_dir=$(pkg_path_for bundler)
+ local _libxml2_dir=$(pkg_path_for libxml2)
+ local _libxslt_dir=$(pkg_path_for libxslt)
+ local _zlib_dir=$(pkg_path_for zlib)
+
+ export GEM_HOME=${pkg_path}
+ 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"
+ bundle config --local build.nokogiri '${NOKOGIRI_CONFIG}'
+
+ 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
+
+}
+
+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
+ done
+
+ 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_verify() {
+ return 0
+}
+
+do_download() {
+ return 0
+}
+
+do_unpack() {
+ return 0
+}
+
+do_strip() {
+ return 0
+}