From a0488f77127ef40b2040fd8e596f81d52c0dd991 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 24 May 2023 13:18:24 -0700 Subject: [PATCH] feat: fallback to version-less package on apt if not found --- src/utils/setup/setupAptPack.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/utils/setup/setupAptPack.ts b/src/utils/setup/setupAptPack.ts index 196d9456..164246c2 100644 --- a/src/utils/setup/setupAptPack.ts +++ b/src/utils/setup/setupAptPack.ts @@ -1,7 +1,5 @@ -/* eslint-disable require-atomic-updates */ import { InstallationInfo } from "./setupBin" import { execRoot, execRootSync } from "admina" -import { info } from "@actions/core" import { GITHUB_ACTIONS } from "ci-info" import { addEnv, cpprc_path, setupCppInProfile } from "../env/addEnv" import which from "which" @@ -10,7 +8,9 @@ import { promises as fsPromises } from "fs" const { appendFile } = fsPromises import { execa } from "execa" import escapeRegex from "escape-string-regexp" +import { warning, info } from "ci-log" +/* eslint-disable require-atomic-updates */ let didUpdate: boolean = false let didInit: boolean = false @@ -67,11 +67,15 @@ async function getAptArg(name: string, version: string | undefined) { if (stdout.trim() !== "") { return `${name}-${version}` } else { - return `${name}=${version}` + // 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}` + } + warning(`Failed to install ${name} ${version} via apt, trying without version`) } - } else { - return name } + return name } function getApt() {