From 32986145e18ec05e5351b4483ecade450ef991a3 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 09:26:18 -0400
Subject: [PATCH 01/41] Update to ubuntu 24.04 and bump version

---
 integrations/docker/images/base/chip-build-minimal/Dockerfile  | 2 +-
 integrations/docker/images/base/chip-build/Dockerfile          | 3 +--
 integrations/docker/images/base/chip-build/version             | 2 +-
 integrations/docker/images/chip-cert-bins/Dockerfile           | 2 +-
 .../docker/images/stage-2/chip-cirque-device-base/Dockerfile   | 2 +-
 5 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/integrations/docker/images/base/chip-build-minimal/Dockerfile b/integrations/docker/images/base/chip-build-minimal/Dockerfile
index f44700ad912842..a0b95841cf6f6f 100644
--- a/integrations/docker/images/base/chip-build-minimal/Dockerfile
+++ b/integrations/docker/images/base/chip-build-minimal/Dockerfile
@@ -1,5 +1,5 @@
 # This minimal build image is intentionally not based on chip-build
-FROM ubuntu:focal
+FROM ubuntu:24.04
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
 
 # ARG NINJA_VERSION=v1.11.1
diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index a2f83fc275a4b0..a8186bab8a6056 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -1,5 +1,4 @@
-# start with Ubuntu 20.04LTS
-FROM ubuntu:focal
+FROM ubuntu:24.04
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
 
 VOLUME "/var/source"
diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version
index 05ab2a03dbdb4f..ee65bfc1e25843 100644
--- a/integrations/docker/images/base/chip-build/version
+++ b/integrations/docker/images/base/chip-build/version
@@ -1 +1 @@
-53 : [Tizen] Add libatomic.so to QEMU Docker image
+54 : [Tizen] Add libatomic.so to QEMU Docker image
diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile
index ef26e30945c943..13c57dc1076a9b 100644
--- a/integrations/docker/images/chip-cert-bins/Dockerfile
+++ b/integrations/docker/images/chip-cert-bins/Dockerfile
@@ -1,5 +1,5 @@
 # Stage 1: Setup dependencies (based on chip-build).
-FROM ubuntu:22.04 as chip-build-cert
+FROM ubuntu:24.04 as chip-build-cert
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
 ARG TARGETPLATFORM
 # COMMITHASH defines the target commit to build from. May be passed in using --build-arg.
diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile b/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile
index 8d79b306c1a327..4c5a46b6395bf2 100644
--- a/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:focal
+FROM ubuntu:24.04
 
 ARG OT_BR_POSIX_CHECKOUT=main
 

From 52e47e797d80125b7568e720b1859326cb3aea8e Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 09:26:50 -0400
Subject: [PATCH 02/41] Fix comment

---
 integrations/docker/images/base/chip-build/version | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version
index ee65bfc1e25843..b9a6272418e4f2 100644
--- a/integrations/docker/images/base/chip-build/version
+++ b/integrations/docker/images/base/chip-build/version
@@ -1 +1 @@
-54 : [Tizen] Add libatomic.so to QEMU Docker image
+54 : Update to Ubuntu 24.04 as the base build image

From b36ae55aa07db2e21bd6926ee1ed62e856b44516 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 09:41:28 -0400
Subject: [PATCH 03/41] Dependencies update

---
 .../docker/images/base/chip-build/Dockerfile  | 121 ++++--------------
 1 file changed, 26 insertions(+), 95 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index a8186bab8a6056..70be79520b43b2 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -38,9 +38,11 @@ RUN set -x \
     clang \
     clang-format \
     clang-tidy \
+    cmake \
     curl \
     flex \
     g++-10 \
+    generate-ninja \
     git \
     git-lfs \
     gperf \
@@ -49,8 +51,8 @@ RUN set -x \
     lcov \
     libavahi-client-dev \
     libavahi-common-dev \
-    libcairo-dev \
     libcairo2-dev \
+    libcairo-dev \
     libdbus-1-dev \
     libdbus-glib-1-dev \
     libdmalloc-dev \
@@ -67,8 +69,8 @@ RUN set -x \
     libpango1.0-dev \
     libpixman-1-dev \
     libreadline-dev \
-    libsdl-pango-dev \
     libsdl2-dev \
+    libsdl-pango-dev \
     libssl-dev \
     libtool \
     libudev-dev \
@@ -79,11 +81,18 @@ RUN set -x \
     meson \
     net-tools \
     ninja-build \
+    nodejs \
     pkg-config \
+    python3 \
+    python3-click \
+    python3-coloredlogs \
+    python3-dev \
+    python3-future \
+    python3-pandas \
+    python3-pip \
+    python3-tabulate \
+    python3-venv \
     python-is-python3 \
-    python3.9 \
-    python3.9-dev \
-    python3.9-venv \
     rsync \
     shellcheck \
     strace \
@@ -106,63 +115,19 @@ RUN set -x \
     && update-alternatives --set c++ /usr/bin/g++ \
     && : # last line
 
-# Cmake v3.23.1
-ENV CMAKE_PLATFORM_VERSION=
-RUN case ${TARGETPLATFORM} in \
-    "linux/amd64") CMAKE_PLATFORM_VERSION="x86_64";; \
-    "linux/arm64") CMAKE_PLATFORM_VERSION="aarch64";; \
-    *) \
-    test -n "$TARGETPLATFORM" \
-    echo "Unsupported platform ${TARGETPLATFORM}" \
-    && return 1 ;\
-    ;; \
-    esac \
-    && set -x \
-    && (cd /tmp \
-    && wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-Linux-$CMAKE_PLATFORM_VERSION.sh \
-    && sh cmake-3.23.1-Linux-$CMAKE_PLATFORM_VERSION.sh --exclude-subdir --prefix=/usr/local \
-    && rm -rf cmake-3.23.1-Linux-$CMAKE_PLATFORM_VERSION.sh) \
-    && exec bash \
-    && : # last line
-
-# Python 3.9 and PIP
+# NOTE: this install is NOT ideal as we are installing over system
+#       we should migrate to venvs for packages we do not directly have
+#       provided by the system
 RUN set -x \
-    && DEBIAN_FRONTEND=noninteractive  apt-get update \
-    && DEBIAN_FRONTEND=noninteractive  apt-get install -y libgirepository1.0-dev \
-    && DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common \
-    && add-apt-repository universe \
-    && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
-    && python3.9 get-pip.py \
-    && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 \
-    && rm -rf /var/lib/apt/lists/ \
-    && : # last line
-
-RUN set -x \
-    && pip3 install --no-cache-dir \
+    && pip3 install --no-cache-dir --break-system-packages \
     attrs \
-    click \
-    coloredlogs \
     cxxfilt \
-    future \
     ghapi \
     mobly \
-    pandas \
     portpicker \
     pygit \
     PyGithub \
     ruff \
-    tabulate \
-    && : # last line
-
-# build and install gn
-RUN set -x \
-    && git clone https://gn.googlesource.com/gn \
-    && cd gn \
-    && python3 build/gen.py \
-    && ninja -C out \
-    && cp out/gn /usr/local/bin \
-    && cd .. \
-    && rm -rf gn \
     && : # last line
 
 # Install bloat comparison tools
@@ -182,22 +147,22 @@ RUN set -x \
 RUN set -x \
     && apt-get update \
     # Install build and runtime requirements for IWYU
-    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing clang-12 libclang-12-dev \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing clang-18 libclang-18-dev \
     # Build and install IWYU
-    && git clone --depth=1 --branch=clang_12 https://github.com/include-what-you-use/include-what-you-use.git \
+    && git clone --depth=1 --branch=clang_18 https://github.com/include-what-you-use/include-what-you-use.git \
     && mkdir -p include-what-you-use/build \
     && cd include-what-you-use/build \
-    && cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr/lib/llvm-12 -DIWYU_LINK_CLANG_DYLIB=OFF .. \
+    && cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr/lib/llvm-18 -DIWYU_LINK_CLANG_DYLIB=OFF .. \
     && make -j8 \
     && strip bin/include-what-you-use \
     && make install \
-    # Save clang-12 files, so we can restore them after build dependencies cleanup
-    && tar -cf clang-12-files.tar $(dpkg -L libclang-common-12-dev |grep /include) /usr/lib/llvm-12/lib/libLLVM-12.so.1 \
+    # Save clang-18 files, so we can restore them after build dependencies cleanup
+    && tar -cf clang-18-files.tar $(dpkg -L libclang-common-18-dev |grep /include) /usr/lib/llvm-18/lib/libLLVM-18.so.1 \
     # Cleanup build dependencies
-    && apt autopurge -fy clang-12 libclang-12-dev \
+    && apt autopurge -fy clang-18 libclang-18-dev \
     && rm -rf /var/lib/apt/lists/ \
-    # Restore clang-12 files
-    && tar -xf clang-12-files.tar -C / \
+    # Restore clang-18 files
+    && tar -xf clang-18-files.tar -C / \
     # Cleanup
     && cd ../.. \
     && rm -rf include-what-you-use \
@@ -230,41 +195,7 @@ RUN case ${TARGETPLATFORM} in \
     ;; \
     esac
 
-# NodeJS: install a newer version than what apt-get would read
-# This installs the latest LTS version of nodejs
-#
-# NodeJS is required by github actions, we use Wandalen/wretry.action@v1.3.0
-# and that seems to use the built-in node installation in the image
-#
-# This is not a CHIP dependency directly, but used by CI
-ENV CHIP_NODE_VERSION=v16.13.2
-ENV NODE_PLATFORM_VERSION=
-RUN case ${TARGETPLATFORM} in \
-    "linux/amd64") NODE_PLATFORM_VERSION=x64;; \
-    "linux/arm64") NODE_PLATFORM_VERSION=arm64;; \
-    *) \
-    test -n "$TARGETPLATFORM" \
-    echo "Unsupported platform ${TARGETPLATFORM}" \
-    && return 1 ;\
-    ;; \
-    esac \
-    && set -x \
-    && mkdir node_js \
-    && cd node_js \
-    && wget https://nodejs.org/dist/$CHIP_NODE_VERSION/node-$CHIP_NODE_VERSION-linux-$NODE_PLATFORM_VERSION.tar.xz \
-    && tar xfvJ node-$CHIP_NODE_VERSION-linux-$NODE_PLATFORM_VERSION.tar.xz \
-    && mv node-$CHIP_NODE_VERSION-linux-$NODE_PLATFORM_VERSION /opt/ \
-    && ln -s /opt/node-$CHIP_NODE_VERSION-linux-$NODE_PLATFORM_VERSION /opt/node \
-    && ln -s /opt/node/bin/* /usr/bin \
-    && cd .. \
-    && rm -rf node_js \
-    && : # last line
-
 # Some things that save space
 # Protoc goes from 108M to 4.6M
 RUN strip /usr/local/bin/protoc*
 
-# CMake documentation not needed, saves 34MB
-# /usr/local/man contains cmake documentation
-RUN rm -rf /usr/local/doc/cmake
-RUN rm -rf /usr/local/man

From a21c73ce53fa0005bd3aca08d48f8b0f06ddf978 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 09:58:39 -0400
Subject: [PATCH 04/41] Use the latest gcc by default

---
 integrations/docker/images/base/chip-build/Dockerfile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 70be79520b43b2..ff6990c93899e1 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -107,8 +107,8 @@ RUN set -x \
 
 # Set gcc 10 as a default compiler to work with TSAN
 RUN set -x \
-    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 \
-    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 \
+    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10 \
+    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10 \
     && update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 \
     && update-alternatives --set cc /usr/bin/gcc \
     && update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 \

From a533b893ae898bbc668eec8c8e442c93df54bcb2 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 10:06:14 -0400
Subject: [PATCH 05/41] Fix up clang save & cleanup

---
 integrations/docker/images/base/chip-build/Dockerfile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index ff6990c93899e1..95ab2fcb930f14 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -157,7 +157,8 @@ RUN set -x \
     && strip bin/include-what-you-use \
     && make install \
     # Save clang-18 files, so we can restore them after build dependencies cleanup
-    && tar -cf clang-18-files.tar $(dpkg -L libclang-common-18-dev |grep /include) /usr/lib/llvm-18/lib/libLLVM-18.so.1 \
+    # AWK logic converts 'libLLVM.so.18.1 => /usr/lib/llvm-18/lib/libLLVM.so.18.1 (0x00007f781ede6000)' to '/usr/lib/llvm-18/lib/libLLVM.so.18.1'
+    && tar -cf clang-18-files.tar $(dpkg -L libclang-common-18-dev |grep /include) $(ldd bin/include-what-you-use | grep /usr/lib/llvm | awk '{print $3}') /usr/lib/llvm-18/lib/libLLVM.so.1 \
     # Cleanup build dependencies
     && apt autopurge -fy clang-18 libclang-18-dev \
     && rm -rf /var/lib/apt/lists/ \

From 73dc8250893d37bbcdafc62f0f8454d18b75cd5f Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 10:20:34 -0400
Subject: [PATCH 06/41] More build fixes

---
 .../images/base/chip-build-minimal/Dockerfile   | 17 ++++++-----------
 .../docker/images/base/chip-build/Dockerfile    |  5 +++++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/integrations/docker/images/base/chip-build-minimal/Dockerfile b/integrations/docker/images/base/chip-build-minimal/Dockerfile
index a0b95841cf6f6f..2a78261115faad 100644
--- a/integrations/docker/images/base/chip-build-minimal/Dockerfile
+++ b/integrations/docker/images/base/chip-build-minimal/Dockerfile
@@ -9,19 +9,14 @@ RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
     && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
-    build-essential ca-certificates git pkg-config python3-venv ninja-build \
+    build-essential \
+    ca-certificates \
+    generate-ninja \
+    git pkg-config \
+    ninja-build \
+    python3-venv \
     && git config --global advice.detachedHead false
 
-# RUN set -x && cd /var/tmp \
-#     && git clone --branch "$NINJA_VERSION" https://github.com/ninja-build/ninja.git \
-#     && ( cd ninja && ./configure.py --bootstrap && install -m 0755 ninja /usr/local/bin/ ) \
-#     && rm -rf ninja
-
-RUN set -x && cd /var/tmp \
-    && git clone https://gn.googlesource.com/gn \
-    && ( cd gn && git checkout "$GN_HASH" && CXX=g++ build/gen.py && ninja -C out && install -m 0755 out/gn /usr/local/bin/ ) \
-    && rm -rf gn
-
 # CHIP build dependencies
 RUN set -x \
     && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 95ab2fcb930f14..95a3534636371c 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -200,3 +200,8 @@ RUN case ${TARGETPLATFORM} in \
 # Protoc goes from 108M to 4.6M
 RUN strip /usr/local/bin/protoc*
 
+# Cleanup unused bits
+RUN set -x \
+    && DEBIAN_FRONTEND=noninteractive apt-get remove python3-scipy -fy --fix-missing \
+    && DEBIAN_FRONTEND=noninteractive apt-get autoremove -fy --fix-missing \
+    && : # last line

From ee7910c4faf37bc030e758ff2c03df9d7d40d601 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 10:37:23 -0400
Subject: [PATCH 07/41] Add more --break-system-packages

---
 .../docker/images/base/chip-build/Dockerfile       |  6 ++++--
 .../docker/images/chip-cert-bins/Dockerfile        |  6 +++---
 .../stage-2/chip-build-bouffalolab/Dockerfile      |  2 +-
 .../images/stage-2/chip-build-cirque/Dockerfile    | 14 +++++++++++---
 .../images/stage-2/chip-build-efr32/Dockerfile     |  2 +-
 .../images/stage-2/chip-build-mbed-os/Dockerfile   |  2 +-
 .../images/stage-2/chip-build-telink/Dockerfile    |  2 +-
 .../stage-2/chip-cirque-device-base/Dockerfile     |  2 +-
 .../images/vscode/chip-build-vscode/Dockerfile     |  2 +-
 9 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 95a3534636371c..fa66a630b3281e 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -119,7 +119,7 @@ RUN set -x \
 #       we should migrate to venvs for packages we do not directly have
 #       provided by the system
 RUN set -x \
-    && pip3 install --no-cache-dir --break-system-packages \
+    && pip3 install --break-system-packages --no-cache-dir --break-system-packages \
     attrs \
     cxxfilt \
     ghapi \
@@ -202,6 +202,8 @@ RUN strip /usr/local/bin/protoc*
 
 # Cleanup unused bits
 RUN set -x \
-    && DEBIAN_FRONTEND=noninteractive apt-get remove python3-scipy -fy --fix-missing \
+    && DEBIAN_FRONTEND=noninteractive apt-get remove -fy --fix-missing \
+    python3-scipy \
+    libllvm17t64 \
     && DEBIAN_FRONTEND=noninteractive apt-get autoremove -fy --fix-missing \
     && : # last line
diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile
index 13c57dc1076a9b..5fe42c49dba935 100644
--- a/integrations/docker/images/chip-cert-bins/Dockerfile
+++ b/integrations/docker/images/chip-cert-bins/Dockerfile
@@ -292,12 +292,12 @@ COPY --from=chip-build-cert-bins /root/connectedhomeip/out/python_env python_env
 COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing python_testing
 
 COPY --from=chip-build-cert-bins /root/connectedhomeip/scripts/tests/requirements.txt /tmp/requirements.txt
-RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt
+RUN pip install --break-system-packages -r /tmp/requirements.txt && rm /tmp/requirements.txt
 
 COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing/requirements.txt /tmp/requirements.txt
-RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt
+RUN pip install --break-system-packages -r /tmp/requirements.txt && rm /tmp/requirements.txt
 
 # PIP requires MASON package compilation, which seems to require a JDK
 RUN set -x && DEBIAN_FRONTEND=noninteractive apt-get install -fy openjdk-8-jdk
 
-RUN pip install --no-cache-dir python_lib/controller/python/chip*.whl
+RUN pip install --break-system-packages --no-cache-dir python_lib/controller/python/chip*.whl
diff --git a/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile b/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile
index faf280dd500e26..ad099fc48b6ef3 100644
--- a/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile
@@ -5,7 +5,7 @@ LABEL org.opencontainers.image.source https://github.com/project-chip/connectedh
 RUN apt update -y \
     && apt install vim -fy \
     && apt clean \
-    && pip3 install bflb-iot-tool==1.8.6 \
+    && pip3 install --break-system-packages bflb-iot-tool==1.8.6 \
     && : # last line
 
 COPY setup.sh /tmp
diff --git a/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile b/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile
index 1f10e8eae866d2..18ae44cb7ab79d 100644
--- a/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile
@@ -33,9 +33,17 @@ RUN set -x \
 RUN set -x \
    && apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -fy \
-   sudo socat psmisc tigervnc-standalone-server xorg xauth \
-   python3-pip python3-venv libdbus-glib-1-dev \
-   uuid-runtime libgirepository1.0-dev \
+   libdbus-glib-1-dev \
+   libgirepository1.0-dev \
+   psmisc \
+   python3-pip \
+   python3-venv \
+   socat \
+   sudo \
+   tigervnc-standalone-server \
+   uuid-runtime \
+   xauth \
+   xorg \
    && : # aids diffs
 
 COPY requirements_nogrpc.txt /requirements.txt
diff --git a/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile b/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile
index 9ac161a4a51800..c121c582bd3cf9 100644
--- a/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile
@@ -59,7 +59,7 @@ RUN set -x \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/ \
     # Install Python Packages
-    && pip3 install -r /tmp/requirements.txt \
+    && pip3 install --break-system-packages -r /tmp/requirements.txt \
     && rm /tmp/requirements.txt \
     && : # last line
 
diff --git a/integrations/docker/images/stage-2/chip-build-mbed-os/Dockerfile b/integrations/docker/images/stage-2/chip-build-mbed-os/Dockerfile
index 74d782772304cb..923d3fd23ef661 100644
--- a/integrations/docker/images/stage-2/chip-build-mbed-os/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-mbed-os/Dockerfile
@@ -25,7 +25,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
 # ------------------------------------------------------------------------------
 # Install Python modules
 RUN set -x \
-    && pip3 install --no-cache-dir -U mbed-cli==1.10.5 mbed-tools==7.44.0 \
+    && pip3 install --break-system-packages --no-cache-dir -U mbed-cli==1.10.5 mbed-tools==7.44.0 \
     && : # last line
 
 # ------------------------------------------------------------------------------
diff --git a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile
index 1333a4bfaaa286..5031afe33748ec 100644
--- a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile
@@ -35,7 +35,7 @@ RUN set -x \
     && apt-get update \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/ \
-    && pip3 install --no-cache-dir --user -r /opt/telink/zephyrproject/zephyr/scripts/requirements.txt \
+    && pip3 install --break-system-packages --no-cache-dir --user -r /opt/telink/zephyrproject/zephyr/scripts/requirements.txt \
     && : # last line
 
 ENV TELINK_ZEPHYR_BASE=/opt/telink/zephyrproject/zephyr
diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile b/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile
index 4c5a46b6395bf2..3ddfe44842e013 100644
--- a/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile
@@ -56,7 +56,7 @@ RUN apt-get update \
   && echo "ctrl_interface=/run/wpa_supplicant" >> /etc/wpa_supplicant/wpa_supplicant.conf \
   && echo "update_config=1" >> /etc/wpa_supplicant/wpa_supplicant.conf \
   && rm -rf /var/lib/apt/lists/* \
-  && pip3 install --no-cache-dir click==8.0.3 paramiko \
+  && pip3 install --break-system-packages --no-cache-dir click==8.0.3 paramiko \
   && mkdir /var/run/sshd \
   && echo 'root:admin' | chpasswd \
   && sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config \
diff --git a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile
index 91d8471cd8ce2f..ca45dafd068f0b 100644
--- a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile
+++ b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile
@@ -100,7 +100,7 @@ RUN set -x \
 
 # Required for the Bouffalolab platform
 RUN set -x \
-    && pip3 install bflb-iot-tool==1.8.6 \
+    && pip3 install --break-system-packages bflb-iot-tool==1.8.6 \
     && : # last line
 
 ENV PATH $PATH:/usr/lib/kotlinc/bin

From 851353f5f43e409079000a46f530555ed30d4037 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 10:41:41 -0400
Subject: [PATCH 08/41] Do not remove libllvm17t64 ... I am unsure about that
 one

---
 integrations/docker/images/base/chip-build/Dockerfile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index fa66a630b3281e..dcd0d7724f5fe3 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -204,6 +204,5 @@ RUN strip /usr/local/bin/protoc*
 RUN set -x \
     && DEBIAN_FRONTEND=noninteractive apt-get remove -fy --fix-missing \
     python3-scipy \
-    libllvm17t64 \
     && DEBIAN_FRONTEND=noninteractive apt-get autoremove -fy --fix-missing \
     && : # last line

From 39dd17e8577872ce3b6746ad5d127e7451c220f7 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 10:43:48 -0400
Subject: [PATCH 09/41] Remove it after all ... seems some size savings  here

---
 integrations/docker/images/base/chip-build/Dockerfile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index dcd0d7724f5fe3..fa66a630b3281e 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -204,5 +204,6 @@ RUN strip /usr/local/bin/protoc*
 RUN set -x \
     && DEBIAN_FRONTEND=noninteractive apt-get remove -fy --fix-missing \
     python3-scipy \
+    libllvm17t64 \
     && DEBIAN_FRONTEND=noninteractive apt-get autoremove -fy --fix-missing \
     && : # last line

From 0127c6a7228a466305c0bf4e6f8cb5b32cc94eab Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 11:14:45 -0400
Subject: [PATCH 10/41] More cleanup

---
 .../docker/images/base/chip-build-minimal/Dockerfile     | 3 ---
 integrations/docker/images/base/chip-build/Dockerfile    | 9 +--------
 2 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/integrations/docker/images/base/chip-build-minimal/Dockerfile b/integrations/docker/images/base/chip-build-minimal/Dockerfile
index 2a78261115faad..c372f040585728 100644
--- a/integrations/docker/images/base/chip-build-minimal/Dockerfile
+++ b/integrations/docker/images/base/chip-build-minimal/Dockerfile
@@ -2,9 +2,6 @@
 FROM ubuntu:24.04
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
 
-# ARG NINJA_VERSION=v1.11.1
-ARG GN_HASH=5a004f9427a050c6c393c07ddb85cba8ff3849fa
-
 RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index fa66a630b3281e..b1d14381a31d74 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -29,7 +29,7 @@ RUN case ${TARGETPLATFORM} in \
 # base build and check tools and libraries layer
 RUN set -x \
     && apt-get update \
-    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing --no-install-recommends \
     autoconf \
     automake \
     bison \
@@ -200,10 +200,3 @@ RUN case ${TARGETPLATFORM} in \
 # Protoc goes from 108M to 4.6M
 RUN strip /usr/local/bin/protoc*
 
-# Cleanup unused bits
-RUN set -x \
-    && DEBIAN_FRONTEND=noninteractive apt-get remove -fy --fix-missing \
-    python3-scipy \
-    libllvm17t64 \
-    && DEBIAN_FRONTEND=noninteractive apt-get autoremove -fy --fix-missing \
-    && : # last line

From 80d2b8a963ab50b8d687acd043384897d01ee5ff Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 11:15:59 -0400
Subject: [PATCH 11/41] Drop alternative install

---
 integrations/docker/images/base/chip-build/Dockerfile | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index b1d14381a31d74..e844f353b096d3 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -105,16 +105,6 @@ RUN set -x \
     && git lfs install \
     && : # last line
 
-# Set gcc 10 as a default compiler to work with TSAN
-RUN set -x \
-    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10 \
-    && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10 \
-    && update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 \
-    && update-alternatives --set cc /usr/bin/gcc \
-    && update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 \
-    && update-alternatives --set c++ /usr/bin/g++ \
-    && : # last line
-
 # NOTE: this install is NOT ideal as we are installing over system
 #       we should migrate to venvs for packages we do not directly have
 #       provided by the system

From 9ea09a6046740168a4cd60b4d22b79a850f7ecc9 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 11:17:46 -0400
Subject: [PATCH 12/41] Install gcc without a specific version. Undoes #28478

---
 integrations/docker/images/base/chip-build/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index e844f353b096d3..6405c1c9091c9b 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -41,7 +41,7 @@ RUN set -x \
     cmake \
     curl \
     flex \
-    g++-10 \
+    g++ \
     generate-ninja \
     git \
     git-lfs \

From 87ea25b19f5a7399e27f9293004685219b0f7a9c Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 11:44:49 -0400
Subject: [PATCH 13/41] Need llvm18-dev as well

---
 integrations/docker/images/base/chip-build/Dockerfile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 6405c1c9091c9b..542744890b0849 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -137,7 +137,7 @@ RUN set -x \
 RUN set -x \
     && apt-get update \
     # Install build and runtime requirements for IWYU
-    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing clang-18 libclang-18-dev \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing clang-18 libclang-18-dev llvm-18-dev \
     # Build and install IWYU
     && git clone --depth=1 --branch=clang_18 https://github.com/include-what-you-use/include-what-you-use.git \
     && mkdir -p include-what-you-use/build \
@@ -150,7 +150,7 @@ RUN set -x \
     # AWK logic converts 'libLLVM.so.18.1 => /usr/lib/llvm-18/lib/libLLVM.so.18.1 (0x00007f781ede6000)' to '/usr/lib/llvm-18/lib/libLLVM.so.18.1'
     && tar -cf clang-18-files.tar $(dpkg -L libclang-common-18-dev |grep /include) $(ldd bin/include-what-you-use | grep /usr/lib/llvm | awk '{print $3}') /usr/lib/llvm-18/lib/libLLVM.so.1 \
     # Cleanup build dependencies
-    && apt autopurge -fy clang-18 libclang-18-dev \
+    && apt autopurge -fy clang-18 libclang-18-dev llvm-18-dev \
     && rm -rf /var/lib/apt/lists/ \
     # Restore clang-18 files
     && tar -xf clang-18-files.tar -C / \

From 0dc6251c158fc47d0e54820030afbc46ac1b7be2 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 12:07:39 -0400
Subject: [PATCH 14/41] Update to lib64 paths

---
 integrations/docker/images/base/chip-build/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 542744890b0849..1a56bbbd61acfe 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -174,7 +174,7 @@ RUN case ${TARGETPLATFORM} in \
     && git clone --depth=1 --branch=$GLIB_VERSION https://github.com/GNOME/glib.git \
     && CFLAGS="-O2 -g -fsanitize=thread" meson glib/build glib -Dtests=false \
     && DESTDIR=../build-image ninja -C glib/build install \
-    && mv glib/build-image/usr/local/lib/x86_64-linux-gnu/lib* $LD_LIBRARY_PATH_TSAN \
+    && mv glib/build-image/usr/local/lib64/lib* $LD_LIBRARY_PATH_TSAN \
     && rm -rf glib \
     ;; \
     "linux/arm64") \

From f14b85c1bf78277767e02ef2c230b92535fd918f Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 12:15:14 -0400
Subject: [PATCH 15/41] Also install xz

---
 .../docker/images/stage-1/chip-build-crosscompile/Dockerfile     | 1 +
 1 file changed, 1 insertion(+)

diff --git a/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile b/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile
index 8767d462be3973..7440c3c16a5f3b 100644
--- a/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile
+++ b/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile
@@ -6,6 +6,7 @@ RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
     git \
+    xz \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/ \
     && : # last line

From fcf3a20b1808cee0f126f2f7a59c93744662938c Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 12:16:05 -0400
Subject: [PATCH 16/41] xz is in utils

---
 .../docker/images/stage-1/chip-build-crosscompile/Dockerfile    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile b/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile
index 7440c3c16a5f3b..5fa709e30d10b9 100644
--- a/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile
+++ b/integrations/docker/images/stage-1/chip-build-crosscompile/Dockerfile
@@ -6,7 +6,7 @@ RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
     git \
-    xz \
+    xz-utils \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/ \
     && : # last line

From ecff592374fe8c79db2ad315ccd431a904606b8f Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 12:24:04 -0400
Subject: [PATCH 17/41] Fix asr depends when no recommends is installed

---
 integrations/docker/images/stage-2/chip-build-asr/Dockerfile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/integrations/docker/images/stage-2/chip-build-asr/Dockerfile b/integrations/docker/images/stage-2/chip-build-asr/Dockerfile
index d3e54310b58550..627d7d83e83096 100644
--- a/integrations/docker/images/stage-2/chip-build-asr/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-asr/Dockerfile
@@ -5,6 +5,8 @@ LABEL org.opencontainers.image.source https://github.com/project-chip/connectedh
 RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
+    bzip2 \
+    tar \
     wget \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/ \

From 73463634b49e65266f90e224e6b2fe6c6bca328f Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 12:58:21 -0400
Subject: [PATCH 18/41] Clean up infineon, make the curl download to NOT be
 silent

---
 .../stage-2/chip-build-infineon/Dockerfile     | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/integrations/docker/images/stage-2/chip-build-infineon/Dockerfile b/integrations/docker/images/stage-2/chip-build-infineon/Dockerfile
index 9b38709d7204a6..5578b27ce50988 100644
--- a/integrations/docker/images/stage-2/chip-build-infineon/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-infineon/Dockerfile
@@ -4,13 +4,23 @@ LABEL org.opencontainers.image.source https://github.com/project-chip/connectedh
 
 # ------------------------------------------------------------------------------
 # Install prerequisites
-RUN apt update -y \
-    && apt install -y curl git make file libglib2.0-0 libusb-1.0-0 libncurses5 sudo \
-    && apt clean
+RUN set -x \
+    && apt-get update \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing --no-install-recommends \
+    curl \
+    git \
+    make \
+    file \
+    libglib2.0-0 \
+    libusb-1.0-0 sudo \
+    && rm -rf /var/lib/apt/lists/ \
+    && : # last line
 
 # ------------------------------------------------------------------------------
 # Download and extract ModusToolbox 2.3
-RUN curl --fail --location --silent --show-error https://itoolspriv.infineon.com/itbhs/api/packages/com.ifx.tb.tool.modustoolbox/Versions/2.4.0.5972-public/artifacts/ModusToolbox_2.4.0.5972-linux-install.tar.gz/download?noredirect -o /tmp/ModusToolbox_2.4.0.5972-linux-install.tar.gz \
+RUN curl --fail --location --show-error \
+    https://itoolspriv.infineon.com/itbhs/api/packages/com.ifx.tb.tool.modustoolbox/Versions/2.4.0.5972-public/artifacts/ModusToolbox_2.4.0.5972-linux-install.tar.gz/download?noredirect \
+    -o /tmp/ModusToolbox_2.4.0.5972-linux-install.tar.gz \
     && tar -C /opt -zxf /tmp/ModusToolbox_2.4.0.5972-linux-install.tar.gz \
     && rm /tmp/ModusToolbox_2.4.0.5972-linux-install.tar.gz
 

From 75bfebd437c2a9f428cd6393f1987f69a81e1265 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 13:24:13 -0400
Subject: [PATCH 19/41] using -j8 is arbitrary ... use nproc instead

---
 integrations/docker/images/base/chip-build/Dockerfile         | 4 ++--
 .../docker/images/stage-2/chip-build-nuttx/Dockerfile         | 2 +-
 .../docker/images/stage-3/chip-build-esp32-qemu/Dockerfile    | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 1a56bbbd61acfe..07a0b5f6467d56 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -126,7 +126,7 @@ RUN set -x \
     && mkdir -p bloaty/build \
     && cd bloaty/build \
     && cmake -DCMAKE_BUILD_TYPE=MinSizeRel ../ \
-    && make -j8 \
+    && make -j$(nproc) \
     && strip bloaty \
     && make install \
     && cd ../.. \
@@ -143,7 +143,7 @@ RUN set -x \
     && mkdir -p include-what-you-use/build \
     && cd include-what-you-use/build \
     && cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr/lib/llvm-18 -DIWYU_LINK_CLANG_DYLIB=OFF .. \
-    && make -j8 \
+    && make -j$(nproc) \
     && strip bin/include-what-you-use \
     && make install \
     # Save clang-18 files, so we can restore them after build dependencies cleanup
diff --git a/integrations/docker/images/stage-2/chip-build-nuttx/Dockerfile b/integrations/docker/images/stage-2/chip-build-nuttx/Dockerfile
index c8677482014320..fdc28b4eaff6a8 100644
--- a/integrations/docker/images/stage-2/chip-build-nuttx/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-nuttx/Dockerfile
@@ -19,7 +19,7 @@ RUN set -x \
     && tar xzf gcc-13.1.0.tar.gz \
     && cd gcc-13.1.0 \
     && ./configure --prefix=/opt/nuttx/gcc-13 --disable-multilib \
-    && make -j8 \
+    && make -j$(nproc) \
     && make install-strip \
     && rm -rf ../../gcc_build \
     && : # last line
diff --git a/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile b/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile
index 847521afe50d6c..768fdb0a6cc613 100644
--- a/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile
+++ b/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile
@@ -15,7 +15,7 @@ WORKDIR /opt/espressif/qemu
 RUN set -x \
     && git clone --depth 1 -b esp-develop-20210826 https://github.com/espressif/qemu.git ../qemu-src \
     && ../qemu-src/configure --target-list=xtensa-softmmu --enable-debug --disable-strip --disable-user --disable-capstone --disable-vnc --disable-sdl --disable-gtk \
-    && make -j8 \
+    && make -j$(nproc) \
     && : # last line
 
 ENV QEMU_ESP32_DIR=/opt/espressif/qemu

From 436b45678c0b34ea2a6e6cd7ab38bdea5b9fb466 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Tue, 28 May 2024 14:44:42 -0400
Subject: [PATCH 20/41] update what qemu means

---
 .../docker/images/stage-2/chip-build-linux-qemu/Dockerfile    | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
index b14a00c2ec9710..d3a56c3ac8876c 100644
--- a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
@@ -32,7 +32,9 @@ RUN set -x \
 	libguestfs-tools \
 	linux-image-generic \
 	ncurses-dev \
-	qemu \
+	qemu-user \
+	qemu-system \
+	qemu-system-x86 \
 	xz-utils \
 	zstd \
 	&& apt-get clean \

From 1123daab5664df3d0d4f4eaca9a944dfce767d66 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Thu, 30 May 2024 12:24:20 -0400
Subject: [PATCH 21/41] Install patch for the qemu image build

---
 .../docker/images/stage-2/chip-build-linux-qemu/Dockerfile       | 1 +
 1 file changed, 1 insertion(+)

diff --git a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
index d3a56c3ac8876c..0a554a150472cc 100644
--- a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
@@ -32,6 +32,7 @@ RUN set -x \
 	libguestfs-tools \
 	linux-image-generic \
 	ncurses-dev \
+  patch \
 	qemu-user \
 	qemu-system \
 	qemu-system-x86 \

From c0f4cd28235aeb2199484eba2836be1cd4e6ad73 Mon Sep 17 00:00:00 2001
From: Maksymilian Knust <m.knust@samsung.com>
Date: Mon, 3 Jun 2024 15:35:49 +0200
Subject: [PATCH 22/41] Adapt Tizen Dockerfiles

---
 .../stage-2/chip-build-tizen/Dockerfile       | 20 ++++---------------
 .../stage-3/chip-build-tizen-qemu/Dockerfile  |  8 +++++---
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/integrations/docker/images/stage-2/chip-build-tizen/Dockerfile b/integrations/docker/images/stage-2/chip-build-tizen/Dockerfile
index 5380812b663a8c..4d907b1d6e48f4 100644
--- a/integrations/docker/images/stage-2/chip-build-tizen/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-tizen/Dockerfile
@@ -2,25 +2,13 @@ ARG VERSION=1
 FROM ghcr.io/project-chip/chip-build:${VERSION}
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
 
-# ------------------------------------------------------------------------------
-# Add group/user for tizen
-ARG USER_NAME=tizen
-ARG USER_UID=1000
-ARG USER_GID=$USER_UID
-ENV USER_HOME /home/$USER_NAME
-
-RUN set -x \
-    && groupadd -g $USER_GID $USER_NAME \
-    && useradd -m $USER_NAME -s /bin/bash -u $USER_UID -g $USER_GID -G sudo -l \
-    && : # last line
-
 # ------------------------------------------------------------------------------
 # Install dependencies
 RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
     cpio \
-    libncurses5 \
+    libncurses6 \
     obs-build \
     openjdk-8-jre-headless \
     wget \
@@ -39,7 +27,7 @@ COPY tizen-sdk-installer $TIZEN_SDK_ROOT/files/installer
 RUN set -x \
     && bash $TIZEN_SDK_ROOT/files/installer/install.sh \
     --tizen-sdk-path $TIZEN_SDK_ROOT \
-    --tizen-sdk-data-path $USER_HOME/tizen-sdk-data \
+    --tizen-sdk-data-path /home/ubuntu/tizen-sdk-data \
     --tizen-version $TIZEN_VERSION  \
     --override-secret-tool \
     && : # last line
@@ -52,5 +40,5 @@ ENV PATH="$TIZEN_SDK_TOOLCHAIN/bin:$TIZEN_SDK_ROOT/tools/ide/bin:$TIZEN_SDK_ROOT
 
 # ------------------------------------------------------------------------------
 # Switch to the non-root user
-USER $USER_NAME
-WORKDIR $USER_HOME
+USER ubuntu
+WORKDIR /home/ubuntu
diff --git a/integrations/docker/images/stage-3/chip-build-tizen-qemu/Dockerfile b/integrations/docker/images/stage-3/chip-build-tizen-qemu/Dockerfile
index 8c38d19c1b3ed8..3bfa46e9ab601c 100644
--- a/integrations/docker/images/stage-3/chip-build-tizen-qemu/Dockerfile
+++ b/integrations/docker/images/stage-3/chip-build-tizen-qemu/Dockerfile
@@ -19,7 +19,9 @@ RUN set -x \
     genisoimage \
     libgmp-dev \
     libmpc-dev \
+    patch \
     qemu-system-arm \
+    xz-utils \
     # Cleanup
     && apt-get clean \
     && rm -rf /var/lib/apt/lists \
@@ -58,7 +60,7 @@ RUN set -x \
     && ./scripts/config -e OVERLAY_FS -e ISO9660_FS \
     && ./scripts/config -e SECURITY_SMACK_PERMISSIVE_MODE \
     && make olddefconfig \
-    && make zImage \
+    && make -j$(nproc) zImage \
     && mv arch/arm/boot/zImage $TIZEN_IOT_QEMU_KERNEL \
     # Cleanup
     && rm -rf /tmp/workdir \
@@ -194,5 +196,5 @@ RUN set -x \
 
 # ------------------------------------------------------------------------------
 # Switch back to the non-root user
-USER $USER_NAME
-WORKDIR $USER_HOME
+USER ubuntu
+WORKDIR /home/ubuntu

From fb18e9b1c69f1c18adefe5649ee1792b3e5a4035 Mon Sep 17 00:00:00 2001
From: Jakub Latusek <j.latusek@samsung.com>
Date: Thu, 6 Jun 2024 08:48:18 +0200
Subject: [PATCH 23/41] Update ubuntu version

---
 .../stage-2/chip-build-linux-qemu/Dockerfile  | 96 +++++++++++++------
 1 file changed, 69 insertions(+), 27 deletions(-)

diff --git a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
index 0a554a150472cc..22ef123d7f0165 100644
--- a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
@@ -1,6 +1,6 @@
 ARG VERSION=latest
 ARG UBUNTU_QEMU_DIR_DEFAULT="/opt/ubuntu-qemu"
-ARG UBUNTU_QEMU_IMG_DEFAULT="${UBUNTU_QEMU_DIR_DEFAULT}/ubuntu-20.04.img"
+ARG UBUNTU_QEMU_IMG_DEFAULT="${UBUNTU_QEMU_DIR_DEFAULT}/ubuntu-24.04.img"
 
 FROM ghcr.io/project-chip/chip-build:${VERSION} as build-env
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
@@ -13,6 +13,8 @@ ARG UBUNTU_QEMU_IMG_DEFAULT
 
 ENV UBUNTU_QEMU_DIR=${UBUNTU_QEMU_DIR_DEFAULT}
 ENV UBUNTU_QEMU_IMG=${UBUNTU_QEMU_IMG_DEFAULT}
+ENV KERNEL_PATH="${UBUNTU_QEMU_DIR_DEFAULT}/bzImage"
+
 
 RUN mkdir -p /tmp/workdir/linux
 COPY files/linux/0001-Bluetooth-MGMT-Synchronize-scan-start-and-LE-Meta-ev.patch /tmp/workdir/linux/0001-Bluetooth-MGMT-Synchronize-scan-start-and-LE-Meta-ev.patch
@@ -32,10 +34,8 @@ RUN set -x \
 	libguestfs-tools \
 	linux-image-generic \
 	ncurses-dev \
-  patch \
-	qemu-user \
+	patch \
 	qemu-system \
-	qemu-system-x86 \
 	xz-utils \
 	zstd \
 	&& apt-get clean \
@@ -122,36 +122,26 @@ RUN mkdir -p /tmp/workdir/linux \
 	&& make \
 	&& make install DESTDIR=/opt/ubuntu-qemu/rootfs && mkdir -p /opt/ubuntu-qemu/rootfs/usr/bin && cp /tmp/workdir/bluez/emulator/btvirt /opt/ubuntu-qemu/rootfs/usr/bin \
 	# Download Ubuntu image for QEMU
-	&& curl https://cloud-images.ubuntu.com/minimal/releases/focal/release/ubuntu-20.04-minimal-cloudimg-amd64.img \
-	-o /tmp/workdir/ubuntu-20.04-minimal-cloudimg-amd64.img \
+	&& curl https://cloud-images.ubuntu.com/minimal/releases/noble/release/ubuntu-24.04-minimal-cloudimg-amd64.img \
+	-o /tmp/workdir/ubuntu-24.04-minimal-cloudimg-amd64.img \
 	# Prepare ubuntu image
 	&& qemu-img create -f qcow2 -o preallocation=off $UBUNTU_QEMU_IMG 10G \
-	&& virt-resize --expand /dev/sda1 /tmp/workdir/ubuntu-20.04-minimal-cloudimg-amd64.img $UBUNTU_QEMU_IMG \
-	&& guestfish -a $UBUNTU_QEMU_IMG \
-	--mount /dev/sda3:/ \
+	&& virt-resize --expand /dev/sda1 /tmp/workdir/ubuntu-24.04-minimal-cloudimg-amd64.img $UBUNTU_QEMU_IMG
+RUN guestfish -a $UBUNTU_QEMU_IMG \
+	--mount /dev/sda4:/ \
 	--network \
 	copy-in /opt/ubuntu-qemu/rootfs/lib /usr : \
 	copy-in /opt/ubuntu-qemu/rootfs/usr / : \
 	sh 'apt-get remove -y snapd' : \
-	sh 'apt-get update' : \
-	sh 'DEBIAN_FRONTEND=noninteractive apt-get install -y dnsmasq hostapd wpasupplicant iw libdw1 rfkill' : \
 	sh '/usr/bin/systemctl enable bluetooth.service' : \
 	sh '/usr/bin/systemctl disable cloud-init.service' : \
-	sh '/usr/bin/systemctl disable dbus-fi.w1.wpa_supplicant1.service' : \
-	sh '/usr/bin/systemctl disable dnsmasq.service' : \
-	sh '/usr/bin/systemctl disable hostapd.service' : \
 	sh '/usr/bin/systemctl disable lxd-agent.service' : \
 	sh '/usr/bin/systemctl disable systemd-networkd-wait-online.service' : \
 	sh '/usr/bin/systemctl disable systemd-timesyncd.service' : \
-	sh '/usr/bin/systemctl disable wpa_supplicant.service' : \
 	sh '/usr/bin/systemctl mask cloud-init.service' : \
-	sh '/usr/bin/systemctl mask dbus-fi.w1.wpa_supplicant1.service' : \
-	sh '/usr/bin/systemctl mask dnsmasq.service' : \
-	sh '/usr/bin/systemctl mask hostapd.service' : \
 	sh '/usr/bin/systemctl mask lxd-agent.service' : \
 	sh '/usr/bin/systemctl mask systemd-networkd-wait-online.service' : \
 	sh '/usr/bin/systemctl mask systemd-timesyncd.service' : \
-	sh '/usr/bin/systemctl mask wpa_supplicant.service' : \
 	sh 'passwd -d root' : \
 	sh 'ssh-keygen -A' : \
 	sh '/bin/echo -e "PermitRootLogin yes\nPasswordAuthentication yes\nPermitEmptyPasswords yes" > /etc/ssh/sshd_config' : \
@@ -164,13 +154,65 @@ RUN mkdir -p /tmp/workdir/linux \
 	sh 'sed -i "s#^ExecStart=.*#ExecStart=-/usr/libexec/bluetooth/bluetoothd -E#" /lib/systemd/system/bluetooth.service' : \
 	sh 'rm -f /etc/resolv.conf && /bin/echo -e "nameserver 8.8.8.8" > /etc/resolv.conf' : \
 	sh '/bin/echo -e "host0 /chip 9p trans=virtio,version=9p2000.L 0 0" >> /etc/fstab' : \
-	sh '/bin/echo -e "export PW_ENVIRONMENT_ROOT=/root/pw_root\n[ -x /launcher.sh ] && /launcher.sh\n" >> /root/.profile' : \
-	sh 'DEBIAN_FRONTEND=noninteractive apt-get -y install git gcc g++ pkg-config libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev ninja-build python3 python3-venv python3-dev python3-pip unzip libgirepository1.0-dev libcairo2-dev libreadline-dev' : \
-	sh 'git config --file /root/.gitconfig  --add safe.directory "*"' : \
-	sh 'apt-get clean' : \
-	sh 'rm -rf /var/lib/apt/lists/*' : \
-	sh 'rm -rf /var/cache/apt/*' : \
-	sh 'echo Configuration completed.' \
+	sh '/bin/echo -e "[ -x /init.sh ] && /init.sh\n" >> /root/.profile' : \
+	sh '/bin/echo -e "export PW_ENVIRONMENT_ROOT=/root/pw_root\n[ -x /launcher.sh ] && /launcher.sh\n" >> /root/.profile'
+RUN echo -n \
+	"#!/bin/bash\n" \
+	"export DEBIAN_FRONTEND=noninteractive \n" \
+	"apt-get update\n" \
+	"apt-get install -y apt-utils\n" \
+	"apt-get install -y dnsmasq hostapd wpasupplicant iw libdw1 rfkill\n" \
+	"DEBIAN_FRONTEND=noninteractive apt-get -y install " \
+	"	g++ " \
+	"	gcc " \
+	"	git " \
+	"	libavahi-client-dev " \
+	"	libcairo2-dev " \
+	"	libdbus-1-dev " \
+	"	libgirepository1.0-dev " \
+	"	libglib2.0-dev " \
+	"	libreadline-dev " \
+	"	libssl-dev " \
+	"	ninja-build " \
+	"	pkg-config " \
+	"	python3 " \
+	"	python3-dev " \
+	"	python3-pip " \
+	"	python3-venv " \
+	"	unzip \n" \
+	"/usr/bin/systemctl disable dbus-fi.w1.wpa_supplicant1.service\n" \
+	"/usr/bin/systemctl disable dnsmasq.service\n" \
+	"/usr/bin/systemctl disable hostapd.service\n" \
+	"/usr/bin/systemctl disable wpa_supplicant.service\n" \
+	"/usr/bin/systemctl mask dnsmasq.service\n" \
+	"/usr/bin/systemctl mask hostapd.service\n" \
+	"/usr/bin/systemctl mask dbus-fi.w1.wpa_supplicant1.service\n" \
+	"/usr/bin/systemctl mask wpa_supplicant.service\n" \
+	"git config --file /root/.gitconfig  --add safe.directory \"*\"\n" \
+	"echo Installed: cleaning and shutting down\n" \
+	"apt-get clean\n" \
+	"rm -rf /var/lib/apt/lists/*\n" \
+	"rm -rf /var/cache/apt/*\n" \
+	"rm /init.sh\n" \
+	"echo Configuration completed\n " \
+	"echo o > /proc/sysrq-trigger\n" \
+	| guestfish --rw -a $UBUNTU_QEMU_IMG -m /dev/sda4:/ upload - /init.sh : chmod 0755 /init.sh
+RUN qemu-system-x86_64 \
+	-machine ubuntu \
+	-smp 4 \
+	-m 2048 \
+	-nographic \
+	-monitor null \
+	-serial stdio \
+	-display none \
+	-device virtio-blk-pci,drive=virtio-blk1 \
+	-drive file="${UBUNTU_QEMU_IMG}",id=virtio-blk1,if=none,format=qcow2,readonly=off \
+	-kernel "${KERNEL_PATH}" \
+	-append 'console=ttyS0 root=/dev/vda4' \
+	-netdev user,id=network0 \
+	-device e1000,netdev=network0,mac=52:54:00:12:34:56 \
+    -virtfs "local,path=/tmp,mount_tag=host0,security_model=passthrough,id=host0" \
+# tmp folder is mounted only to preserve error during boot
 	&& mkdir -p /chip \
 	&& rm -rf /opt/ubuntu-qemu/rootfs \
 	&& echo -n \
@@ -208,7 +250,7 @@ RUN set -x \
 	&& apt-get update \
 	&& DEBIAN_FRONTEND=noninteractive apt-get install -fy \
 	cpu-checker \
-	qemu \
+	libgirepository-1.0-1 \
 	qemu-system-x86 \
 	&& apt-get clean \
 	&& rm -rf /var/lib/apt/lists/* \

From 745ed8cd46b553d62cdad193d5c177143f7df7bf Mon Sep 17 00:00:00 2001
From: Jakub Latusek <j.latusek@samsung.com>
Date: Thu, 6 Jun 2024 19:11:54 +0200
Subject: [PATCH 24/41] Update Dockerfile for chip-build-linux-qemu image

---
 .../stage-2/chip-build-linux-qemu/Dockerfile  | 24 +++++++++----------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
index 22ef123d7f0165..02a65e01a7a829 100644
--- a/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-linux-qemu/Dockerfile
@@ -123,11 +123,11 @@ RUN mkdir -p /tmp/workdir/linux \
 	&& make install DESTDIR=/opt/ubuntu-qemu/rootfs && mkdir -p /opt/ubuntu-qemu/rootfs/usr/bin && cp /tmp/workdir/bluez/emulator/btvirt /opt/ubuntu-qemu/rootfs/usr/bin \
 	# Download Ubuntu image for QEMU
 	&& curl https://cloud-images.ubuntu.com/minimal/releases/noble/release/ubuntu-24.04-minimal-cloudimg-amd64.img \
-	-o /tmp/workdir/ubuntu-24.04-minimal-cloudimg-amd64.img \
+	-o /tmp/workdir/ubuntu-24.04-minimal-cloudimg-amd64.img
 	# Prepare ubuntu image
-	&& qemu-img create -f qcow2 -o preallocation=off $UBUNTU_QEMU_IMG 10G \
-	&& virt-resize --expand /dev/sda1 /tmp/workdir/ubuntu-24.04-minimal-cloudimg-amd64.img $UBUNTU_QEMU_IMG
-RUN guestfish -a $UBUNTU_QEMU_IMG \
+RUN qemu-img create -f qcow2 -o preallocation=off $UBUNTU_QEMU_IMG 10G \
+	&& virt-resize --expand /dev/sda1 /tmp/workdir/ubuntu-24.04-minimal-cloudimg-amd64.img $UBUNTU_QEMU_IMG \
+	&& guestfish -a $UBUNTU_QEMU_IMG \
 	--mount /dev/sda4:/ \
 	--network \
 	copy-in /opt/ubuntu-qemu/rootfs/lib /usr : \
@@ -154,10 +154,11 @@ RUN guestfish -a $UBUNTU_QEMU_IMG \
 	sh 'sed -i "s#^ExecStart=.*#ExecStart=-/usr/libexec/bluetooth/bluetoothd -E#" /lib/systemd/system/bluetooth.service' : \
 	sh 'rm -f /etc/resolv.conf && /bin/echo -e "nameserver 8.8.8.8" > /etc/resolv.conf' : \
 	sh '/bin/echo -e "host0 /chip 9p trans=virtio,version=9p2000.L 0 0" >> /etc/fstab' : \
-	sh '/bin/echo -e "[ -x /init.sh ] && /init.sh\n" >> /root/.profile' : \
-	sh '/bin/echo -e "export PW_ENVIRONMENT_ROOT=/root/pw_root\n[ -x /launcher.sh ] && /launcher.sh\n" >> /root/.profile'
-RUN echo -n \
+	sh '/bin/echo -e "[ -x /init.sh ] && /init.sh && rm -f /init.sh && sync && systemctl poweroff\n" >> /root/.profile' : \
+	sh '/bin/echo -e "export PW_ENVIRONMENT_ROOT=/root/pw_root\n[ -x /launcher.sh ] && /launcher.sh\n" >> /root/.profile' \
+	&& echo -n \
 	"#!/bin/bash\n" \
+	"set -e \n" \
 	"export DEBIAN_FRONTEND=noninteractive \n" \
 	"apt-get update\n" \
 	"apt-get install -y apt-utils\n" \
@@ -189,15 +190,12 @@ RUN echo -n \
 	"/usr/bin/systemctl mask dbus-fi.w1.wpa_supplicant1.service\n" \
 	"/usr/bin/systemctl mask wpa_supplicant.service\n" \
 	"git config --file /root/.gitconfig  --add safe.directory \"*\"\n" \
-	"echo Installed: cleaning and shutting down\n" \
 	"apt-get clean\n" \
 	"rm -rf /var/lib/apt/lists/*\n" \
 	"rm -rf /var/cache/apt/*\n" \
-	"rm /init.sh\n" \
 	"echo Configuration completed\n " \
-	"echo o > /proc/sysrq-trigger\n" \
-	| guestfish --rw -a $UBUNTU_QEMU_IMG -m /dev/sda4:/ upload - /init.sh : chmod 0755 /init.sh
-RUN qemu-system-x86_64 \
+	| guestfish --rw -a $UBUNTU_QEMU_IMG -m /dev/sda4:/ upload - /init.sh : chmod 0755 /init.sh \
+	&& qemu-system-x86_64 \
 	-machine ubuntu \
 	-smp 4 \
 	-m 2048 \
@@ -230,7 +228,7 @@ RUN qemu-system-x86_64 \
 	"fi\n" \
 	"echo 'Shutting down emulated system...'\n" \
 	"echo o > /proc/sysrq-trigger\n" \
-	| guestfish --rw -a $UBUNTU_QEMU_IMG -m /dev/sda3:/ upload - /launcher.sh : chmod 0755 /launcher.sh \
+	| guestfish --rw -a $UBUNTU_QEMU_IMG -m /dev/sda4:/ upload - /launcher.sh : chmod 0755 /launcher.sh \
 	&& virt-sparsify --compress ${UBUNTU_QEMU_IMG} ${UBUNTU_QEMU_IMG}.compressed \
 	&& mv ${UBUNTU_QEMU_IMG}.compressed ${UBUNTU_QEMU_IMG} \
 	&& rm -rf /var/tmp/.guestfs-0/* \

From 777791f7abd452517c8b931f6e3f845f8c968d80 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Thu, 13 Jun 2024 16:24:37 -0400
Subject: [PATCH 25/41] Restyle

---
 integrations/docker/images/base/chip-build/Dockerfile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 07a0b5f6467d56..f79970653d88c0 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -189,4 +189,3 @@ RUN case ${TARGETPLATFORM} in \
 # Some things that save space
 # Protoc goes from 108M to 4.6M
 RUN strip /usr/local/bin/protoc*
-

From dfe83e43a8b33113acff9fd868e3117507f84c74 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 09:21:50 -0400
Subject: [PATCH 26/41] Add ability to skip already built things, otherwise
 docker keeps re-building stuff

---
 integrations/docker/build-all.sh | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/integrations/docker/build-all.sh b/integrations/docker/build-all.sh
index 5b684b63a063b3..26972ec2560a3f 100755
--- a/integrations/docker/build-all.sh
+++ b/integrations/docker/build-all.sh
@@ -25,19 +25,33 @@ set -e
 
 SUB_PATH="*"
 ALL_ARGS=""
+SKIP_BUILT=0
 
 for i in "$@"; do
     case $i in
+    -h | --help)
+       echo "Supported arguments:"
+       echo "  -h/--help       This help text"
+       echo "  -p/--path       TODO: document this"
+       echo "  -skip-built     Do not rebuild images already found as built"
+       exit 0
+       ;;
     -p=* | --path=*)
         SUB_PATH="${i#*=}"
         ;;
+    --skip-built)
+        SKIP_BUILT=1
+	;;
     *)
         ALL_ARGS="$ALL_ARGS ${i#*=}"
         ;;
     esac
 done
 
+VERSION=${DOCKER_BUILD_VERSION:-$(sed 's/ .*//' "$(git rev-parse --show-toplevel)"/integrations/docker/images/base/chip-build/version)}
+
 echo "SUB_PATH: $SUB_PATH"
