I have written a script which downloads the Grooveshark DEB and makes it into an ipa.
However, when i get to the point

echo "Resigning binary..."
script_dir=$(dirname "$0")
cp "$script_dir/ResourceRules.plist" Applications/Grooveshark.app/
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
codesign -f -s "iPhone Developer" Applications/Grooveshark.app/
it says:
codesign: Applications/Grooveshark.app/: code object is not signed
and that is exactly my point, I NEED TO SIGN IT! I KNOW IT"S NOT SIGNED!

Anyway, I did more testing and it seems that there is a strange problem with LDID:
any binary which has only been signed with LDID will refuse to be signed with codesign!!!

what I mean is:
compile -> codesign -> LDID -> codesign = OK
compile -> LDID -> codesign = FAIL

My theory is that LDID is leaving un-inited some flag, etc. in the binary that says "I can be signed".

I really need help on this!

download script: http://pastebin.com/9R3ktfy5
resource rules: put in same dir as script: http://www.sendspace.com/file/c7e1wm