bug 1135700 - make uploadsymbols use Socorro symbol upload API. r=gps
authorTed Mielczarek <ted@mielczarek.org>
Mon, 23 Feb 2015 13:48:54 -0500
changeset 231076 db9a70fc3230fbe0572a3fac0931c6b8cd06dde8
parent 231075 6512200e17e21633a00ee5b27c66eb1ed2236c92
child 231077 23fb39cb0f9761b56d8207abc6aa431aa1addf43
push id11525
push userkwierso@gmail.com
push dateFri, 27 Feb 2015 02:56:09 +0000
treeherderfx-team@5badb47eed19 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1135700
milestone39.0a1
bug 1135700 - make uploadsymbols use Socorro symbol upload API. r=gps
Makefile.in
configure.in
toolkit/crashreporter/tools/upload_symbols.py
--- a/Makefile.in
+++ b/Makefile.in
@@ -244,16 +244,19 @@ ifdef MOZ_CRASHREPORTER
 	grep 'sym' $(SYMBOL_INDEX_NAME) > $(SYMBOL_INDEX_NAME).tmp && \
 	  mv $(SYMBOL_INDEX_NAME).tmp $(SYMBOL_INDEX_NAME)
 	cd $(DIST)/crashreporter-symbols && \
           zip -r9D '../$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip' . -i '*.sym' -i '*.txt'  -x '*test*' -x '*Test*'
 endif # MOZ_CRASHREPORTER
 
 uploadsymbols:
 ifdef MOZ_CRASHREPORTER
+ifdef SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE
+	$(PYTHON) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.py '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
+endif
 	$(SHELL) $(topsrcdir)/toolkit/crashreporter/tools/upload_symbols.sh $(SYMBOL_INDEX_NAME) '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip'
 endif
 
 # MOZ_SOURCE_STAMP is defined in package-name.mk with a deferred assignment.
 # exporting it makes make run its $(shell) command for each invoked submake,
 # so transform it to an immediate assignment.
 MOZ_SOURCE_STAMP := $(MOZ_SOURCE_STAMP)
 export MOZ_SOURCE_STAMP
--- a/configure.in
+++ b/configure.in
@@ -8887,16 +8887,17 @@ AC_SUBST(LIBJPEG_TURBO_ASFLAGS)
 AC_SUBST(LIBJPEG_TURBO_X86_ASM)
 AC_SUBST(LIBJPEG_TURBO_X64_ASM)
 AC_SUBST(LIBJPEG_TURBO_ARM_ASM)
 AC_SUBST(LIBJPEG_TURBO_ARM64_ASM)
 AC_SUBST(LIBJPEG_TURBO_MIPS_ASM)
 
 AC_SUBST(MOZ_PACKAGE_JSSHELL)
 AC_SUBST(MOZ_FOLD_LIBS)
+AC_SUBST(SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE)
 
 AC_SUBST(MOZ_ENABLE_SZIP)
 AC_SUBST(MOZ_SZIP_FLAGS)
 
 dnl Host JavaScript runtime, if any, to use during cross compiles.
 AC_SUBST(JS_BINARY)
 
 if test "$MOZ_DEBUG"; then
new file mode 100644
--- /dev/null
+++ b/toolkit/crashreporter/tools/upload_symbols.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This script uploads a symbol zip file passed on the commandline
+# to the Socorro symbol upload API hosted on crash-stats.mozilla.org.
+#
+# Using this script requires you to have generated an authentication
+# token in the crash-stats web interface. You must put the token in a file
+# and set SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE to the path to the file in
+# the mozconfig you're using.
+
+from __future__ import print_function
+
+import os
+import requests
+import sys
+
+from buildconfig import substs
+
+# This is the staging server
+url = 'https://crash-stats.allizom.org/symbols/upload'
+# This is the production server, we'll switch this
+# once we're comfortable this works.
+#url = 'https://crash-stats.mozilla.com/symbols/upload'
+
+def main():
+    if len(sys.argv) != 2:
+        print('Usage: uploadsymbols.py <zip file>', file=sys.stderr)
+        return 1
+
+    if not os.path.isfile(sys.argv[1]):
+        print('Error: zip file "{0}" does not exist!'.format(sys.argv[1]),
+              file=sys.stderr)
+        return 1
+    symbols_zip = sys.argv[1]
+
+    if 'SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE' not in substs:
+        print('Error: you must set SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE in your mozconfig!', file=sys.stderr)
+        return 1
+    token_file = substs['SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE']
+
+    if not os.path.isfile(token_file):
+        print('Error: SOCORRO_SYMBOL_UPLOAD_TOKEN_FILE "{0}" does not exist!'.format(token_file), file=sys.stderr)
+        return 1
+    auth_token = open(token_file, 'r').read().strip()
+
+    print('Uploading symbol file "{0}" to "{1}"...'.format(sys.argv[1], url))
+
+    try:
+        r = requests.post(
+            url,
+            files={'symbols.zip': open(sys.argv[1], 'rb')},
+            headers={'Auth-Token': auth_token},
+            allow_redirects=False,
+            timeout=60,
+        )
+    except requests.exceptions.RequestException as e:
+        print('Error: {0}'.format(e))
+        return 1
+
+    if r.status_code >= 200 and r.status_code < 300:
+        print('Uploaded successfully!')
+    elif r.status_code < 400:
+        print('Error: bad auth token? ({0})'.format(r.status_code),
+              file=sys.stderr)
+        return 1
+    else:
+        print('Error: got HTTP response {0}'.format(r.status_code),
+              file=sys.stderr)
+        return 1
+    return 0
+
+if __name__ == '__main__':
+    sys.exit(main())
+