File tree Expand file tree Collapse file tree 2 files changed +64
-1
lines changed
Expand file tree Collapse file tree 2 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 11ARG VARIANT=ubuntu-20.04
2+ ARG CMAKE_VERSION=3.30.5
3+
24FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
35
4- RUN apt-get update && apt-get install -y \
6+ RUN apt-get update && apt-get install --yes \
57 lcov python python3.8-venv pip pipx \
68 && rm -rf /var/lib/apt/lists/*
79
810RUN pip install clang-format pre-commit
911
12+ COPY ./reinstall-cmake.sh /tmp/
13+ RUN chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${CMAKE_VERSION} && rm -f /tmp/reinstall-cmake.sh
14+
1015COPY post-start.sh /
1116RUN chmod +x /post-start.sh
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # -------------------------------------------------------------------------------------------------------------
3+ # Copyright (c) Microsoft Corporation. All rights reserved.
4+ # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5+ # -------------------------------------------------------------------------------------------------------------
6+ #
7+ set -e
8+
9+ CMAKE_VERSION=${1:- " none" }
10+
11+ if [ " ${CMAKE_VERSION} " = " none" ]; then
12+ echo " No CMake version specified, skipping CMake reinstallation"
13+ exit 0
14+ fi
15+
16+ # Cleanup temporary directory and associated files when exiting the script.
17+ cleanup () {
18+ EXIT_CODE=$?
19+ set +e
20+ if [[ -n " ${TMP_DIR} " ]]; then
21+ echo " Executing cleanup of tmp files"
22+ rm -Rf " ${TMP_DIR} "
23+ fi
24+ exit $EXIT_CODE
25+ }
26+ trap cleanup EXIT
27+
28+
29+ echo " Installing CMake..."
30+ apt-get -y purge --auto-remove cmake
31+ mkdir -p /opt/cmake
32+
33+ architecture=$( dpkg --print-architecture)
34+ case " ${architecture} " in
35+ arm64)
36+ ARCH=aarch64 ;;
37+ amd64)
38+ ARCH=x86_64 ;;
39+ * )
40+ echo " Unsupported architecture ${architecture} ."
41+ exit 1
42+ ;;
43+ esac
44+
45+ CMAKE_BINARY_NAME=" cmake-${CMAKE_VERSION} -linux-${ARCH} .sh"
46+ CMAKE_CHECKSUM_NAME=" cmake-${CMAKE_VERSION} -SHA-256.txt"
47+ TMP_DIR=$( mktemp -d -t cmake-XXXXXXXXXX)
48+
49+ echo " ${TMP_DIR} "
50+ cd " ${TMP_DIR} "
51+
52+ curl -sSL " https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION} /${CMAKE_BINARY_NAME} " -O
53+ curl -sSL " https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION} /${CMAKE_CHECKSUM_NAME} " -O
54+
55+ sha256sum -c --ignore-missing " ${CMAKE_CHECKSUM_NAME} "
56+ sh " ${TMP_DIR} /${CMAKE_BINARY_NAME} " --prefix=/opt/cmake --skip-license
57+
58+ ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
You can’t perform that action at this time.
0 commit comments