@@ -86,10 +86,6 @@ hash -r
8686curl --version
8787curl-config --features
8888
89- # Install a git we link against OpenSSL so that we can use TLS 1.2
90- build_git $GIT_ROOT $GIT_HASH
91- git version
92-
9389# Install newest autoconf
9490build_autoconf $AUTOCONF_ROOT $AUTOCONF_HASH
9591autoconf --version
@@ -102,6 +98,45 @@ automake --version
10298build_libtool $LIBTOOL_ROOT $LIBTOOL_HASH
10399libtool --version
104100
101+ # Install patchelf (latest with unreleased bug fixes)
102+ curl -fsSL -o patchelf.tar.gz https://github.com/NixOS/patchelf/archive/$PATCHELF_VERSION .tar.gz
103+ check_sha256sum patchelf.tar.gz $PATCHELF_HASH
104+ tar -xzf patchelf.tar.gz
105+ (cd patchelf-$PATCHELF_VERSION && ./bootstrap.sh && do_standard_install)
106+ rm -rf patchelf.tar.gz patchelf-$PATCHELF_VERSION
107+
108+ # We strip curl now because stripping after patchelf breaks it
109+ strip --strip-unneeded /opt/_internal/_vendor/lib/libcurl.so.4
110+ strip --strip-unneeded /usr/local/bin/curl
111+
112+ # Let's patch curl & openssl:
113+ CHECKSUM=$( sha256sum /opt/_internal/_vendor/lib/libcrypto.so.1.0.0)
114+ CHECKSUM=${CHECKSUM: 0: 8}
115+ patchelf --set-soname /opt/_internal/_vendor/lib/libcrypto.so.1.0.0-${CHECKSUM} /opt/_internal/_vendor/lib/libcrypto.so.1.0.0
116+ mv /opt/_internal/_vendor/lib/libcrypto.so.1.0.0 /opt/_internal/_vendor/lib/libcrypto.so.1.0.0-${CHECKSUM}
117+ ln -sf libcrypto.so.1.0.0-${CHECKSUM} /opt/_internal/_vendor/lib/libcrypto.so
118+ patchelf --replace-needed libcrypto.so.1.0.0 /opt/_internal/_vendor/lib/libcrypto.so.1.0.0-${CHECKSUM} /opt/_internal/_vendor/lib/libssl.so.1.0.0
119+ patchelf --replace-needed libcrypto.so.1.0.0 /opt/_internal/_vendor/lib/libcrypto.so.1.0.0-${CHECKSUM} /opt/_internal/_vendor/lib/libcurl.so.4
120+ patchelf --replace-needed libcrypto.so.1.0.0 /opt/_internal/_vendor/lib/libcrypto.so.1.0.0-${CHECKSUM} /usr/local/bin/curl
121+
122+ CHECKSUM=$( sha256sum /opt/_internal/_vendor/lib/libssl.so.1.0.0)
123+ CHECKSUM=${CHECKSUM: 0: 8}
124+ patchelf --set-soname /opt/_internal/_vendor/lib/libssl.so.1.0.0-${CHECKSUM} /opt/_internal/_vendor/lib/libssl.so.1.0.0
125+ mv /opt/_internal/_vendor/lib/libssl.so.1.0.0 /opt/_internal/_vendor/lib/libssl.so.1.0.0-${CHECKSUM}
126+ ln -sf libssl.so.1.0.0-${CHECKSUM} /opt/_internal/_vendor/lib/libssl.so
127+ patchelf --replace-needed libssl.so.1.0.0 /opt/_internal/_vendor/lib/libssl.so.1.0.0-${CHECKSUM} /opt/_internal/_vendor/lib/libcurl.so.4
128+ patchelf --replace-needed libssl.so.1.0.0 /opt/_internal/_vendor/lib/libssl.so.1.0.0-${CHECKSUM} /usr/local/bin/curl
129+
130+ CHECKSUM=$( sha256sum /opt/_internal/_vendor/lib/libcurl.so.4)
131+ CHECKSUM=${CHECKSUM: 0: 8}
132+ patchelf --set-soname /opt/_internal/_vendor/lib/libcurl.so.4-${CHECKSUM} /opt/_internal/_vendor/lib/libcurl.so.4
133+ mv /opt/_internal/_vendor/lib/libcurl.so.4 /opt/_internal/_vendor/lib/libcurl.so.4-${CHECKSUM}
134+ patchelf --replace-needed libcurl.so.4 /opt/_internal/_vendor/lib/libcurl.so.4-${CHECKSUM} /usr/local/bin/curl
135+
136+ # Install a git we link against OpenSSL so that we can use TLS 1.2
137+ build_git $GIT_ROOT $GIT_HASH
138+ git version
139+
105140# Install a more recent SQLite3
106141curl -fsSLO $SQLITE_AUTOCONF_DOWNLOAD_URL /$SQLITE_AUTOCONF_VERSION .tar.gz
107142check_sha256sum $SQLITE_AUTOCONF_VERSION .tar.gz $SQLITE_AUTOCONF_HASH
@@ -110,11 +145,14 @@ cd $SQLITE_AUTOCONF_VERSION
110145do_standard_install
111146cd ..
112147rm -rf $SQLITE_AUTOCONF_VERSION *
148+ rm -f /usr/local/lib/libsqlite3.a
149+
150+ # Create a symbolic link for python to find openssl
151+ ln -s /opt/_internal/_vendor /usr/local/ssl
113152
114153# Compile the latest Python releases.
115154# (In order to have a proper SSL module, Python is compiled
116- # against a recent openssl [see env vars above], which is linked
117- # statically.
155+ # against a recent openssl [see env vars above])
118156mkdir -p /opt/python
119157build_cpythons $CPYTHON_VERSIONS
120158
@@ -134,14 +172,8 @@ ln -s $($PY36_BIN/python -c 'import certifi; print(certifi.where())') \
134172export SSL_CERT_FILE=/opt/_internal/certs.pem
135173
136174# Now we can delete our built OpenSSL headers/static libs since we've linked everything we need
137- rm -rf /usr/local/ssl
138-
139- # Install patchelf (latest with unreleased bug fixes)
140- curl -fsSL -o patchelf.tar.gz https://github.com/NixOS/patchelf/archive/$PATCHELF_VERSION .tar.gz
141- check_sha256sum patchelf.tar.gz $PATCHELF_HASH
142- tar -xzf patchelf.tar.gz
143- (cd patchelf-$PATCHELF_VERSION && ./bootstrap.sh && do_standard_install)
144- rm -rf patchelf.tar.gz patchelf-$PATCHELF_VERSION
175+ unlink /usr/local/ssl
176+ find /opt/_internal/_vendor -mindepth 1 -maxdepth 1 -not -path ' /opt/_internal/_vendor/lib*' | xargs rm -rf
145177
146178ln -s $PY36_BIN /auditwheel /usr/local/bin/auditwheel
147179
@@ -164,10 +196,18 @@ yum list installed
164196find /opt/_internal -name ' *.a' -print0 | xargs -0 rm -f
165197
166198# Strip what we can -- and ignore errors, because this just attempts to strip
167- # *everything*, including non-ELF files:
168- find /opt/_internal -type f -print0 \
199+ # *everything*, including non-ELF files.
200+ # We ignore curl which was stripped before patching it with patchelf
201+ find /opt/_internal -type f -not -name ' libcurl.so*' -print0 \
202+ | xargs -0 -n1 strip --strip-unneeded 2> /dev/null || true
203+ find /usr/local -type f -not -name ' curl' -print0 \
169204 | xargs -0 -n1 strip --strip-unneeded 2> /dev/null || true
170205
206+ # Make sure curl is still working after stripping, patchelf can break things
207+ # libcurl is in exceptions for stripping and this will help catch errors if openssl gets broken after an update
208+ curl -fsSLO $GET_PIP_URL
209+ rm -f get-pip.py
210+
171211for PYTHON in /opt/python/* /bin/python; do
172212 # Smoke test to make sure that our Pythons work, and do indeed detect as
173213 # being manylinux compatible:
0 commit comments