Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit 0e3bcc5

Browse files
committed
-changed the country code selection parameter to -C (from -z)
-fixed fetching apps unavailable on the US app store -fixed another Invalid App bug -fixed watch app removal -patched up ipatool verbose again -added a legacy compression toggle that may shrink the final ipa size, at the cost of azule running much slower that way (-z)
1 parent bc6df92 commit 0e3bcc5

File tree

1 file changed

+51
-35
lines changed

1 file changed

+51
-35
lines changed

azule

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ help () {
350350
echo " -n [Name] Specify a name for the Output iPA"
351351
echo " -A [Source URL/Repo List] Specify custom sources to get packages from"
352352
echo " -L Ignore packages from Canister"
353-
echo " -H Inject Libhooker in dylibs (highly discouraged)"
354353
echo " -k Ignore packages from APT Sources"
355354
echo " -d Don't install package dependencies"
356355
echo " -D Disable refreshing Procursus/Elcubratus repos"
@@ -367,14 +366,16 @@ help () {
367366
echo " -r Skip Encryption Check"
368367
echo " -y Don't remove watch app"
369368
echo " -q Ignore errors"
370-
echo " -j Allow for Azule to be ran as root [Not Reccommended]"
369+
echo " -H Inject Libhooker in dylibs [Highly Discouraged]"
370+
echo " -j Allow for Azule to be ran as root [Discouraged]"
371+
echo " -z Use Legacy Compression (outputs smaller .ipa files, but runs slower)"
371372
echo " -h Print this help menu"
372373

373374
if [ "$os" == "iOS" ]; then
374375
echo
375376
echo "iOS Only:"
376377
echo " -x [Apple ID] [Password] Fetch and decrypt iPA with specified Apple ID"
377-
echo " -z [Country Code] Specify country code for ipatool"
378+
echo " -C [Country Code] Specify country code for ipatool"
378379
echo " -g Force Update Apps"
379380
echo " -l Don't Update Outdated Apps"
380381
else
@@ -405,6 +406,7 @@ Announce "Platform is $os" -v
405406
# PLATFORM-SPECIFIC FUNCTIONS
406407
case "$os" in
407408
iOS)
409+
country_code="US"
408410
RemovePlistKey () {
409411
plutil -remove -key "$1" "$2" &>/dev/null
410412
}
@@ -477,7 +479,7 @@ trap "cleanup" SIGINT
477479
trap "cleanup" EXIT
478480

479481
# CLI ARGUEMENTS
480-
while getopts Hn:i:o:c:b:x:f:p:z:huSewsrDHqAdjRyUgFLklv args; do
482+
while getopts Hn:i:o:c:b:x:f:p:C:huSewsrDHqAdjRyUzgFLklv args; do
481483

482484
# STUFF WITH PARAMETERS
483485
if [[ "$args" == @(x|n|b|p|i|o|c|f|A|H|z) ]]; then
@@ -493,7 +495,7 @@ while getopts Hn:i:o:c:b:x:f:p:z:huSewsrDHqAdjRyUgFLklv args; do
493495
if [[ "$args" == @(U|F) ]]; then
494496
Announce "-$args is not supported on your platform" 6
495497
fi
496-
elif [[ "$args" == @(x|l|g|z) ]]; then
498+
elif [[ "$args" == @(x|l|g|C) ]]; then
497499
Announce "-$args is not supported on your platform" 6
498500
fi
499501

@@ -509,7 +511,7 @@ while getopts Hn:i:o:c:b:x:f:p:z:huSewsrDHqAdjRyUgFLklv args; do
509511
o) outdir="$(expand "${tmp[*]}")" ;;
510512
p) displayname="${tmp[*]}" && run=1 ;;
511513
x) IPATOOL_EMAIL="${tmp[0]}" && unset "tmp[0]" && IPATOOL_PASSWORD="${tmp[*]}" ;;
512-
z) country_code="-c ${tmp[*]}" ;;
514+
C) country_code="${tmp[*]}" ;;
513515

514516
# SWITCHES
515517
e) remove_extensions=1 && run=1 ;;
@@ -526,6 +528,7 @@ while getopts Hn:i:o:c:b:x:f:p:z:huSewsrDHqAdjRyUgFLklv args; do
526528
L) ignore_canister=1 ;;
527529
d) no_recurse=1 ;;
528530
D) disable_dists=1 ;;
531+
z) legacy_compression=1 ;;
529532

