fix: fix: dnf search

This commit is contained in:
Amin Yahyaabadi 2023-07-16 23:42:25 -07:00
parent 41b2cf629a
commit 9fa897444d
7 changed files with 15 additions and 8 deletions

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@ import { execRootSync } from "admina"
import { info, warning } from "ci-log"
import { execa } from "execa"
export type DnfPackage = {
type DnfPackage = {
name: string
version?: string
}
@ -23,11 +23,18 @@ export async function setupDnfPack(packages: DnfPackage[]): Promise<Installation
async function getDnfArg(name: string, version: string | undefined) {
if (version !== undefined && version !== "") {
// check if name-version is available
const { stdout } = await execa("dnf", ["search", `${name}-${version}`, "--exact", "--quiet"])
const { stdout } = await execa("dnf", ["search", "-q", `${name}-${version}`])
if (stdout.trim() !== "") {
return `${name}-${version}`
} else {
// try with ${name}${version}
// eslint-disable-next-line @typescript-eslint/no-shadow
const { stdout } = await execa("dnf", ["search", "-q", `${name}${version}`])
if (stdout.trim() !== "") {
return `${name}${version}`
}
warning(`Failed to install ${name} ${version} via dnf, trying without version`)
}
}