-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathls_ipa
executable file
·65 lines (50 loc) · 985 Bytes
/
ls_ipa
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
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# List files in IPA with size
set -e
# Show usage and quit
usage () {
echo "Usage: ls_ipa [-s] /path/to/ipa"
return 1
}
prepare () {
ipa=$1
# Create temp working dir
WS=$(mktemp -t ck-ios-build-scripts)
[ -d "$WS" ] || rm -rf "$WS"
mkdir "$WS"
# Unzip ipa
unzip -q "$ipa" -d "$WS"
# Get it done
cd "$WS/Payload/"
}
ls_ipa_by_size () {
find ./*.app -depth 1 -print0 | xargs -0 -I{} du -s {} | sort -rn | cut -f2 | xargs -I{} du -sh {}
}
ls_ipa_by_name () {
find ./*.app -depth 1 -print0 | xargs -0 -I{} du -hs {}
}
main () {
while getopts :sh opt; do
case $opt in
s)
ls_by_size=1
;;
\?)
usage
;;
esac
done
shift $((OPTIND-1))
if [ ! -f "$1" ];
then
usage
fi
prepare "$1"
if [ -n "$ls_by_size" ];
then
ls_ipa_by_size
else
ls_ipa_by_name
fi
}
main "$@"