From 05cec013fe7a79828dac9cb5c058b9755dd2d309 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 9 Nov 2015 08:37:30 +0000 Subject: [PATCH] Ensure support for more Linux flavours Add docker-based packaging tests --- .gitignore | 1 - binding.gyp | 22 ++++++++++++-- binding.js | 4 +-- package.json | 7 +++-- packaging/test.sh | 58 +++++++++++++++++++++++++++++++++++++ packaging/test/archlinux.sh | 5 ++++ packaging/test/centos6.sh | 8 +++++ packaging/test/debian.sh | 5 ++++ packaging/test/opensuse.sh | 7 +++++ preinstall.sh | 6 ++-- src/common.cc | 4 +-- 11 files changed, 114 insertions(+), 13 deletions(-) create mode 100755 packaging/test.sh create mode 100755 packaging/test/archlinux.sh create mode 100755 packaging/test/centos6.sh create mode 100755 packaging/test/debian.sh create mode 100755 packaging/test/opensuse.sh diff --git a/.gitignore b/.gitignore index a2a5cc46..221c9831 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ coverage test/bench/node_modules test/fixtures/output* test/leak/libvips.supp -bin lib include packaging/libvips* diff --git a/binding.gyp b/binding.gyp index bf8d59c7..84e850f8 100644 --- a/binding.gyp +++ b/binding.gyp @@ -10,11 +10,11 @@ }, { 'pkg_config_path': '' }] - ] + ], }, 'conditions': [ ['OS != "win"', { - 'global_vips_version': '/dev/null 2>&1 && pkg-config --exists vips && pkg-config --modversion vips || true)' + 'global_vips_version': '/dev/null || true)' }, { 'global_vips_version': '' }] @@ -77,6 +77,24 @@ '<(module_root_dir)/lib/libvips.so', '<(module_root_dir)/lib/libglib-2.0.so', '<(module_root_dir)/lib/libgobject-2.0.so', + # Dependencies of dependencies, included for openSUSE support + '<(module_root_dir)/lib/libMagickCore-6.Q16.so', + '<(module_root_dir)/lib/libMagickWand-6.Q16.so', + '<(module_root_dir)/lib/libexif.so', + '<(module_root_dir)/lib/libgio-2.0.so', + '<(module_root_dir)/lib/libgmodule-2.0.so', + '<(module_root_dir)/lib/libgsf-1.so', + '<(module_root_dir)/lib/libjpeg.so', + '<(module_root_dir)/lib/libpng.so', + '<(module_root_dir)/lib/libtiff.so', + '<(module_root_dir)/lib/libwebp.so', + '<(module_root_dir)/lib/libz.so', + '<(module_root_dir)/lib/libffi.so', + '<(module_root_dir)/lib/libgthread-2.0.so', + '<(module_root_dir)/lib/liblcms2.so', + '<(module_root_dir)/lib/libpng16.so', + '<(module_root_dir)/lib/libxml2.so', + # Ensure runtime linking is relative to sharp.node '-Wl,-rpath=\'$${ORIGIN}/../../lib\'' ] }] diff --git a/binding.js b/binding.js index bda0dbee..45b3d4e3 100644 --- a/binding.js +++ b/binding.js @@ -56,14 +56,14 @@ module.exports.download_vips = function() { if (!isFile(vipsHeaderPath)) { // 32-bit if (process.arch === 'ia32') { - error('32-bit systems require manual installation - see http://sharp.dimens.io/en/stable/install/'); + error('32-bit systems require manual installation - please see http://sharp.dimens.io/en/stable/install/'); } // Ensure libc >= 2.15 var lddVersion = process.env.LDD_VERSION; if (lddVersion) { var libcVersion = lddVersion ? lddVersion.split(/\n/)[0].split(' ').slice(-1)[0].trim() : ''; if (libcVersion && semver.lt(libcVersion + '.0', '2.15.0')) { - error('Unsupported version of libc:\n' + lddVersion + '\nPlease see http://sharp.dimens.io/en/stable/install/'); + error('libc version ' + libcVersion + ' requires manual installation - please see http://sharp.dimens.io/en/stable/install/'); } } // Platform-specific .tar.gz diff --git a/package.json b/package.json index 81d49a7f..1c3e33fa 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,12 @@ ], "description": "High performance Node.js module to resize JPEG, PNG, WebP and TIFF images using the libvips library", "scripts": { - "clean": "rm -rf test/fixtures/output.*", + "clean": "rm -rf build/ include/ lib/ coverage/ test/fixtures/output.*", "test": "VIPS_WARNING=0 node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- --slow=5000 --timeout=20000 ./test/unit/*.js", - "test-clean": "npm run clean && npm install && npm test", + "test-win": "node ./node_modules/mocha/bin/mocha --slow=5000 --timeout=30000 ./test/unit/*.js", "test-leak": "./test/leak/leak.sh", - "test-win": "node ./node_modules/mocha/bin/mocha --slow=5000 --timeout=30000 ./test/unit/*.js" + "test-packaging": "./packaging/test.sh", + "test-clean": "rm -rf coverage/ test/fixtures/output.* && npm install && npm test" }, "main": "index.js", "repository": { diff --git a/packaging/test.sh b/packaging/test.sh new file mode 100755 index 00000000..10db2adf --- /dev/null +++ b/packaging/test.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# Verify docker is available +if ! type docker >/dev/null; then + echo "Please install docker" + exit 1 +fi + +test="npm run clean && NODE_ENV=development npm install --unsafe-perm && npm test && npm run clean" + +# Debian 7 +echo -n "Testing wheezy... " +if docker run -i -t --rm -v $PWD:/v nodesource/wheezy:0.12 sh -c "cd /v && ./packaging/test/debian.sh && ./preinstall.sh && $test" >/dev/null; +then echo "OK" +else echo "fail" +fi + +# Debian 8 +# Ubuntu 12.04, 14.04 +for dist in jessie precise trusty; do + echo -n "Testing $dist... " + if docker run -i -t --rm -v $PWD:/v nodesource/$dist:0.12 sh -c "cd /v && ./packaging/test/debian.sh && $test" >/dev/null; + then echo "OK" + else echo "fail" + fi +done + +# Centos 6 +echo -n "Testing centos6... " +if docker run -i -t --rm -v $PWD:/v nodesource/centos6:0.12 sh -c "cd /v && source ./packaging/test/centos6.sh && ./preinstall.sh && $test" >/dev/null; +then echo "OK" +else echo "fail" +fi + +# Centos 7 +# Fedora 20, 21 + +for dist in centos7 fedora20 fedora21; do + echo -n "Testing $dist... " + if docker run -i -t --rm -v $PWD:/v nodesource/$dist:0.12 sh -c "cd /v && $test" >/dev/null; + then echo "OK" + else echo "fail" + fi +done + +# openSUSE 13.2 +echo -n "Testing opensuse... " +docker run -i -t --rm -v $PWD:/v opensuse:13.2 sh -c "cd /v && ./packaging/test/opensuse.sh && $test" >/dev/null; +then echo "OK" +else echo "fail" +fi + +# Archlinux 2015.06.01 +echo -n "Testing archlinux... " +docker run -i -t --rm -v $PWD:/v base/archlinux:2015.06.01 sh -c "cd /v && ./packaging/test/archlinux.sh && $test" >/dev/null; +then echo "OK" +else echo "fail" +fi diff --git a/packaging/test/archlinux.sh b/packaging/test/archlinux.sh new file mode 100755 index 00000000..07d3eb7f --- /dev/null +++ b/packaging/test/archlinux.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# Install Node.js on Archlinux +pacman -Sy --noconfirm gcc make python2 nodejs npm +ln -s /usr/bin/python2 /usr/bin/python diff --git a/packaging/test/centos6.sh b/packaging/test/centos6.sh new file mode 100755 index 00000000..ebe66857 --- /dev/null +++ b/packaging/test/centos6.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Install C++11 compatible version of g++ on Centos 6 +curl -o /etc/yum.repos.d/devtools-1.1.repo http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo +yum install -y devtoolset-1.1 +export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc +export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp +export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++ diff --git a/packaging/test/debian.sh b/packaging/test/debian.sh new file mode 100755 index 00000000..578e5006 --- /dev/null +++ b/packaging/test/debian.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# Install pkg-config on Debian/Ubuntu +apt-get update +apt-get install -y pkg-config diff --git a/packaging/test/opensuse.sh b/packaging/test/opensuse.sh new file mode 100755 index 00000000..c195de99 --- /dev/null +++ b/packaging/test/opensuse.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Install Node.js on openSUSE 13.2 +zypper addrepo http://download.opensuse.org/repositories/devel:languages:nodejs/openSUSE_13.2/devel:languages:nodejs.repo +zypper --gpg-auto-import-keys refresh +zypper --non-interactive install gcc-c++ make nodejs-devel +npm install -g npm diff --git a/preinstall.sh b/preinstall.sh index 2bbff4af..1e754c0b 100755 --- a/preinstall.sh +++ b/preinstall.sh @@ -33,7 +33,7 @@ install_libvips_from_source() { rm -rf vips-$vips_version_latest_major_minor.$vips_version_latest_patch rm vips-$vips_version_latest_major_minor.$vips_version_latest_patch.tar.gz ldconfig - echo "Installed libvips $vips_version_latest_major_minor.$vips_version_latest_patch" + echo "Installed libvips $(PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig pkg-config --modversion vips)" } install_libopenslide_from_source() { @@ -249,14 +249,14 @@ elif [ -f /etc/redhat-release ]; then # 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 libgsf-devel lcms2-devel ImageMagick-devel gobject-introspection-devel libwebp-devel curl + yum install -y tar curl gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel libgsf-devel lcms2-devel ImageMagick-devel gobject-introspection-devel libwebp-devel 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 libgsf-devel lcms-devel ImageMagick-devel curl + yum install -y tar curl gtk-doc libxml2-devel libjpeg-turbo-devel libpng-devel libtiff-devel libexif-devel libgsf-devel lcms-devel ImageMagick-devel 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 diff --git a/src/common.cc b/src/common.cc index c6c5caeb..9533df02 100755 --- a/src/common.cc +++ b/src/common.cc @@ -7,8 +7,8 @@ // Verify platform and compiler compatibility -#if (VIPS_MAJOR_VERSION < 7 || (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 40)) -#error libvips version 7.40.0+ required - see http://sharp.dimens.io/page/install +#if (VIPS_MAJOR_VERSION < 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 1 && VIPS_PATCH_VERSION < 1)) +#error libvips version 8.1.1+ required - see http://sharp.dimens.io/page/install #endif #if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))