530533
# MACOS/LINUX ONLY SWITCHES
531534
U) no_update_azule=1 ;;
@@ -678,7 +681,7 @@ if [ -z "$outdir" ]; then
678681
Announce "No Output Directory Specified. Run 'azule -h' for help" 27
679682
elif [ -z "$ipadir" ]; then
680683
Announce "No iPA Specified. Run 'azule -h' for help" 27
681-
elif [[ -z "$run" ]] && [[ "$os" != "iOS" || -e "$ipadir" ]] ; then
684+
elif [[ -z "$run" ]] && [[ "$os" != "iOS" || ( -e "$ipadir" && ( "$ipadir" == "*.ipa" || "$ipadir" == "*.app" ) ) ]] ; then
682685
Announce "No Modifiers Specified. Run 'azule -h' for help" 27
683686
fi
684687

@@ -690,7 +693,8 @@ Verbose "Temporary Directory has been created" "Couldn't create Temporary Direct
690693
cd "$dir" || exit
691694

692695
# INSTALLING UPDATES AND DECRYPTION
693-
if [[ ! -e "$ipadir" && "$os" == "iOS" ]]; then
696+
if [ "$os" == "iOS" ] && [[ ! -e "$ipadir" || ( -e "$ipadir" && ! ( "$ipadir" == "*.ipa" || "$ipadir" == "*.app" ) ) ]]; then
697+
ipadir="$(basename "$ipadir")"
694698
if [ -z "$ignore_outdated" ]; then
695699
Announce "Checking for App Updates..."
696700

@@ -706,7 +710,7 @@ if [[ ! -e "$ipadir" && "$os" == "iOS" ]]; then
706710

707711
# CHECK IF APP IS OUTDATED
708712
if ! curl -I google.com &>/dev/null; then Announce "No Connection to the Internet" 26; fi
709-
latestv="$(curl -s "http://itunes.apple.com/lookup?bundleId=$ipadir" | jq -r '.results[].version')"
713+
latestv="$(curl -s "http://itunes.apple.com/lookup?bundleId=$ipadir&country=$country_code" | jq -r '.results[].version')"
710714
currentv="$(ExtractPlistValue CFBundleShortVersionString "$info_plist")"
711715

712716
# VARIABLE CHECK
@@ -719,12 +723,12 @@ if [[ ! -e "$ipadir" && "$os" == "iOS" ]]; then
719723

720724
# DOWNLOAD AND INSTALL UPDATES
721725
Announce "Downloading $ipadir..."
722-
ipatool download -b "$ipadir" $country_code --purchase --output "$dir/$ipadir.ipa"
726+
ipatool download -b "$ipadir" -c "$country_code" --purchase --output "$dir/$ipadir.ipa"
723727
status="$?"
724728
if [ "$status" == "1" ]; then
725729
rm -f "$azule/ipatool_authenticated"
726730
ipatool_auth
727-
ipatool download -b "$ipadir" $country_code --purchase --output "$dir/$ipadir.ipa"
731+
ipatool download -b "$ipadir" -c "$country_code" --purchase --output "$dir/$ipadir.ipa"
728732
status="$?"
729733
fi
730734

@@ -829,6 +833,13 @@ elif [ -e "$ipadir" ]; then
829833
cp -R "$ipadir" "$dir/Payload" &>/dev/null
830834
Verbose "Copied App to Work Directory" "Couldn't Copy App to Work Directory" 11
831835
full_unzipped=1
836+
elif [ "${ipadir: -4}" == ".ipa" ] && [ -n "$legacy_compression" ]; then
837+
838+
# EXTRACTING IPA
839+
Announce "Extracting iPA..."
840+
unzip -q "$ipadir" -d "$dir"
841+
Verbose "IPA extracted" "Couldn't extract IPA" 11
842+
full_unzipped=1
832843
fi
833844
else
834845
Announce "Invalid App" 8
@@ -847,24 +858,25 @@ if [ -n "$run" ] || [ -n "$bfplist" ]; then
847858
fi
848859

