Bug 1087104 - Set the partialInfo property for Balrog; r=glandium a=NPOTB
authorMike Shal <mshal@mozilla.com>
Thu, 06 Nov 2014 17:10:13 -0500
changeset 233696 0ebb0de0bb584aa540276ae022d7558e53fd9fc3
parent 233695 f81cf71ec0cd996629b35c3eec2e7b3a8f27b72d
child 233697 c4b670cb5a6d4039e443879ae2dafd30a3e7feb4
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewersglandium, NPOTB
bugs1087104
milestone35.0a2
Bug 1087104 - Set the partialInfo property for Balrog; r=glandium a=NPOTB
build/gen_mach_buildprops.py
--- a/build/gen_mach_buildprops.py
+++ b/build/gen_mach_buildprops.py
@@ -71,28 +71,45 @@ def getUrlProperties(filename):
                             properties.update({prop: m})
                             break
     except IOError as e:
         if e.errno != errno.ENOENT:
             raise
         properties = {prop: 'UNKNOWN' for prop, condition in property_conditions}
     return properties
 
+def getPartialInfo(props):
+    return [{
+        "from_buildid": props.get("previous_buildid"),
+        "size": props.get("partialMarSize"),
+        "hash": props.get("partialMarHash"),
+        "url": props.get("partialMarUrl"),
+    }]
+
 if __name__ == '__main__':
     parser = ArgumentParser(description='Generate mach_build_properties.json for automation builds.')
     parser.add_argument("--complete-mar-file", required=True,
                         action="store", dest="complete_mar_file",
                         help="Path to the complete MAR file, relative to the objdir.")
     parser.add_argument("--partial-mar-file", required=False,
                         action="store", dest="partial_mar_file",
                         help="Path to the partial MAR file, relative to the objdir.")
     parser.add_argument("--upload-output", required=True,
                         action="store", dest="upload_output",
                         help="Path to the text output of 'make upload'")
     args = parser.parse_args()
 
     json_data = getMarProperties(args.complete_mar_file)
+    json_data.update(getUrlProperties(args.upload_output))
     if args.partial_mar_file:
         json_data.update(getMarProperties(args.partial_mar_file, partial=True))
-    json_data.update(getUrlProperties(args.upload_output))
+
+        # Pull the previous buildid from the partial mar filename.
+        res = re.match(r'.*\.([0-9]+)-[0-9]+.mar', args.partial_mar_file)
+        if res:
+            json_data['previous_buildid'] = res.group(1)
+
+            # Set partialInfo to be a collection of the partial mar properties
+            # useful for balrog.
+            json_data['partialInfo'] = getPartialInfo(json_data)
 
     with open('mach_build_properties.json', 'w') as outfile:
         json.dump(json_data, outfile, indent=4)