feat: fallback to version-less package on apt if not found

This commit is contained in:
Amin Yahyaabadi 2023-05-24 13:18:24 -07:00
parent 455be30e8f
commit a0488f7712
1 changed files with 9 additions and 5 deletions

View File

@ -1,7 +1,5 @@
/* eslint-disable require-atomic-updates */
import { InstallationInfo } from "./setupBin" import { InstallationInfo } from "./setupBin"
import { execRoot, execRootSync } from "admina" import { execRoot, execRootSync } from "admina"
import { info } from "@actions/core"
import { GITHUB_ACTIONS } from "ci-info" import { GITHUB_ACTIONS } from "ci-info"
import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv" import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv"
import which from "which" import which from "which"
@ -10,7 +8,9 @@ import { promises as fsPromises } from "fs"
const { appendFile } = fsPromises const { appendFile } = fsPromises
import { execa } from "execa" import { execa } from "execa"
import escapeRegex from "escape-string-regexp" import escapeRegex from "escape-string-regexp"
import { warning, info } from "ci-log"
/* eslint-disable require-atomic-updates */
let didUpdate: boolean = false let didUpdate: boolean = false
let didInit: boolean = false let didInit: boolean = false
@ -67,11 +67,15 @@ async function getAptArg(name: string, version: string | undefined) {
if (stdout.trim() !== "") { if (stdout.trim() !== "") {
return `${name}-${version}` return `${name}-${version}`
} else { } else {
// check if apt-get show can find the version
const { stdout: showStdout } = await execa("apt-get", ["show", `${name}=${version}`])
if (showStdout.trim() === "") {
return `${name}=${version}` return `${name}=${version}`
} }
} else { warning(`Failed to install ${name} ${version} via apt, trying without version`)
return name
} }
}
return name
} }
function getApt() { function getApt() {