-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpbuilder-environment-installer
executable file
·200 lines (176 loc) · 6.72 KB
/
pbuilder-environment-installer
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
set -ex
### Basic initialization ###
environment="$1"
platform="$2"
step="$3"
eval "$environment"
export CCACHE_DIR="/srv/passenger_autobuilder/ccache/pbuilder/$platform"
mkdir -p "$CCACHE_DIR"
cd /tmp
# Disable apt-get fsync to make it faster.
apt_version=`apt-get --version | head -n 1 | awk '{print $2}'`
[[ "$apt_version" =~ ^([0-9]+)\.([0-9]+) ]]
if [[ ${BASH_REMATCH[1]} > 0 ]] || [[ ${BASH_REMATCH[1]} == 0 && ${BASH_REMATCH[2]} > 7 ]]; then
echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/02apt-speedup
fi
### Functions ###
function is_step()
{
local query="$1"
[[ "$step" = "" || "$step" = "$query" ]]
}
function apt_get_install()
{
apt-get install -y --no-install-recommends "$@"
}
function run_as_psg_autobuilder_chroot()
{
sudo -u psg_autobuilder_chroot -H -E bash -lc \
"export CCACHE_DIR=/srv/passenger_autobuilder/ccache/psg_autobuilder_chroot/$platform; $1"
}
function install_apache()
{
local version="$1"
local compat_version="$2"
local with_included_apr="$3"
local download_apr="$4"
if [[ ! -e /usr/local/apache-$compat_version ]]; then
pushd /tmp
wget http://archive.apache.org/dist/httpd/httpd-$version.tar.bz2
tar xjvf httpd-$version.tar.bz2
rm httpd-$version.tar.bz2
cd httpd-$version
if [[ "$download_apr" = --download-apr ]]; then
pushd srclib
wget http://archive.apache.org/dist/apr/apr-1.5.1.tar.bz2
tar xjvf apr-1.5.1.tar.bz2
rm apr-1.5.1.tar.bz2
mv apr-1.5.1 apr
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.bz2
tar xjvf apr-util-1.5.4.tar.bz2
rm apr-util-1.5.4.tar.bz2
mv apr-util-1.5.4 apr-util
popd
fi
./configure --prefix=/usr/local/apache-$compat_version \
--disable-ssl $with_included_apr
make
make install
rm -f /usr/local/apache-$compat_version/lib/*.a
strip --strip-debug /usr/local/apache-$compat_version/lib/*.so
if ls /usr/local/apache-$compat_version/modules/*.so >/dev/null 2>/dev/null; then
strip --strip-debug /usr/local/apache-$compat_version/modules/*.so
fi
cd ..
rm -rf httpd-$version
popd
fi
}
### Start installation code ###
apt-get update
apt-get upgrade -y
if [[ ! -f /etc/apt/sources.list.d/phusion.nl-misc-lucid.list ]]; then
apt_get_install python-software-properties lsb-release
add-apt-repository ppa:phusion.nl/misc
apt-get update
fi
distro_version=`lsb_release -r | awk '{print $2}'`
if is_step 1; then
if ! grep -q psg_autobuilder_chroot /etc/group >/dev/null; then
addgroup --gid 2457 psg_autobuilder_chroot
fi
if ! grep -q psg_autobuilder_chroot /etc/passwd; then
adduser --uid 2457 --gid 2457 --disabled-password --gecos "Passenger Autobuilder Chroot" psg_autobuilder_chroot
fi
if [[ $distro_version = 10.04 ]]; then
apt_get_install git-core
else
apt_get_install git
fi
apt_get_install build-essential libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev
apt_get_install ccache wget curl less ssh sudo mizuho source-highlight libpcre3-dev libgeoip-dev
fi
if is_step 2; then
# Install RVM, Ruby 1.8 and Ruby 1.9.2.
usermod -a -G sudo psg_autobuilder_chroot
if ! [[ -e /usr/local/rvm ]]; then
sudo -u psg_autobuilder_chroot -H gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -L https://get.rvm.io | sudo -u psg_autobuilder_chroot -H -E bash -s stable
fi
(
export HOME=/home/psg_autobuilder_chroot
/home/psg_autobuilder_chroot/.rvm/bin/rvm-exec requirements
chown -R psg_autobuilder_chroot:psg_autobuilder_chroot /home/psg_autobuilder_chroot/.rvm
)
run_as_psg_autobuilder_chroot 'rvm install 1.8.7'
run_as_psg_autobuilder_chroot 'rvm install 1.9.2'
fi
if is_step 3; then
# Install Ruby 1.9.3, 2.0.0, 2.1.0 and Ruby tools.
run_as_psg_autobuilder_chroot 'rvm install 1.9.3'
run_as_psg_autobuilder_chroot 'rvm install 2.0.0'
run_as_psg_autobuilder_chroot 'rvm install 2.1.7'
run_as_psg_autobuilder_chroot 'rvm install 2.2.3'
run_as_psg_autobuilder_chroot 'rvm --default 2.2.3'
run_as_psg_autobuilder_chroot 'rvm cleanup all'
run_as_psg_autobuilder_chroot 'gem install drake bluecloth --no-rdoc --no-ri'
run_as_psg_autobuilder_chroot 'gem install rspec -v 2.14.1 --no-rdoc --no-ri'
fi
if is_step 4; then
# Install a newer version of pkg-config without bugs.
if [[ ! -e /usr/local/override/bin/pkg-config ]]; then
sudo apt-get install libglib2.0-dev
wget http://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz
tar xzf pkg-config-$PKG_CONFIG_VERSION.tar.gz
rm pkg-config-$PKG_CONFIG_VERSION.tar.gz
cd pkg-config-$PKG_CONFIG_VERSION
./configure --prefix=/usr/local/override
make install-strip
cd ..
rm -rf pkg-config-$PKG_CONFIG_VERSION
fi
# Compile a static OpenSSL library.
if [[ ! -e /usr/local/override/bin/openssl ]]; then
wget http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar xzvf openssl-$OPENSSL_VERSION.tar.gz
rm openssl-$OPENSSL_VERSION.tar.gz
cd openssl-$OPENSSL_VERSION
./config --prefix=/usr/local/override --openssldir=/usr/local/override/openssl \
threads zlib no-shared no-sse2
make
make install_sw
strip --strip-all /usr/local/override/bin/openssl
strip --strip-debug /usr/local/override/lib/libcrypto.a
strip --strip-debug /usr/local/override/lib/libssl.a
sed -i 's/^Libs:.*/Libs: -L${libdir} -lssl -lcrypto -ldl/' /usr/local/override/lib/pkgconfig/openssl.pc
sed -i 's/^Libs.private:.*/Libs.private: -L${libdir} -lssl -lcrypto -ldl -lz/' /usr/local/override/lib/pkgconfig/openssl.pc
sed -i 's/^Libs:.*/Libs: -L${libdir} -lssl -lcrypto -ldl/' /usr/local/override/lib/pkgconfig/libssl.pc
sed -i 's/^Libs.private:.*/Libs.private: -L${libdir} -lssl -lcrypto -ldl -lz/' /usr/local/override/lib/pkgconfig/libssl.pc
cd ..
rm -rf openssl-$OPENSSL_VERSION
fi
# Compile a minimalist libcurl with almost no dependencies.
if [[ ! -e /usr/local/override/bin/curl ]]; then
wget http://curl.haxx.se/download/curl-$CURL_VERSION.tar.bz2
tar xjvf curl-$CURL_VERSION.tar.bz2
rm curl-$CURL_VERSION.tar.bz2
cd curl-$CURL_VERSION
./configure --prefix=/usr/local/override --disable-shared --disable-debug --enable-optimize --disable-werror \
--disable-curldebug --enable-symbol-hiding --disable-ares --disable-manual --disable-ldap --disable-ldaps \
--disable-rtsp --disable-dict --disable-ftp --disable-ftps --disable-gopher --disable-imap \
--disable-imaps --disable-pop3 --disable-pop3s --without-librtmp --disable-smtp --disable-smtps \
--disable-telnet --disable-tftp --disable-smb --disable-versioned-symbols \
--without-libmetalink --without-libidn --without-libssh2 --without-libmetalink --without-nghttp2 \
--with-ssl
make install-strip
cd ..
rm -rf curl-$CURL_VERSION
fi
fi
if is_step 5; then
# Compile Apaches.
install_apache 2.0.65 2.0
install_apache 2.2.25 2.2 --with-included-apr
install_apache 2.4.6 2.4 --with-included-apr --download-apr
fi