From ed6a9665344a494b20fce6e60f9c8c8c12eb8fff Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 23 Oct 2014 21:17:21 +0100 Subject: [PATCH] Add shell script to install libvips --- .travis.yml | 13 +---- README.md | 66 +++++++++--------------- preinstall.sh | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 55 deletions(-) create mode 100755 preinstall.sh diff --git a/.travis.yml b/.travis.yml index 5b84189f..763713fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,6 @@ node_js: - "0.10" - "0.11" before_install: - - sudo add-apt-repository ppa:lyrasis/precise-backports -y - - sudo apt-get update -qq - - sudo apt-get install -qq automake gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexif-dev libxml2-dev swig libmagick++-dev - - git clone https://github.com/jcupitt/libvips.git - - cd libvips - - git checkout 7.38 - - ./bootstrap.sh - - ./configure --enable-debug=no --enable-cxx=yes --without-orc --without-python --without-fftw - - make - - sudo make install - - sudo ldconfig - - cd $TRAVIS_BUILD_DIR + - curl -s https://raw.githubusercontent.com/lovell/sharp/preinstall/preinstall.sh | sudo bash - after_success: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js diff --git a/README.md b/README.md index ebcc1de5..ff80a0aa 100755 --- a/README.md +++ b/README.md @@ -31,9 +31,30 @@ This module is powered by the blazingly fast [libvips](https://github.com/jcupit * Node.js v0.10+ * [libvips](https://github.com/jcupitt/libvips) v7.38.5+ -_libvips_ can take advantage of [liborc](http://code.entropywave.com/orc/) if present. Warning: versions of _liborc_ prior to 0.4.19 suffer [memory leaks](https://github.com/lovell/sharp/issues/21#issuecomment-42367306) and version 0.4.19 suffers [buffer overflows](https://github.com/lovell/sharp/issues/21#issuecomment-44813498). +To install the latest version of libvips on the following Operating Systems: -### Install libvips on Mac OS +* Mac OS (homebrew, MacPorts) +* Debian Linux + * Debian 8 + * Ubuntu 12.04, 14.04, 14.10 + * Mint 17 +* Red Hat Linux + * RHEL/Centos/Scientific 6, 7 + * Fedora 21, 22 + +run the following as a user with `sudo` access: + + curl -s https://raw.githubusercontent.com/lovell/sharp/preinstall/preinstall.sh | sudo bash - + +or run the following as `root`: + + curl -s https://raw.githubusercontent.com/lovell/sharp/preinstall/preinstall.sh | bash - + +The `preinstall.sh` script requires `curl` and `pkg-config`. + +### Mac OS tips + +Manual install via homebrew: brew install homebrew/science/vips --with-webp --with-graphicsmagick @@ -45,47 +66,6 @@ The _gettext_ dependency of _libvips_ [can lead](https://github.com/lovell/sharp brew link gettext --force -### Install libvips on Linux - -#### Ubuntu 14.04 LTS - - sudo apt-get install libvips-dev - -#### Ubuntu 12.04 LTS - - sudo add-apt-repository -y ppa:lyrasis/precise-backports - sudo apt-get update - sudo apt-get install -y automake build-essential git gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexif-dev libxml2-dev swig libmagickwand-dev - git clone https://github.com/jcupitt/libvips.git - cd libvips - git checkout 7.40 - ./bootstrap.sh - ./configure --enable-debug=no --enable-cxx=yes --without-python --without-orc --without-fftw - make - sudo make install - sudo ldconfig - -#### Debian Jessie - - apt-get install libvips-dev - -#### Centos 6 - - sudo yum groupinstall -y "Development Tools" - sudo yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel ImageMagick-devel - sudo yum install -y http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm - sudo yum install -y --enablerepo=nux-dextop gobject-introspection-devel - sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm - sudo yum install -y --enablerepo=remi libwebp-devel - git clone https://github.com/jcupitt/libvips.git - cd libvips - git checkout 7.40 - ./bootstrap.sh - ./configure --prefix=/usr --enable-docs=no --enable-debug=no --enable-cxx=yes --without-orc --without-python --without-fftw - make - sudo make install - sudo ldconfig - ### Install libvips on Heroku [Alessandro Tagliapietra](https://github.com/alex88) maintains an [Heroku buildpack for libvips](https://github.com/alex88/heroku-buildpack-vips) and its dependencies. diff --git a/preinstall.sh b/preinstall.sh new file mode 100755 index 00000000..0c5cdff2 --- /dev/null +++ b/preinstall.sh @@ -0,0 +1,139 @@ +#!/bin/sh + +# Ensures libvips is installed and attempts to install it if not +# Currently supports: +# * Mac OS +# * Debian Linux +# * Debian 8 +# * Ubuntu 12.04, 14.04, 14.10 +# * Mint 17 +# * Red Hat Linux +# * RHEL/Centos/Scientific 6, 7 +# * Fedora 21, 22 + +vips_version_minimum=7.38.5 +vips_version_latest_major=7.40 +vips_version_latest_minor=11 + +install_libvips_from_source() { + echo "Compiling libvips $vips_version_latest_major.$vips_version_latest_minor from source" + curl -O http://www.vips.ecs.soton.ac.uk/supported/$vips_version_latest_major/vips-$vips_version_latest_major.$vips_version_latest_minor.tar.gz + tar zvxf vips-$vips_version_latest_major.$vips_version_latest_minor.tar.gz + cd vips-$vips_version_latest_major.$vips_version_latest_minor + ./configure --enable-debug=no --enable-docs=no --enable-cxx=yes --without-python --without-orc --without-fftw $1 + make + make install + cd .. + rm -rf vips-$vips_version_latest_major.$vips_version_latest_minor + rm vips-$vips_version_latest_major.$vips_version_latest_minor.tar.gz + ldconfig + echo "Installed libvips $vips_version_latest_major.$vips_version_latest_minor" +} + +sorry() { + echo "Sorry, I don't yet know how to install libvips on $1" + exit 1 +} + +# Is libvips already installed, and is it at least the minimum required version? + +if ! type pkg-config >/dev/null; then + sorry "a system without pkg-config" +fi + +pkg_config_path_homebrew=`which brew >/dev/null 2>&1 && eval $(brew --env) && echo $PKG_CONFIG_LIBDIR || true` +pkg_config_path="$pkg_config_path_homebrew:$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" + +PKG_CONFIG_PATH=$pkg_config_path pkg-config --exists vips +if [ $? -eq 0 ]; then + vips_version_found=$(PKG_CONFIG_PATH=$pkg_config_path pkg-config --modversion vips) + pkg-config --atleast-version=$vips_version_minimum vips + if [ $? -eq 0 ]; then + # Found suitable version of libvips + echo "Found libvips $vips_version_found" + exit 0 + fi + echo "Found libvips $vips_version_found but require $vips_version_minimum" +else + echo "Could not find libvips using a PKG_CONFIG_PATH of '$pkg_config_path'" +fi + +# OS-specific installations of libvips follows + +case $(uname -s) in + *[Dd]arwin*) + # Mac OS + echo "Detected Mac OS" + if type "brew" > /dev/null; then + echo "Installing libvips via homebrew" + brew install homebrew/science/vips --with-webp --with-graphicsmagick + elif type "port" > /dev/null; then + echo "Installing libvips via MacPorts" + port install vips + else + sorry "Mac OS without homebrew or MacPorts" + fi + ;; + *) + if [ -f /etc/debian_version ]; then + # Debian Linux + DISTRO=$(lsb_release -c -s) + echo "Detected Debian Linux '$DISTRO'" + case "$DISTRO" in + jessie|trusty|utopic|qiana) + # Debian 8, Ubuntu 14, Mint 17 + echo "Installing libvips via apt-get" + apt-get install -y libvips-dev + ;; + precise) + # Ubuntu 12 + echo "Installing libvips dependencies via apt-get" + add-apt-repository -y ppa:lyrasis/precise-backports + apt-get update + apt-get install -y automake build-essential gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexif-dev libxml2-dev swig libmagickwand-dev curl + install_libvips_from_source + ;; + *) + # Unsupported Debian-based OS + sorry "Debian-based $DISTRO" + ;; + esac + elif [ -f /etc/redhat-release ]; then + # Red Hat Linux + RELEASE=$(cat /etc/redhat-release) + echo "Detected Red Hat Linux '$RELEASE'" + case $RELEASE in + "Red Hat Enterprise Linux release 7."*|"CentOS Linux release 7."*|"Scientific Linux release 7."*) + # RHEL/CentOS 7 + echo "Installing libvips dependencies via yum" + yum groupinstall -y "Development Tools" + yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl + install_libvips_from_source "--prefix=/usr" + ;; + "Red Hat Enterprise Linux release 6."*|"CentOS release 6."*|"Scientific Linux release 6."*) + # RHEL/CentOS 6 + echo "Installing libvips dependencies via yum" + yum groupinstall -y "Development Tools" + yum install -y gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel ImageMagick-devel curl + yum install -y http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm + yum install -y --enablerepo=nux-dextop gobject-introspection-devel + yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm + yum install -y --enablerepo=remi libwebp-devel + install_libvips_from_source "--prefix=/usr" + ;; + "Fedora release 21 "*|"Fedora release 22 "*) + # Fedora 21, 22 + echo "Installing libvips via yum" + yum install vips-devel + ;; + *) + # Unsupported RHEL-based OS + sorry "$RELEASE" + ;; + esac + else + # Unsupported OS + sorry "$(uname -a)" + fi + ;; +esac