-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload-symbols.sh
executable file
·125 lines (99 loc) · 3.11 KB
/
upload-symbols.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
OPT="value"
opts=":hf:"
cmd(){ echo `basename $0`; }
usage(){
echo "\
`cmd` [OPTION...]
-h optional Print this help message
-f required Path to zip file containing .app and dSYM
" | column -t -s ";"
}
error() {
echo "`cmd`: invalid option -- '$1'";
echo "Try '`cmd` -h' for more information.";
exit 1;
}
if [ $# -eq 0 ]; then
usage;
exit 1
fi
while getopts ${opts} opt; do
case ${opt} in
f )
FILE=$OPTARG
;;
h )
usage
exit 1
;;
\? )
error
;;
: )
echo "Option: $OPTARG requires an argument" 1>&2
usage
exit 1
;;
esac
done
shift $((OPTIND -1))
if [ ! -f "${HOME}/.bugsplat.conf" ]
then
echo "Missing bugsplat config file: ~/.bugsplat.conf"
exit
fi
source "${HOME}/.bugsplat.conf"
if [ -z "${BUGSPLAT_USER}" ]
then
echo "BUGSPLAT_USER must be set in ~/.bugsplat.conf"
exit
fi
if [ -z "${BUGSPLAT_PASS}" ]
then
echo "BUGSPLAT_PASS must be set in ~/.bugsplat.conf"
exit
fi
# Print the variables
echo "File: ${FILE}"
# extract to tmp directory for inspection
UNZIP_DIR=$(zipinfo -1 $FILE | grep -oE '^[^/]+' | uniq)
UNZIP_LOCATION="/tmp/Bugsplat"
UNZIP_PATH="${UNZIP_LOCATION}/${UNZIP_DIR}"
mkdir -p ${UNZIP_LOCATION}
unzip -o $FILE -d ${UNZIP_LOCATION}
APP=$(find $UNZIP_PATH -name *.app -type d -maxdepth 1 -print | head -n1)
echo "App: ${APP}"
APP_MARKETING_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${APP}/Contents/Info.plist")
APP_BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${APP}/Contents/Info.plist")
if [ -z "${APP_MARKETING_VERSION}" ]
then
echo "CFBundleShortVersionString not found in app Info.plist"
exit
fi
echo "App marketing version: ${APP_MARKETING_VERSION}"
echo "App bundle version: ${APP_BUNDLE_VERSION}"
APP_VERSION="${APP_MARKETING_VERSION}"
if [ -n "${APP_BUNDLE_VERSION}" ]
then
APP_VERSION="${APP_VERSION} (${APP_BUNDLE_VERSION})"
fi
PRODUCT_NAME=$(/usr/libexec/PlistBuddy -c "Print CFBundleName" "${APP}/Contents/Info.plist")
BUGSPLAT_SERVER_URL=$(/usr/libexec/PlistBuddy -c "Print BugsplatServerURL" "${APP}/Contents/Info.plist")
BUGSPLAT_SERVER_URL=${BUGSPLAT_SERVER_URL%/}
UPLOAD_URL="${BUGSPLAT_SERVER_URL}/post/plCrashReporter/symbol/"
echo "App version: ${APP_VERSION}"
UUID_CMD_OUT=$(xcrun dwarfdump --uuid "${APP}/Contents/MacOS/${PRODUCT_NAME}")
UUID_CMD_OUT=$([[ "${UUID_CMD_OUT}" =~ ^(UUID: )([0-9a-zA-Z\-]+) ]] && echo ${BASH_REMATCH[2]})
echo "UUID found: ${UUID_CMD_OUT}"
echo "Signing into bugsplat and storing session cookie for use in upload"
COOKIEPATH="/tmp/bugsplat-cookie.txt"
LOGIN_URL="${BUGSPLAT_SERVER_URL}/browse/login.php"
echo "Login URL: ${LOGIN_URL}"
rm "${COOKIEPATH}"
curl -b "${COOKIEPATH}" -c "${COOKIEPATH}" --data-urlencode "currusername=${BUGSPLAT_USER}" --data-urlencode "currpasswd=${BUGSPLAT_PASS}" "${LOGIN_URL}"
echo "Uploading ${FILE} to ${UPLOAD_URL}"
curl -i -b "${COOKIEPATH}" -c "${COOKIEPATH}" -F filedata=@"${FILE}" -F appName="${PRODUCT_NAME}" -F appVer="${APP_VERSION}" -F buildId="${UUID_CMD_OUT}" $UPLOAD_URL