849860
# SETTING APP VARIABLES
850-
decompress Payload/*.app/Info.plist
851-
appname="$(basename Payload/*.app)"
852-
exec_name="$(ExtractPlistValue CFBundleExecutable Payload/"$appname"/Info.plist)"
853-
executable="Payload/$appname/$exec_name"
854-
decompress "$executable"
855-
checkvar "$exec_name"
856-
Verbose "App executable is ${executable//*.app/@executable_path}" "Couldn't set app executable" 12 -v
857-
858-
ldid -e "$executable" > "$dir/exec_entitlements"
859-
ldid -r "$executable" || status=1
860-
Verbose "Stripped codesign from app executable" "Couldn't strip codesign from app executable" 33 -v
861-
rpath="$(otool -l "$executable" | grep RPATH -A2 | sed 's/.*path \(.*\)/\1/' | grep -o '^\S*' | grep "^@executable_path*" | tail -1 | sed "s|@executable_path|Payload/$appname|g")"
862-
checkvar "$rpath"
863-
Verbose "App rpath is ${rpath//*.app/@executable_path}" "Couldn't set app rpath" 13 -v
864-
mkdir -p "$rpath"
865-
866-
# ENCRYPTION CHECK
867-
if [ -z "$ignore_encrypted" ] && otool -l "$executable" | grep -q 'cryptid 1'; then Announce "Fatal Error: $executable is encrypted" 14; fi
861+
if [ -n "$run" ]; then
862+
decompress Payload/*.app/Info.plist
863+
appname="$(basename Payload/*.app)"
864+
exec_name="$(ExtractPlistValue CFBundleExecutable Payload/"$appname"/Info.plist)"
865+
executable="Payload/$appname/$exec_name"
866+
decompress "$executable"
867+
checkvar "$exec_name"
868+
Verbose "App executable is ${executable//*.app/@executable_path}" "Couldn't set app executable" 12 -v
869+
ldid -e "$executable" > "$dir/exec_entitlements"
870+
ldid -r "$executable" || status=1
871+
Verbose "Stripped codesign from app executable" "Couldn't strip codesign from app executable" 33 -v
872+
rpath="$(otool -l "$executable" | grep RPATH -A2 | sed 's/.*path \(.*\)/\1/' | grep -o '^\S*' | grep "^@executable_path*" | tail -1 | sed "s|@executable_path|Payload/$appname|g")"
873+
checkvar "$rpath"
874+
Verbose "App rpath is ${rpath//*.app/@executable_path}" "Couldn't set app rpath" 13 -v
875+
mkdir -p "$rpath"
876+
877+
# ENCRYPTION CHECK
878+
if [ -z "$ignore_encrypted" ] && otool -l "$executable" | grep -q 'cryptid 1'; then Announce "Fatal Error: $executable is encrypted" 14; fi
879+
fi
868880

869881
# PROCESSING FILES
870882
if [ -n "${files[*]}" ]; then
@@ -1299,8 +1311,10 @@ if [ -n "$fakesign" ]; then
12991311
fi
13001312

13011313
# RESTORING ENTITLEMENTS
1302-
ldid -S"$dir/exec_entitlements" "$executable"
1303-
Verbose "Restored App Entitlements" "Couldn't Restore App Entitlements" -v
1314+
if [ -n "$run" ]; then
1315+
ldid -S"$dir/exec_entitlements" "$executable"
1316+
Verbose "Restored App Entitlements" "Couldn't Restore App Entitlements" -v
1317+
fi
13041318

13051319
# GENERATING IPA
13061320
if [ -n "$run" ] || [ -n "$bfplist" ]; then
@@ -1334,6 +1348,7 @@ if [ -n "$run" ] || [ -n "$bfplist" ]; then
13341348
zip -qq -u "$outdir" "${ziparr[@]}"
13351349
status="$?"
13361350
fi
1351+
Verbose "Generated IPA at $outdir" "Couldn't generate IPA" 25 -X
13371352

13381353
# REMOVING WATCH APP
13391354
if [ -z "$no_remove_watchapp" ]; then
@@ -1344,8 +1359,11 @@ if [ -n "$run" ] || [ -n "$bfplist" ]; then
13441359
if [ -z "$status" ]; then
13451360
Announce "Removing Watch App..." -v
13461361
fi
1347-
zip -qq -d "$outdir" "$(dirname "$i")/*"
1348-
status=$(( status + $? ))
1362+
if [ -d "$(dirname "$i")" ]; then
1363+
zip -qq -d "$outdir" "$(dirname "$i")/*" &>/dev/null
1364+
stat="$?"
1365+
if [ "$stat" != "12" ]; then status=$(( status + "$stat" )); fi
1366+
fi
13491367
fi
13501368
done < <(find "$dir/Payload" -name "Info.plist")
13511369
Verbose "Removed Watch App" "Couldn't Remove Watch App" -x -v
@@ -1356,6 +1374,4 @@ if [ -n "$run" ] || [ -n "$bfplist" ]; then
13561374
zip -qq -d "$outdir" "Payload/*.app/PlugIns/*"
13571375
Verbose "Removed Extensions" "Couldn't Remove Extensions"
13581376
fi
1359-
1360-
Verbose "Generated IPA at $outdir" "Couldn't generate IPA" 25
13611377
fi

0 commit comments

Comments
 (0)