From fa84227c2f65c2c72d11e75d532a2e501e77abd6 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 30 Oct 2023 12:06:26 +0100 Subject: [PATCH] Combining multiple RUN commands for build envirnoment setup and tests. --- crossbuild.containerfile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crossbuild.containerfile b/crossbuild.containerfile index 2edb06a..9a81868 100644 --- a/crossbuild.containerfile +++ b/crossbuild.containerfile @@ -33,7 +33,7 @@ WORKDIR /tmp COPY debian-src.sources local-pkgs.list /etc/apt/sources.list.d/ COPY local-pkgs /etc/apt/preferences.d/ -# Install packages from pkgs list and mark them as held +# Install packages from pkgs list and mark them as held, test gcc and cleanup COPY pkgs ./ RUN mkdir /pkgs \ && touch /pkgs/Packages \ @@ -41,7 +41,12 @@ RUN mkdir /pkgs \ && DEBIAN_FRONTEND=noninteractive apt-get install \ --no-install-recommends -y build-essential ca-certificates debhelper \ devscripts git yq $(awk '{ print $1 }' pkgs) \ - && apt-mark hold $(awk '{ print $1 }' pkgs) + && apt-mark hold $(awk '{ print $1 }' pkgs) \ + && gcc --print-search-dir \ + && echo 'int main() { return 0; }' > main.c \ + && gcc -o main main.c \ + && ./main \ + && find /tmp -mindepth 1 -delete # Copy the native build artifacts from the previous stage COPY --from=native /native /native @@ -50,13 +55,6 @@ COPY --from=native /native /native COPY setup_native ./ RUN [ "/native/bash", "-c", "PATH=/native:$PATH ./setup_native import $(awk '{ print $1 }' pkgs)" ] -# Test gcc and cleanup -RUN gcc --print-search-dir \ - && echo 'int main() { return 0; }' > main.c \ - && gcc -o main main.c \ - && ./main \ - && find /tmp -mindepth 1 -delete - # Copy the build scripts to /usr/local/bin COPY build_source build_indep build_archdep build /usr/local/bin/