Skip to content

Commit ce38370

Browse files
committed
apply patches more specfically
1 parent 8ab6518 commit ce38370

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

cpython-unix/build-cpython.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ fi
316316
# RHEL 8 (supported until 2029) and below, including Fedora 33 and below, do not
317317
# ship an /etc/ssl/cert.pem or a hashed /etc/ssl/cert/ directory. Patch to look at
318318
# /etc/pki/tls/cert.pem instead, if that file exists and /etc/ssl/cert.pem does not.
319-
patch -p1 -i ${ROOT}/patch-cpython-redhat-cert-file.patch
319+
if [[ "${TARGET_TRIPLE}" =~ linux ]]; then
320+
patch -p1 -i "${ROOT}/patch-cpython-redhat-cert-file.patch"
321+
fi
320322

321323
# Cherry-pick an upstream change in Python 3.15 to build _asyncio as
322324
# static (which we do anyway in our own fashion) and more importantly to
@@ -1361,10 +1363,12 @@ if [ -d "${TOOLS_PATH}/deps/usr/share/terminfo" ]; then
13611363
cp -av "${TOOLS_PATH}/deps/usr/share/terminfo" "${ROOT}/out/python/install/share/"
13621364
fi
13631365

1364-
# Copy a fallback CA bundle. Python will prefer the host trust store when one
1365-
# exists and use this only for minimal environments without root certificates.
1366-
mkdir -p "${ROOT}/out/python/install/etc/ssl"
1367-
cp -av "${TOOLS_PATH}/deps/share/certifi/cacert.pem" "${ROOT}/out/python/install/etc/ssl/cert.pem"
1366+
# Copy a Linux fallback CA bundle. Python will prefer the host trust store when
1367+
# one exists and use this only for minimal environments without root certificates.
1368+
if [[ "${TARGET_TRIPLE}" =~ linux ]]; then
1369+
mkdir -p "${ROOT}/out/python/install/etc/ssl"
1370+
cp -av "${TOOLS_PATH}/deps/share/certifi/cacert.pem" "${ROOT}/out/python/install/etc/ssl/cert.pem"
1371+
fi
13681372

13691373
# config.c defines _PyImport_Inittab and extern references to modules, which
13701374
# downstream consumers may want to strip. We bundle config.c and config.c.in so
@@ -1391,5 +1395,7 @@ find "${ROOT}/out/python/install/lib/pkgconfig" -name \*.pc -type f -exec \
13911395
sed "${sed_args[@]}" 's|^prefix=/install|prefix=${pcfiledir}/../..|' {} +
13921396

13931397
mkdir "${ROOT}/out/python/licenses"
1394-
cp "${ROOT}/LICENSE" "${ROOT}/out/python/licenses/"
1398+
if [[ "${TARGET_TRIPLE}" =~ linux ]]; then
1399+
cp "${ROOT}/LICENSE" "${ROOT}/out/python/licenses/"
1400+
fi
13951401
cp "${ROOT}"/LICENSE.*.txt "${ROOT}/out/python/licenses/"

cpython-unix/build.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,14 @@ def build_cpython(
775775
python_archive,
776776
setuptools_archive,
777777
pip_archive,
778-
ROOT / "LICENSE",
779778
SUPPORT / "build-cpython.sh",
780779
SUPPORT / "run_tests-13.py",
781780
):
782781
build_env.copy_file(p)
783782

783+
if "-linux-" in target_triple:
784+
build_env.copy_file(ROOT / "LICENSE")
785+
784786
for f in sorted(os.listdir(ROOT)):
785787
if f.startswith("LICENSE.") and f.endswith(".txt"):
786788
build_env.copy_file(ROOT / f)

cpython-unix/patch-cpython-redhat-cert-file.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ index 42ebb8ed384..c15c0ec940f 100644
1313

1414
sslsocket_class = None # SSLSocket is assigned later.
1515
sslobject_class = None # SSLObject is assigned later.
16-
@@ -531,6 +534,38 @@ def load_default_certs(self, purpose=Purpose.SERVER_AUTH):
16+
@@ -531,6 +535,41 @@ def load_default_certs(self, purpose=Purpose.SERVER_AUTH):
1717
if sys.platform == "win32":
1818
for storename in self._windows_cert_stores:
1919
self._load_windows_store_certs(storename, purpose)

0 commit comments

Comments
 (0)