1#!/usr/bin/env python3 2# This Source Code Form is subject to the terms of the Mozilla Public 3# License, v. 2.0. If a copy of the MPL was not distributed with this file, 4# You can obtain one at http://mozilla.org/MPL/2.0/. 5 6from __future__ import absolute_import, print_function 7 8import logging 9import os 10from os import path 11import sys 12from tempfile import mkstemp 13 14sys.path.append(path.join(path.dirname(__file__), "../python")) 15logging.basicConfig(stream=sys.stdout, level=logging.INFO, format="%(message)s") 16log = logging.getLogger(__name__) 17 18from mozrelease.update_verify import UpdateVerifyConfig 19from util.commands import run_cmd 20 21UPDATE_VERIFY_COMMAND = ["bash", "verify.sh", "-c"] 22UPDATE_VERIFY_DIR = path.join(path.dirname(__file__), "../release/updates") 23 24 25if __name__ == "__main__": 26 from argparse import ArgumentParser 27 28 parser = ArgumentParser("") 29 30 parser.set_defaults( 31 chunks=None, 32 thisChunk=None, 33 ) 34 parser.add_argument("--verify-config", required=True, dest="verifyConfig") 35 parser.add_argument("--verify-channel", required=True, dest="verify_channel") 36 parser.add_argument("--chunks", required=True, dest="chunks", type=int) 37 parser.add_argument("--this-chunk", required=True, dest="thisChunk", type=int) 38 parser.add_argument("--diff-summary", required=True, type=str) 39 40 options = parser.parse_args() 41 assert options.chunks and options.thisChunk, "chunks and this-chunk are required" 42 assert path.isfile(options.verifyConfig), "Update verify config must exist!" 43 verifyConfigFile = options.verifyConfig 44 45 fd, configFile = mkstemp() 46 # Needs to be opened in "bytes" mode because we perform relative seeks on it 47 fh = os.fdopen(fd, "wb") 48 try: 49 verifyConfig = UpdateVerifyConfig() 50 verifyConfig.read(path.join(UPDATE_VERIFY_DIR, verifyConfigFile)) 51 myVerifyConfig = verifyConfig.getChunk(options.chunks, options.thisChunk) 52 # override the channel if explicitly set 53 if options.verify_channel: 54 myVerifyConfig.channel = options.verify_channel 55 myVerifyConfig.write(fh) 56 fh.close() 57 run_cmd(["cat", configFile]) 58 run_cmd( 59 UPDATE_VERIFY_COMMAND + [configFile], 60 cwd=UPDATE_VERIFY_DIR, 61 env={"DIFF_SUMMARY_LOG": path.abspath(options.diff_summary)}, 62 ) 63 finally: 64 if path.exists(configFile): 65 os.unlink(configFile) 66