@@ -196,7 +196,6 @@ class Build
196
196
relink_eln_files : options [ :relink_eln ]
197
197
) . embed
198
198
GccLibEmbedder . new ( app , gcc_info ) . embed if options [ :native_comp ]
199
- # EmbeddedLibrarySdkFixer.new(app).fix
200
199
self_sign_app ( app ) if options [ :self_sign ]
201
200
202
201
archive_build ( build_dir ) if options [ :archive ]
@@ -1420,120 +1419,6 @@ class LibEmbedder < AbstractEmbedder
1420
1419
end
1421
1420
end
1422
1421
1423
- # This is a horrible hack attempt to fix a application signing verification bug
1424
- # with the x86_64 builds. It seems that most of the Intel based libraries from
1425
- # Nix uses `LC_VERSION_MIN_MACOSX`, most specify both `version` and `sdk`
1426
- # values. However some don't specify a `sdk` value, and when checked with
1427
- # `codeside -vv -d <path/to/file>`, it complains with a warning:
1428
- #
1429
- # Library validation warning=OS X SDK version before 10.9 does not support Library Validation
1430
- #
1431
- # I suspect this is why the Intel builds fail signing verification. This is an
1432
- # attempt to fix that. It uses `vtool` to force set the newer `LC_BUILD_VERSION`
1433
- # load command's `minos` and `sdk` values to that of the old load command's
1434
- # `version` value. But only if the old load command is present and missing an
1435
- # `sdk` value.
1436
- class EmbeddedLibrarySdkFixer < AbstractEmbedder
1437
- # SDK versions below 10.9 do not support Library signing, so let's ensure we
1438
- # set it to 10.9 or higher.
1439
- MIN_VERSION = 657_664
1440
- MIN_VERSION_STRING = '10.9.0'
1441
-
1442
- def fix
1443
- debug 'Checking embedded libraries for ' \
1444
- 'missing SDK version in Mach-O headers...'
1445
- Dir [ File . join ( frameworks_dir , '**' , '*.{dylib,so,la}' ) ] . each do |file_path |
1446
- debug "-- Checking #{ relative_path ( file_path ) } "
1447
- fix_macho ( file_path )
1448
- end
1449
- end
1450
-
1451
- def each_macho ( file_path , &block )
1452
- mo = nil
1453
-
1454
- begin
1455
- mo = MachO . open ( file_path )
1456
- rescue MachO ::NotAMachOError
1457
- debug '-- -- Skipping Mach-O SDK version check/fix, not a Mach-O file'
1458
- return
1459
- end
1460
-
1461
- if mo . is_a? ( MachO ::FatFile )
1462
- mo . machos . each ( &block )
1463
- else
1464
- yield ( mo )
1465
- end
1466
- end
1467
-
1468
- def fix_macho ( file_path )
1469
- blank_legacy_sdk = false
1470
- legacy_version = nil
1471
- legacy_version_string = nil
1472
- lc_build_version = false
1473
-
1474
- each_macho ( file_path ) do |mf |
1475
- mf . load_commands . each do |lc |
1476
- if !blank_legacy_sdk &&
1477
- lc . is_a? ( MachO ::LoadCommands ::VersionMinCommand ) &&
1478
- lc . sdk . zero? && !lc . version . zero?
1479
- blank_legacy_sdk = true
1480
- legacy_version = lc . version
1481
- legacy_version_string = lc . version_string
1482
- end
1483
-
1484
- if lc . is_a? ( MachO ::LoadCommands ::BuildVersionCommand )
1485
- lc_build_version = true
1486
- end
1487
- end
1488
- end
1489
-
1490
- return unless blank_legacy_sdk && !lc_build_version && legacy_version_string
1491
-
1492
- # If the legacy version is less than the minimum version, we set it to the
1493
- # minimum version.
1494
- if legacy_version < MIN_VERSION
1495
- legacy_version = MIN_VERSION
1496
- legacy_version_string = MIN_VERSION_STRING
1497
- end
1498
-
1499
- debug '-- -- Adding LC_BUILD_VERSION to Mach-O header'
1500
- run_cmd (
1501
- vtool_path , '-set-build-version' ,
1502
- 'macos' , legacy_version_string , legacy_version_string ,
1503
- '-replace' , '-output' , "#{ file_path } .patched" , file_path
1504
- )
1505
-
1506
- while_writable ( file_path ) do
1507
- FileUtils . remove_file ( file_path )
1508
- FileUtils . mv ( "#{ file_path } .patched" , file_path )
1509
- end
1510
-
1511
- legacy_version
1512
- end
1513
-
1514
- # Try and locate vtool.
1515
- def vtool_path
1516
- return @vtool_path if @vtool_path
1517
-
1518
- # Default approach
1519
- path = `sh -c "xcrun -f vtool 2>/dev/null"` . strip
1520
- return @vtool_path = path unless path . empty?
1521
-
1522
- # Unset DEVELOPER_DIR to revert to default dev tools and try again.
1523
- path = `sh -c "env DEVELOPER_DIR='' xcrun -f vtool 2>/dev/null"` . strip
1524
- return @vtool_path = path unless path . empty?
1525
-
1526
- # Unset DEVELOPER_DIR and use full path to xcrun. This should escape out of
1527
- # the Nix environment and pull in the default vtool from macOS itself.
1528
- path = `sh -c "env DEVELOPER_DIR='' /usr/bin/xcrun -f vtool 2>/dev/null"`
1529
- . strip
1530
- return @vtool_path = path unless path . empty?
1531
-
1532
- fatal 'Could not locate vtool, please ensure Xcode Command Line Tools ' \
1533
- 'are installed'
1534
- end
1535
- end
1536
-
1537
1422
class GccLibEmbedder < AbstractEmbedder
1538
1423
attr_reader :gcc_info
1539
1424
0 commit comments