@@ -4,11 +4,12 @@ FROM $BUILD_FROM
44ARG \
55 PYTHON_VERSION \
66 PIP_VERSION \
7- GPG_KEY \
7+ CERT_IDENTITY \
8+ CERT_OIDC_ISSUER \
89 QEMU_CPU
910
1011# ensure local python is preferred over distribution python
11- ENV PATH /usr/local/bin:$PATH
12+ ENV PATH= /usr/local/bin:$PATH
1213
1314# Set shell
1415SHELL ["/bin/ash" , "-o" , "pipefail" , "-c" ]
@@ -17,19 +18,20 @@ COPY *.patch /usr/src/
1718RUN set -ex \
1819 && export PYTHON_VERSION=${PYTHON_VERSION} \
1920 && apk add --no-cache --virtual .fetch-deps \
20- gnupg \
2121 openssl \
2222 tar \
2323 xz \
24+ && apk add --no-cache --virtual .cosign cosign \
25+ --repository="https://dl-cdn.alpinelinux.org/alpine/v3.21/community" \
2426 \
2527 && curl -L -o python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
26- && curl -L -o python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc " \
27- && export GNUPGHOME= "$(mktemp -d)" \
28- && echo "disable-ipv6" >> "$GNUPGHOME/dirmngr.conf" \
29- && gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "${GPG_KEY }" \
30- && gpg --batch --verify python.tar.xz.asc python.tar.xz \
31- && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \
32- && rm -rf "$GNUPGHOME" python.tar.xz.asc \
28+ && curl -L -o python.tar.xz.sigstore "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.sigstore " \
29+ && cosign verify-blob \
30+ --new-bundle-format \
31+ --certificate-identity "${CERT_IDENTITY }" \
32+ --certificate-oidc-issuer "${CERT_OIDC_ISSUER}" \
33+ --bundle python.tar.xz.sigstore \
34+ python.tar.xz \
3335 && mkdir -p /usr/src/python \
3436 && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
3537 && rm python.tar.xz \
@@ -63,7 +65,7 @@ RUN set -ex \
6365 zlib-dev \
6466 bluez-dev \
6567 # add build deps before removing fetch deps in case there's overlap
66- && apk del .fetch-deps \
68+ && apk del .fetch-deps .cosign \
6769 \
6870 && for i in /usr/src/*.patch; do \
6971 patch -d /usr/src/python -p 1 < "${i}" ; done \
0 commit comments