|
1 | | -_chef_client_ruby="core/ruby31" |
2 | | -pkg_name="chef-cli" |
3 | | -pkg_origin="ngupta26" |
4 | | -pkg_maintainer= "The Chef Maintainers <[email protected]>" |
5 | | -pkg_description="The Chef CLI" |
6 | | -pkg_license=('Apache-2.0') |
7 | | -pkg_bin_dirs=( |
8 | | - bin |
9 | | - vendor/bin |
10 | | -) |
| 1 | +pkg_name=chef-cli |
| 2 | +pkg_origin=chef |
| 3 | +ruby_pkg="core/ruby3_1" |
| 4 | +pkg_deps=(${ruby_pkg} core/coreutils) |
11 | 5 | pkg_build_deps=( |
12 | | - core/make |
13 | | - core/gcc |
14 | | - core/git |
15 | | - core/libarchive |
16 | | -) |
17 | | -pkg_deps=( |
18 | | - $_chef_client_ruby |
19 | | - core/coreutils |
20 | | -) |
21 | | -pkg_svc_user=root |
| 6 | + core/make |
| 7 | + core/sed |
| 8 | + core/gcc |
| 9 | + core/libarchive |
| 10 | + ) |
| 11 | +pkg_bin_dirs=(bin) |
| 12 | +do_setup_environment() { |
| 13 | + build_line 'Setting GEM_HOME="$pkg_prefix/vendor"' |
| 14 | + export GEM_HOME="$pkg_prefix/vendor" |
22 | 15 |
|
23 | | -pkg_version() { |
24 | | - cat "${SRC_PATH}/VERSION" |
| 16 | + build_line "Setting GEM_PATH=$GEM_HOME" |
| 17 | + export GEM_PATH="$GEM_HOME" |
25 | 18 | } |
26 | 19 |
|
| 20 | +pkg_version() { |
| 21 | + cat "$SRC_PATH/VERSION" |
| 22 | +} |
27 | 23 | do_before() { |
28 | | - do_default_before |
29 | 24 | update_pkg_version |
30 | | - # We must wait until we update the pkg_version to use the pkg_version |
31 | | - pkg_filename="${pkg_name}-${pkg_version}.tar.gz" |
32 | 25 | } |
33 | | - |
34 | | -do_download() { |
35 | | - build_line "Locally creating archive of latest repository commit at ${HAB_CACHE_SRC_PATH}/${pkg_filename}" |
36 | | - # source is in this repo, so we're going to create an archive from the |
37 | | - # appropriate path within the repo and place the generated tarball in the |
38 | | - # location expected by do_unpack |
39 | | - ( cd "${SRC_PATH}" || exit_with "unable to enter hab-src directory" 1 |
40 | | - git archive --prefix="${pkg_name}-${pkg_version}/" --output="${HAB_CACHE_SRC_PATH}/${pkg_filename}" HEAD |
41 | | - ) |
42 | | -} |
43 | | - |
44 | | -do_verify() { |
45 | | - build_line "Skipping checksum verification on the archive we just created." |
46 | | - return 0 |
47 | | -} |
48 | | - |
49 | | -do_setup_environment() { |
50 | | - push_runtime_env GEM_PATH "${pkg_prefix}/vendor" |
51 | | - |
52 | | - set_runtime_env APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH |
53 | | - set_runtime_env LANG "en_US.UTF-8" |
54 | | - set_runtime_env LC_CTYPE "en_US.UTF-8" |
| 26 | +do_unpack() { |
| 27 | + mkdir -pv "$HAB_CACHE_SRC_PATH/$pkg_dirname" |
| 28 | + cp -RT "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" |
55 | 29 | } |
| 30 | +do_build() { |
56 | 31 |
|
57 | | -do_prepare() { |
58 | | - export GEM_HOME="${pkg_prefix}/vendor" |
59 | | - export CPPFLAGS="${CPPFLAGS} ${CFLAGS}" |
| 32 | + export GEM_HOME="$pkg_prefix/vendor" |
60 | 33 |
|
61 | | - ( cd "$CACHE_PATH" |
62 | | - bundle config --local jobs "$(nproc)" |
63 | | - bundle config --local without server docgen maintenance pry travis integration ci chefstyle |
64 | | - bundle config --local shebang "$(pkg_path_for "$_chef_client_ruby")/bin/ruby" |
| 34 | + build_line "Setting GEM_PATH=$GEM_HOME" |
| 35 | + export GEM_PATH="$GEM_HOME" |
| 36 | + bundle config --local without integration deploy maintenance |
| 37 | + bundle config --local jobs 4 |
65 | 38 | bundle config --local retry 5 |
66 | 39 | bundle config --local silence_root_warning 1 |
67 | | - ) |
68 | | - |
69 | | - build_line "Setting link for /usr/bin/env to 'coreutils'" |
70 | | - if [ ! -f /usr/bin/env ]; then |
71 | | - ln -s "$(pkg_interpreter_for core/coreutils bin/env)" /usr/bin/env |
72 | | - fi |
73 | | -} |
74 | | - |
75 | | -do_build() { |
76 | | - ( cd "$CACHE_PATH" || exit_with "unable to enter hab-cache directory" 1 |
77 | | - build_line "Installing gem dependencies ..." |
78 | | - bundle install --jobs=3 --retry=3 |
79 | | - build_line "Installing gems from git repos properly ..." |
80 | | - build_line "Installing this project's gems ..." |
81 | | - bundle exec rake install:local |
82 | | - gem install chef-utils chef-config appbundler |
83 | | - ) |
| 40 | + bundle install |
| 41 | + gem build chef-cli.gemspec |
84 | 42 | } |
85 | | - |
86 | 43 | do_install() { |
87 | | - ( cd "$pkg_prefix" || exit_with "unable to enter pkg prefix directory" 1 |
88 | | - export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile" |
89 | | - build_line "** fixing binstub shebangs" |
90 | | - fix_interpreter "${pkg_prefix}/vendor/bin/*" "$_chef_client_ruby" bin/ruby |
91 | | - export BUNDLE_GEMFILE="${CACHE_PATH}/Gemfile" |
92 | | - for gem in chef-cli; do |
93 | | - build_line "** generating binstubs for $gem with precise version pins" |
94 | | - appbundler $CACHE_PATH $pkg_prefix/bin $gem |
95 | | - done |
96 | | - ) |
97 | | - sed -i '1s|^.*|#!'$(pkg_path_for $_chef_client_ruby)/bin/ruby'|' ${pkg_prefix}/vendor/bin/rspec |
| 44 | + export GEM_HOME="$pkg_prefix/vendor" |
98 | 45 |
|
| 46 | + build_line "Setting GEM_PATH=$GEM_HOME" |
| 47 | + export GEM_PATH="$GEM_HOME" |
| 48 | + gem install chef-cli-*.gem --no-document |
| 49 | + set_runtime_env "GEM_PATH" "${pkg_prefix}/vendor" |
| 50 | + wrap_ruby_bin |
99 | 51 | } |
100 | | - |
101 | | -do_after() { |
102 | | - build_line "Trimming the fat ..." |
103 | | - |
104 | | - # We don't need the cache of downloaded .gem files ... |
105 | | - rm -rf "$pkg_prefix/vendor/cache" |
106 | | - |
107 | | - # We don't need the gem docs. |
108 | | - rm -rf "$pkg_prefix/vendor/doc" |
109 | | - # We don't need to ship the test suites for every gem dependency, |
110 | | - # only Chef's for package verification. |
111 | | - find "$pkg_prefix/vendor/gems" -name spec -type d | grep -v "chef-cli-${pkg_version}" \ |
112 | | - | while read spec_dir; do rm -rf "$spec_dir"; done |
| 52 | +wrap_ruby_bin() { |
| 53 | + local bin="$pkg_prefix/bin/$pkg_name" |
| 54 | + local real_bin="$GEM_HOME/gems/chef-cli-${pkg_version}/bin/chef-cli" |
| 55 | + build_line "Adding wrapper $bin to $real_bin" |
| 56 | + cat <<EOF > "$bin" |
| 57 | +#!$(pkg_path_for core/bash)/bin/bash |
| 58 | +set -e |
| 59 | +
|
| 60 | +# Set binary path that allows InSpec to use non-Hab pkg binaries |
| 61 | +export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH" |
| 62 | +
|
| 63 | +# Set Ruby paths defined from 'do_setup_environment()' |
| 64 | + export GEM_HOME="$pkg_prefix/vendor" |
| 65 | + export GEM_PATH="$GEM_PATH" |
| 66 | +
|
| 67 | +exec $(pkg_path_for core/ruby31)/bin/ruby $real_bin \$@ |
| 68 | +EOF |
| 69 | + chmod -v 755 "$bin" |
113 | 70 | } |
114 | 71 |
|
115 | | -do_end() { |
116 | | - if [ "$(readlink /usr/bin/env)" = "$(pkg_interpreter_for core/coreutils bin/env)" ]; then |
117 | | - build_line "Removing the symlink we created for '/usr/bin/env'" |
118 | | - rm /usr/bin/env |
119 | | - fi |
120 | | -} |
121 | 72 |
|
122 | 73 | do_strip() { |
123 | 74 | return 0 |
|
0 commit comments