X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/blobdiff_plain/8ad9f90741a2f254ee1dedd51befc464319c6b25..675ed12f6047c8d40475e83a3925bbf84ea107c0:/invirt-submit-build diff --git a/invirt-submit-build b/invirt-submit-build index 42446b0..4bed2ee 100755 --- a/invirt-submit-build +++ b/invirt-submit-build @@ -18,6 +18,7 @@ keeping. import datetime +import optparse import os import sys import tempfile @@ -27,7 +28,12 @@ import invirt.builder as b def main(): - pocket, package, commit = sys.argv[1:4] + parser = optparse.OptionParser('Usage: %prog pocket package commit') + opts, args = parser.parse_args() + if len(args) != 3: + parser.print_help() + return 1 + pocket, package, commit = args principal = os.environ['REMOTE_USER'] request_time = datetime.datetime.utcnow() q_path = os.path.join(b._QUEUE_DIR, @@ -35,9 +41,16 @@ def main(): uuid.uuid4())) try: + # TODO: clean up this interface. + b.ensureValidPackage(package) + commit = b.canonicalize_commit(package, commit) b.validateBuild(pocket, package, commit) except b.InvalidBuild, e: - print >>sys.stderr, "E: %s" % e + msg = "E: %s" % e + print >>sys.stderr, msg + # Prevent an attack by submitting excessively long arguments + args = [arg[:min(len(arg), 80)] for arg in (pocket, package, commit)] + b.runHook('failed-submit', args + [principal], stdin_str=msg) sys.exit(1) # To keep from triggering the Invirtibuilder before we've actually @@ -46,7 +59,11 @@ def main(): q_fd, q_name = tempfile.mkstemp() q = os.fdopen(q_fd, 'r+') print >>q, "%s %s %s %s" % (pocket, package, commit, principal) + q.close() os.rename(q_name, q_path) + short_commit = b.canonicalize_commit(package, commit, shorten=True) + b.runHook('post-submit', [pocket, package, short_commit, principal]) + print '%s, your job to build %s for %s:%s has been submitted!' % (principal, short_commit, package, pocket) if __name__ == '__main__':