1-
21#! /bin/bash
32# Copyright (c) Meta Platforms, Inc. and affiliates.
43# All rights reserved.
98
109set -ex
1110
11+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
12+
1213# shellcheck source=/dev/null
13- source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
14+ source " ${SCRIPT_DIR} /utils.sh"
1415
15- # Double check if the NDK version is set
16+ # Double check if Zephyr setup is enabled.
1617[ -n " ${ZEPHYR_SDK} " ]
1718
18- install_prerequiresites () {
19+ install_prerequisites () {
1920 rm /var/lib/dpkg/info/libc-bin.*
2021 apt-get clean
2122 apt-get -y update
2223 apt-get install -y libc-bin
2324 apt-get -y update
2425 apt-get clean
25- apt-get install --no-install-recommends -y dos2unix
2626 apt-get install --no-install-recommends -y ca-certificates
2727 apt-get install -y --reinstall libc-bin
2828 apt-get install --no-install-recommends -y file
2929 apt-get install --no-install-recommends -y locales
3030 apt-get install --no-install-recommends -y git
3131 apt-get install --no-install-recommends -y build-essential
32- apt-get install --no-install-recommends -y cmake
3332 apt-get install --no-install-recommends -y ninja-build gperf
3433 apt-get install --no-install-recommends -y device-tree-compiler
3534 apt-get install --no-install-recommends -y wget
@@ -49,16 +48,14 @@ install_prerequiresites() {
4948 apt install -y python3.12 python3.12-dev python3.12-venv python3-pip
5049 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1
5150
52- # Upgrade cmake ot 3.24
53- apt update
54- apt install cmake
55- apt install software-properties-common lsb-release
51+ # Upgrade cmake to 3.24 or newer.
52+ apt install -y software-properties-common lsb-release
5653 apt update
5754 test -f /usr/share/doc/kitware-archive-keyring/copyright || \
5855 wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2> /dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null
59- " deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $( lsb_release -cs) main" | tee /etc/apt/sources.list.d/kitware.list > /dev/null
56+ echo " deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $( lsb_release -cs) main" | tee /etc/apt/sources.list.d/kitware.list > /dev/null
6057 apt update
61- apt install cmake
58+ apt install -y cmake
6259
6360 # Install additional required software for Zephyr
6461 apt install --no-install-recommends -y ccache \
@@ -77,19 +74,19 @@ install_prerequiresites() {
7774 apt-get clean -y
7875 apt-get autoremove --purge -y
7976 rm -rf /var/lib/apt/lists/*
80- wget https://apt.kitware.com/kitware-archive.sh && \
81- chmod +x kitware-archive.sh && \
82- ./kitware-archive.sh && \
83- rm -f kitware-archive.sh
8477 pip_install --no-cache-dir west
8578 pip_install pyelftools
8679
87- # Zephyr SDK
88- wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/zephyr-sdk-0.17.4_linux-x86_64.tar.xz
89- tar -xf zephyr-sdk-0.17.4_linux-x86_64.tar.xz
90- rm -f zephyr-sdk-0.17.4_linux-x86_64.tar.xz*
91- # Save setup to later and this get symlinked in to another folder in the test in trunk.yml
92- # ./zephyr-sdk-0.17.4/setup.sh -c -t arm-zephyr-eabi
80+ # Cache the Zephyr SDK release assets in the image. CI still runs
81+ # `west sdk install` in its workspace, but the local proxy fallback can serve
82+ # these files without downloading them on every job.
83+ local zephyr_sdk_version
84+ zephyr_sdk_version=" $( python3 " ${SCRIPT_DIR} /zephyr_sdk_release_proxy.py" --print-version) "
85+ local zephyr_sdk_cache_dir=" ${ZEPHYR_SDK_RELEASE_PROXY_CACHE_DIR:-/ opt/ zephyr-sdk-cache/ v${zephyr_sdk_version} } "
86+ python3 " ${SCRIPT_DIR} /zephyr_sdk_release_proxy.py" \
87+ --version " ${zephyr_sdk_version} " \
88+ --cache-dir " ${zephyr_sdk_cache_dir} " \
89+ --populate-cache
9390}
9491
95- install_prerequiresites
92+ install_prerequisites
0 commit comments