|
1 |
| -# webi-build-classifier |
2 |
| -Determine OS, Vendor, Arch, & Libc from a filename string. |
| 1 | +# Webi's Host & Asset Target Triplet Classifier |
| 2 | + |
| 3 | +Determine Host Target Triplet (Arch, Libc, OS, Vendor) from a filenames / |
| 4 | +download URL and uname / User-Agent strings. |
| 5 | + |
| 6 | +Also compares versions lexicographically. |
| 7 | + |
| 8 | +```json |
| 9 | +{ |
| 10 | + "arch": "aarch64", |
| 11 | + "os": "linux", |
| 12 | + "libc": "none", |
| 13 | + "vendor": "unknown" |
| 14 | +} |
| 15 | +``` |
| 16 | + |
| 17 | +## Table of Contents |
| 18 | + |
| 19 | +- All Targets |
| 20 | +- Host to Target (`uname` to triplet) |
| 21 | +- Lexicographical Versions |
| 22 | +- Build to Target (_filename_ to triplet) |
| 23 | + |
| 24 | +## All Target Options |
| 25 | + |
| 26 | +```json |
| 27 | +{ |
| 28 | + "arches": [ |
| 29 | + "", |
| 30 | + "ANYARCH", |
| 31 | + "POSIX", |
| 32 | + "aarch64", |
| 33 | + "armel", |
| 34 | + "armhf", |
| 35 | + "armv6", |
| 36 | + "armv7", |
| 37 | + "armv7a", |
| 38 | + "loong64", |
| 39 | + "mips", |
| 40 | + "mips64", |
| 41 | + "mips64el", |
| 42 | + "mips64r6", |
| 43 | + "mips64r6el", |
| 44 | + "mipsel", |
| 45 | + "mipsr6", |
| 46 | + "mipsr6el", |
| 47 | + "ppc", |
| 48 | + "ppc64", |
| 49 | + "ppc64le", |
| 50 | + "riscv64", |
| 51 | + "s390x", |
| 52 | + "wasm32", |
| 53 | + "x86", |
| 54 | + "x86_64", |
| 55 | + "x86_64_v2", |
| 56 | + "x86_64_v3" |
| 57 | + ], |
| 58 | + "oses": [ |
| 59 | + "", |
| 60 | + "ANYOS", |
| 61 | + "posix_2017", |
| 62 | + "aix", |
| 63 | + "android", |
| 64 | + "darwin", |
| 65 | + "dragonfly", |
| 66 | + "freebsd", |
| 67 | + "illumos", |
| 68 | + "linux", |
| 69 | + "netbsd", |
| 70 | + "openbsd", |
| 71 | + "plan9", |
| 72 | + "solaris", |
| 73 | + "sunos", |
| 74 | + "wasi", |
| 75 | + "windows" |
| 76 | + ], |
| 77 | + "libcs": ["", "ANYLIBC", "none", "bionic", "gnu", "libc", "msvc", "musl"], |
| 78 | + "vendors": ["", "ANYVENDOR", "apple", "pc", "unknown"] |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +## `require('./build_classifier/host-targets.js')` |
| 83 | + |
| 84 | +```text |
| 85 | +HostTargets.termsToTarget(target, terms) |
| 86 | +// Example: |
| 87 | +// { arch: 'x86_64', os: 'linux', libc: 'musl' } |
| 88 | +``` |
| 89 | + |
| 90 | +**Don't rely on these** as part of the API, but they're available to inspect. |
| 91 | + |
| 92 | +(they're used for matching _uname_ and _User-Agent_ values to target triplets) |
| 93 | + |
| 94 | +```text |
| 95 | +HostTargets.WATERFALL // { darwin: { aarch64: ['aarch64', 'x86_64'] } } |
| 96 | +HostTargets.TERMS // { amd64: { arch: 'x86_64' } } |
| 97 | +``` |
| 98 | + |
| 99 | +## `require('./build_classifier/lexver.js')` |
| 100 | + |
| 101 | +Turns versions in just about any format into a Lexicographically Sorted version. |
| 102 | + |
| 103 | +```text |
| 104 | +Lexver.matchSorted(versions, prefix) // v1 => v0001 matches v0001.0000.0000@ |
| 105 | +Lexver.toTags(lexvers) // sorts and calls sortedToTags |
| 106 | +Lexver.sortedToTags(descLexvers) // gets { latest, stable, default } |
| 107 | +Lexver.parseVersion(fullVersion) // 'v1-beta1' => 'v0001.0000.0000-beta-0001' |
| 108 | +Lexver.parsePrefix(version) // v1 => v0001 |
| 109 | +``` |
| 110 | + |
| 111 | +## `require('./build_classifier/triplet.js')` |
| 112 | + |
| 113 | +Turns a filename or URL, along with project and release info, into a target |
| 114 | +triplet. |
| 115 | + |
| 116 | +```text |
| 117 | +Triplet.maybeInstallable(proj, build); // exclude non-build assets |
| 118 | +Triplet.toPattern(proj, build); // foo-1.0.0-mac64 => {NAME}-{VER}-mac64 |
| 119 | +Triplet.patternToTerms(filename); // {NAME}-mac-x86.64 => [ 'mac', 'x86_64' ] |
| 120 | +Triplet.termsToTarget( |
| 121 | + target, proj, build, terms // => 'x86_64_v2-pc-windows-msvc' |
| 122 | +); |
| 123 | +Triplet.buildToPackageType(build); // uses 'build.name' or 'build.download' |
| 124 | +Triplet.filenameToPackageType(filename); // ex: '.zip', '.app.zip', '.tar.gz', '' |
| 125 | +``` |
| 126 | + |
| 127 | +**Don't rely on these** as part of the API, but they're available to inspect. |
| 128 | + |
| 129 | +(they're used for excluding and classifying release assets) |
| 130 | + |
| 131 | +```text |
| 132 | +Triplet.TERMS_CHANNEL // [ 'master', 'nightly', '...' ] |
| 133 | +Triplet.TERMS_CHECKSUM // [ 'MD5SUMS', 'SHA1SUMS', '...' ] |
| 134 | +Triplet.TERMS_EXTS_NON_BUILD // [ '.asc', '.json', '.sha1', '...' ] |
| 135 | +Triplet.TERMS_EXTS_NON_INFORMATIVE // [ '.gz', '.zip', '...', '.tar' ] |
| 136 | +Triplet.TERMS_EXTS_PKG // [ '.exe', '.tar', '.dmg', '...' ] |
| 137 | +Triplet.TERMS_EXTS_SOURCE // [ '.zip', '.tar.gz', '...' ] |
| 138 | +Triplet.TERMS_EXTS_ZIP // [ '.gz', '.xz', '.zip', '...' ] |
| 139 | +Triplet.TERMS_NON_BUILD // [ 'debug', 'src', 'vendor', '...' ] |
| 140 | +Triplet.TERMS_PRIMARY_MAP // { 'APPLE_AARCH64': { /* ... */ } } |
| 141 | +Triplet.TERMS_TIERED_MAPS // [ { 'gnu': { os: 'windows' } ] |
| 142 | +``` |
0 commit comments