Skip to content

Commit 9366f7a

Browse files
authored
Merge pull request #13 from aminya/linux-init [skip ci]
2 parents ba55ef6 + f83c7d7 commit 9366f7a

File tree

12 files changed

+56
-16
lines changed

12 files changed

+56
-16
lines changed

building/docker/debian.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ WORKDIR "/"
66
RUN apt-get update -qq
77
RUN apt-get install -y --no-install-recommends apt-utils
88
RUN apt-get install -y --no-install-recommends ca-certificates wget unzip
9-
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.5.2/setup_cpp_linux"
9+
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.5.4/setup_cpp_linux"
1010
RUN chmod +x ./setup_cpp_linux
1111

1212
# install llvm, cmake, ninja, and ccache
13-
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true
13+
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
1414

1515
# reload the environment
1616
CMD source ~/.profile

building/docker/debian_node.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ADD "./dist/" "/"
66
WORKDIR "/"
77

88
# run installation
9-
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true
9+
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
1010

1111
# reload the environment
1212
CMD source ~/.profile

building/docker/debian_node_slim.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN apt-get update -qq
1010
RUN apt-get install -y --no-install-recommends unzip
1111

1212
# run installation
13-
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --conan true
13+
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --conan true --vcpkg true
1414

1515
# reload the environment
1616
CMD source ~/.profile

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/kcov/kcov.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import execa from "execa"
22
// import { join } from "path"
3-
// import untildify from "untildify"
3+
// import { untildify_user as untildify } from "./utils/path/untildify"
44
// import { setupCmake } from "../cmake/cmake"
55
import { execaSudo } from "../utils/env/sudo"
66
import { addBinExtension } from "../utils/extension/extension"
@@ -33,7 +33,7 @@ function getKcovPackageInfo(version: string): PackageInfo {
3333
extractFunction: async (file: string, dest: string): Promise<string> => {
3434
const out = await extractTarByExe(file, dest)
3535
// build after extraction using CMake
36-
// await setupCmake("3.22.0", join(untildify("~/"), "cmake"), "")
36+
// await setupCmake("3.22.0", join(untildify(""), "cmake"), "")
3737
await setupAptPack("libdw-dev")
3838
await setupAptPack("libcurl4-openssl-dev")
3939
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out })

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { setupNinja } from "./ninja/ninja"
1414
import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage"
1515
import { setupPython } from "./python/python"
1616
import mri from "mri"
17-
import untildify from "untildify"
17+
import { untildify_user as untildify } from "./utils/path/untildify"
1818
import { isGitHubCI } from "./utils/env/isci"
1919

2020
import semverValid from "semver/functions/valid"
@@ -101,7 +101,7 @@ export async function main(args: string[]): Promise<number> {
101101
const arch = opts.architecture ?? process.arch
102102

103103
// the installation dir for the tools that are downloaded directly
104-
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildify("~/")
104+
const setupCppDir = process.env.SETUP_CPP_DIR ?? untildify("")
105105

106106
// report messages
107107
const successMessages: string[] = []

src/utils/env/addEnv.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { exportVariable } from "@actions/core"
22
import * as core from "@actions/core"
33
import execa from "execa"
44
import { isGitHubCI } from "./isci"
5-
import untildify from "untildify"
5+
import { untildify_user as untildify } from "../path/untildify"
66
import { appendFileSync } from "fs"
7+
import { join } from "path"
8+
import { isRoot } from "./sudo"
79

810
/** An add path function that works locally or inside GitHub Actions */
911
export function addEnv(name: string, val: string | undefined) {
@@ -33,8 +35,14 @@ function addEnvSystem(name: string, val: string | undefined) {
3335
}
3436
case "linux":
3537
case "darwin": {
36-
const profile_path = untildify("~/.profile")
37-
appendFileSync(profile_path, `\nexport ${name}="${val}\n`)
38+
// find profile path
39+
let profile_path = untildify(".profile")
40+
if (isRoot() && typeof process.env.SUDO_USER === "string") {
41+
// use the user profile even if root
42+
profile_path = join("/home/", process.env.SUDO_USER, ".profile")
43+
}
44+
45+
appendFileSync(profile_path, `\nexport ${name}="${val}"\n`)
3846
core.info(`${name}="${val} was added to "${profile_path}"`)
3947
return
4048
}

src/utils/path/addPath.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { delimiter } from "path"
33
import * as core from "@actions/core"
44
import execa from "execa"
55
import { isGitHubCI } from "../env/isci"
6-
import untildify from "untildify"
6+
import { untildify_user as untildify } from "./untildify"
77
import { appendFileSync } from "fs"
88

99
/** An add path function that works locally or inside GitHub Actions */
@@ -34,7 +34,7 @@ function addPathSystem(path: string) {
3434
}
3535
case "linux":
3636
case "darwin": {
37-
const profile_path = untildify("~/.profile")
37+
const profile_path = untildify(".profile")
3838
appendFileSync(profile_path, `\nexport PATH=${path}:$PATH\n`)
3939
core.info(`${path} was added to "${profile_path}"`)
4040
return

src/utils/path/untildify.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { join } from "path"
2+
import untildify from "untildify"
3+
import { isRoot } from "../env/sudo"
4+
5+
export function untildify_user(path: string) {
6+
if (isRoot() && typeof process.env.SUDO_USER === "string") {
7+
// use the user profile even if root
8+
return join("/home/", process.env.SUDO_USER, path)
9+
} else {
10+
return untildify(`~/${path}`)
11+
}
12+
}

0 commit comments

Comments
 (0)