Merge pull request #100 from aminya/fedora [skip ci]

This commit is contained in:
Amin Yahyaabadi 2022-07-10 19:20:33 -07:00 committed by GitHub
commit a910f0daaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 251 additions and 92 deletions

View File

@ -92,6 +92,7 @@ jobs:
- "ubuntu_node.dockerfile"
- "ubuntu_20.04_node.dockerfile"
- "arch_node.dockerfile"
- "fedora_node.dockerfile"
node:
- 14
pnpm:

View File

@ -2,20 +2,13 @@
FROM archlinux as base
RUN pacman -Syuu --noconfirm
RUN pacman-db-upgrade
# Install packages available from standard repos
RUN pacman-db-upgrade && \
pacman -S --noconfirm --needed \
wget curl pkg-config zip unzip tar git && \
pacman -S --noconfirm \
nodejs && \
pacman -Scc --noconfirm
# nodejs
RUN pacman -S --noconfirm --needed nodejs
# install yay
#RUN useradd -m -G nobody -s /bin/bash yay && passwd -d yay && echo "yay ALL=(ALL) ALL" >> /etc/sudoers
#RUN git clone --depth 1 https://aur.archlinux.org/yay.git /opt/yay && cd /opt/yay && \
# chown -R yay:root . && chmod -R 775 . && \
# runuser -l yay -c "cd /opt/yay && makepkg -si --noprogressbar --noconfirm"
# curl for downloading setup-cpp
RUN pacman -S --noconfirm --needed curl
# add setup_cpp.js
COPY "./dist/" "/"
@ -26,7 +19,6 @@ RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck tru
# clean up
RUN pacman -Scc --noconfirm
#RUN rm -rf /home/yay/.cache/*
RUN rm -rf /tmp/*
CMD source ~/.cpprc

View File

@ -0,0 +1,36 @@
## base image
FROM fedora as base
# nodejs
RUN dnf -y install nodejs
# curl for downloading setup-cpp
RUN dnf -y install curl
# add setup_cpp.js
COPY "./dist/" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
# clean up
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

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

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.mjs vendored

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,6 +3,9 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupCcache(version: string, _setupDir: string, _arch: string) {
@ -16,8 +19,12 @@ export function setupCcache(version: string, _setupDir: string, _arch: string) {
case "linux": {
if (isArch()) {
return setupPacmanPack("ccache", version)
} else if (hasDnf()) {
return setupDnfPack("ccache", version)
} else if (isUbuntu()) {
return setupAptPack("ccache", version)
}
return setupAptPack("ccache", version)
throw new Error(`Unsupported linux distribution`)
}
default: {
throw new Error(`Unsupported platform`)

View File

@ -1,6 +1,6 @@
import { setupCmake } from "../cmake"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { isGitHubCI } from "../../utils/env/isci"
import { isGitHubCI } from "../../utils/env/isCI"
import { getVersion } from "../../default_versions"
jest.setTimeout(300000)

View File

@ -4,6 +4,9 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupCppcheck(version: string | undefined, _setupDir: string, _arch: string) {
@ -19,8 +22,12 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
case "linux": {
if (isArch()) {
return setupPacmanPack("cppcheck", version)
} else if (hasDnf()) {
return setupDnfPack("ccache", version)
} else if (isUbuntu()) {
return setupAptPack("cppcheck", version)
}
return setupAptPack("cppcheck", version)
throw new Error(`Unsupported linux distribution`)
}
default: {
throw new Error(`Unsupported platform`)

View File

@ -12,6 +12,9 @@ import { getVersion } from "../default_versions"
import { existsSync } from "fs"
import { join } from "path"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
/** Get the platform data for cmake */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -58,25 +61,27 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
}
case "linux": {
let installationInfo: InstallationInfo
if (version === "") {
if (version === "" || isArch() || hasDnf()) {
if (isArch()) {
installationInfo = setupPacmanPack("doxygen", undefined)
installationInfo = setupPacmanPack("doxygen", version)
} else if (hasDnf()) {
return setupDnfPack("doxygen", version)
} else if (isUbuntu()) {
installationInfo = setupAptPack("doxygen", version)
} else {
throw new Error(`Unsupported linux distributions`)
}
} else if (isUbuntu()) {
try {
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
setupAptPack("libclang-cpp9")
} catch (err) {
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
installationInfo = setupAptPack("doxygen", undefined)
}
} else {
if (isArch()) {
installationInfo = setupPacmanPack("doxygen", version)
} else {
try {
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
setupAptPack("libclang-cpp9")
} catch (err) {
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
installationInfo = setupAptPack("doxygen", undefined)
}
}
throw new Error(`Unsupported linux distributions`)
}
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
return installationInfo

View File

@ -9,12 +9,14 @@ import semverCoerce from "semver/functions/coerce"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
import path from "path"
import { warning, info } from "../utils/io/io"
import { isGitHubCI } from "../utils/env/isci"
import { isGitHubCI } from "../utils/env/isCI"
import { addBinExtension } from "../utils/extension/extension"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { extract7Zip } from "../utils/setup/extract"
import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
interface MingwInfo {
releaseName: string
@ -84,7 +86,11 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
if (arch === "x64") {
if (isArch()) {
installationInfo = setupPacmanPack("gcc", version)
} else {
} else if (hasDnf()) {
installationInfo = setupDnfPack("gcc", version)
setupDnfPack("gcc-c++", version)
setupDnfPack("libstdc++-devel", undefined)
} else if (isUbuntu()) {
setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
installationInfo = setupAptPack("g++", version, [])
}
@ -92,7 +98,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
info(`Install g++-multilib because gcc for ${arch} was requested`)
if (isArch()) {
setupPacmanPack("gcc-multilib", version)
} else {
} else if (isUbuntu()) {
setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
}
}

View File

@ -5,6 +5,9 @@ import { InstallationInfo } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupGraphviz(version: string, _setupDir: string, _arch: string) {
@ -19,8 +22,12 @@ export async function setupGraphviz(version: string, _setupDir: string, _arch: s
case "linux": {
if (isArch()) {
return setupPacmanPack("graphviz", version)
} else if (hasDnf()) {
return setupDnfPack("graphviz", version)
} else if (isUbuntu()) {
return setupAptPack("graphviz", version)
}
return setupAptPack("graphviz", version)
throw new Error(`Unsupported linux distribution`)
}
default: {
throw new Error(`Unsupported platform`)

View File

@ -11,6 +11,9 @@ import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
function getKcovPackageInfo(version: string): PackageInfo {
const version_number = parseInt(version.replace(/^v/, ""), 10)
@ -47,7 +50,10 @@ async function buildKcov(file: string, dest: string) {
if (isArch()) {
setupPacmanPack("libdwarf")
setupPacmanPack("libcurl-openssl")
} else {
} else if (hasDnf()) {
setupDnfPack("libdwarf-devel")
setupDnfPack("libcurl-devel")
} else if (isUbuntu()) {
setupAptPack("libdw-dev")
setupAptPack("libcurl4-openssl-dev")
}
@ -61,14 +67,14 @@ async function buildKcov(file: string, dest: string) {
export async function setupKcov(version: string, setupDir: string, arch: string) {
switch (process.platform) {
case "linux": {
if (isArch()) {
// TODO install kcov ? setupPacmanPack("kcov")
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir, arch)
setupPacmanPack("binutils")
return installationInfo
}
const installationInfo = await setupBin("kcov", version, getKcovPackageInfo, setupDir, arch)
setupAptPack("libbinutils")
if (isArch()) {
setupPacmanPack("binutils")
} else if (hasDnf()) {
setupDnfPack("binutils")
} else if (isUbuntu()) {
setupAptPack("libbinutils")
}
return installationInfo
}
default: {

View File

@ -2,7 +2,7 @@ import { setupLLVM, VERSIONS, getUrl, setupClangTools, getLinuxUrl } from "../ll
import { getSpecificVersionAndUrl } from "../../utils/setup/version"
import { isValidUrl } from "../../utils/http/validate_url"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { isGitHubCI } from "../../utils/env/isci"
import { isGitHubCI } from "../../utils/env/isCI"
import execa from "execa"
import path from "path"
import { addBinExtension } from "../../utils/extension/extension"

View File

@ -17,7 +17,7 @@ import { setOutput } from "@actions/core"
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
import { info, warning } from "../utils/io/io"
import { existsSync } from "fs"
import { isGitHubCI } from "../utils/env/isci"
import { isGitHubCI } from "../utils/env/isCI"
import { setupGcc } from "../gcc/gcc"
import { getVersion } from "../default_versions"
import { isArch } from "../utils/env/isArch"
@ -290,7 +290,7 @@ async function _setupLLVM(version: string, setupDir: string, arch: string) {
if (isArch()) {
// setupPacmanPack("ncurses")
// TODO: install libtinfo ?
} else {
} else if (isUbuntu()) {
setupAptPack("libtinfo-dev")
}
}

View File

@ -17,7 +17,7 @@ import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage"
import { setupPython } from "./python/python"
import mri from "mri"
import { untildify_user as untildify } from "./utils/path/untildify"
import { isGitHubCI } from "./utils/env/isci"
import { isGitHubCI } from "./utils/env/isCI"
import * as timeDelta from "time-delta"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore

View File

@ -4,6 +4,9 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupMake(version: string, _setupDir: string, _arch: string) {
@ -19,8 +22,12 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
case "linux": {
if (isArch()) {
return setupPacmanPack("make", version)
} else if (hasDnf()) {
return setupDnfPack("make", version)
} else if (isUbuntu()) {
return setupAptPack("make", version)
}
return setupAptPack("make", version)
throw new Error(`Unsupported linux distribution`)
}
default: {
throw new Error(`Unsupported platform`)

View File

@ -3,7 +3,7 @@ import { setupVCVarsall } from "../vcvarsall/vcvarsall"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { vsversion_to_versionnumber, findVcvarsall } from "msvc-dev-cmd/lib.js"
import { isGitHubCI } from "../utils/env/isci"
import { isGitHubCI } from "../utils/env/isCI"
import path from "path"
import { existsSync } from "fs"
import { error, info, warning } from "../utils/io/io"

View File

@ -1,6 +1,6 @@
import { setupNinja } from "../ninja"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { isGitHubCI } from "../../utils/env/isci"
import { isGitHubCI } from "../../utils/env/isCI"
import { getVersion } from "../../default_versions"
jest.setTimeout(300000)

View File

@ -2,7 +2,7 @@ import { setupPython } from "../python"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { getVersion } from "../../default_versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { isGitHubCI } from "../../utils/env/isci"
import { isGitHubCI } from "../../utils/env/isCI"
import { info } from "../../utils/io/io"
jest.setTimeout(300000)

View File

@ -4,7 +4,7 @@ import { existsSync } from "fs"
import { info, warning } from "../utils/io/io"
import { debug } from "@actions/core"
import path from "path"
import { isGitHubCI } from "../utils/env/isci"
import { isGitHubCI } from "../utils/env/isCI"
import { isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS } from "setup-python/src/utils"
import { getCacheDistributor } from "setup-python/src/cache-distributions/cache-factory"

View File

@ -3,12 +3,15 @@ import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isGitHubCI } from "../utils/env/isci"
import { isGitHubCI } from "../utils/env/isCI"
import { warning, info } from "../utils/io/io"
import { isArch } from "../utils/env/isArch"
import which from "which"
import { InstallationInfo } from "../utils/setup/setupBin"
import { dirname, join } from "path"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
export async function setupPython(version: string, setupDir: string, arch: string) {
if (!isGitHubCI()) {
@ -52,13 +55,19 @@ export async function setupPythonViaSystem(
return setupBrewPack("python3", version)
}
case "linux": {
let installInfo: InstallationInfo
if (isArch()) {
const installInfo = setupPacmanPack("python", version)
installInfo = setupPacmanPack("python", version)
setupPacmanPack("python-pip")
return installInfo
} else if (hasDnf()) {
installInfo = setupDnfPack("python3", version)
setupDnfPack("python3-pip")
} else if (isUbuntu()) {
installInfo = setupAptPack("python3", version)
setupAptPack("python3-pip")
} else {
throw new Error(`Unsupported linux distributions`)
}
const installInfo = setupAptPack("python3", version)
setupAptPack("python3-pip")
return installInfo
}
default: {

View File

@ -3,6 +3,9 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupSevenZip(version: string, _setupDir: string, _arch: string) {
@ -16,8 +19,13 @@ export function setupSevenZip(version: string, _setupDir: string, _arch: string)
case "linux": {
if (isArch()) {
return setupPacmanPack("p7zip", version)
} else if (hasDnf()) {
setupDnfPack("p7zip", version)
return setupDnfPack("p7zip-plugins", version)
} else if (isUbuntu()) {
return setupAptPack("p7zip-full", version)
}
return setupAptPack("p7zip-full", version)
throw new Error(`Unsupported linux distribution`)
}
default: {
throw new Error(`Unsupported platform`)

View File

@ -1,6 +1,6 @@
import { setupTask } from "../task"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { isGitHubCI } from "../../utils/env/isci"
import { isGitHubCI } from "../../utils/env/isCI"
import { getVersion } from "../../default_versions"
jest.setTimeout(300000)

View File

@ -1,5 +1,5 @@
import { exportVariable, addPath as ghAddPath, info, setFailed } from "@actions/core"
import { isGitHubCI } from "./isci"
import { isGitHubCI } from "./isCI"
import { untildify_user as untildify } from "../path/untildify"
import { appendFileSync, existsSync, readFileSync } from "fs"
import { error, warning } from "../io/io"

14
src/utils/env/hasDnf.ts vendored Normal file
View File

@ -0,0 +1,14 @@
import which from "which"
let hasDnfCache: undefined | boolean = undefined
export function hasDnf(): boolean {
if (process.platform !== "linux") {
return false
}
if (hasDnfCache === undefined) {
hasDnfCache = which.sync("dnf", { nothrow: true }) !== null
}
return hasDnfCache
}

View File

@ -0,0 +1,13 @@
import { isRoot } from "../env/sudo"
import { execSudo } from "../exec/sudo"
/// change the owner to the SUDO_USER. This is required so the user can use the folder without sudo
export function folderUserAccess(folder: string) {
if (
(process.platform === "linux" || process.platform === "darwin") &&
isRoot() &&
process.env.SUDO_USER !== undefined
) {
execSudo("chown", ["-R", process.env.SUDO_USER, folder], folder)
}
}

View File

@ -1,5 +1,5 @@
import * as core from "@actions/core"
import { isGitHubCI } from "../env/isci"
import { isGitHubCI } from "../env/isCI"
export function error(err: string | Error) {
return isGitHubCI() ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`)

View File

@ -3,6 +3,7 @@ import { mkdirP } from "@actions/io"
import which from "which"
import { setupSevenZip } from "../../sevenzip/sevenzip"
import { warning } from "../io/io"
import { folderUserAccess } from "../fs/userAccess"
export { extractTar, extractXar } from "@actions/tool-cache"
let sevenZip: string | undefined
@ -10,6 +11,7 @@ let sevenZip: string | undefined
/// Extract 7z using 7z
export async function extract7Zip(file: string, dest: string) {
await execa(await getSevenZip(), ["x", file, `-o${dest}`, "-y"], { stdio: "inherit" })
folderUserAccess(dest)
return dest
}
@ -53,5 +55,6 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
}
}
folderUserAccess(dest)
return dest
}

View File

@ -3,7 +3,7 @@ import { InstallationInfo } from "./setupBin"
import { execSudo } from "../exec/sudo"
import { info } from "@actions/core"
import { warning } from "../io/io"
import { isGitHubCI } from "../env/isci"
import { isGitHubCI } from "../env/isCI"
import { cpprc_path, setupCppInProfile } from "../env/addEnv"
import { appendFileSync } from "fs"
@ -29,9 +29,6 @@ export function setupAptPack(
if (!didInit) {
// install apt utils and certificates (usually missing from docker containers)
// set time - zone
// TZ = Canada / Pacific
// ln - snf / usr / share / zoneinfo / $TZ / etc / localtime && echo $TZ > /etc/timezone
execSudo(apt, [
"install",
"--fix-broken",

View File

@ -4,10 +4,13 @@ import { addPath } from "../env/addEnv"
import { join } from "path"
import { existsSync } from "fs"
import { tmpdir } from "os"
import { isGitHubCI } from "../env/isci"
import { isGitHubCI } from "../env/isCI"
import { setupAptPack } from "./setupAptPack"
import { setupPacmanPack } from "./setupPacmanPack"
import { isArch } from "../env/isArch"
import { hasDnf } from "../env/hasDnf"
import { setupDnfPack } from "./setupDnfPack"
import { isUbuntu } from "../env/isUbuntu"
/** A type that describes a package */
export type PackageInfo = {
@ -94,7 +97,11 @@ export async function setupBin(
setupPacmanPack("unzip")
setupPacmanPack("tar")
setupPacmanPack("xz")
} else {
} else if (hasDnf()) {
setupDnfPack("unzip")
setupDnfPack("tar")
setupDnfPack("xz")
} else if (isUbuntu()) {
setupAptPack("unzip")
setupAptPack("tar")
setupAptPack("xz-utils")

View File

@ -0,0 +1,31 @@
/* eslint-disable require-atomic-updates */
import { InstallationInfo } from "./setupBin"
import { execSudo } from "../exec/sudo"
import { info, warning } from "../io/io"
// let didUpdate: boolean = false
/** A function that installs a package using dnf */
export function setupDnfPack(name: string, version?: string): InstallationInfo {
info(`Installing ${name} ${version ?? ""} via dnf`)
const dnf = "dnf"
// if (!didUpdate) {
// execSudo(dnf, ["-y", "check-update"])
// didUpdate = true
// }
if (version !== undefined && version !== "") {
try {
execSudo(dnf, ["-y", "install", `${name}-${version}`])
} catch (err) {
warning(`${(err as Error).toString()}\nInstalling the default version available via dnf`)
execSudo(dnf, ["-y", "install", name])
}
} else {
execSudo(dnf, ["-y", "install", name])
}
return { binDir: "/usr/bin/" }
}

View File

@ -18,10 +18,6 @@ export function setupPacmanPack(name: string, version?: string, aur?: string): I
}
if (!didInit) {
// set time - zone
// TZ = Canada / Pacific
// ln - snf / usr / share / zoneinfo / $TZ / etc / localtime && echo $TZ > /etc/timezone
// install base-devel
execSudo(pacman, ["-Sy", "--noconfirm", "base-devel"])
didInit = true

View File

@ -12,6 +12,9 @@ import { InstallationInfo } from "./setupBin"
import { setupAptPack } from "./setupAptPack"
import { setupPacmanPack } from "./setupPacmanPack"
import { isArch } from "../env/isArch"
import { isUbuntu } from "../env/isUbuntu"
import { hasDnf } from "../env/hasDnf"
import { setupDnfPack } from "./setupDnfPack"
let python: string | undefined
let binDir: string | undefined
@ -46,7 +49,9 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
// ensure that pip is installed on Linux (happens when python is found but pip not installed)
if (isArch()) {
setupPacmanPack("python-pip")
} else {
} else if (hasDnf()) {
setupDnfPack("python3-pip")
} else if (isUbuntu()) {
setupAptPack("python3-pip")
}
}

View File

@ -3,14 +3,16 @@ import { existsSync } from "fs"
import { dirname, join } from "path"
import which from "which"
import { addPath } from "../utils/env/addEnv"
import { isRoot } from "../utils/env/sudo"
import { execSudo } from "../utils/exec/sudo"
import { addShellExtension, addShellHere } from "../utils/extension/extension"
import { notice } from "../utils/io/io"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
import { folderUserAccess } from "../utils/fs/userAccess"
let hasVCPKG = false
@ -26,7 +28,14 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
setupPacmanPack("tar")
setupPacmanPack("git")
setupPacmanPack("pkg-config")
} else {
} else if (hasDnf()) {
setupDnfPack("curl")
setupDnfPack("zip")
setupDnfPack("unzip")
setupDnfPack("tar")
setupDnfPack("git")
setupDnfPack("pkg-config")
} else if (isUbuntu()) {
setupAptPack("curl")
setupAptPack("zip")
setupAptPack("unzip")
@ -44,14 +53,7 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
execa.sync(addShellExtension(addShellHere("bootstrap-vcpkg")), { cwd: setupDir, shell: true, stdio: "inherit" })
// change the owner to the SUDO_USER in setupDir. vcpkg requires this so it can install things without sudo
if (
(process.platform === "linux" || process.platform === "darwin") &&
isRoot() &&
process.env.SUDO_USER !== undefined
) {
execSudo("chown", ["-R", process.env.SUDO_USER, setupDir], setupDir)
}
folderUserAccess(setupDir)
await addPath(setupDir)
// eslint-disable-next-line require-atomic-updates