The Mystery of the Supranational Rabbit (porsupah) wrote,
The Mystery of the Supranational Rabbit
porsupah

  • Mood:

Parse nip

I'm only vaguely aware of Perl, sad to say, though I'm finally getting around to picking up bits and pieces. So, this script has me a little puzzled. Any Perl guru feel like offering a smidgen of assistance?


file, as you may know, offers up information about what kind of file a particular file actually is. In this case, the output from file is:

/Users/porsupah/Development/ iPhone/Cocoa is my Girlfriend - First App demo/Basic iPhone App/build/Debug-iphoneos/Basic iPhone App.app/Basic iPhone App: Mach-O executable arm


(Cocoa is my Girlfriend being the name of the site which offered up this handy starter tutorial for iPhone development)

The script, by one Tiku, gained from a thread on Apple's discussion boards:

#!/usr/bin/perl
#
$appDir=$ARGV[$#ARGV];
@tmpAry=split(/\//,$appDir);
$baseAppName=$tmpAry[$#tmpAry];
$baseAppName=~s/\.app$//;
$realAppName="$appDir"."/$baseAppName";

$sign=0;
for($b=0;$b<$#ARGV;$b++) {
if($ARGV[$b] eq "-s") {
$sign=1;
}
}

$mums=`/usr/bin/file $realAppName`;
if($sign==1) {
print "codesign debug: we are attempting to sign a file.\n";
}
if($mums=~/executable arm/) {
print "codesign debug: verified the file is an ARM executable.\n";
}
if(($sign==1) && ($mums=~/executable arm/)) {
print "Signing armv6 new style..\n";
$dev="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/";
$tmp="$appDir"."/tmpbin";
`$dev/lipo -create $realAppName -output $tmp`;
`mv $tmp $realAppName`;
system("/usr/bin/codesign.orig",@ARGV);
`$dev/lipo -thin armv6 $realAppName -output $tmp`;
`mv $tmp $realAppName`;
system("rm $appDir"."/CodeResources");
system("cp $appDir"."/_CodeSignature/CodeResources $appDir"."/CodeResources");
exit 0;
} else {
print "Signing armv6 old style..\n";
exec '/usr/bin/codesign.orig',@ARGV;
}


So, the problem at paw: the hack is carried out if both conditions are true - we're passing the -s option in, and the file we want to sign is an ARM executable. I see the first debug output, noting the -s flag, but not the second. Why? Certainly, the output given should match the condition specified, executable arm, so is $mums not being assigned correctly?
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 10 comments