+echo "VERSION: $VERSION"
 
 function build_image() {
     PARSE_PATH=$1
@@ -47,7 +61,16 @@ function build_image() {
     echo "ARGS_TO_PASS: $ARGS_TO_PASS"
 
     find "$(git rev-parse --show-toplevel)"/integrations/docker/images/$PARSE_PATH -name Dockerfile ! -path "*chip-cert-bins/*" | while read -r dockerfile; do
-        echo "$(dirname "$dockerfile")"
+        # Images are of the form `ghcr.io/project-chip/{name}` and tagged as "${VERSION}"
+        DOCKER_PATH=$(dirname $dockerfile) # Drop the file name
+        IMAGE_NAME="ghcr.io/project-chip/${DOCKER_PATH##*/}:${VERSION}"     # Drop directory prefix
+
+        if [ $SKIP_BUILT -ne 0 ] && docker images "${IMAGE_NAME}" | grep 'ghcr.io' >/dev/null; then
+          echo "Image ${IMAGE_NAME} already exists. Skipping build"
+          continue
+        fi
+
+        echo "BUILDING $(dirname "$dockerfile") (i.e. ${IMAGE_NAME})"
         pushd "$(dirname "$dockerfile")" >/dev/null
         ./build.sh "$ARGS_TO_PASS"
         popd >/dev/null

From 6be0a0cc3f784374a78b77907c5df16e5eb78ab6 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 09:30:16 -0400
Subject: [PATCH 27/41] Docker image inspect is MUCH faster than docker images

---
 integrations/docker/build-all.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/build-all.sh b/integrations/docker/build-all.sh
index 26972ec2560a3f..f4749bc8f63f83 100755
--- a/integrations/docker/build-all.sh
+++ b/integrations/docker/build-all.sh
@@ -65,7 +65,7 @@ function build_image() {
         DOCKER_PATH=$(dirname $dockerfile) # Drop the file name
         IMAGE_NAME="ghcr.io/project-chip/${DOCKER_PATH##*/}:${VERSION}"     # Drop directory prefix
 
-        if [ $SKIP_BUILT -ne 0 ] && docker images "${IMAGE_NAME}" | grep 'ghcr.io' >/dev/null; then
+        if [ $SKIP_BUILT -ne 0 ] && docker image inspect "${IMAGE_NAME}" >/dev/null 2>&1; then
           echo "Image ${IMAGE_NAME} already exists. Skipping build"
           continue
         fi

From 745b7f7daa91dcf63aa38977cf084c694639a8fd Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 09:40:46 -0400
Subject: [PATCH 28/41] Fix nrf build

---
 .../stage-2/chip-build-nrf-platform/Dockerfile  | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/integrations/docker/images/stage-2/chip-build-nrf-platform/Dockerfile b/integrations/docker/images/stage-2/chip-build-nrf-platform/Dockerfile
index 355e1b6e040568..0ec2b78bca1782 100644
--- a/integrations/docker/images/stage-2/chip-build-nrf-platform/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-nrf-platform/Dockerfile
@@ -9,6 +9,13 @@ LABEL org.opencontainers.image.source https://github.com/project-chip/connectedh
 # Compatible Nordic Connect SDK revision.
 ARG NCS_REVISION=v2.6.0
 
+# Requirements to clone SDKs in temporary container
+RUN set -x \
+    && apt-get update \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
+    xz-utils \
+    && : # last line
+
 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
 WORKDIR /opt/NordicSemiconductor/nRF5_tools
 RUN set -x \
@@ -23,7 +30,7 @@ RUN set -x \
 
 WORKDIR /opt/NordicSemiconductor/nrfconnect
 RUN set -x \
-    && python3 -m pip install -U --no-cache-dir west==1.2.0 \
+    && python3 -m pip install --break-system-packages -U --no-cache-dir west==1.2.0 \
     && west init -m https://github.com/nrfconnect/sdk-nrf --mr "$NCS_REVISION" \
     && west config update.narrow true \
     && west config update.fetch smart \
@@ -50,10 +57,10 @@ COPY --from=build /opt/NordicSemiconductor/nrfconnect/ /opt/NordicSemiconductor/
 RUN set -x \
     # python3-yaml package conflicts with nRF Python requirements
     && (apt-get remove -fy python3-yaml && apt-get autoremove || exit 0) \
-    && python3 -m pip install -U --no-cache-dir cmake==3.25.0 \
-    && python3 -m pip install --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/zephyr/scripts/requirements-base.txt \
-    && python3 -m pip install --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/nrf/scripts/requirements-build.txt \
-    && python3 -m pip install --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/bootloader/mcuboot/scripts/requirements.txt \
+    && python3 -m pip install --break-system-packages -U --no-cache-dir cmake==3.25.0 \
+    && python3 -m pip install --break-system-packages --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/zephyr/scripts/requirements-base.txt \
+    && python3 -m pip install --break-system-packages --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/nrf/scripts/requirements-build.txt \
+    && python3 -m pip install --break-system-packages --no-cache-dir -r /opt/NordicSemiconductor/nrfconnect/bootloader/mcuboot/scripts/requirements.txt \
     && : # last line
 
 ENV NRF5_TOOLS_ROOT=/opt/NordicSemiconductor/nRF5_tools

From c2a07c0f2be6b0dca670f336a88810353e2b2adc Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 09:42:09 -0400
Subject: [PATCH 29/41] Fix ameba dockerfile build

---
 .../docker/images/stage-2/chip-build-ameba/Dockerfile      | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/integrations/docker/images/stage-2/chip-build-ameba/Dockerfile b/integrations/docker/images/stage-2/chip-build-ameba/Dockerfile
index 08c0cf878392fd..93217c332ef671 100644
--- a/integrations/docker/images/stage-2/chip-build-ameba/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-ameba/Dockerfile
@@ -2,6 +2,13 @@ ARG VERSION=1
 FROM ghcr.io/project-chip/chip-build:${VERSION}
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
 
+RUN set -x \
+    && apt-get update \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
+    bzip2 \
+    && rm -rf /var/lib/apt/lists/ \
+    && : # last line
+
 # Setup Ameba
 ARG AMEBA_DIR=/opt/ameba
 ARG TAG_NAME=ameba_update_2024_03_22

From b35b5ce4e5a389d85b09a6801817f233784f6573 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 09:49:06 -0400
Subject: [PATCH 30/41] Fix cirque image build

---
 .../docker/images/stage-2/chip-build-cirque/Dockerfile        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile b/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile
index 18ae44cb7ab79d..5d40e342cd3543 100644
--- a/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile
@@ -22,7 +22,7 @@ RUN set -x \
    curl gnupg-agent apt-transport-https ca-certificates \
    software-properties-common \
    && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
-   && python3.8 `which add-apt-repository` \
+   && python3 `which add-apt-repository` \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
    && apt-get update \
    && DEBIAN_FRONTEND=noninteractive apt-get install -fy \
@@ -49,6 +49,6 @@ RUN set -x \
 COPY requirements_nogrpc.txt /requirements.txt
 
 RUN set -x \
-   && pip3 install -r requirements.txt \
+   && pip3 install --break-system-packages -r requirements.txt \
    && xinit -- /usr/bin/Xvnc \
    && : # aids diffs

From a06ec35f65786fa7b3839755ba71b8cc634098dc Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 10:00:52 -0400
Subject: [PATCH 31/41] Make imx image work

---
 integrations/docker/images/stage-2/chip-build-imx/Dockerfile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/integrations/docker/images/stage-2/chip-build-imx/Dockerfile b/integrations/docker/images/stage-2/chip-build-imx/Dockerfile
index 9fe24051e0b2d3..864087ee4c9f8c 100644
--- a/integrations/docker/images/stage-2/chip-build-imx/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-imx/Dockerfile
@@ -6,6 +6,7 @@ RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
     wget \
+    xz-utils \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/ \
     && : # last line

From 3f443e0bf972db23e3f18cd214f2441a5820bd5e Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 10:07:53 -0400
Subject: [PATCH 32/41] Make build ordering predictable

---
 integrations/docker/build-all.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/build-all.sh b/integrations/docker/build-all.sh
index f4749bc8f63f83..4eb4ab53d8a747 100755
--- a/integrations/docker/build-all.sh
+++ b/integrations/docker/build-all.sh
@@ -60,7 +60,7 @@ function build_image() {
     echo "PARSE_PATH: $PARSE_PATH"
     echo "ARGS_TO_PASS: $ARGS_TO_PASS"
 
-    find "$(git rev-parse --show-toplevel)"/integrations/docker/images/$PARSE_PATH -name Dockerfile ! -path "*chip-cert-bins/*" | while read -r dockerfile; do
+    find "$(git rev-parse --show-toplevel)"/integrations/docker/images/$PARSE_PATH -name Dockerfile ! -path "*chip-cert-bins/*" | sort | while read -r dockerfile; do
         # Images are of the form `ghcr.io/project-chip/{name}` and tagged as "${VERSION}"
         DOCKER_PATH=$(dirname $dockerfile) # Drop the file name
         IMAGE_NAME="ghcr.io/project-chip/${DOCKER_PATH##*/}:${VERSION}"     # Drop directory prefix

From fc549929e9a74f55034063f98e5c348275d53f68 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 10:22:38 -0400
Subject: [PATCH 33/41] Fix k32w image build

---
 .../docker/images/stage-2/chip-build-k32w/Dockerfile         | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile
index 78c1bf6ca77422..83f9f7561321b4 100644
--- a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile
@@ -5,7 +5,8 @@ LABEL org.opencontainers.image.source https://github.com/project-chip/connectedh
 RUN set -x \
     && apt-get update \
     && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
-    wget unzip \
+    unzip \
+    wget \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/ \
     && : # last line
@@ -13,7 +14,7 @@ RUN set -x \
 WORKDIR /opt/sdk
 
 RUN set -x \
-    && python3 -m pip install -U --no-cache-dir west==1.0.0 \
+    && python3 -m pip install --break-system-packages -U --no-cache-dir west==1.0.0 \
     && west init -m https://github.com/nxp-mcuxpresso/mcux-sdk --mr "MCUX_2.6.14_K32W0" \
     && west update \
     && chmod +x core/tools/imagetool/sign_images.sh \

From db321795e67f2d2f6fd94026cd19e22fdee98e65 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 10:36:06 -0400
Subject: [PATCH 34/41] Fix telink image build

---
 .../docker/images/stage-2/chip-build-telink/Dockerfile    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile
index b618675dd80ce9..a9e53dca6824b8 100644
--- a/integrations/docker/images/stage-2/chip-build-telink/Dockerfile
+++ b/integrations/docker/images/stage-2/chip-build-telink/Dockerfile
@@ -2,6 +2,12 @@ ARG VERSION=1
 FROM ghcr.io/project-chip/chip-build:${VERSION} as build
 LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip
 
+RUN set -x \
+    && apt-get update \
+    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --no-install-recommends \
+    xz-utils \
+    && : # last line
+
 # Setup toolchain
 WORKDIR /opt/telink
 RUN set -x \
@@ -15,7 +21,7 @@ RUN set -x \
 ARG ZEPHYR_REVISION=0e8032dfef7e02498f34ba0b5d5d2df71a62adb1
 WORKDIR /opt/telink/zephyrproject
 RUN set -x \
-    && python3 -m pip install -U --no-cache-dir west \
+    && python3 -m pip install --break-system-packages -U --no-cache-dir west \
     && git clone https://github.com/telink-semi/zephyr \
     && cd zephyr \
     && git reset ${ZEPHYR_REVISION} --hard \

From a7558e438d668e675d2ca36d56224858962314c5 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 10:49:58 -0400
Subject: [PATCH 35/41] Speed up android image build by a lot

---
 .../docker/images/stage-3/chip-build-android/Dockerfile       | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/integrations/docker/images/stage-3/chip-build-android/Dockerfile b/integrations/docker/images/stage-3/chip-build-android/Dockerfile
index 9d1f0ef119f543..b2c33e7aaa512c 100644
--- a/integrations/docker/images/stage-3/chip-build-android/Dockerfile
+++ b/integrations/docker/images/stage-3/chip-build-android/Dockerfile
@@ -59,9 +59,9 @@ RUN set -x \
     && export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH \
     && cd /tmp && wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz \
     && mkdir -p $OPENSSL_ARMV7 && cd $OPENSSL_ARMV7 && tar xfz /tmp/openssl-1.1.1t.tar.gz \
-    && cd $OPENSSL_ARMV7/openssl-1.1.1t && CC=clang ANDROID_API=26 ./Configure android-arm -U__ANDROID_API__ -D__ANDROID_API__=26 && make SHLIB_VERSION_NUMBER= SHLIB_EXT=.so \
+    && cd $OPENSSL_ARMV7/openssl-1.1.1t && CC=clang ANDROID_API=26 ./Configure android-arm -U__ANDROID_API__ -D__ANDROID_API__=26 && make -j$(nproc) SHLIB_VERSION_NUMBER= SHLIB_EXT=.so \
     && mkdir -p $OPENSSL_X86 && cd $OPENSSL_X86 && tar xfz /tmp/openssl-1.1.1t.tar.gz \
-    && cd $OPENSSL_X86/openssl-1.1.1t && CC=clang ANDROID_API=26 ./Configure android-x86 -U__ANDROID_API__ -D__ANDROID_API__=26 && make SHLIB_VERSION_NUMBER= SHLIB_EXT=.so \
+    && cd $OPENSSL_X86/openssl-1.1.1t && CC=clang ANDROID_API=26 ./Configure android-x86 -U__ANDROID_API__ -D__ANDROID_API__=26 && make  -j$(nproc) SHLIB_VERSION_NUMBER= SHLIB_EXT=.so \
     && rm -rf /tmp/openssl-1.1.1t.tar.gz \
     && : # last line
 

From 26ed2307323ca8feb7c0177c7754d7e50b324f42 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 10:53:31 -0400
Subject: [PATCH 36/41] Bump up espressif qemu build, do not use the 3-year old
 version

---
 .../docker/images/stage-3/chip-build-esp32-qemu/Dockerfile      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile b/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile
index 768fdb0a6cc613..aad71b4f2b7ff0 100644
--- a/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile
+++ b/integrations/docker/images/stage-3/chip-build-esp32-qemu/Dockerfile
@@ -13,7 +13,7 @@ RUN set -x \
 WORKDIR /opt/espressif/qemu
 # Setup QEMU emulator for ESP32 platform
 RUN set -x \
-    && git clone --depth 1 -b esp-develop-20210826 https://github.com/espressif/qemu.git ../qemu-src \
+    && git clone --depth 1 -b v9.0.0 https://github.com/espressif/qemu.git ../qemu-src \
     && ../qemu-src/configure --target-list=xtensa-softmmu --enable-debug --disable-strip --disable-user --disable-capstone --disable-vnc --disable-sdl --disable-gtk \
     && make -j$(nproc) \
     && : # last line

From 40d81dfd456a243ce278815dc96bd108c772688e Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 12:59:34 -0400
Subject: [PATCH 37/41] Update versions to match system package versions, so
 that bootstrap is faster

---
 integrations/docker/images/base/chip-build/Dockerfile | 1 +
 scripts/setup/constraints.txt                         | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index f79970653d88c0..4e0c591be832d9 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -57,6 +57,7 @@ RUN set -x \
     libdbus-glib-1-dev \
     libdmalloc-dev \
     libgif-dev \
+    libgirepository-1.0-1 \
     libglib2.0-dev \
     libical-dev \
     libjpeg-dev \
diff --git a/scripts/setup/constraints.txt b/scripts/setup/constraints.txt
index ab4bea6e965a9c..49aff90df0715c 100644
--- a/scripts/setup/constraints.txt
+++ b/scripts/setup/constraints.txt
@@ -134,7 +134,7 @@ mypy-extensions==1.0.0
     # via mypy
 mypy-protobuf==3.5.0
     # via -r requirements.all.txt
-numpy==1.24.2
+numpy==1.26.4
     # via pandas
 packaging==23.0
     # via
@@ -143,7 +143,7 @@ packaging==23.0
     #   ghapi
     #   idf-component-manager
     #   west
-pandas==1.5.3 ; platform_machine != "aarch64" and platform_machine != "arm64"
+pandas==2.1.4 ; platform_machine != "aarch64" and platform_machine != "arm64"
     # via -r requirements.memory.txt
 parso==0.8.3
     # via jedi

From defd85e913f4a01d9d668e57957a589abb4f4324 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 13:43:57 -0400
Subject: [PATCH 38/41] Make sure that patch is available in the base image, we
 seem to use it ocassionally

---
 integrations/docker/images/base/chip-build/Dockerfile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index 4e0c591be832d9..b2b304797c2c97 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -83,6 +83,7 @@ RUN set -x \
     net-tools \
     ninja-build \
     nodejs \
+    patch \
     pkg-config \
     python3 \
     python3-click \

From 6593add55894c9368c110109498f28a97099b5d1 Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 14:15:14 -0400
Subject: [PATCH 39/41] One documentation update

---
 integrations/docker/build-all.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/integrations/docker/build-all.sh b/integrations/docker/build-all.sh
index 4eb4ab53d8a747..34371e00036acc 100755
--- a/integrations/docker/build-all.sh
+++ b/integrations/docker/build-all.sh
@@ -32,7 +32,7 @@ for i in "$@"; do
     -h | --help)
        echo "Supported arguments:"
        echo "  -h/--help       This help text"
-       echo "  -p/--path       TODO: document this"
+       echo "  -p/--path       sub-path in integrations/docker/images to build (defaults to * for everything)"
        echo "  -skip-built     Do not rebuild images already found as built"
        exit 0
        ;;

From 7151dc57113ab4cb92d2f18f36c7ea2b71e18a1d Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Fri, 14 Jun 2024 14:19:03 -0400
Subject: [PATCH 40/41] Also allow compilation of mbedos bits in the vscode
 image

---
 .../images/vscode/chip-build-vscode/Dockerfile      | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile
index ca45dafd068f0b..c3a9f37baa264a 100644
--- a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile
+++ b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile
@@ -4,7 +4,6 @@ FROM ghcr.io/project-chip/chip-build-nrf-platform:${VERSION} AS nrf
 FROM ghcr.io/project-chip/chip-build-efr32:${VERSION} AS efr32
 FROM ghcr.io/project-chip/chip-build-android:${VERSION} AS android
 FROM ghcr.io/project-chip/chip-build-esp32-qemu:${VERSION} as esp32
-FROM ghcr.io/project-chip/chip-build-mbed-os:${VERSION} AS mbedos
 FROM ghcr.io/project-chip/chip-build-telink:${VERSION} AS telink
 FROM ghcr.io/project-chip/chip-build-infineon:${VERSION} AS p6
 FROM ghcr.io/project-chip/chip-build-tizen:${VERSION} AS tizen
@@ -36,9 +35,6 @@ COPY --from=android /opt/android/sdk /opt/android/sdk
 COPY --from=android /opt/android/android-ndk-r23c /opt/android/android-ndk-r23c
 COPY --from=android /usr/lib/kotlinc /usr/lib/kotlinc
 
-# FIXME: OpenOCD was removed during the move to infineon's repo
-# COPY --from=mbedos /opt/openocd/ /opt/openocd/
-
 COPY --from=p6 /opt/ModusToolbox /opt/ModusToolbox
 
 COPY --from=telink /opt/telink/zephyrproject /opt/telink/zephyrproject
@@ -78,6 +74,15 @@ RUN set -x \
     && chmod -R a+w /opt/android/sdk/licenses \
     && : # last line
 
+# mbedos requirements are generally just PIP packages
+RUN set -x \
+    && pip3 install --break-system-packages --no-cache-dir -U mbed-cli==1.10.5 mbed-tools==7.44.0 \
+    && : # last line
+RUN set -x \
+    && mbed config -G GCC_ARM_PATH /opt/mbed-os-toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/ \
+    && mbed toolchain -G -s GCC_ARM \
+    && : # last line
+
 # Required for the Tizen SDK:
 #   - zip
 # Required for the Open IoT SDK platform

From bee5cda906b6bb4a632e588f08c3e496c11d244a Mon Sep 17 00:00:00 2001
From: Andrei Litvin <andreilitvin@google.com>
Date: Mon, 17 Jun 2024 09:28:06 -0400
Subject: [PATCH 41/41] Include what you use from system

---
 .../docker/images/base/chip-build/Dockerfile  | 27 +------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/integrations/docker/images/base/chip-build/Dockerfile b/integrations/docker/images/base/chip-build/Dockerfile
index b2b304797c2c97..52009834302249 100644
--- a/integrations/docker/images/base/chip-build/Dockerfile
+++ b/integrations/docker/images/base/chip-build/Dockerfile
@@ -47,6 +47,7 @@ RUN set -x \
     git-lfs \
     gperf \
     iproute2 \
+    iwyu \
     jq \
     lcov \
     libavahi-client-dev \
@@ -135,32 +136,6 @@ RUN set -x \
     && rm -rf bloaty \
     && : # last line
 
-# Need newer version of include-what-you-use
-RUN set -x \
-    && apt-get update \
-    # Install build and runtime requirements for IWYU
-    && DEBIAN_FRONTEND=noninteractive apt-get install -fy --fix-missing clang-18 libclang-18-dev llvm-18-dev \
-    # Build and install IWYU
-    && git clone --depth=1 --branch=clang_18 https://github.com/include-what-you-use/include-what-you-use.git \
-    && mkdir -p include-what-you-use/build \
-    && cd include-what-you-use/build \
-    && cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr/lib/llvm-18 -DIWYU_LINK_CLANG_DYLIB=OFF .. \
-    && make -j$(nproc) \
-    && strip bin/include-what-you-use \
-    && make install \
-    # Save clang-18 files, so we can restore them after build dependencies cleanup
-    # AWK logic converts 'libLLVM.so.18.1 => /usr/lib/llvm-18/lib/libLLVM.so.18.1 (0x00007f781ede6000)' to '/usr/lib/llvm-18/lib/libLLVM.so.18.1'
-    && tar -cf clang-18-files.tar $(dpkg -L libclang-common-18-dev |grep /include) $(ldd bin/include-what-you-use | grep /usr/lib/llvm | awk '{print $3}') /usr/lib/llvm-18/lib/libLLVM.so.1 \
-    # Cleanup build dependencies
-    && apt autopurge -fy clang-18 libclang-18-dev llvm-18-dev \
-    && rm -rf /var/lib/apt/lists/ \
-    # Restore clang-18 files
-    && tar -xf clang-18-files.tar -C / \
-    # Cleanup
-    && cd ../.. \
-    && rm -rf include-what-you-use \
-    && : # last line
-
 # Build glib-2.0 from source with enabled thread sanitizer. This is needed for
 # running CHIP tests with TSAN enabled. When running applications with TSAN
 # all shared libraries should be built with TSAN enabled, otherwise TSAN might