From f849ee113ec20f57abcf2f9023784595cd9d95c9 Mon Sep 17 00:00:00 2001 From: abeimler Date: Thu, 20 Jul 2023 12:26:09 +0200 Subject: [PATCH] fix: docker mingw build (test) --- dev/cpp_vcpkg_project | 2 +- dev/docker/__tests__/arch.mingw.dockerfile | 22 +++++++++++++++++--- dev/docker/__tests__/fedora.mingw.dockerfile | 4 ++-- dev/docker/__tests__/ubuntu.mingw.dockerfile | 2 +- src/utils/setup/setupPacmanPack.ts | 6 +++++- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dev/cpp_vcpkg_project b/dev/cpp_vcpkg_project index b10f2e84..c3058919 160000 --- a/dev/cpp_vcpkg_project +++ b/dev/cpp_vcpkg_project @@ -1 +1 @@ -Subproject commit b10f2e841835b93cee67dff1eb70d6fa5c0ac0cd +Subproject commit c30589196b2c59a3055dfc7c24244b4a1f48b081 diff --git a/dev/docker/__tests__/arch.mingw.dockerfile b/dev/docker/__tests__/arch.mingw.dockerfile index 00c6d09d..d6624b10 100644 --- a/dev/docker/__tests__/arch.mingw.dockerfile +++ b/dev/docker/__tests__/arch.mingw.dockerfile @@ -1,13 +1,29 @@ ## base image -FROM archlinux:base as setup-cpp-arch-mingw +FROM archlinux:base-devel as setup-cpp-arch-mingw COPY "./dist/legacy" "/usr/lib/setup-cpp/" +# install git +RUN pacman -Syuu --noconfirm && \ + pacman-db-upgrade && \ + pacman -S --noconfirm --needed git +# 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 +WORKDIR /opt/yay +RUN chown -R yay:root . && chmod -R 775 . +USER yay +WORKDIR /opt/yay +RUN makepkg -si --noprogressbar --noconfirm +## clean up +USER root +WORKDIR / +RUN rm -rf /opt/yay + RUN pacman -Syuu --noconfirm && \ pacman-db-upgrade && \ # install nodejs pacman -S --noconfirm --needed nodejs npm && \ - # install the compiler and tools node /usr/lib/setup-cpp/setup-cpp.js \ --compiler mingw \ @@ -21,7 +37,7 @@ RUN pacman -Syuu --noconfirm && \ --gcovr true \ --doxygen true \ --ccache true \ - --powerchell true && \ + --powershell true && \ # arch cleanup pacman -Scc --noconfirm && \ rm -rf /var/cache/pacman/pkg/* && \ diff --git a/dev/docker/__tests__/fedora.mingw.dockerfile b/dev/docker/__tests__/fedora.mingw.dockerfile index 3ca2f4a0..f7edb4cc 100644 --- a/dev/docker/__tests__/fedora.mingw.dockerfile +++ b/dev/docker/__tests__/fedora.mingw.dockerfile @@ -19,7 +19,7 @@ RUN dnf -y install nodejs npm && \ --gcovr true \ --doxygen true \ --ccache true \ - --powerchell true && \ + --powershell true && \ # cleanup dnf clean all && \ rm -rf /tmp/* @@ -27,7 +27,7 @@ RUN dnf -y install nodejs npm && \ ENTRYPOINT ["/bin/bash"] #### Building (example) -FROM setup-cpp-fedora AS builder +FROM setup-cpp-fedora-mingw AS builder COPY ./dev/cpp_vcpkg_project /home/app WORKDIR /home/app diff --git a/dev/docker/__tests__/ubuntu.mingw.dockerfile b/dev/docker/__tests__/ubuntu.mingw.dockerfile index 1b9f8fb8..3f497c52 100644 --- a/dev/docker/__tests__/ubuntu.mingw.dockerfile +++ b/dev/docker/__tests__/ubuntu.mingw.dockerfile @@ -21,7 +21,7 @@ RUN apt-get update -qq && \ --gcovr true \ --doxygen true \ --ccache true \ - --powerchell true && \ + --powershell true && \ # cleanup nala autoremove -y && \ nala autopurge -y && \ diff --git a/src/utils/setup/setupPacmanPack.ts b/src/utils/setup/setupPacmanPack.ts index b329460c..d384eb4e 100644 --- a/src/utils/setup/setupPacmanPack.ts +++ b/src/utils/setup/setupPacmanPack.ts @@ -1,7 +1,7 @@ import { InstallationInfo } from "./setupBin" import { execRootSync } from "admina" import { info, warning } from "ci-log" -import { execa } from "execa" +import { execa, execaSync } from "execa" /* eslint-disable require-atomic-updates */ let didUpdate: boolean = false @@ -26,6 +26,10 @@ export async function setupPacmanPack(name: string, version?: string, aur?: stri } const runInstall = (arg: string) => { + if (aur === "yay") { + // run yay as non-root, ERROR: Running makepkg as root is not allowed as it can cause permanent, catastrophic damage to your system. + return execaSync(aur, ["-S", "--noconfirm", arg]) + } return execRootSync(aur ?? pacman, ["-S", "--noconfirm", arg]) }