Author vstinner
Recipients gregory.p.smith, izbyshev, koobs, nanjekyejoannah, pablogsal, pitrou, serhiy.storchaka, vstinner
Date 2019-01-15.10:04:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547546646.93.0.99566067649.issue35537@roundup.psfhosted.org>
In-reply-to
Content
If someone wants to implement a runtime check for musl, here is an heuristic based on ldd output and libc filenames:

https://github.com/lovell/detect-libc/blob/master/lib/detect-libc.js

var GLIBC = 'glibc';
var MUSL = 'musl';

    // Try ldd
    var ldd = spawnSync('ldd', ['--version'], spawnOptions);
    if (ldd.status === 0 && ldd.stdout.indexOf(MUSL) !== -1) {
      family = MUSL;
      version = versionFromMuslLdd(ldd.stdout);
      method = 'ldd';
    } else if (ldd.status === 1 && ldd.stderr.indexOf(MUSL) !== -1) {
      family = MUSL;
      version = versionFromMuslLdd(ldd.stderr);
      method = 'ldd';
    } else {
      // Try filesystem (family only)
      var lib = safeReaddirSync('/lib');
      if (lib.some(contains('-linux-gnu'))) {
        family = GLIBC;
        method = 'filesystem';
      } else if (lib.some(contains('libc.musl-'))) {
        family = MUSL;
        method = 'filesystem';
      } else if (lib.some(contains('ld-musl-'))) {
        family = MUSL;
        method = 'filesystem';
      } else {
        var usrSbin = safeReaddirSync('/usr/sbin');
        if (usrSbin.some(contains('glibc'))) {
          family = GLIBC;
          method = 'filesystem';
        }
      }
}
History
Date User Action Args
2019-01-15 10:04:08vstinnersetrecipients: + vstinner, gregory.p.smith, pitrou, serhiy.storchaka, koobs, izbyshev, pablogsal, nanjekyejoannah
2019-01-15 10:04:06vstinnersetmessageid: <1547546646.93.0.99566067649.issue35537@roundup.psfhosted.org>
2019-01-15 10:04:06vstinnerlinkissue35537 messages
2019-01-15 10:04:06vstinnercreate