Use detect-libc instead of ldd output parsing

This commit is contained in:
Lovell Fuller 2017-07-15 11:16:11 +01:00
parent b40e3fa1f1
commit eb8773fe3e
4 changed files with 12 additions and 14 deletions

View File

@ -144,7 +144,7 @@
}], }],
['OS == "linux"', { ['OS == "linux"', {
'variables': { 'variables': {
'download_vips': '<!(LDD_VERSION="<!(ldd --version 2>&1 || true)" node -e "require(\'./binding\').download_vips()")' 'download_vips': '<!(node -e "require(\'./binding\').download_vips()")'
}, },
'defines': [ 'defines': [
'_GLIBCXX_USE_CXX11_ABI=0' '_GLIBCXX_USE_CXX11_ABI=0'

View File

@ -8,6 +8,7 @@ const caw = require('caw');
const got = require('got'); const got = require('got');
const semver = require('semver'); const semver = require('semver');
const tar = require('tar'); const tar = require('tar');
const detectLibc = require('detect-libc');
const distBaseUrl = process.env.SHARP_DIST_BASE_URL || 'https://dl.bintray.com/lovell/sharp/'; const distBaseUrl = process.env.SHARP_DIST_BASE_URL || 'https://dl.bintray.com/lovell/sharp/';
@ -68,19 +69,15 @@ module.exports.download_vips = function () {
if (!isFile(vipsHeaderPath)) { if (!isFile(vipsHeaderPath)) {
// Ensure Intel 64-bit or ARM // Ensure Intel 64-bit or ARM
if (arch === 'ia32') { if (arch === 'ia32') {
error('Intel Architecture 32-bit systems require manual installation - please see http://sharp.dimens.io/en/stable/install/'); error('Intel Architecture 32-bit systems require manual installation of libvips - please see http://sharp.dimens.io/page/install');
} }
// Ensure glibc >= 2.15 // Ensure glibc Linux
const lddVersion = process.env.LDD_VERSION; if (detectLibc.isNonGlibcLinux) {
if (lddVersion) { error(`Use with ${detectLibc.family} libc requires manual installation of libvips - please see http://sharp.dimens.io/page/install`);
if (/(glibc|gnu libc|gentoo|solus)/i.test(lddVersion)) {
const glibcVersion = lddVersion ? lddVersion.split(/\n/)[0].split(' ').slice(-1)[0].trim() : '';
if (glibcVersion && semver.lt(glibcVersion + '.0', '2.13.0')) {
error('glibc version ' + glibcVersion + ' requires manual installation - please see http://sharp.dimens.io/en/stable/install/');
}
} else {
error(lddVersion.split(/\n/)[0] + ' requires manual installation - please see http://sharp.dimens.io/en/stable/install/');
} }
// Ensure glibc >= 2.13
if (detectLibc.family === detectLibc.GLIBC && detectLibc.version && semver.lt(`${detectLibc.version}.0`, '2.13.0')) {
error(`Use with glibc version ${detectLibc.version} requires manual installation of libvips - please see http://sharp.dimens.io/page/install`);
} }
// Arch/platform-specific .tar.gz // Arch/platform-specific .tar.gz
const tarFilename = ['libvips', minimumLibvipsVersion, platformId()].join('-') + '.tar.gz'; const tarFilename = ['libvips', minimumLibvipsVersion, platformId()].join('-') + '.tar.gz';

View File

@ -47,7 +47,7 @@ This allows the use of newer versions of libvips with older versions of sharp.
For 32-bit Intel CPUs and older Linux-based operating systems such as Centos 6, For 32-bit Intel CPUs and older Linux-based operating systems such as Centos 6,
it is recommended to install a system-wide installation of libvips from source: it is recommended to install a system-wide installation of libvips from source:
https://github.com/jcupitt/libvips#building-libvips-from-a-source-tarball https://jcupitt.github.io/libvips/install.html#building-libvips-from-a-source-tarball
#### Alpine Linux #### Alpine Linux

View File

@ -69,6 +69,7 @@
"dependencies": { "dependencies": {
"caw": "^2.0.0", "caw": "^2.0.0",
"color": "^2.0.0", "color": "^2.0.0",
"detect-libc": "^0.2.0",
"got": "^7.1.0", "got": "^7.1.0",
"nan": "^2.6.2", "nan": "^2.6.2",
"semver": "^5.3.0", "semver": "^5.3.0",