Skip to content

Commit 6af1666

Browse files
committed
(Attempt) Install node canvas dependencies during npm install
1 parent 3316713 commit 6af1666

File tree

5 files changed

+85
-3
lines changed

5 files changed

+85
-3
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
doc
44
node_modules
55
*.out
6-
*.log
6+
*.log
7+
*.tar.gz

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unsafe-perm = true

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ os:
77
- linux
88
before_install:
99
# node-canvas dependency
10-
- sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
10+
# - sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
1111
# ROS deps for examples
1212
- sudo sh -c 'echo "deb http://packages.ros.org/ros-shadow-fixed/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'
1313
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -

misc/install.sh

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/sh
2+
3+
set -e
4+
if type 'apt-get' > /dev/null; then
5+
{
6+
apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ -qq &&
7+
exit 0
8+
}
9+
elif type 'yum' > /dev/null; then
10+
{
11+
yum erase cairo &&
12+
yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel giflib-devel &&
13+
exit 0
14+
}
15+
fi
16+
17+
PKG_CONFIG="http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz"
18+
PIXMAN="http://www.cairographics.org/releases/pixman-0.32.4.tar.gz"
19+
CAIRO="http://cairographics.org/releases/cairo-1.12.16.tar.xz"
20+
FREETYPE="http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz"
21+
LIBPNG="http://downloads.sourceforge.net/project/libpng/libpng16/1.6.10/libpng-1.6.10.tar.gz"
22+
GIF_LIB="https://downloads.sourceforge.net/project/giflib/giflib-4.x/giflib-4.1.6/giflib-4.1.6.tar.gz"
23+
PREFIX=${1-/usr/local}
24+
25+
require() {
26+
echo "... checking for $1"
27+
if test `which $1`; then
28+
echo "... found"
29+
else
30+
echo "... not found"
31+
exit 1
32+
fi
33+
}
34+
35+
fetch() {
36+
local tarball=`basename $1`
37+
echo "... downloading $tarball"
38+
local dir=`basename $tarball .tar.gz`
39+
curl -# -L $1 -o $tarball \
40+
&& echo "... unpacking" \
41+
&& tar -zxf $tarball \
42+
&& echo "... removing tarball" \
43+
&& rm -fr $tarball \
44+
&& install $dir
45+
}
46+
47+
fetch_xz() {
48+
local tarball=`basename $1`
49+
echo "... downloading $tarball"
50+
local dir=`basename $tarball .tar.xz`
51+
curl -# -L $1 -o $tarball \
52+
&& echo "... unpacking" \
53+
&& tar -xJf $tarball \
54+
&& echo "... removing tarball" \
55+
&& rm -fr $tarball \
56+
&& install $dir
57+
}
58+
59+
install() {
60+
local dir=$1
61+
echo "... installing $1"
62+
cd $dir \
63+
&& ./configure --disable-dependency-tracking --prefix=$PREFIX \
64+
&& make \
65+
&& make install \
66+
&& echo "... removing $dir" \
67+
&& cd .. && rm -fr $dir
68+
}
69+
70+
echo "... installing to $PREFIX"
71+
require curl
72+
require tar
73+
test `which pkg-config` || fetch $PKG_CONFIG
74+
require 'pkg-config'
75+
fetch $LIBPNG
76+
fetch $GIF_LIB
77+
fetch $FREETYPE
78+
fetch $PIXMAN
79+
fetch_xz $CAIRO

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"test": "grunt test",
4141
"test-examples": "grunt mochaTest:examples && karma start test/examples/karma.conf.js",
4242
"test-tcp": "grunt mochaTest:tcp",
43-
"publish": "grunt build"
43+
"publish": "grunt build",
44+
"preinstall": "sh misc/install.sh"
4445
},
4546
"repository": {
4647
"type": "git",

0 commit comments

Comments
 (0)