-
Notifications
You must be signed in to change notification settings - Fork 209
/
Copy pathplan.sh
120 lines (109 loc) · 2.99 KB
/
plan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
pkg_name=oc_id
pkg_origin=chef
pkg_maintainer="The Chef Server Maintainers <support@chef.io>"
pkg_license=('Apache-2.0')
pkg_deps=(
core/sqitch
core/postgresql17-client
core/curl
core/node
core/ruby3_4
core/rsync
core/sed
core/libffi
core/sqlite
core/tzdata
core/openssl
core/gcc-libs
core/glibc
)
pkg_build_deps=(
core/git
core/make
core/gcc
core/tar
core/pkg-config
core/coreutils
core/libxml2
core/libxslt
)
pkg_binds_optional=(
[database]="port"
[chef-server-ctl]="secrets"
)
pkg_exports=(
[port]="port"
)
pkg_exposes=(port)
pkg_bin_dirs=(binstubs)
pkg_version() {
cat "$PLAN_CONTEXT/../../../VERSION"
}
do_before() {
do_default_before
if [ ! -f "$PLAN_CONTEXT/../../../VERSION" ]; then
exit_with "Cannot find VERSION file! You must run \"hab studio enter\" from the chef-server project root." 56
fi
update_pkg_version
}
do_unpack() {
# Copy everything over to the cache path so we don't write out our compiled
# deps into the working directory, but into the cache directory.
mkdir -p "$HAB_CACHE_SRC_PATH/$pkg_dirname"
cp -R "$PLAN_CONTEXT/../"* "$HAB_CACHE_SRC_PATH/$pkg_dirname"
}
do_prepare() {
# clean up any lingering bundle artifacts
rm -rf $PLAN_CONTEXT/../.bundle
}
do_build() {
export LD_LIBRARY_PATH="$(pkg_path_for core/libffi)/lib:$(pkg_path_for core/sqlite)/lib"
export USE_SYSTEM_LIBFFI=1
export C_INCLUDE_PATH="$(pkg_path_for core/sqlite)/include"
export BUNDLE_SILENCE_ROOT_WARNING=1
}
_tar_pipe_app_cp_to() {
local dst_path tar
dst_path="$1"
tar="$(pkg_path_for tar)/bin/tar"
"$tar" -cp \
--no-xattrs \
--exclude-backups \
--exclude-vcs \
--exclude='habitat' \
--exclude='vendor/bundle' \
--exclude='results' \
--files-from=- \
-f - \
| "$tar" -x \
--no-same-owner \
-C "$dst_path" \
-f -
}
do_install() {
export HOME="${pkg_prefix}/oc_id"
mkdir $HOME
export GEM_HOME="${pkg_prefix}/vendor/bundle"
mkdir -p "$GEM_HOME"
{ git ls-files; git ls-files --exclude-standard --others; } \
| _tar_pipe_app_cp_to "$HOME"
bundle config path ${HOME}/vendor/bundle
bundle config build.sqlite3 --with-sqlite3-lib=$(pkg_path_for core/sqlite)/lib
bundle config build.nokogiri --with-xml2-include=$(pkg_path_for core/libxml2)/include/libxml2 \
--with-xml2-lib=$(pkg_path_for core/libxml2)/lib \
--with-xslt-include=$(pkg_path_for core/libxslt)/include/libxslt \
--with-xslt-lib=$(pkg_path_for core/libxslt)/lib
bundle config set path "${HOME}/vendor/bundle"
bundle config set deployment 'true'
bundle config set --local shebang 'ruby'
bundle install --binstubs="${HOME}/bin"
# fix tzdata location
echo "Adding core/tzdata zoneinfo search path to tzinfo gem"
grep -l DEFAULT_SEARCH_PATH $HOME/vendor/bundle/ruby/*/gems/tzinfo*/lib/tzinfo/zoneinfo_data_source.rb | while read -r f; do
sed -e "s,/etc/zoneinfo,$(pkg_path_for core/tzdata)/share/zoneinfo,g" -i "$f"
done
}
# needed due to libffi Bad value error
do_strip() {
return 0
}