Created
October 16, 2009 18:26
-
-
Save drudge/211947 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## | |
## grabAppFromCydia.sh | |
## Random scripts / Public domain | |
## | |
## Created by Nicholas Penree on 10/16/09. | |
## Copyright 2009 Conceited Software. All rights reserved. | |
## | |
version="0.5" | |
components=("$@") | |
parentFolder="/tmp" | |
applicationsFolder="Applications" | |
dataFile="data.tar.gz" | |
controlFile="control.tar.gz" | |
binaryFile="debian-binary" | |
if [ ${#components[@]} -ge 1 ]; then | |
debURL="${components[0]}" | |
debFile=`basename "$debURL"` | |
folderName=`basename "$debURL" .deb` | |
# step 1: create working folder | |
if [ -d "$parentFolder/$folderName" ]; then | |
rm -rf "$parentFolder/$folderName" | |
fi | |
mkdir "$parentFolder/$folderName" || (echo "error: could not create $parentFolder/$folderName! aborting" && exit 1) | |
cd "$parentFolder/$folderName" || (echo "error: could not change directory to $parentFolder/$folderName! aborting" && exit 1) | |
# step 2: download .deb | |
curl -O "$debURL" || (echo "error: download attempt failed! aborting" && exit 1) | |
# step 3: extract .deb | |
if [ -e "$debFile" ]; then | |
ar -x "$debFile" &> /dev/null | |
if [ $? -ne 0 ]; then | |
echo "error: .deb extract failed! check file format. aborting" | |
rm -rf "$parentFolder/$folderName" | |
exit 1 | |
fi | |
else | |
echo "error: download failed, $debFile does not exist! aborting" && exit 1 | |
fi | |
# step 4: extract data tarball | |
if [ -e "$dataFile" ]; then | |
tar zxf "$dataFile" | |
else | |
echo "error: data extract failed! aborting" && exit 1 | |
fi | |
# step 5: clean up | |
rm -f "$debFile" &> /dev/null | |
rm -f "$dataFile" &> /dev/null | |
rm -f "$controlFile" &> /dev/null | |
rm -f "$binaryFile" &> /dev/null | |
# step 6: re-sign app with your certificate | |
## TODO: Add me! | |
## export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform\ | |
## /Developer/usr/bin/codesign_allocate | |
## codesign -f -s "iPhone Developer" $1.app | |
# step 7: show finder window | |
if [ -d "$parentFolder/$folderName/$applicationsFolder" ]; then | |
open "$parentFolder/$folderName/$applicationsFolder" | |
else | |
open "$parentFolder/$folderName" | |
fi | |
else | |
echo "getAppFromCydia.sh version $version" | |
echo " usage: getAppFromCydia.sh <url to .deb>" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment