262176ea26891f7cf7970ad86977acd14a05b95de0292eaf46adcd3414eac9b9d9918dbadab31b92755cbc9eff5c2e7918f62f649c58c73b45342eb1ecc89b 2.4 KB

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