|
279 | 279 | # in the binary that references it using patchelf |
280 | 280 | cryptography_folder = "#{site_packages_path}/cryptography" |
281 | 281 | so_to_patch = "#{cryptography_folder}/hazmat/bindings/_rust.abi3.so" |
282 | | - libssl_match = Dir.glob("#{cryptography_folder}.libs/libssl-*.so.3")[0] |
283 | | - libcrypto_match = Dir.glob("#{cryptography_folder}.libs/libcrypto-*.so.3")[0] |
| 282 | + libssl_matches = Dir.glob("#{cryptography_folder}.libs/libssl-*.so.3") |
| 283 | + libcrypto_matches = Dir.glob("#{cryptography_folder}.libs/libcrypto-*.so.3") |
| 284 | + raise "expected exactly one match for 'libssl-*.so.3' but got: #{libssl_matches}" if libssl_matches.size != 1 |
| 285 | + raise "expected exactly one match for 'libcrypto-*.so.3' but got: #{libcrypto_matches}" if libcrypto_matches.size != 1 |
| 286 | + libssl_match = libssl_matches.fetch(0) |
| 287 | + libcrypto_match = libcrypto_matches.fetch(0) |
284 | 288 | shellout! "patchelf --replace-needed #{File.basename(libssl_match)} libssl.so.3 #{so_to_patch}" |
285 | 289 | shellout! "patchelf --replace-needed #{File.basename(libcrypto_match)} libcrypto.so.3 #{so_to_patch}" |
286 | 290 | shellout! "patchelf --add-rpath #{install_dir}/embedded/lib #{so_to_patch}" |
|
290 | 294 | block "Patch psycopg's openssl linking" do |
291 | 295 | # Same for psycopg |
292 | 296 | psycopg_folder = "#{site_packages_path}/psycopg_c" |
293 | | - libssl_match = Dir.glob("#{psycopg_folder}.libs/libssl-*.so.3")[0] |
294 | | - libcrypto_match = Dir.glob("#{psycopg_folder}.libs/libcrypto-*.so.3")[0] |
295 | | - sos_to_patch = Dir.glob("#{psycopg_folder}/*.so*") + Dir.glob("#{psycopg_folder}.libs/*.so*") |
| 297 | + libssl_matches = Dir.glob("#{psycopg_folder}.libs/libssl-*.so.3") |
| 298 | + libcrypto_matches = Dir.glob("#{psycopg_folder}.libs/libcrypto-*.so.3") |
| 299 | + raise "expected exactly one match for 'libssl-*.so.3' but got: #{libssl_matches}" if libssl_matches.size != 1 |
| 300 | + raise "expected exactly one match for 'libcrypto-*.so.3' but got: #{libcrypto_matches}" if libcrypto_matches.size != 1 |
| 301 | + libssl_match = libssl_matches.fetch(0) |
| 302 | + libcrypto_match = libcrypto_matches.fetch(0) |
| 303 | + |
| 304 | + # Files that might refer to the OpenSSL libraries and that need patching. |
| 305 | + # Note that if we miss any file that would need patching, the Omnibus health check will have our back |
| 306 | + sos_to_patch = [ |
| 307 | + Dir.glob("#{psycopg_folder}/_psycopg.cpython-*-linux-gnu.so").fetch(0), |
| 308 | + Dir.glob("#{psycopg_folder}/pq.cpython-*-linux-gnu.so").fetch(0), |
| 309 | + Dir.glob("#{psycopg_folder}.libs/libpq-*.so*").fetch(0), |
| 310 | + ] |
296 | 311 | sos_to_patch.each do |so_to_patch| |
297 | 312 | shellout! "patchelf --replace-needed #{File.basename(libssl_match)} libssl.so.3 #{so_to_patch}" |
298 | 313 | shellout! "patchelf --replace-needed #{File.basename(libcrypto_match)} libcrypto.so.3 #{so_to_patch}" |
|
0 commit comments