Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Habitat package for chef-vault #431

Merged
merged 46 commits into from
Jan 24, 2025
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
062a032
added plan.sh and plan.ps1 to build chef-vault as hab package
nikhil2611 Sep 9, 2024
a4775f9
updating min ruby version to 3.1
nikhil2611 Sep 9, 2024
764a668
updated plan.sh
nikhil2611 Sep 23, 2024
fe2b295
updated gemspec and version.rb
nikhil2611 Sep 23, 2024
bba07ed
updated the plan file for linux
nikhil2611 Dec 3, 2024
59741b7
updated the plan file for win
nikhil2611 Dec 3, 2024
3ed8ff9
reverted the version
nikhil2611 Dec 3, 2024
ccc80c4
Merge pull request #413 from chef/nikhil-CHEF-14471-chef-vault-hab-pa…
nikhil2611 Dec 4, 2024
ab33aec
Automated pipelines for the build and publish hab pkgs
ashiqueps Dec 5, 2024
974b728
Committed config for testing
ashiqueps Dec 5, 2024
1e130d8
Linting updates
ashiqueps Dec 5, 2024
683c0b2
Linting updates
ashiqueps Dec 5, 2024
5d73c08
Subscription changes
ashiqueps Dec 5, 2024
99d777d
Linting updates
ashiqueps Dec 5, 2024
3849995
Added the release branch config
ashiqueps Dec 5, 2024
98fe9b7
Merge pull request #419 from chef/CHEF-17477-buildkite-automated-pipe…
ashiqueps Dec 6, 2024
ed39cde
Merge branch 'workstation-LTS' of github.com:chef/chef-vault into ash…
ashiqueps Dec 9, 2024
0d96d14
Config updates
ashiqueps Dec 9, 2024
15bb959
Pipeline fixes
ashiqueps Dec 9, 2024
c9b3530
Test updates
ashiqueps Dec 9, 2024
a6111f0
Fixed the verify tests for windows
ashiqueps Dec 9, 2024
d82159d
Testing the linux habitat verify test
ashiqueps Dec 9, 2024
71a2091
Fixed the issue with the shell script parameter
ashiqueps Dec 9, 2024
1581903
Removed the logs added for testing
ashiqueps Dec 9, 2024
6964e66
Updated the file permissions and changed the notify channel
ashiqueps Dec 10, 2024
11619ce
Merge pull request #423 from chef/ashique/test-hab-pipelines
ashiqueps Dec 10, 2024
5e3f3ff
Test commit for pipeline testing - 1
ashiqueps Dec 10, 2024
b3b66f2
Merge pull request #424 from chef/ashique/test-hab-pipelines
ashiqueps Dec 10, 2024
17cb3d9
Bump version to 4.1.14 by Chef Expeditor
chef-ci Dec 10, 2024
d834206
removed the manually created pipelines and added the channels
nikhil2611 Jan 6, 2025
2d73a04
added the workload to promote packages
nikhil2611 Jan 6, 2025
bad9d07
Merge pull request #425 from chef/removing_pipelines
sanghinitin Jan 6, 2025
01e9e9e
Bump version to 0.1.0 by Chef Expeditor
chef-ci Jan 6, 2025
a834141
added the pipelines to get create automatically
nikhil2611 Jan 6, 2025
c9a0b09
updated the workload
nikhil2611 Jan 6, 2025
3072511
updated the workload
nikhil2611 Jan 6, 2025
8237aaa
Merge pull request #426 from chef/adding_pipelines
sanghinitin Jan 6, 2025
92809fe
Bump version to 0.1.1 by Chef Expeditor
chef-ci Jan 6, 2025
0edf8e7
empty commit to test pipelines
nikhil2611 Jan 6, 2025
9d42d45
Merge pull request #427 from chef/test_pipeline
sanghinitin Jan 6, 2025
4ff900c
Bump version to 0.1.2 by Chef Expeditor
chef-ci Jan 6, 2025
32f8dfd
Chef-18535 Removed the release branch changes and fixed pipeline (#428)
nikhil2611 Jan 23, 2025
9cc13de
updated workload and removed release branch
nikhil2611 Jan 23, 2025
7f790f8
removing the build and publish ruby gem as its failing the expeditor …
nikhil2611 Jan 23, 2025
4949848
fixing expeditor config error
nikhil2611 Jan 23, 2025
0721d39
removed the workload as per comments
nikhil2611 Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated plan.sh
Signed-off-by: nikhil2611 <[email protected]>
nikhil2611 committed Sep 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 764a66808c42cf57c7496d35bb2b0363bd728127
171 changes: 127 additions & 44 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -1,76 +1,159 @@
_chef_client_ruby="core/ruby31"
pkg_name=chef-vault
pkg_origin=core
pkg_version="4.1.12"
pkg_origin=ngupta26
pkg_description="Gem that allows you to encrypt a Chef Data Bag Item using the public keys of a list of chef nodes. This allows only those chef nodes to decrypt the encrypted values."
pkg_license=('Apache-2.0')
pkg_deps=(
core/ruby31
core/bash
core/git
pkg_bin_dirs=(
bin
vendor/bin
)
pkg_build_deps=(
core/gcc
core/make
core/gcc
core/git
core/libarchive
)
pkg_deps=(
$_chef_client_ruby
core/coreutils
)
pkg_bin_dirs=(bin)
pkg_svc_user=root

pkg_version() {
cat "${SRC_PATH}/VERSION"
}

do_before() {
do_default_before
update_pkg_version
# We must wait until we update the pkg_version to use the pkg_version
pkg_filename="${pkg_name}-${pkg_version}.tar.gz"
}

do_download() {
build_line "Locally creating archive of latest repository commit at ${HAB_CACHE_SRC_PATH}/${pkg_filename}"
# source is in this repo, so we're going to create an archive from the
# appropriate path within the repo and place the generated tarball in the
# location expected by do_unpack
( cd "${SRC_PATH}" || exit_with "unable to enter hab-src directory" 1
git archive --prefix="${pkg_name}-${pkg_version}/" --output="${HAB_CACHE_SRC_PATH}/${pkg_filename}" HEAD
)
}

do_verify() {
build_line "Skipping checksum verification on the archive we just created."
return 0
}

# Setup environment variables for Ruby Gems
do_setup_environment() {
build_line "Setting up GEM_HOME and GEM_PATH"
export GEM_HOME="$pkg_prefix/lib"
export GEM_PATH="$GEM_HOME"
push_runtime_env GEM_PATH "${pkg_prefix}/vendor"

set_runtime_env APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH
set_runtime_env LANG "en_US.UTF-8"
set_runtime_env LC_CTYPE "en_US.UTF-8"
}

# Unpack the source files into the cache directory
do_unpack() {
local unpack_dir="$HAB_CACHE_SRC_PATH/$pkg_dirname"
build_line "Creating unpack directory: $unpack_dir"
mkdir -pv "$unpack_dir"
cp -RT "$PLAN_CONTEXT"/.. "$unpack_dir/"
do_prepare() {
export GEM_HOME="${pkg_prefix}/vendor"
export CPPFLAGS="${CPPFLAGS} ${CFLAGS}"

( cd "$CACHE_PATH"
bundle config --local jobs "$(nproc)"
bundle config --local without server docgen maintenance pry travis integration ci chefstyle
bundle config --local shebang "$(pkg_path_for "$_chef_client_ruby")/bin/ruby"
bundle config --local retry 5
bundle config --local silence_root_warning 1
)

build_line "Setting link for /usr/bin/env to 'coreutils'"
if [ ! -f /usr/bin/env ]; then
ln -s "$(pkg_interpreter_for core/coreutils bin/env)" /usr/bin/env
fi
}

# Unpack the source files into the cache directory
# do_unpack() {
# local unpack_dir="$HAB_CACHE_SRC_PATH/$pkg_dirname"
# build_line "Creating unpack directory: $unpack_dir"
# mkdir -pv "$unpack_dir"
# cp -RT "$PLAN_CONTEXT"/.. "$unpack_dir/"
# }

# Build the gem from the gemspec file
do_build() {
build_line "Building the gem from the gemspec file"
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname" > /dev/null
gem build chef-vault.gemspec
popd > /dev/null
( cd "$CACHE_PATH" || exit_with "unable to enter hab-cache directory" 1
build_line "Installing gem dependencies ..."
bundle install --jobs=3 --retry=3
build_line "Installing gems from git repos properly ..."
build_line "Installing this project's gems ..."
bundle exec rake install:local
gem install chef-utils chef-config appbundler
)
}

# Install the built gem into the package directory
do_install() {
build_line "Installing the gem"
pushd "$HAB_CACHE_SRC_PATH/$pkg_dirname" > /dev/null
gem install chef-vault-*.gem --no-document
popd > /dev/null
( cd "$pkg_prefix" || exit_with "unable to enter pkg prefix directory" 1
export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile"
build_line "** fixing binstub shebangs"
fix_interpreter "${pkg_prefix}/vendor/bin/*" "$_chef_client_ruby" bin/ruby
export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile"
for gem in chef-vault; do
build_line "** generating binstubs for $gem with precise version pins"
appbundler $CACHE_PATH $pkg_prefix/bin $gem
done
)
}

do_after() {
build_line "Trimming the fat ..."

# We don't need the cache of downloaded .gem files ...
rm -rf "$pkg_prefix/vendor/cache"

wrap_chef_vault_bin
rm -r "$pkg_prefix/vendor/bundler"

# We don't need the gem docs.
rm -rf "$pkg_prefix/vendor/doc"
# We don't need to ship the test suites for every gem dependency,
# only Chef's for package verification.
find "$pkg_prefix/vendor/gems" -name spec -type d | grep -v "chef-vault-${pkg_version}" \
| while read spec_dir; do rm -rf "$spec_dir"; done
}


# Create a wrapper script to properly set paths and execute the chef-vault command
wrap_chef_vault_bin() {
local bin="$pkg_prefix/bin/chef-vault"
local real_bin="$GEM_HOME/gems/chef-vault-${pkg_version}/bin/chef-vault"
build_line "Adding wrapper $bin to $real_bin"
# wrap_chef_vault_bin() {
# local bin="$pkg_prefix/bin/chef-vault"
# local real_bin="$GEM_HOME/gems/chef-vault-${pkg_version}/bin/chef-vault"
# build_line "Adding wrapper $bin to $real_bin"

# # build_line "Creating wrapper script: $bin"
# cat <<EOF > "$bin"
# #!$(pkg_path_for core/bash)/bin/bash
# set -e

# build_line "Creating wrapper script: $bin"
cat <<EOF > "$bin"
#!$(pkg_path_for core/bash)/bin/bash
set -e
# # Set the PATH for chef-vault to include necessary binaries
# export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH"

# Set the PATH for chef-vault to include necessary 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"

# Set Ruby paths defined from 'do_setup_environment()'
export GEM_HOME="$GEM_HOME"
export GEM_PATH="$GEM_PATH"
# # Execute the chef-vault binary
# exec $(pkg_path_for core/ruby31)/bin/ruby $real_bin "\$@"
# EOF

# Execute the chef-vault binary
exec $(pkg_path_for core/ruby31)/bin/ruby $real_bin "\$@"
EOF
# # Ensure the wrapper script is executable
# chmod -v 755 "$bin"
# }

# Ensure the wrapper script is executable
chmod -v 755 "$bin"
do_end() {
if [ "$(readlink /usr/bin/env)" = "$(pkg_interpreter_for core/coreutils bin/env)" ]; then
build_line "Removing the symlink we created for '/usr/bin/env'"
rm /usr/bin/env
fi
}

# No additional stripping needed