-
Notifications
You must be signed in to change notification settings - Fork 30
/
deploy
executable file
·56 lines (53 loc) · 1.09 KB
/
deploy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl -w
#
use strict;
my($i, $found, $test, $rex);
my($line);
my($id) = 0;
my($lib) = $ARGV[0];
my(@rexps) = split(":", $ARGV[1]);
for($i = 0; $i < @rexps; ++$i){
$rexps[$i] =~ s/\//\\\//g;
#$rexps[$i] =~ s/(.*)/\/$1\//;
$rexps[$i] = qr/^\s+$rexps[$i]/;
}
my($dylib);
if($lib =~ /.dylib$/){
$dylib = 1;
}else{
$dylib = 0;
$id = 1;
}
#$lib =~//;
my($libname) = $lib;
$libname =~ s/^.*\/([^\/]+)$/$1/;
open(L, "otool -L ".$lib." |");
while($line=<L>){
$found = 0;
foreach $rex (@rexps){
if($line =~ $rex){
$found = 1;
last;
}
}
if($found == 1){
if($id == 0){
if($dylib == 1){
system('install_name_tool -id @executable_path/../Frameworks/'.$libname." ".$lib);
}
$id = 1;
}else{
$line =~ /^\s*(\S*\/)(\S+)/;
$libname = $2;
my($libpath) = $1.$2;
if($dylib == 1){
system('install_name_tool -change '.$libpath.' @loader_path/'.$libname.' '.$lib);
}else{
system('install_name_tool -change '.$libpath.' @executable_path/../Frameworks/'.$libname.' '.$lib);
}
}
}
}
sub process{
}
#