Skip to content

Commit

Permalink
(Attempt) Install node canvas dependencies during npm install
Browse files Browse the repository at this point in the history
  • Loading branch information
gyeates committed Oct 20, 2014
1 parent 3316713 commit 6af1666
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
doc
node_modules
*.out
*.log
*.log
*.tar.gz
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unsafe-perm = true
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ os:
- linux
before_install:
# node-canvas dependency
- sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
# - sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
# ROS deps for examples
- sudo sh -c 'echo "deb http://packages.ros.org/ros-shadow-fixed/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'
- wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
Expand Down
79 changes: 79 additions & 0 deletions misc/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh

set -e
if type 'apt-get' > /dev/null; then
{
apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++ -qq &&
exit 0
}
elif type 'yum' > /dev/null; then
{
yum erase cairo &&
yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel giflib-devel &&
exit 0
}
fi

PKG_CONFIG="http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz"
PIXMAN="http://www.cairographics.org/releases/pixman-0.32.4.tar.gz"
CAIRO="http://cairographics.org/releases/cairo-1.12.16.tar.xz"
FREETYPE="http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz"
LIBPNG="http://downloads.sourceforge.net/project/libpng/libpng16/1.6.10/libpng-1.6.10.tar.gz"
GIF_LIB="https://downloads.sourceforge.net/project/giflib/giflib-4.x/giflib-4.1.6/giflib-4.1.6.tar.gz"
PREFIX=${1-/usr/local}

require() {
echo "... checking for $1"
if test `which $1`; then
echo "... found"
else
echo "... not found"
exit 1
fi
}

fetch() {
local tarball=`basename $1`
echo "... downloading $tarball"
local dir=`basename $tarball .tar.gz`
curl -# -L $1 -o $tarball \
&& echo "... unpacking" \
&& tar -zxf $tarball \
&& echo "... removing tarball" \
&& rm -fr $tarball \
&& install $dir
}

fetch_xz() {
local tarball=`basename $1`
echo "... downloading $tarball"
local dir=`basename $tarball .tar.xz`
curl -# -L $1 -o $tarball \
&& echo "... unpacking" \
&& tar -xJf $tarball \
&& echo "... removing tarball" \
&& rm -fr $tarball \
&& install $dir
}

install() {
local dir=$1
echo "... installing $1"
cd $dir \
&& ./configure --disable-dependency-tracking --prefix=$PREFIX \
&& make \
&& make install \
&& echo "... removing $dir" \
&& cd .. && rm -fr $dir
}

echo "... installing to $PREFIX"
require curl
require tar
test `which pkg-config` || fetch $PKG_CONFIG
require 'pkg-config'
fetch $LIBPNG
fetch $GIF_LIB
fetch $FREETYPE
fetch $PIXMAN
fetch_xz $CAIRO
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"test": "grunt test",
"test-examples": "grunt mochaTest:examples && karma start test/examples/karma.conf.js",
"test-tcp": "grunt mochaTest:tcp",
"publish": "grunt build"
"publish": "grunt build",
"preinstall": "sh misc/install.sh"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 6af1666

Please sign in to comment.