mirror of https://github.com/aminya/setup-cpp
Merge pull request #312 from aminya/update-versions [skip ci]
This commit is contained in:
commit
75454f9c75
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
{"ninja":"1.12.1","cmake":"3.30.4","task":"3.39.2","powershell":"7.4.5","pip":">=22.2.0","python":">=3.7.9","meson":{"linux":{"ubuntu":{"20":"1.5.2","18":"0.61.4","else":"0.61.4"},"else":"1.5.2"},"else":"1.5.2"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.12.0-2","ubuntu":{"22":"1.12.0","18":"1.10.0","else":"1.10.0"},"else":"1.12.0"},"else":"1.12.0"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","linux":{"ubuntu":{"22":"8.0.0-1","20":"7.0.0-2","else":"7.0.0-2"},"else":""},"else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"},"else":""},"else":""},"nala":{"linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"},"else":""},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"}}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
{"ninja":"1.12.1","cmake":"3.30.4","task":"3.39.2","powershell":"7.4.5","pip":">=22.2.0","python":">=3.7.9","meson":{"linux":{"ubuntu":{"20":"1.5.2","18":"0.61.4","else":"0.61.4"},"else":"1.5.2"},"else":"1.5.2"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.12.0-2","ubuntu":{"22":"1.12.0","18":"1.10.0","else":"1.10.0"},"else":"1.12.0"},"else":"1.12.0"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","linux":{"ubuntu":{"22":"8.0.0-1","20":"7.0.0-2","else":"7.0.0-2"},"else":""},"else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"},"else":""},"else":""},"nala":{"linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"},"else":""},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"}}
|
|
@ -1,7 +1,6 @@
|
|||
import { parseArgs } from "../cli-options.js"
|
||||
import { getCompilerInfo } from "../compilers.js"
|
||||
import { type Inputs, llvmTools } from "../tool.js"
|
||||
import { DefaultUbuntuVersion, DefaultVersions } from "../versions/default_versions.js"
|
||||
import { getVersion, syncVersions } from "../versions/versions.js"
|
||||
|
||||
jest.setTimeout(300000)
|
||||
|
@ -90,18 +89,13 @@ describe("getVersion", () => {
|
|||
it("gcovr", () => {
|
||||
expect(getVersion("gcovr", "5.0")).toBe("5.0")
|
||||
if (process.platform === "linux") {
|
||||
expect(getVersion("gcovr", "true", [22, 4])).toBe(DefaultUbuntuVersion.gcovr![22])
|
||||
expect(getVersion("gcovr", "true", [20, 4])).toBe(DefaultUbuntuVersion.gcovr![20])
|
||||
expect(getVersion("gcovr", "true", [18, 4])).toBe(DefaultUbuntuVersion.gcovr![18])
|
||||
expect(getVersion("gcovr", "true", [22, 4])).toBe("")
|
||||
expect(getVersion("gcovr", "true", [20, 4])).toBe("")
|
||||
expect(getVersion("gcovr", "true", [18, 4])).toBe("5.0")
|
||||
}
|
||||
})
|
||||
|
||||
it("llvm", () => {
|
||||
expect(getVersion("llvm", "13.0.0")).toBe("13.0.0")
|
||||
if (process.platform === "linux") {
|
||||
expect(getVersion("llvm", "true", [20, 4])).toBe(DefaultVersions.llvm)
|
||||
expect(getVersion("llvm", "true", [18, 4])).toBe(DefaultVersions.llvm)
|
||||
expect(getVersion("llvm", "true", [16, 4])).toBe(DefaultVersions.llvm)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -25,7 +25,7 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
|
|||
import { hasPipx, setupPipPackSystem, setupPipPackWithPython } from "../utils/setup/setupPipPack.js"
|
||||
import { isBinUptoDate } from "../utils/setup/version.js"
|
||||
import { unique } from "../utils/std/index.js"
|
||||
import { MinVersions } from "../versions/default_versions.js"
|
||||
import { getVersionDefault, isMinVersion } from "../versions/versions.js"
|
||||
|
||||
export async function setupPython(
|
||||
version: string,
|
||||
|
@ -89,7 +89,10 @@ async function setupWheel(foundPython: string) {
|
|||
}
|
||||
}
|
||||
|
||||
async function findOrSetupPython(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||
async function findOrSetupPython(givenVersion: string, setupDir: string, arch: string): Promise<InstallationInfo> {
|
||||
// if a version range specified, use the default version, and later check the range
|
||||
const version = isMinVersion(givenVersion) ? "" : givenVersion
|
||||
|
||||
let installInfo: InstallationInfo | undefined
|
||||
let foundPython = await findPython(setupDir)
|
||||
|
||||
|
@ -214,9 +217,11 @@ async function findPython(binDir?: string) {
|
|||
|
||||
async function isPythonUpToDate(candidate: string, binDir?: string) {
|
||||
try {
|
||||
const targetVersion = getVersionDefault("python")
|
||||
|
||||
if (binDir !== undefined) {
|
||||
const pythonBinPath = join(binDir, addExeExt(candidate))
|
||||
if (await pathExists(pythonBinPath) && await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
|
||||
if (await pathExists(pythonBinPath) && await isBinUptoDate(pythonBinPath, targetVersion!)) {
|
||||
return pythonBinPath
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +229,7 @@ async function isPythonUpToDate(candidate: string, binDir?: string) {
|
|||
const pythonBinPaths = (await which(candidate, { nothrow: true, all: true })) ?? []
|
||||
for (const pythonBinPath of pythonBinPaths) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
|
||||
if (await isBinUptoDate(pythonBinPath, targetVersion!)) {
|
||||
return pythonBinPath
|
||||
}
|
||||
}
|
||||
|
@ -260,11 +265,13 @@ async function findPip() {
|
|||
|
||||
async function isPipUptoDate(pip: string) {
|
||||
try {
|
||||
const targetVersion = getVersionDefault("pip")
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
const pipPaths = (await which(pip, { nothrow: true, all: true })) ?? []
|
||||
for (const pipPath of pipPaths) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (await isBinUptoDate(pipPath, MinVersions.pip!)) {
|
||||
if (await isBinUptoDate(pipPath, targetVersion!)) {
|
||||
return pipPath
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import { info } from "ci-log"
|
|||
import { isUrlOnline } from "is-url-online"
|
||||
import semverCoerce from "semver/functions/coerce"
|
||||
import semverCompare from "semver/functions/compare"
|
||||
import semverSatisfies from "semver/functions/satisfies"
|
||||
import semverValid from "semver/functions/valid"
|
||||
|
||||
/**
|
||||
|
@ -112,7 +113,15 @@ export async function isBinUptoDate(
|
|||
) {
|
||||
const givenVersion = await getBinVersion(givenFile, versionRegex)
|
||||
if (givenVersion !== undefined && targetVersion !== "") {
|
||||
try {
|
||||
// if -1, it means the given version is newer than the target version
|
||||
// this requires the target version to be a valid semver range
|
||||
return semverCompare(givenVersion, targetVersion) !== -1
|
||||
} catch {
|
||||
// check if the given version satisfies the target version
|
||||
// this works even if the target version is not a valid semver range (e.g. >=1.2.3)
|
||||
return semverSatisfies(givenVersion, targetVersion)
|
||||
}
|
||||
} else {
|
||||
// assume given version is old
|
||||
return false
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
import { isArch } from "../utils/env/isArch.js"
|
||||
|
||||
const defaultLLVM = process.platform === "darwin" && process.arch === "x64"
|
||||
? "15.0.7"
|
||||
: "18.1.8"
|
||||
|
||||
/**
|
||||
* Default versions for the tools
|
||||
* DefaultUbuntuVersion overrides the default version for the tools on Ubuntu
|
||||
*/
|
||||
export const DefaultVersions: Record<string, string | undefined> = {
|
||||
// https://github.com/llvm/llvm-project/releases
|
||||
llvm: defaultLLVM,
|
||||
clang: defaultLLVM,
|
||||
"clang++": defaultLLVM,
|
||||
"clang-tidy": defaultLLVM,
|
||||
clangtidy: defaultLLVM,
|
||||
"clang-format": defaultLLVM,
|
||||
clangformat: defaultLLVM,
|
||||
ninja: "1.12.1", // https://github.com/ninja-build/ninja/releases
|
||||
cmake: "3.30.4", // https://github.com/Kitware/CMake/releases
|
||||
meson: "1.5.2", // https://github.com/mesonbuild/meson/releases
|
||||
kcov: "42", // https://github.com/SimonKagstrom/kcov/releases
|
||||
task: "3.39.2", // https://github.com/go-task/task/releases
|
||||
doxygen: isArch() ? "1.12.0-2" : "1.12.0", // https://www.doxygen.nl/download.html // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen // https://formulae.brew.sh/formula/doxygen // https://archlinux.org/packages/extra/x86_64/doxygen/
|
||||
gcc: process.platform === "win32"
|
||||
? "14.2.0posix-18.1.8-12.0.0-ucrt-r1"
|
||||
: "", // use the default version on Ubuntu, Fedora, Arch, macOS, etc.
|
||||
// mingw: isArch() ? "12.2.0-1" : "8", // https://archlinux.org/packages/extra/x86_64/mingw-w64-gcc/
|
||||
powershell: "7.4.5",
|
||||
}
|
||||
|
||||
export const MinVersions: Record<string, string | undefined> = {
|
||||
pip: "22.2.0",
|
||||
python: "3.7.9",
|
||||
}
|
||||
|
||||
/// If an ubuntu versions is not in this map:
|
||||
// - the newer ubuntu versions use the first entry (e.g. v20),
|
||||
// - the older ones use ""
|
||||
export const DefaultUbuntuVersion: Record<string, Record<number, string> | undefined> = {
|
||||
// https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=mingw-w64
|
||||
mingw: {
|
||||
24: "8.0.0-1",
|
||||
22: "8.0.0-1",
|
||||
20: "7.0.0-2",
|
||||
},
|
||||
gcovr: {
|
||||
24: "6.0",
|
||||
22: "6.0",
|
||||
20: "6.0",
|
||||
18: "5.0",
|
||||
},
|
||||
meson: {
|
||||
24: "1.0.0",
|
||||
22: "1.0.0",
|
||||
20: "1.0.0",
|
||||
18: "0.61.4",
|
||||
},
|
||||
nala: {
|
||||
24: "",
|
||||
22: "",
|
||||
21: "legacy",
|
||||
20: "legacy",
|
||||
18: "legacy",
|
||||
16: "legacy",
|
||||
14: "legacy",
|
||||
},
|
||||
kcov: {
|
||||
24: "42-binary",
|
||||
22: "42-binary",
|
||||
20: "40-binary", // https://github.com/SimonKagstrom/kcov/releases
|
||||
18: "40",
|
||||
16: "40",
|
||||
14: "40",
|
||||
},
|
||||
doxygen: {
|
||||
24: "1.11.0",
|
||||
22: "1.11.0",
|
||||
20: "1.10.0",
|
||||
18: "1.10.0",
|
||||
},
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
{
|
||||
"ninja": "1.12.1",
|
||||
"cmake": "3.30.4",
|
||||
"task": "3.39.2",
|
||||
"powershell": "7.4.5",
|
||||
"pip": ">=22.2.0",
|
||||
"python": ">=3.7.9",
|
||||
"meson": {
|
||||
"linux": {
|
||||
"ubuntu": {
|
||||
"20": "1.5.2",
|
||||
"18": "0.61.4",
|
||||
"else": "0.61.4"
|
||||
},
|
||||
"else": "1.5.2"
|
||||
},
|
||||
"else": "1.5.2"
|
||||
},
|
||||
"kcov": {
|
||||
"linux": {
|
||||
"ubuntu": {
|
||||
"22": "42-binary",
|
||||
"20": "40-binary",
|
||||
"14": "40",
|
||||
"else": "42"
|
||||
},
|
||||
"else": "42"
|
||||
},
|
||||
"else": "42"
|
||||
},
|
||||
"doxygen": {
|
||||
"linux": {
|
||||
"archlinux": "1.12.0-2",
|
||||
"ubuntu": {
|
||||
"22": "1.12.0",
|
||||
"18": "1.10.0",
|
||||
"else": "1.10.0"
|
||||
},
|
||||
"else": "1.12.0"
|
||||
},
|
||||
"else": "1.12.0"
|
||||
},
|
||||
"gcc": {
|
||||
"win32": "14.2.0posix-18.1.8-12.0.0-ucrt-r1",
|
||||
"else": ""
|
||||
},
|
||||
"mingw": {
|
||||
"win32": "14.2.0posix-18.1.8-12.0.0-ucrt-r1",
|
||||
"linux": {
|
||||
"ubuntu": {
|
||||
"22": "8.0.0-1",
|
||||
"20": "7.0.0-2",
|
||||
"else": "7.0.0-2"
|
||||
},
|
||||
"else": ""
|
||||
},
|
||||
"else": ""
|
||||
},
|
||||
"gcovr": {
|
||||
"linux": {
|
||||
"ubuntu": {
|
||||
"20": "",
|
||||
"18": "5.0",
|
||||
"else": "5.0"
|
||||
},
|
||||
"else": ""
|
||||
},
|
||||
"else": ""
|
||||
},
|
||||
"nala": {
|
||||
"linux": {
|
||||
"ubuntu": {
|
||||
"22": "",
|
||||
"21": "legacy",
|
||||
"else": "legacy"
|
||||
},
|
||||
"else": ""
|
||||
},
|
||||
"else": ""
|
||||
},
|
||||
"llvm": {
|
||||
"darwin": {
|
||||
"else": {
|
||||
"else": {
|
||||
"x64": "15.0.7",
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": "18.1.8"
|
||||
},
|
||||
"clang": {
|
||||
"darwin": {
|
||||
"else": {
|
||||
"else": {
|
||||
"x64": "15.0.7",
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": "18.1.8"
|
||||
},
|
||||
"clang++": {
|
||||
"darwin": {
|
||||
"else": {
|
||||
"else": {
|
||||
"x64": "15.0.7",
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": "18.1.8"
|
||||
},
|
||||
"clang-tidy": {
|
||||
"darwin": {
|
||||
"else": {
|
||||
"else": {
|
||||
"x64": "15.0.7",
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": "18.1.8"
|
||||
},
|
||||
"clangtidy": {
|
||||
"darwin": {
|
||||
"else": {
|
||||
"else": {
|
||||
"x64": "15.0.7",
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": "18.1.8"
|
||||
},
|
||||
"clang-format": {
|
||||
"darwin": {
|
||||
"else": {
|
||||
"else": {
|
||||
"x64": "15.0.7",
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": "18.1.8"
|
||||
},
|
||||
"clangformat": {
|
||||
"darwin": {
|
||||
"else": {
|
||||
"else": {
|
||||
"x64": "15.0.7",
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": "18.1.8"
|
||||
}
|
||||
}
|
|
@ -1,37 +1,116 @@
|
|||
import fs from "fs"
|
||||
import path from "path"
|
||||
import { fileURLToPath } from "url"
|
||||
import memoize from "memoizee"
|
||||
import type { Opts } from "../cli-options.js"
|
||||
import type { CompilerInfo } from "../compilers.js"
|
||||
import type { Inputs } from "../tool.js"
|
||||
import { DefaultUbuntuVersion, DefaultVersions } from "./default_versions.js"
|
||||
import type { Inputs, ToolName } from "../tool.js"
|
||||
import { isArch } from "../utils/env/isArch.js"
|
||||
import { isUbuntu } from "../utils/env/isUbuntu.js"
|
||||
|
||||
export function getVersion(name: ToolName, version: string | undefined, distroVersion: number[] | null = null) {
|
||||
if (isVersionDefault(version)) {
|
||||
return getVersionDefault(name, distroVersion) ?? ""
|
||||
}
|
||||
|
||||
return version
|
||||
}
|
||||
|
||||
type ArchVersionMap = Record<NodeJS.Architecture | "else", string | undefined>
|
||||
type DistroVersionMap = Record<
|
||||
`${number}` | `${number}.${number}` | `${number}.${number}.${number}` | string | "else",
|
||||
ArchVersionMap | string | undefined
|
||||
>
|
||||
type DistroMap = Record<"ubuntu" | "archlinux" | string | "else", DistroVersionMap | string | undefined>
|
||||
type PlatformMap = Record<NodeJS.Platform | "else", DistroMap | string | undefined>
|
||||
type Versions = Record<ToolName | "pip", PlatformMap | string | undefined>
|
||||
|
||||
function readVersions_(): Versions {
|
||||
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const jsonPath = path.join(dirname, "versions.json")
|
||||
return JSON.parse(fs.readFileSync(jsonPath, "utf-8")) as Versions
|
||||
}
|
||||
const readVersions = memoize(readVersions_)
|
||||
|
||||
/** Get the default version if passed true or undefined, otherwise return the version itself */
|
||||
export function getVersion(name: string, version: string | undefined, osVersion: number[] | null = null) {
|
||||
if (isVersionDefault(version) && process.platform === "linux" && osVersion !== null && name in DefaultUbuntuVersion) {
|
||||
return getDefaultLinuxVersion(osVersion, DefaultUbuntuVersion[name]!)
|
||||
} else if (isVersionDefault(version) && name in DefaultVersions) {
|
||||
return DefaultVersions[name] ?? ""
|
||||
} else if (version === "true") {
|
||||
return ""
|
||||
export function getVersionDefault(
|
||||
tool: ToolName | "pip",
|
||||
distroVersion: number[] | null = null,
|
||||
): string | undefined {
|
||||
// get the tool
|
||||
const versions = readVersions()
|
||||
const platformMapOrVersion = versions[tool]
|
||||
if (platformMapOrVersion === undefined) {
|
||||
return undefined // no default version for this tool
|
||||
}
|
||||
return version ?? ""
|
||||
// platform-independent versions
|
||||
if (typeof platformMapOrVersion === "string") {
|
||||
return platformMapOrVersion
|
||||
}
|
||||
const platformMap = platformMapOrVersion
|
||||
|
||||
// Check for platform-specific versions
|
||||
const distroMapOrVersion = platformMap[process.platform] ?? platformMap.else
|
||||
if (distroMapOrVersion === undefined) {
|
||||
throw new Error(`Platform "${process.platform}" not found in versions data for tool "${tool}"`)
|
||||
}
|
||||
// distro-independent versions
|
||||
if (typeof distroMapOrVersion === "string") {
|
||||
return distroMapOrVersion
|
||||
}
|
||||
const distroMap = distroMapOrVersion
|
||||
|
||||
// check for distro-specific versions
|
||||
const distro = isUbuntu() ? "ubuntu" : isArch() ? "archlinux" : "else"
|
||||
const distroVersionMapOrVersion = distroMap[distro] ?? distroMap.else
|
||||
if (distroVersionMapOrVersion === undefined) {
|
||||
throw new Error(`Distro "${distro}" not found in versions data for tool "${tool}"`)
|
||||
}
|
||||
|
||||
// distro version independent versions
|
||||
if (typeof distroVersionMapOrVersion === "string") {
|
||||
return distroVersionMapOrVersion
|
||||
}
|
||||
const distroVersionMap = distroVersionMapOrVersion
|
||||
|
||||
// check for the distro-specific version for the current architecture
|
||||
const archVersionMapOrVersion = distroVersion !== null
|
||||
? matchDistroVersion(distroVersion, distroVersionMap)
|
||||
: distroVersionMap.else
|
||||
if (archVersionMapOrVersion === undefined) {
|
||||
throw new Error(`Architecture "${process.arch}" not found in versions data for tool "${tool}"`)
|
||||
}
|
||||
if (typeof archVersionMapOrVersion === "string") {
|
||||
return archVersionMapOrVersion
|
||||
}
|
||||
const archVersionMap = archVersionMapOrVersion
|
||||
|
||||
// get the version for the current architecture
|
||||
return archVersionMap[process.arch] ?? archVersionMap.else
|
||||
}
|
||||
|
||||
/// choose the default linux version based on ubuntu version
|
||||
function matchDistroVersion(distroVersion: number[], distroVersionMap: DistroVersionMap) {
|
||||
const distroVersionMaj = distroVersion[0]
|
||||
|
||||
// find which version block the os version is in
|
||||
const satisfyingVersion = Object.keys(distroVersionMap)
|
||||
.map((v) => Number.parseInt(v, 10))
|
||||
.filter((v) => !Number.isNaN(v))
|
||||
.sort((a, b) => b - a) // sort in descending order
|
||||
.find((v) => distroVersionMaj >= v)
|
||||
|
||||
return satisfyingVersion !== undefined
|
||||
? distroVersionMap[satisfyingVersion]
|
||||
?? distroVersionMap.else
|
||||
: distroVersionMap.else
|
||||
}
|
||||
|
||||
function isVersionDefault(version: string | undefined) {
|
||||
return version === "true" || version === undefined
|
||||
}
|
||||
|
||||
/// choose the default linux version based on ubuntu version
|
||||
function getDefaultLinuxVersion(osVersion: number[], toolLinuxVersions: Record<number, string>) {
|
||||
const osVersionMaj = osVersion[0]
|
||||
|
||||
// find which version block the os version is in
|
||||
const satisfyingVersion = Object.keys(toolLinuxVersions)
|
||||
.map((v) => Number.parseInt(v, 10))
|
||||
.sort((a, b) => b - a) // sort in descending order
|
||||
.find((v) => osVersionMaj >= v)
|
||||
|
||||
return satisfyingVersion === undefined ? "" : toolLinuxVersions[satisfyingVersion]
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync the versions for the given inputs
|
||||
*
|
||||
|
@ -92,3 +171,7 @@ export function syncVersions(
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
export function isMinVersion(version: string) {
|
||||
return version.startsWith(">")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue