|
77 | 77 | for my $file (keys %deps) {
|
78 | 78 | my $copy = $file =~ s|^$install_dir|/tmp/$dist|r;
|
79 | 79 | system("mkdir -p " . dirname($copy));
|
80 |
| - system("cp -R $file $copy"); |
81 |
| - next if -l $file; |
| 80 | + if ($file =~ m|^$install_dir/bin/|) { |
| 81 | + # symlinks in the bin directory are replaced by the target file because in |
| 82 | + # macOS Monterey @executable_path refers to the symlink target and not the |
| 83 | + # symlink location itself, breaking the dylib lookup. |
| 84 | + system("cp $file $copy"); |
| 85 | + } |
| 86 | + else { |
| 87 | + system("cp -R $file $copy"); |
| 88 | + next if -l $file; |
| 89 | + } |
82 | 90 | next unless qx(file $copy) =~ /Mach-O/;
|
83 | 91 |
|
84 | 92 | open(my $fh, "otool -L $file |") or die "Failed to run 'otool -L $file': $!";
|
@@ -125,7 +133,11 @@ sub record {
|
125 | 133 | my $segment = shift @segments;
|
126 | 134 | my $name = "$filename/$segment";
|
127 | 135 | my $link = readlink $name;
|
128 |
| - if (defined $link) { |
| 136 | + # symlinks in the bin directory are replaced by the target, and the symlinks are not |
| 137 | + # recorded (see above). However, at least "share/qemu" needs to remain a symlink to |
| 138 | + # "../Cellar/qemu/6.0.0/share/qemu" so qemu will still find its data files. Therefore |
| 139 | + # symlinks are still recorded for all other files. |
| 140 | + if (defined $link && $name !~ m|^$install_dir/bin/|) { |
129 | 141 | # Record the symlink itself with the link target as the comment
|
130 | 142 | $deps{$name} = "→ $link";
|
131 | 143 | if ($link =~ m|^/|) {
|
|
0 commit comments