oss-fuzz/infra/gcb/build_msan_libs.py

67 lines
1.5 KiB
Python
Raw Normal View History

2017-12-07 02:20:01 +00:00
#!/usr/bin/python2
"""Build base images on Google Cloud Builder.
Usage: build_base_images.py
"""
2018-01-19 03:12:44 +00:00
import datetime
2017-12-07 02:20:01 +00:00
import os
import yaml
import sys
2017-12-07 02:20:01 +00:00
from oauth2client.client import GoogleCredentials
from googleapiclient.discovery import build
import build_base_images
def main():
options = {}
2018-07-27 03:32:09 +00:00
if 'GCB_OPTIONS' in os.environ:
options = yaml.safe_load(os.environ['GCB_OPTIONS'])
2017-12-07 02:20:01 +00:00
2018-01-19 03:12:44 +00:00
image = 'gcr.io/oss-fuzz-base/msan-builder'
2018-02-27 04:35:41 +00:00
steps = build_base_images.get_steps(['base-msan-builder', 'msan-builder'])
2018-01-19 03:12:44 +00:00
ts = datetime.datetime.utcnow().strftime('%Y%m%d%H%M')
upload_name = 'msan-libs-' + ts + '.zip'
steps.extend([{
'name': image,
'args': [
'bash',
'-c',
'cd /msan && zip -r /workspace/libs.zip .',
],
}, {
2018-07-27 03:32:09 +00:00
'name':
'gcr.io/cloud-builders/gsutil',
2018-01-19 03:12:44 +00:00
'args': [
'cp',
'/workspace/libs.zip',
'gs://oss-fuzz-msan-libs/' + upload_name,
],
}])
2017-12-07 02:20:01 +00:00
build_body = {
2018-01-19 03:12:44 +00:00
'steps': steps,
2017-12-07 02:20:01 +00:00
'timeout': str(6 * 3600) + 's',
'options': options,
'images': [
2018-02-27 04:35:41 +00:00
'gcr.io/oss-fuzz-base/base-msan-builder',
2018-01-19 03:12:44 +00:00
image,
],
2017-12-07 02:20:01 +00:00
}
credentials = GoogleCredentials.get_application_default()
cloudbuild = build('cloudbuild', 'v1', credentials=credentials)
2018-07-27 03:32:09 +00:00
build_info = cloudbuild.projects().builds().create(
projectId='oss-fuzz-base', body=build_body).execute()
build_id = build_info['metadata']['build']['id']
2017-12-07 02:20:01 +00:00
print >> sys.stderr, 'Logs:', build_base_images.get_logs_url(build_id)
2017-12-07 02:20:01 +00:00
print build_id
2018-07-27 03:32:09 +00:00
if __name__ == '__main__':
2017-12-07 02:20:01 +00:00
main()