123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- use strict;
- use warnings;
- print "This script is highly experimental. Modify it to suit your needs and take care to run it only in controlled environments.\n";
- exit 1;
- my $OUTPUTDIR='/tmp/SuperTux.app/Contents/MacOS';
- my $EXECUTABLE='./supertux2';
- my %COPIED;
- my @TOCOPY;
- my %PATCHED;
- my @TOPATCH;
- system('mkdir '.$OUTPUTDIR);
- push (@TOCOPY, $EXECUTABLE);
- while (my $EXECUTABLE = pop @TOCOPY) {
- next if $COPIED{$EXECUTABLE};
- $COPIED{$EXECUTABLE} = 1;
- next unless $EXECUTABLE =~ /^(.*)\/(.*)$/;
- my $PATH = $1;
- my $FNAME = $2;
- print("copying ".$EXECUTABLE."\n");
- system('cp '.$EXECUTABLE.' '.$OUTPUTDIR.'/'.$FNAME);
- system('chmod u+w '.$OUTPUTDIR.'/'.$FNAME);
-
- push(@TOPATCH, $OUTPUTDIR.'/'.$FNAME);
- $EXECUTABLE = $OUTPUTDIR.'/'.$FNAME;
- my @LIBS = qx{/usr/bin/otool -L $EXECUTABLE};
- while ($_ = pop @LIBS) {
-
- next unless /^\t(.*) \(.*\).*$/;
- my $FULLPATH = $1;
-
- next unless $FULLPATH =~ /\.dylib$/;
-
- next if $FULLPATH =~ /^@/;
-
- next unless $FULLPATH =~ /^(.*)\/(.*)$/;
- my $PATH = $1;
- my $FNAME = $2;
-
- next if $PATH =~ q{^/usr/lib$};
- # mark dependency as to-be-copied
- push(@TOCOPY, $FULLPATH);
- }
- }
- while (my $EXECUTABLE = pop @TOPATCH) {
- next if $PATCHED{$EXECUTABLE};
- $PATCHED{$EXECUTABLE} = 1;
- print "patching ".$EXECUTABLE."\n";
- my @LIBS = qx{/usr/bin/otool -L $EXECUTABLE};
- while ($_ = pop @LIBS) {
-
- next unless /^\t(.*) \(.*\).*$/;
- my $FULLPATH = $1;
-
- next unless $FULLPATH =~ /\.dylib$/;
-
- next if $FULLPATH =~ /^@/;
-
- next unless $FULLPATH =~ /^(.*)\/(.*)$/;
- my $PATH = $1;
- my $FNAME = $2;
-
- next if $PATH =~ q{^/usr/lib$};
- # patch binary to depend on copy in @executable_path instead
- system('install_name_tool -change '.$FULLPATH.' @executable_path/'.$FNAME.' '.$EXECUTABLE);
- }
- }
|