feat: add pacman support (#31)

* add `setupPacmanPack`
* add arch linux docker image
* add container tests
This commit is contained in:
abeimler 2022-06-29 18:06:35 +02:00
parent e11034e0a8
commit aecb4b3e29
24 changed files with 375 additions and 61 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
.parcel-cache/
node_modules/
dev/docker/
dev/container-tests/

View File

@ -9,3 +9,7 @@ pnpm install
Before running the tests locally, backup your environment variables because faulty code might corrupt the environment.
<https://stackoverflow.com/a/5147185/7910299>
Install [container-structure-test](https://github.com/GoogleContainerTools/container-structure-test) for docker testing.

View File

@ -0,0 +1,45 @@
schemaVersion: 2.0.0
commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*GCC.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*GCC.*"]
- name: cmake
command: cmake
args: ["--version"]
expectedOutput: [".*cmake version.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: ninja
args: ["--version"]
expectedOutput: [".*1.*"]
- name: gcovr
command: gcovr
args: ["--version"]
expectedOutput: [".*gcovr.*"]
- name: ccache
command: ccache
args: ["--version"]
expectedOutput: [".*ccache.*"]
- name: doxygen
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]
fileExistenceTests:
- name: 'vcpkg'
path: '/root/vcpkg'
shouldExist: true

View File

@ -0,0 +1,48 @@
schemaVersion: 2.0.0
commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: /root/ninja/ninja
args: ["--version"]
expectedOutput: [".*1.*"]
- name: gcovr
command: gcovr
args: ["--version"]
expectedOutput: [".*gcovr.*"]
- name: ccache
command: ccache
args: ["--version"]
expectedOutput: [".*ccache.*"]
- name: doxygen
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]
- name: clang
command: /root/llvm/bin/clang
args: ["--version"]
expectedOutput: [".*clang.*"]
fileExistenceTests:
- name: 'vcpkg'
path: '/root/vcpkg'
shouldExist: true
- name: 'llvm'
path: '/root/llvm'
shouldExist: true

View File

@ -0,0 +1,48 @@
## base image
FROM archlinux as base
RUN pacman -Syuu --noconfirm
# 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
# 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"
# 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 pacman -Scc --noconfirm
#RUN rm -rf /home/yay/.cache/*
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"]

View File

@ -4,18 +4,22 @@ RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs
# add setup_cpp.js
ADD "./dist/" "/"
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 apt-get clean && rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'

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

View File

@ -14,6 +14,8 @@
"scripts": {
"build": "shx rm -rf dist/ && shx mkdir ./dist && run-p test.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp:ubuntu .",
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup_cpp:arch .",
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report",
"bump": "ncu -u -x execa,numerous && pnpm update",
"clean": "shx rm -rf .parcel-cache dist exe",
@ -24,6 +26,10 @@
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.js",
"prepare": "npm run build",
"start.docker": "docker run -t setup_cpp .",
"start.docker.ubuntu": "docker run -t setup_cpp:ubuntu .",
"start.docker.arch": "docker run -t setup_cpp:arch .",
"test.docker.ubuntu": "docker build -f ./dev/docker/ubuntu_node.dockerfile --target base -t setup_cpp:ubuntu-base . && container-structure-test test --image setup_cpp:ubuntu-base --config ./dev/container-tests/ubuntu.yml",
"test.docker.arch": "docker build -f ./dev/docker/arch_node.dockerfile --target base -t setup_cpp:arch-base . && container-structure-test test --image setup_cpp:arch-base --config ./dev/container-tests/arch.yml",
"test": "run-p test.format test.lint test.cspell test.tsc test.unit",
"test.cspell": "cspell lint --no-progress --show-suggestions",
"test.format": "prettier . --check",

View File

@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
overrides:
semver: 7.3.7
@ -87,7 +87,7 @@ devDependencies:
prettier-config-atomic: 3.0.10
shx: 0.3.4
terser-config-atomic: 0.1.1
ts-jest: 28.0.5_jest@28.1.1+typescript@4.7.4
ts-jest: 28.0.5_zv2ltmnvcc5apkdaecods742je
typescript: 4.7.4
packages:
@ -321,7 +321,7 @@ packages:
- supports-color
dev: true
/@babel/eslint-parser/7.18.2_@babel+core@7.18.5+eslint@8.18.0:
/@babel/eslint-parser/7.18.2_cz6e4qppzra6gosrrzcvbsxiom:
resolution: {integrity: sha512-oFQYkE8SuH14+uR51JVAmdqwKYXGRjEXx7s+WiagVjqQ+HPE+nnwyF2qlVG8evUsUHmPcA+6YXMEDbIhEyQc5A==}
engines: {node: ^10.13.0 || ^12.13.0 || >=14.0.0}
peerDependencies:
@ -2360,7 +2360,7 @@ packages:
'@types/yargs-parser': 21.0.0
dev: true
/@typescript-eslint/eslint-plugin/5.29.0_841815610045eaf78ed2b3f13a174733:
/@typescript-eslint/eslint-plugin/5.29.0_qqmbkyiaixvppdwswpytuf2hgm:
resolution: {integrity: sha512-kgTsISt9pM53yRFQmLZ4npj99yGl3x3Pl7z4eA66OuTzAGC4bQB5H5fuLwPnqTKU3yyrrg4MIhjF17UYnL4c0w==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -2371,10 +2371,10 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/parser': 5.29.0_eslint@8.18.0+typescript@4.7.4
'@typescript-eslint/parser': 5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e
'@typescript-eslint/scope-manager': 5.29.0
'@typescript-eslint/type-utils': 5.29.0_eslint@8.18.0+typescript@4.7.4
'@typescript-eslint/utils': 5.29.0_eslint@8.18.0+typescript@4.7.4
'@typescript-eslint/type-utils': 5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e
'@typescript-eslint/utils': 5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e
debug: 4.3.4
eslint: 8.18.0
functional-red-black-tree: 1.0.1
@ -2387,7 +2387,7 @@ packages:
- supports-color
dev: true
/@typescript-eslint/parser/5.29.0_eslint@8.18.0+typescript@4.7.4:
/@typescript-eslint/parser/5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e:
resolution: {integrity: sha512-ruKWTv+x0OOxbzIw9nW5oWlUopvP/IQDjB5ZqmTglLIoDTctLlAJpAQFpNPJP/ZI7hTT9sARBosEfaKbcFuECw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -2415,7 +2415,7 @@ packages:
'@typescript-eslint/visitor-keys': 5.29.0
dev: true
/@typescript-eslint/type-utils/5.29.0_eslint@8.18.0+typescript@4.7.4:
/@typescript-eslint/type-utils/5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e:
resolution: {integrity: sha512-JK6bAaaiJozbox3K220VRfCzLa9n0ib/J+FHIwnaV3Enw/TO267qe0pM1b1QrrEuy6xun374XEAsRlA86JJnyg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -2425,7 +2425,7 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/utils': 5.29.0_eslint@8.18.0+typescript@4.7.4
'@typescript-eslint/utils': 5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e
debug: 4.3.4
eslint: 8.18.0
tsutils: 3.21.0_typescript@4.7.4
@ -2460,7 +2460,7 @@ packages:
- supports-color
dev: true
/@typescript-eslint/utils/5.29.0_eslint@8.18.0+typescript@4.7.4:
/@typescript-eslint/utils/5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e:
resolution: {integrity: sha512-3Eos6uP1nyLOBayc/VUdKZikV90HahXE5Dx9L5YlSd/7ylQPXhLk1BYb29SDgnBnTp+jmSZUU0QxUiyHgW4p7A==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -3764,7 +3764,7 @@ packages:
engines: {node: '>=10'}
dev: true
/eslint-config-airbnb-base/14.2.1_9462c2f560e8d8d9149a63cde905d125:
/eslint-config-airbnb-base/14.2.1_srrmf5la5dmnsfe2mpg6sboreu:
resolution: {integrity: sha512-GOrQyDtVEc1Xy20U7vsB2yAoB4nBlfH5HZJeatRXHleO+OS5Ot+MWij4Dpltw4/DyIkqUfqz1epfhVR5XWWQPA==}
engines: {node: '>= 6'}
peerDependencies:
@ -3773,13 +3773,13 @@ packages:
dependencies:
confusing-browser-globals: 1.0.11
eslint: 8.18.0
eslint-plugin-import: 2.26.0_c98dd95c676de54ce87ba8db61cd826d
eslint-plugin-import: 2.26.0_zgg5sxdhnxsuz2d3vdnwdtmcnu
object.assign: 4.1.2
object.entries: 1.1.5
dev: true
optional: true
/eslint-config-airbnb/18.2.1_5cd494cb9c5361701be934d5d6e756ed:
/eslint-config-airbnb/18.2.1_ltkjjs44knqxag7jgtk5nz2w5u:
resolution: {integrity: sha512-glZNDEZ36VdlZWoxn/bUR1r/sdFKPd1mHPbqUtkctgNG4yT2DLLtJ3D+yCV+jzZCc2V1nBVkmdknOJBZ5Hc0fg==}
engines: {node: '>= 6'}
peerDependencies:
@ -3790,8 +3790,8 @@ packages:
eslint-plugin-react-hooks: ^4 || ^3 || ^2.3.0 || ^1.7.0
dependencies:
eslint: 8.18.0
eslint-config-airbnb-base: 14.2.1_9462c2f560e8d8d9149a63cde905d125
eslint-plugin-import: 2.26.0_c98dd95c676de54ce87ba8db61cd826d
eslint-config-airbnb-base: 14.2.1_srrmf5la5dmnsfe2mpg6sboreu
eslint-plugin-import: 2.26.0_zgg5sxdhnxsuz2d3vdnwdtmcnu
eslint-plugin-jsx-a11y: 6.6.0_eslint@8.18.0
eslint-plugin-react: 7.23.2_eslint@8.18.0
eslint-plugin-react-hooks: 4.6.0_eslint@8.18.0
@ -3804,15 +3804,15 @@ packages:
resolution: {integrity: sha512-wS/1xK1detB18BYj3EFOFjpxp9H01kQNKJbO6tgGDycHYgurZyHKh+kU+o0zRoZMqwXw4hmFimTN0EvVerBX1w==}
dependencies:
'@babel/core': 7.18.5
'@babel/eslint-parser': 7.18.2_@babel+core@7.18.5+eslint@8.18.0
'@babel/eslint-parser': 7.18.2_cz6e4qppzra6gosrrzcvbsxiom
'@babel/plugin-syntax-flow': 7.17.12_@babel+core@7.18.5
'@babel/plugin-syntax-jsx': 7.17.12_@babel+core@7.18.5
'@typescript-eslint/eslint-plugin': 5.29.0_841815610045eaf78ed2b3f13a174733
'@typescript-eslint/parser': 5.29.0_eslint@8.18.0+typescript@4.7.4
'@typescript-eslint/eslint-plugin': 5.29.0_qqmbkyiaixvppdwswpytuf2hgm
'@typescript-eslint/parser': 5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e
eslint: 8.18.0
eslint-config-prettier: 8.5.0_eslint@8.18.0
eslint-plugin-html: 6.2.0
eslint-plugin-import: 2.26.0_c98dd95c676de54ce87ba8db61cd826d
eslint-plugin-import: 2.26.0_zgg5sxdhnxsuz2d3vdnwdtmcnu
eslint-plugin-json: 3.1.0
eslint-plugin-node: 11.1.0_eslint@8.18.0
eslint-plugin-only-warn: /@aminya/eslint-plugin-only-warn/1.2.2
@ -3825,7 +3825,7 @@ packages:
typescript: 4.7.4
optionalDependencies:
coffeescript: 1.12.7
eslint-plugin-coffee: 0.1.15_71a5b804ebf7d01bcef72e514ee6421d
eslint-plugin-coffee: 0.1.15_ogs3qbhl67ibxtxxfziu5zscdu
eslint-plugin-react-hooks: 4.6.0_eslint@8.18.0
transitivePeerDependencies:
- eslint-import-resolver-typescript
@ -3851,7 +3851,7 @@ packages:
- supports-color
dev: true
/eslint-module-utils/2.7.3_997a240915676dc771d6b5349fa398d5:
/eslint-module-utils/2.7.3_tf5cicivm5w4o4owwu2j7i4y2u:
resolution: {integrity: sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==}
engines: {node: '>=4'}
peerDependencies:
@ -3869,7 +3869,7 @@ packages:
eslint-import-resolver-webpack:
optional: true
dependencies:
'@typescript-eslint/parser': 5.29.0_eslint@8.18.0+typescript@4.7.4
'@typescript-eslint/parser': 5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e
debug: 3.2.7
eslint-import-resolver-node: 0.3.6
find-up: 2.1.0
@ -3877,21 +3877,21 @@ packages:
- supports-color
dev: true
/eslint-plugin-coffee/0.1.15_71a5b804ebf7d01bcef72e514ee6421d:
/eslint-plugin-coffee/0.1.15_ogs3qbhl67ibxtxxfziu5zscdu:
resolution: {integrity: sha512-+qtkIPSc9etYqOODIlENqiRjID/oEoGMAAQJN988Aczy461NIwzaamFY6Fi0QDVVDb2v+OL/StVrk/QmyItfeg==}
requiresBuild: true
peerDependencies:
eslint: '*'
dependencies:
axe-core: 3.5.6
babel-eslint: /@babel/eslint-parser/7.18.2_@babel+core@7.18.5+eslint@8.18.0
babel-eslint: /@babel/eslint-parser/7.18.2_cz6e4qppzra6gosrrzcvbsxiom
babylon: 7.0.0-beta.47
coffeescript: 2.7.0
doctrine: 2.1.0
eslint: 8.18.0
eslint-config-airbnb: 18.2.1_5cd494cb9c5361701be934d5d6e756ed
eslint-config-airbnb-base: 14.2.1_9462c2f560e8d8d9149a63cde905d125
eslint-plugin-import: 2.26.0_c98dd95c676de54ce87ba8db61cd826d
eslint-config-airbnb: 18.2.1_ltkjjs44knqxag7jgtk5nz2w5u
eslint-config-airbnb-base: 14.2.1_srrmf5la5dmnsfe2mpg6sboreu
eslint-plugin-import: 2.26.0_zgg5sxdhnxsuz2d3vdnwdtmcnu
eslint-plugin-jsx-a11y: 6.6.0_eslint@8.18.0
eslint-plugin-react: 7.23.2_eslint@8.18.0
eslint-plugin-react-native: 3.11.0_eslint@8.18.0
@ -3927,7 +3927,7 @@ packages:
htmlparser2: 7.2.0
dev: true
/eslint-plugin-import/2.26.0_c98dd95c676de54ce87ba8db61cd826d:
/eslint-plugin-import/2.26.0_zgg5sxdhnxsuz2d3vdnwdtmcnu:
resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==}
engines: {node: '>=4'}
peerDependencies:
@ -3937,14 +3937,14 @@ packages:
'@typescript-eslint/parser':
optional: true
dependencies:
'@typescript-eslint/parser': 5.29.0_eslint@8.18.0+typescript@4.7.4
'@typescript-eslint/parser': 5.29.0_b5e7v2qnwxfo6hmiq56u52mz3e
array-includes: 3.1.5
array.prototype.flat: 1.3.0
debug: 2.6.9
doctrine: 2.1.0
eslint: 8.18.0
eslint-import-resolver-node: 0.3.6
eslint-module-utils: 2.7.3_997a240915676dc771d6b5349fa398d5
eslint-module-utils: 2.7.3_tf5cicivm5w4o4owwu2j7i4y2u
has: 1.0.3
is-core-module: 2.9.0
is-glob: 4.0.3
@ -7730,7 +7730,7 @@ packages:
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
dev: false
/ts-jest/28.0.5_jest@28.1.1+typescript@4.7.4:
/ts-jest/28.0.5_zv2ltmnvcc5apkdaecods742je:
resolution: {integrity: sha512-Sx9FyP9pCY7pUzQpy4FgRZf2bhHY3za576HMKJFs+OnQ9jS96Du5vNsDKkyedQkik+sEabbKAnCliv9BEsHZgQ==}
engines: {node: ^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0}
hasBin: true

View File

@ -1,6 +1,8 @@
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 which from "which"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupCcache(version: string, _setupDir: string, _arch: string) {
@ -12,6 +14,9 @@ export function setupCcache(version: string, _setupDir: string, _arch: string) {
return setupBrewPack("ccache", version)
}
case "linux": {
if (which.sync("pacman", { nothrow: true })) {
return setupPacmanPack("ccache", version)
}
return setupAptPack("ccache", version)
}
default: {

View File

@ -1,7 +1,9 @@
import { addPath } from "../utils/env/addEnv"
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 which from "which"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupCppcheck(version: string | undefined, _setupDir: string, _arch: string) {
@ -15,6 +17,9 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
return setupBrewPack("cppcheck", version)
}
case "linux": {
if (which.sync("pacman", { nothrow: true })) {
return setupPacmanPack("cppcheck", version)
}
return setupAptPack("cppcheck", version)
}
default: {

View File

@ -1,5 +1,6 @@
import { addPath } from "../utils/env/addEnv"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
@ -10,6 +11,7 @@ import { setupGraphviz } from "../graphviz/graphviz"
import { getVersion } from "../default_versions"
import { existsSync } from "fs"
import { join } from "path"
import which from "which"
/** Get the platform data for cmake */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -57,7 +59,14 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
case "linux": {
let installationInfo: InstallationInfo
if (version === "") {
if (which.sync("pacman", { nothrow: true })) {
installationInfo = setupPacmanPack("doxygen", undefined)
} else {
installationInfo = setupAptPack("doxygen", undefined)
}
} else {
if (which.sync("pacman", { nothrow: true })) {
installationInfo = setupPacmanPack("doxygen", version)
} else {
try {
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
@ -68,6 +77,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
installationInfo = setupAptPack("doxygen", undefined)
}
}
}
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
return installationInfo
}

View File

@ -1,6 +1,7 @@
import { addPath, addEnv } from "../utils/env/addEnv"
import { existsSync } from "fs"
import { setupAptPack, updateAptAlternatives } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import semverMajor from "semver/functions/major"
@ -12,6 +13,7 @@ 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 which from "which"
interface MingwInfo {
releaseName: string
@ -79,12 +81,19 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
}
case "linux": {
if (arch === "x64") {
if (which.sync("pacman", { nothrow: true })) {
installationInfo = setupPacmanPack("gcc", version)
} else {
setupAptPack("gcc", version, ["ppa:ubuntu-toolchain-r/test"])
installationInfo = setupAptPack("g++", version, [])
}
} else {
info(`Install g++-multilib because gcc for ${arch} was requested`)
if (which.sync("pacman", { nothrow: true })) {
setupPacmanPack("gcc-multilib", version)
} else {
setupAptPack("gcc-multilib", version, ["ppa:ubuntu-toolchain-r/test"])
installationInfo = setupAptPack("g++-multilib", version, [])
}
}
break
}

View File

@ -1,8 +1,10 @@
import { addPath } from "../utils/env/addEnv"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { InstallationInfo } from "../utils/setup/setupBin"
import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import which from "which"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupGraphviz(version: string, _setupDir: string, _arch: string) {
@ -15,6 +17,9 @@ export async function setupGraphviz(version: string, _setupDir: string, _arch: s
return setupBrewPack("graphviz", version)
}
case "linux": {
if (which.sync("pacman", { nothrow: true })) {
return setupPacmanPack("graphviz", version)
}
return setupAptPack("graphviz", version)
}
default: {

View File

@ -8,6 +8,7 @@ import { execSudo } from "../utils/exec/sudo"
import { addBinExtension } from "../utils/extension/extension"
import { extractTarByExe } from "../utils/setup/extract"
import { setupAptPack } from "../utils/setup/setupAptPack"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack"
import { PackageInfo, setupBin } from "../utils/setup/setupBin"
function getKcovPackageInfo(version: string): PackageInfo {
@ -42,9 +43,14 @@ async function buildKcov(file: string, dest: string) {
await setupCmake(getVersion("cmake", undefined), join(untildify(""), "cmake"), "")
}
if (process.platform === "linux") {
if (which.sync("pacman", { nothrow: true })) {
setupPacmanPack("libdwarf")
setupPacmanPack("libcurl-openssl")
} else {
setupAptPack("libdw-dev")
setupAptPack("libcurl4-openssl-dev")
}
}
await execa("cmake", ["-S", "./", "-B", "./build"], { cwd: out, stdio: "inherit" })
await execa("cmake", ["--build", "./build", "--config", "Release"], { cwd: out, stdio: "inherit" })
execSudo("cmake", ["--install", "./build"], out)
@ -54,6 +60,12 @@ async function buildKcov(file: string, dest: string) {
export async function setupKcov(version: string, setupDir: string, arch: string) {
switch (process.platform) {
case "linux": {
if (which.sync("pacman", { nothrow: true })) {
// 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")
return installationInfo

View File

@ -20,6 +20,7 @@ import { existsSync } from "fs"
import { isGitHubCI } from "../utils/env/isci"
import { setupGcc } from "../gcc/gcc"
import { getVersion } from "../default_versions"
import which from "which"
//================================================
// Version
@ -285,8 +286,13 @@ async function _setupLLVM(version: string, setupDir: string, arch: string) {
if (process.platform === "linux") {
// install llvm build dependencies
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
if (which.sync("pacman", { nothrow: true })) {
// setupPacmanPack("ncurses")
// TODO: install libtinfo ?
} else {
setupAptPack("libtinfo-dev")
}
}
// eslint-disable-next-line require-atomic-updates
didInit = true
}

View File

@ -1,7 +1,9 @@
import { addPath } from "../utils/env/addEnv"
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 which from "which"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function setupMake(version: string, _setupDir: string, _arch: string) {
@ -15,6 +17,9 @@ export async function setupMake(version: string, _setupDir: string, _arch: strin
return { binDir: "/usr/local/opt/make/libexec/gnubin" }
}
case "linux": {
if (which.sync("pacman", { nothrow: true })) {
return setupPacmanPack("make", version)
}
return setupAptPack("make", version)
}
default: {

View File

@ -1,9 +1,11 @@
import { addPath } from "../utils/env/addEnv"
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 { warning, info } from "../utils/io/io"
import which from "which"
export async function setupPython(version: string, setupDir: string, arch: string) {
if (!isGitHubCI()) {
@ -38,6 +40,11 @@ export async function setupPythonViaSystem(version: string, setupDir: string, _a
return setupBrewPack("python3", version)
}
case "linux": {
if (which.sync("pacman", { nothrow: true })) {
const installInfo = setupPacmanPack("python", version)
setupPacmanPack("python-pip")
return installInfo
}
const installInfo = setupAptPack("python3", version)
setupAptPack("python3-pip")
return installInfo

View File

@ -1,6 +1,8 @@
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 which from "which"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function setupSevenZip(version: string, _setupDir: string, _arch: string) {
@ -12,6 +14,9 @@ export function setupSevenZip(version: string, _setupDir: string, _arch: string)
return setupBrewPack("p7zip", version)
}
case "linux": {
if (which.sync("pacman", { nothrow: true })) {
return setupPacmanPack("p7zip", version)
}
return setupAptPack("p7zip-full", version)
}
default: {

View File

@ -6,6 +6,8 @@ import { existsSync } from "fs"
import { tmpdir } from "os"
import { isGitHubCI } from "../env/isci"
import { setupAptPack } from "./setupAptPack"
import { setupPacmanPack } from "./setupPacmanPack"
import which from "which"
/** A type that describes a package */
export type PackageInfo = {
@ -88,10 +90,16 @@ export async function setupBin(
if (!didInit) {
if (process.platform === "linux") {
// extraction dependencies
if (which.sync("pacman", { nothrow: true })) {
setupPacmanPack("unzip")
setupPacmanPack("tar")
setupPacmanPack("xz")
} else {
setupAptPack("unzip")
setupAptPack("tar")
setupAptPack("xz-utils")
}
}
// eslint-disable-next-line require-atomic-updates
didInit = true
}

View File

@ -0,0 +1,63 @@
/* eslint-disable require-atomic-updates */
import { InstallationInfo } from "./setupBin"
import { execSudo } from "../exec/sudo"
import { info } from "@actions/core"
import { isGitHubCI } from "../env/isci"
import { cpprc_path, setupCppInProfile } from "../env/addEnv"
import { appendFileSync } from "fs"
let didUpdate: boolean = false
let didInit: boolean = false
/** A function that installs a package using pacman */
export function setupPacmanPack(
name: string,
version?: string,
aur?: string,
): InstallationInfo {
info(`Installing ${name} ${version ?? ""} via pacman`)
const pacman = "pacman"
if (!didUpdate) {
execSudo(pacman, ["-Syuu", "--noconfirm"])
didUpdate = true
}
if (!didInit) {
// install base-devel
// set time - zone
// TZ = Canada / Pacific
// ln - snf / usr / share / zoneinfo / $TZ / etc / localtime && echo $TZ > /etc/timezone
execSudo(pacman, [
"-Sy",
"--noconfirm",
"base-devel",
])
didInit = true
}
if (version !== undefined && version !== "") {
try {
execSudo(aur ?? pacman, ["-S", "--noconfirm", `${name}=${version}`])
} catch {
execSudo(aur ?? pacman, ["-S", "--noconfirm", `${name}${version}`])
}
} else {
execSudo(aur ?? pacman, ["-S", "--noconfirm", name])
}
return { binDir: "/usr/bin/" }
}
export function updateAptAlternatives(name: string, path: string) {
if (isGitHubCI()) {
return execSudo("update-alternatives", ["--install", `/usr/bin/${name}`, name, path, "40"])
} else {
setupCppInProfile()
return appendFileSync(
cpprc_path,
`\nif [ $UID -eq 0 ]; then update-alternatives --install /usr/bin/${name} ${name} ${path} 40; fi\n`
)
}
}

View File

@ -10,6 +10,7 @@ import { join } from "path"
import { getVersion } from "../../default_versions"
import { InstallationInfo } from "./setupBin"
import { setupAptPack } from "./setupAptPack"
import { setupPacmanPack } from "./setupPacmanPack"
let python: string | undefined
let binDir: string | undefined
@ -42,8 +43,12 @@ export async function setupPipPack(name: string, version?: string): Promise<Inst
execa.sync(python, ["-m", "pip", "install", "-U", "pip==21.3.1"], { stdio: "inherit" })
} else if (process.platform === "linux") {
// ensure that pip is installed on Linux (happens when python is found but pip not installed)
if (which.sync("pacman", { nothrow: true })) {
setupPacmanPack("python-pip")
} else {
setupAptPack("python3-pip")
}
}
// install wheel (required for Conan, Meson, etc.)
execa.sync(python, ["-m", "pip", "install", "-U", "wheel"], { stdio: "inherit" })

View File

@ -8,6 +8,7 @@ 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"
let hasVCPKG = false
@ -17,6 +18,14 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
if (!hasVCPKG || which.sync("vcpkg", { nothrow: true }) === null) {
if (process.platform === "linux") {
// vcpkg download and extraction dependencies
if (which.sync("pacman", { nothrow: true })) {
setupPacmanPack("curl")
setupPacmanPack("zip")
setupPacmanPack("unzip")
setupPacmanPack("tar")
setupPacmanPack("git")
setupPacmanPack("pkg-config")
} else {
setupAptPack("curl")
setupAptPack("zip")
setupAptPack("unzip")
@ -24,6 +33,7 @@ export async function setupVcpkg(_version: string, setupDir: string, _arch: stri
setupAptPack("git")
setupAptPack("pkg-config")
}
}
if (!existsSync(join(setupDir, addShellExtension("bootstrap-vcpkg")))) {
execa.sync("git", ["clone", "https://github.com/microsoft/vcpkg"], { cwd: dirname(setupDir), stdio: "inherit" })