forked from alex88/heroku-buildpack-vips
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·343 lines (313 loc) · 8.05 KB
/
build.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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#!/bin/bash
# Set vips version
export VIPS_VERSION=8.3.1
export WEBP_VERSION=0.4.0
export ORC_VERSION=0.4.18
export TIFF_VERSION=4.0.3
export GETTEXT_VERSION=0.19.1
export SVG_VERSION=2.40.15
export GIF_VERSION=5.1.4
export BUILD_PATH=/tmp
export OUT_PATH=$OUT_DIR/app/vendor/vips
export PKG_CONFIG_PATH=$OUT_PATH/lib/pkgconfig:$PKG_CONFIG_PATH
export PATH=$OUT_PATH/bin:$PATH
# Based on https://gist.github.com/chrismdp/6c6b6c825b07f680e710
function putS3 {
file=$1
aws_path=$2
aws_id=$3
aws_token=$4
aws_bucket=$5
date=$(date +"%a, %d %b %Y %T %z")
acl="x-amz-acl:public-read"
content_type='application/x-compressed-tar'
string="PUT\n\n$content_type\n$date\n$acl\n/$aws_bucket$aws_path$file"
signature=$(echo -en "${string}" | openssl sha1 -hmac "${aws_token}" -binary | base64)
curl -X PUT -T "$file" \
-H "Host: $aws_bucket.s3.amazonaws.com" \
-H "Date: $date" \
-H "Content-Type: $content_type" \
-H "$acl" \
-H "Authorization: AWS ${aws_id}:$signature" \
"https://$aws_bucket.s3.amazonaws.com$aws_path$file"
echo "Uploaded to https://$aws_bucket.s3.amazonaws.com$aws_path$file"
}
# These should be set from the outside. A git version and heroku/travis respectively
if [ -z "$VERSION" ]
then
VERSION="unknown"
fi
if [ -z "$TARGET" ]
then
TARGET="unknown"
fi
# Remove out path if already exists
rm -Rf $OUT_PATH
# Build path
cd $BUILD_PATH
###############
# Orc #
###############
function build_orc {
# Download orc dependency
curl http://cgit.freedesktop.org/gstreamer/orc/snapshot/orc-$ORC_VERSION.tar.gz -o orc.tar.gz
# Unzip
tar -xvf orc.tar.gz
# Get into orc folder
cd orc-$ORC_VERSION
# Configure
./autogen.sh
# Configure build
./configure --prefix $OUT_PATH
# Make orc
make
# Install orc
make install
}
###############
# WebP #
###############
function build_webp {
# Download webp dependency
curl https://webp.googlecode.com/files/libwebp-$WEBP_VERSION.tar.gz -o libwebp.tar.gz
# Unzip
tar -xvf libwebp.tar.gz
# Get into webp folder
cd libwebp-$WEBP_VERSION
# Configure build
./configure --prefix $OUT_PATH
# Make libwebp
make
# Install webp
make install
}
# Build path
cd $BUILD_PATH
# Build path
cd $BUILD_PATH
###############
# LIBTIFF #
###############
function build_libtiff {
# Download tiff dependency
curl http://download.osgeo.org/libtiff/tiff-$TIFF_VERSION.tar.gz -o libtiff.tar.gz
# Unzip
tar -xvf libtiff.tar.gz
# Get into libtiff folder
cd tiff-$TIFF_VERSION
# Configure build
./configure --prefix $OUT_PATH
# Make libtiff
make
# Install libtiff
make install
}
###############
# CPANM #
###############
function build_cpanm {
# Download cpanm
curl https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm -o cpanm
# Make it executable
chmod +x cpanm
# Use local lib
./cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
# Install xml module (in /app/perl5)
./cpanm -v XML::Parser
}
###############
# INTLTOOL #
###############
function build_intltool {
# Download intltool dependency
curl http://ftp.gnome.org/pub/GNOME/sources/intltool/0.40/intltool-0.40.6.tar.gz -o intltool.tar.gz
# Unzip
tar -xvf intltool.tar.gz
# Get into intltool folder
cd intltool-0.40.6
# Configure build
./configure --prefix $OUT_PATH
# Make intltool
make
# Install intltool
make install
}
###############
# GETTEXT #
###############
function build_gettext {
# Download gettext dependency
curl http://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz -o gettext.tar.gz
# Unzip
tar -xvf gettext.tar.gz
# Get into gettext folder
cd gettext-$GETTEXT_VERSION
# Configure build
./configure --prefix $OUT_PATH
# Make gettext
make
# Install gettext
make install
}
###############
# LIBFFI #
###############
function build_libffi {
# Download libffi dependency
curl ftp://sourceware.org/pub/libffi/libffi-3.1.tar.gz -o libffi.tar.gz
# Unzip
tar -xvf libffi.tar.gz
# Get into libffi folder
cd libffi-3.1
# Configure build
./configure --prefix $OUT_PATH
# Make libffi
make
# Install libffi
make install
}
###############
# GLIB #
###############
function build_glib {
# Download glib dependency
curl http://ftp.gnome.org/pub/gnome/sources/glib/2.41/glib-2.41.1.tar.xz -o glib.tar.xz
# Unzip
tar -xvf glib.tar.xz
# Get into glib folder
cd glib-2.41.1
# Configure build
./configure --prefix $OUT_PATH
# Make glib
make
# Install glib
make install
}
###############
# GSF #
###############
function build_gsf {
# Download libgsf dependency
curl -L http://ftp.gnome.org/pub/GNOME/sources/libgsf/1.14/libgsf-1.14.30.tar.xz -o libgsf.tar.xz
# Unzip
tar -xvf libgsf.tar.xz
# Get into libgsf folder
cd libgsf-1.14.30
# Configure build
./configure --prefix $OUT_PATH
# Make gsf
make
# Install gsf
make install
}
###############
# CFITSIO #
###############
function build_cftsio {
# Download CFITSIO dependency
curl -L ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3370.tar.gz -o cfitsio.tar.gz
# Unzip
tar -xvf cfitsio.tar.gz
# Get into CFITSIO folder
cd cfitsio
# Configure build
./configure --prefix $OUT_PATH
# Make cfitsio
make
# Install cfitsio
make install
}
# SVG
function build_svg {
curl -L https://download.gnome.org/sources/librsvg/2.40/librsvg-${SVG_VERSION}.tar.xz -o librsvg.tar.xz
tar -xvf librsvg.tar.xz
cd librsvg-${SVG_VERSION}
./configure --prefix $OUT_PATH --enable-shared --disable-static \
--disable-dependency-tracking --disable-introspection --disable-tools
make
make install
}
# GIF
function build_gif {
curl -L http://downloads.sourceforge.net/project/giflib/giflib-${GIF_VERSION}.tar.gz -o giflib.tar.gz
tar -xvf giflib.tar.gz
cd giflib-$GIF_VERSION
./configure --prefix $OUT_PATH --enable-shared --disable-static \
--disable-dependency-tracking
make
make install
}
###############
# LCMS #
###############
function build_lcms2 {
# Download lcms dependency
curl -L http://downloads.sourceforge.net/project/lcms/lcms/2.6/lcms2-2.6.tar.gz -o lcms.tar.gz
# Unzip
tar -xvf lcms.tar.gz
# Get into lcms folder
cd lcms2-2.6
# Configure build
./configure --prefix $OUT_PATH
# Make lcms
make
# Install lcms
make install
}
###############
# VIPS #
###############
function build_vips {
# Download vips runtime
curl http://www.vips.ecs.soton.ac.uk/supported/current/vips-$VIPS_VERSION.tar.gz -o vips.tar.gz
# Unzip
tar -xvf vips.tar.gz
# Get into vips folder
cd vips-$VIPS_VERSION
# Configure build and output everything in /tmp/vips
./configure --prefix $OUT_PATH --enable-shared --disable-static --disable-dependency-tracking \
--disable-debug --disable-introspection --without-python --without-fftw \
--without-magick --without-pangoft2 --without-ppm --without-analyze --without-radiance \
--with-giflib-includes=$OUT_PATH/include \
--with-giflib-libraries=$OUT_PATH/lib
# Make
make
# install vips
make install
}
### Build
# TODO: separate what is built on Travis and Heroku, minimize by pulling in relevant packages from APT
cd $BUILD_PATH
build_webp
# cd $BUILD_PATH
# build_libtiff # DISABLED
cd $BUILD_PATH
build_gsf
cd $BUILD_PATH
build_cftsio
cd $BUILD_PATH
build_lcms2
cd $BUILD_PATH
#build_svg
cd $BUILD_PATH
build_gif
cd $BUILD_PATH
build_vips
###############
# Output #
###############
# Get into output path
cd $OUT_PATH
# Clean useless files
rm -rf $OUT_PATH/share/{doc,gtk-doc}
# Create dist package
tar -cvzf libvips-${VERSION}-${TARGET}.tgz *
###############
# S3 #
###############
if [ -z "$AMAZON_API_TOKEN" ];
then
echo "Amazon API Token not provided, skipping upload";
else
putS3 "libvips-${VERSION}-${TARGET}.tgz" "/bundles/" $AMAZON_API_ID $AMAZON_API_TOKEN $AMAZON_API_BUCKET
fi