-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-fatclient-bundle
executable file
·103 lines (91 loc) · 3.46 KB
/
build-fatclient-bundle
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
#!/opt/local/bin/bash
#
# Builds the Joyent-style Chef Fatclient installer
#
# Copyright (c) 2013-2014 Jacques Marneweck. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
if [[ "$1" == "-v" ]]; then
shift;
export PS4='[\D{%FT%TZ}] ${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o xtrace
fi
set -o errexit
set -o pipefail
BUILD_BASE=/var/tmp/fatclient
RUBY_VERSION=1.9.3
RUBY_PATCH_LEVEL=448
GEMS_RUBY_VERSION=1.9.1
LIBYAML_VERSION=0.1.4
if [[ $(cat /etc/pkgsrc_version | grep architecture | cut -d' ' -f 2) == "i386" ]]; then
ARCH=32
FATCLIENT_ARCH=i386
else
ARCH=64
FATCLIENT_ARCH=x86_64
fi
#
# Building under ${BUILD_BASE} at present
#
if [[ ! -d ${BUILD_BASE} ]]; then
mkdir ${BUILD_BASE}
fi
#
# Start with building libyaml (needed for pysch for ruby yaml support)
#
cd ${BUILD_BASE}
if [[ ! -f yaml-${LIBYAML_VERSION}.tar.gz ]]; then
wget http://pyyaml.org/download/libyaml/yaml-${LIBYAML_VERSION}.tar.gz
gtar -zxf yaml-${LIBYAML_VERSION}.tar.gz
fi
cd yaml-0.1.4
./configure --prefix=/opt/chef
make install
#
# Now build ruby
#
cd ${BUILD_BASE}
if [[ ! -f ruby-${RUBY_VERSION}-p${RUBY_PATCH_LEVEL}.tar.bz2 ]]; then
wget ftp://ftp.ruby-lang.org/pub/ruby/$(echo $RUBY_VERSION | cut -c1-3)/ruby-${RUBY_VERSION}-p${RUBY_PATCH_LEVEL}.tar.bz2
gtar -jxf ruby-${RUBY_VERSION}-p${RUBY_PATCH_LEVEL}.tar.bz2
fi
cd ruby-${RUBY_VERSION}-p${RUBY_PATCH_LEVEL}
if [[ $ARCH -eq 32 ]]; then
./configure 'CFLAGS=-m32 -std=gnu99' 'CXXFLAGS=-m32' 'LDFLAGS=-m32' --prefix=/opt/chef --disable-install-doc --disable-install-capi --with-opt-dir=/opt/chef/lib
else
./configure 'CFLAGS=-m64 -std=gnu99' 'CXXFLAGS=-m64' 'LDFLAGS=-m64' --prefix=/opt/chef --disable-install-doc --disable-install-capi --with-opt-dir=/opt/chef/lib
fi
make
make install
/opt/chef/bin/gem install chef --no-ri --no-rdoc
#
# Install knife-solo_data_bag for dealing with data_bags with Chef Solo better
#
/opt/chef/bin/gem install knife-solo_data_bag
#
# Apply local patches not yet in upstream opscode ohai
#
OHAI_VERSION=$(/opt/chef/bin/gem list ohai | grep "^ohai" | cut -c7- | gsed -e '/)/s/)//g')
cd /opt/chef/lib/ruby/gems/${GEMS_RUBY_VERSION}/gems/ohai-${OHAI_VERSION}/lib/ohai/plugins/
patch -p0 < /var/tmp/chef-fatclient-builder/patches/ohai-lib-ohai-plugins-hostname.rb.patch
#
# Build the tarball
#
CHEF_VERSION=$(/opt/chef/bin/gem list chef | grep "^chef " | cut -c7- | gsed -e '/)/s/)//g')
cd /
gtar -jcf /var/tmp/Chef-fatclient-${CHEF_VERSION}-${FATCLIENT_ARCH}.tar.bz2 /opt/chef