1 | # detect-libc
|
---|
2 |
|
---|
3 | Node.js module to detect the C standard library (libc) implementation
|
---|
4 | family and version in use on a given Linux system.
|
---|
5 |
|
---|
6 | Provides a value suitable for use with the `LIBC` option of
|
---|
7 | [prebuild](https://www.npmjs.com/package/prebuild),
|
---|
8 | [prebuild-ci](https://www.npmjs.com/package/prebuild-ci) and
|
---|
9 | [prebuild-install](https://www.npmjs.com/package/prebuild-install),
|
---|
10 | therefore allowing build and provision of pre-compiled binaries
|
---|
11 | for musl-based Linux e.g. Alpine as well as glibc-based.
|
---|
12 |
|
---|
13 | Currently supports libc detection of `glibc` and `musl`.
|
---|
14 |
|
---|
15 | ## Install
|
---|
16 |
|
---|
17 | ```sh
|
---|
18 | npm install detect-libc
|
---|
19 | ```
|
---|
20 |
|
---|
21 | ## Usage
|
---|
22 |
|
---|
23 | ### API
|
---|
24 |
|
---|
25 | ```js
|
---|
26 | const { GLIBC, MUSL, family, version, isNonGlibcLinux } = require('detect-libc');
|
---|
27 | ```
|
---|
28 |
|
---|
29 | * `GLIBC` is a String containing the value "glibc" for comparison with `family`.
|
---|
30 | * `MUSL` is a String containing the value "musl" for comparison with `family`.
|
---|
31 | * `family` is a String representing the system libc family.
|
---|
32 | * `version` is a String representing the system libc version number.
|
---|
33 | * `isNonGlibcLinux` is a Boolean representing whether the system is a non-glibc Linux, e.g. Alpine.
|
---|
34 |
|
---|
35 | ### detect-libc command line tool
|
---|
36 |
|
---|
37 | When run on a Linux system with a non-glibc libc,
|
---|
38 | the child command will be run with the `LIBC` environment variable
|
---|
39 | set to the relevant value.
|
---|
40 |
|
---|
41 | On all other platforms will run the child command as-is.
|
---|
42 |
|
---|
43 | The command line feature requires `spawnSync` provided by Node v0.12+.
|
---|
44 |
|
---|
45 | ```sh
|
---|
46 | detect-libc child-command
|
---|
47 | ```
|
---|
48 |
|
---|
49 | ## Integrating with prebuild
|
---|
50 |
|
---|
51 | ```json
|
---|
52 | "scripts": {
|
---|
53 | "install": "detect-libc prebuild-install || node-gyp rebuild",
|
---|
54 | "test": "mocha && detect-libc prebuild-ci"
|
---|
55 | },
|
---|
56 | "dependencies": {
|
---|
57 | "detect-libc": "^1.0.2",
|
---|
58 | "prebuild-install": "^2.2.0"
|
---|
59 | },
|
---|
60 | "devDependencies": {
|
---|
61 | "prebuild": "^6.2.1",
|
---|
62 | "prebuild-ci": "^2.2.3"
|
---|
63 | }
|
---|
64 | ```
|
---|
65 |
|
---|
66 | ## Licence
|
---|
67 |
|
---|
68 | Copyright 2017 Lovell Fuller
|
---|
69 |
|
---|
70 | Licensed under the Apache License, Version 2.0 (the "License");
|
---|
71 | you may not use this file except in compliance with the License.
|
---|
72 | You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
---|
73 |
|
---|
74 | Unless required by applicable law or agreed to in writing, software
|
---|
75 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
76 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
77 | See the License for the specific language governing permissions and
|
---|
78 | limitations under the License.
|
---|