mirror of https://github.com/aminya/setup-cpp
fix: give user access to the extracted folders
This commit is contained in:
parent
3d6f9a38eb
commit
485b3298a2
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,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)
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ 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"
|
||||
|
@ -14,6 +12,7 @@ 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
|
||||
|
||||
|
@ -54,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
|
||||
|
|
Loading…
Reference in New Issue