From ba17db3ab3c7cc0be3f8dc8c80c4d7f3912ead9e Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 29 Jun 2020 20:53:58 +0100 Subject: [PATCH] Switch to Brotli-compressed binaries, requires Node.js 10.16.0+ --- README.md | 2 +- docs/README.md | 2 +- docs/changelog.md | 8 ++++++++ docs/install.md | 8 ++++---- install/libvips.js | 29 ++++++++++++++++------------- package.json | 6 +++--- src/common.h | 2 +- 7 files changed, 34 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 70f0992e..28541f24 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Lanczos resampling ensures quality is not sacrificed for speed. As well as image resizing, operations such as rotation, extraction, compositing and gamma correction are available. -Most modern macOS, Windows and Linux systems running Node.js v10+ +Most modern macOS, Windows and Linux systems running Node.js v10.16.0+ do not require any additional install or runtime dependencies. ## Examples diff --git a/docs/README.md b/docs/README.md index c4c1b15e..31683731 100644 --- a/docs/README.md +++ b/docs/README.md @@ -16,7 +16,7 @@ Lanczos resampling ensures quality is not sacrificed for speed. As well as image resizing, operations such as rotation, extraction, compositing and gamma correction are available. -Most modern macOS, Windows and Linux systems running Node.js v10+ +Most modern macOS, Windows and Linux systems running Node.js v10.16.0+ do not require any additional install or runtime dependencies. ### Formats diff --git a/docs/changelog.md b/docs/changelog.md index ce3551a2..c7ef02fd 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,13 @@ # Changelog +## v0.26 - *zoom* + +Requires libvips v8.9.2 + +### v0.26.0 - TBD + +* Prebuilt libvips binaries are now statically-linked and Brotli-compressed, requiring Node.js 10.16.0+. + ## v0.25 - *yield* Requires libvips v8.9.1 diff --git a/docs/install.md b/docs/install.md index 8546523a..0bfade7c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -10,19 +10,19 @@ yarn add sharp ## Prerequisites -* Node.js v10+ +* Node.js v10.16.0+ ## Prebuilt binaries Ready-compiled sharp and libvips binaries are provided for use with -Node.js v10+ on the most common platforms: +Node.js v10.16.0+ on the most common platforms: * macOS x64 (>= 10.13) * Linux x64 (glibc >= 2.17, musl >= 1.1.24) * Linux ARM64 (glibc >= 2.29) * Windows -A ~10MB tarball containing libvips and its most commonly used dependencies +A ~7MB tarball containing libvips and its most commonly used dependencies is downloaded via HTTPS and stored within `node_modules/sharp/vendor` during `npm install`. This provides support for the @@ -93,7 +93,7 @@ The version subpath and file name are appended to these. For example, if `sharp_libvips_binary_host` is set to `https://hostname/path` and the libvips version is `1.2.3` then the resultant URL will be -`https://hostname/path/v1.2.3/libvips-1.2.3-platform-arch.tar.gz`. +`https://hostname/path/v1.2.3/libvips-1.2.3-platform-arch.tar.br`. See the Chinese mirror below for a further example. diff --git a/install/libvips.js b/install/libvips.js index 5fca5f28..84eb9955 100644 --- a/install/libvips.js +++ b/install/libvips.js @@ -3,12 +3,14 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); +const stream = require('stream'); +const zlib = require('zlib'); const detectLibc = require('detect-libc'); const npmLog = require('npmlog'); const semver = require('semver'); const simpleGet = require('simple-get'); -const tar = require('tar'); +const tarFs = require('tar-fs'); const agent = require('../lib/agent'); const libvips = require('../lib/libvips'); @@ -39,18 +41,19 @@ const extractTarball = function (tarPath) { libvips.mkdirSync(vendorPath); const versionedVendorPath = path.join(vendorPath, minimumLibvipsVersion); libvips.mkdirSync(versionedVendorPath); - tar - .extract({ - file: tarPath, - cwd: versionedVendorPath, - strict: true - }) - .catch(function (err) { - if (/unexpected end of file/.test(err.message)) { - npmLog.error('sharp', `Please delete ${tarPath} as it is not a valid tarball`); + stream.pipeline( + fs.createReadStream(tarPath), + new zlib.BrotliDecompress(), + tarFs.extract(versionedVendorPath), + function (err) { + if (err) { + if (/unexpected end of file/.test(err.message)) { + npmLog.error('sharp', `Please delete ${tarPath} as it is not a valid tarball`); + } + fail(err); } - fail(err); - }); + } + ); }; try { @@ -78,7 +81,7 @@ try { } } // Download to per-process temporary file - const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.gz'; + const tarFilename = ['libvips', minimumLibvipsVersion, platformAndArch].join('-') + '.tar.br'; const tarPathCache = path.join(libvips.cachePath(), tarFilename); if (fs.existsSync(tarPathCache)) { npmLog.info('sharp', `Using cached ${tarPathCache}`); diff --git a/package.json b/package.json index cfd93674..8a98caff 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "prebuild-install": "^5.3.4", "semver": "^7.3.2", "simple-get": "^4.0.0", - "tar": "^6.0.2", + "tar-fs": "^2.1.0", "tunnel-agent": "^0.6.0" }, "devDependencies": { @@ -137,10 +137,10 @@ }, "license": "Apache-2.0", "config": { - "libvips": "8.9.2-alpha2" + "libvips": "8.9.2-alpha5" }, "engines": { - "node": ">=10" + "node": ">=10.16.0" }, "funding": { "url": "https://opencollective.com/libvips" diff --git a/src/common.h b/src/common.h index 2d3ca0c9..f5e1d965 100644 --- a/src/common.h +++ b/src/common.h @@ -25,7 +25,7 @@ // Verify platform and compiler compatibility #if (VIPS_MAJOR_VERSION < 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 9)) -#error "libvips version 8.9.1+ is required - please see https://sharp.pixelplumbing.com/install" +#error "libvips version 8.9.2+ is required - please see https://sharp.pixelplumbing.com/install" #endif #if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)))