Skip to content

Commit b0ccf52

Browse files
partheavchudnov-g
authored andcommitted
remove gpg;add sigstore;remove python 2.7 which doesn't support sigstore
1 parent c09e441 commit b0ccf52

File tree

2 files changed

+63
-93
lines changed

2 files changed

+63
-93
lines changed

.kokoro/docker/Dockerfile

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -110,43 +110,68 @@ RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
110110
&& rm -rf /var/lib/apt/lists/* \
111111
&& rm -f /var/cache/apt/archives/*.deb
112112

113-
COPY fetch_gpg_keys.sh /tmp
114-
# Install the desired versions of Python.
115-
RUN set -ex \
116-
&& export GNUPGHOME="$(mktemp -d)" \
117-
&& echo "disable-ipv6" >> "${GNUPGHOME}/dirmngr.conf" \
118-
&& /tmp/fetch_gpg_keys.sh \
119-
&& PYTHON_VERSIONS="\
120-
2.7.18 \
121-
3.7.17 \
122-
3.8.20 \
123-
3.9.23 \
124-
3.10.18 \
125-
3.11.13 \
126-
3.12.11 \
127-
3.13.8 \
128-
3.14.0" \
129-
&& for VERSION in $PYTHON_VERSIONS; do \
130-
wget --no-check-certificate -O python-${VERSION}.tar.xz "https://www.python.org/ftp/python/${VERSION%%[a-z]*}/Python-$VERSION.tar.xz" \
131-
&& wget --no-check-certificate -O python-${VERSION}.tar.xz.asc "https://www.python.org/ftp/python/${VERSION%%[a-z]*}/Python-$VERSION.tar.xz.asc" \
132-
&& gpg --batch --verify python-${VERSION}.tar.xz.asc python-${VERSION}.tar.xz \
133-
&& rm -r python-${VERSION}.tar.xz.asc \
134-
&& mkdir -p /usr/src/python-${VERSION} \
135-
&& tar -xJC /usr/src/python-${VERSION} --strip-components=1 -f python-${VERSION}.tar.xz \
136-
&& rm python-${VERSION}.tar.xz \
137-
&& cd /usr/src/python-${VERSION} \
138-
&& ./configure \
139-
--enable-shared \
140-
# This works only on Python 2.7 and throws a warning on every other
141-
# version, but seems otherwise harmless.
142-
--enable-unicode=ucs4 \
143-
--with-system-ffi \
144-
--without-ensurepip \
145-
&& make -j$(nproc) \
146-
&& make install \
147-
&& ldconfig \
113+
# From https://www.python.org/downloads/metadata/sigstore/
114+
# Starting with Python 3.14, Sigstore is the only method of signing and verification of release artifacts.
115+
RUN LATEST_VERSION="2.6.1" && \
116+
wget "https://github.com/sigstore/cosign/releases/download/v${LATEST_VERSION}/cosign_${LATEST_VERSION}_amd64.deb" && \
117+
dpkg -i cosign_${LATEST_VERSION}_amd64.deb && \
118+
rm cosign_${LATEST_VERSION}_amd64.deb
119+
120+
ARG PYTHON_VERSIONS="3.7.17 3.8.20 3.9.23 3.10.18 3.11.13 3.12.11 3.13.8 3.14.0"
121+
122+
SHELL ["/bin/bash", "-c"]
123+
124+
RUN set -eux; \
125+
# Define the required associative arrays completely.
126+
declare -A PYTHON_IDENTITIES; \
127+
PYTHON_IDENTITIES=(\
128+
[3.7]="nad@python.org" \
129+
[3.8]="lukasz@langa.pl" \
130+
[3.9]="lukasz@langa.pl" \
131+
[3.10]="pablogsal@python.org" \
132+
[3.11]="pablogsal@python.org" \
133+
[3.12]="thomas@python.org" \
134+
[3.13]="thomas@python.org" \
135+
[3.14]="hugo@python.org" \
136+
); \
137+
declare -A PYTHON_ISSUERS; \
138+
PYTHON_ISSUERS=(\
139+
[3.7]="https://github.com/login/oauth" \
140+
[3.8]="https://github.com/login/oauth" \
141+
[3.9]="https://github.com/login/oauth" \
142+
[3.10]="https://accounts.google.com" \
143+
[3.11]="https://accounts.google.com" \
144+
[3.12]="https://accounts.google.com" \
145+
[3.13]="https://accounts.google.com" \
146+
[3.14]="https://github.com/login/oauth" \
147+
); \
148+
\
149+
for VERSION in $PYTHON_VERSIONS; do \
150+
# 1. Define VERSION_GROUP (e.g., 3.14 from 3.14.0)
151+
VERSION_GROUP="$(echo "${VERSION}" | cut -d . -f 1,2)"; \
152+
\
153+
# 2. Look up IDENTITY and ISSUER using the defined VERSION_GROUP
154+
IDENTITY="${PYTHON_IDENTITIES[$VERSION_GROUP]}"; \
155+
ISSUER="${PYTHON_ISSUERS[$VERSION_GROUP]}"; \
156+
\
157+
wget --quiet -O python-${VERSION}.tar.xz "https://www.python.org/ftp/python/${VERSION}/Python-$VERSION.tar.xz" \
158+
&& wget --quiet -O python-${VERSION}.tar.xz.sigstore "https://www.python.org/ftp/python/${VERSION}/Python-$VERSION.tar.xz.sigstore" \
159+
# Verify the Python tarball signature with cosign.
160+
&& cosign verify-blob python-${VERSION}.tar.xz \
161+
--certificate-oidc-issuer "${ISSUER}" \
162+
--certificate-identity "${IDENTITY}" \
163+
--bundle python-${VERSION}.tar.xz.sigstore \
164+
&& mkdir -p /usr/src/python-${VERSION} \
165+
&& tar -xJC /usr/src/python-${VERSION} --strip-components=1 -f python-${VERSION}.tar.xz \
166+
&& rm python-${VERSION}.tar.xz \
167+
&& cd /usr/src/python-${VERSION} \
168+
&& ./configure \
169+
--enable-shared \
170+
--with-system-ffi \
171+
&& make -j$(nproc) \
172+
&& make install \
173+
&& ldconfig \
148174
; done \
149-
&& rm -rf "${GNUPGHOME}" \
150175
&& rm -rf /usr/src/python* \
151176
&& rm -rf ~/.cache/
152177

@@ -168,6 +193,7 @@ RUN wget --no-check-certificate -O /tmp/get-pip-3-7.py 'https://bootstrap.pypa.i
168193
&& [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == "pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ]
169194

170195
# Ensure Pip for all python3 versions
196+
RUN python3.14 /tmp/get-pip.py
171197
RUN python3.13 /tmp/get-pip.py
172198
RUN python3.12 /tmp/get-pip.py
173199
RUN python3.11 /tmp/get-pip.py
@@ -185,6 +211,7 @@ RUN python3.10 -m pip
185211
RUN python3.11 -m pip
186212
RUN python3.12 -m pip
187213
RUN python3.13 -m pip
214+
RUN python3.14 -m pip
188215

189216
# Install "setuptools" for Python 3.12+ (see https://docs.python.org/3/whatsnew/3.12.html#distutils)
190217
RUN python3.12 -m pip install --no-cache-dir setuptools

.kokoro/docker/fetch_gpg_keys.sh

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)