Skip to content

Commit

Permalink
Install: coerce libc version to semver #3641
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Apr 23, 2023
1 parent bf9bb56 commit 4d7957a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Requires libvips v8.14.2
* Ensure `trim` operation works with CMYK images (regression in 0.31.0).
[#3636](https://github.com/lovell/sharp/issues/3636)

* Install: coerce libc version to semver.
[#3641](https://github.com/lovell/sharp/issues/3641)

### v0.32.0 - 24th March 2023

* Default to using sequential rather than random access read where possible.
Expand Down
11 changes: 6 additions & 5 deletions install/libvips.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const zlib = require('zlib');
const { createHash } = require('crypto');

const detectLibc = require('detect-libc');
const semverCoerce = require('semver/functions/coerce');
const semverLessThan = require('semver/functions/lt');
const semverSatisfies = require('semver/functions/satisfies');
const simpleGet = require('simple-get');
Expand Down Expand Up @@ -140,16 +141,16 @@ try {
}
// Linux libc version check
const libcFamily = detectLibc.familySync();
const libcVersion = detectLibc.versionSync();
const libcVersionRaw = detectLibc.versionSync();
const libcVersion = semverCoerce(libcVersionRaw).version;
if (libcFamily === detectLibc.GLIBC && libcVersion && minimumGlibcVersionByArch[arch]) {
const libcVersionWithoutPatch = libcVersion.split('.').slice(0, 2).join('.');
if (semverLessThan(`${libcVersionWithoutPatch}.0`, `${minimumGlibcVersionByArch[arch]}.0`)) {
handleError(new Error(`Use with glibc ${libcVersion} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
if (semverLessThan(libcVersion, semverCoerce(minimumGlibcVersionByArch[arch]).version)) {
handleError(new Error(`Use with glibc ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
}
}
if (libcFamily === detectLibc.MUSL && libcVersion) {
if (semverLessThan(libcVersion, '1.1.24')) {
handleError(new Error(`Use with musl ${libcVersion} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
handleError(new Error(`Use with musl ${libcVersionRaw} requires manual installation of libvips >= ${minimumLibvipsVersion}`));
}
}
// Node.js minimum version check
Expand Down

0 comments on commit 4d7957a

Please sign in to comment.