Ignore:
Timestamp:
Jul 6, 2010, 12:27:50 AM (14 years ago)
Author:
gdb
Message:

Added reporting

Location:
trunk/packages/invirt-dev
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-dev/debian/invirt-dev.dirs

    r2627 r3036  
    11var/lib/invirt-dev/queue
    22var/log/invirt/builds
    3 usr/share/invirt-dev/build.d
     3usr/share/invirt-dev/build-hooks
  • trunk/packages/invirt-dev/debian/invirt-dev.install

    r2555 r3036  
    11reprepro-env usr/bin
    22repository-config/* srv/repository/conf
     3build-hooks usr/share/invirt-dev
  • trunk/packages/invirt-dev/invirt-submit-build

    r3035 r3036  
    4747        b.validateBuild(pocket, package, commit)
    4848    except b.InvalidBuild, e:
    49         print >>sys.stderr, "E: %s" % e
     49        msg = "E: %s" % e
     50        print >>sys.stderr, msg
     51        # Prevent an attack by submitting excessively long arguments
     52        args = [arg[:min(len(arg), 80)] for arg in (pocket, package, commit)]
     53        b.runHook('failed-submit', args + [principal], stdin_str=msg)
    5054        sys.exit(1)
    5155
     
    5862    q.close()
    5963    os.rename(q_name, q_path)
     64    short_commit = b.canonicalize_commit(package, commit, shorten=True)
     65    b.runHook('post-submit', [pocket, package, short_commit, principal])
     66    print '%s, your job to build %s for %s:%s has been submitted!' % (principal, short_commit, package, pocket)
    6067
    6168
  • trunk/packages/invirt-dev/invirtibuilder

    r3035 r3036  
    250250        shutil.rmtree(workdir)
    251251
    252 
    253 def reportBuild(build):
    254     """Run hooks to report the results of a build attempt."""
    255 
    256     c.captureOutput(['run-parts',
    257                    '--arg=%s' % build.build_id,
    258                    '--',
    259                    b._HOOKS_DIR])
    260 
    261 
    262252def build():
    263253    """Deal with items in the build queue.
     
    296286
    297287            db.version = str(b.getVersion(package, commit))
     288            b.runHook('pre-build', [str(db.build_id), db.pocket, db.package,
     289                                    db.commit, db.principal, db.version, str(db.inserted_at)])
    298290
    299291            # If validateBuild returns something other than True, then
     
    367359            os.unlink(os.path.join(b._QUEUE_DIR, build))
    368360
    369             reportBuild(db)
    370 
     361            if db.succeeded:
     362                b.runHook('post-build', [str(db.build_id)])
     363            else:
     364                b.runHook('failed-build', [str(db.build_id)])
    371365
    372366class Invirtibuilder(pyinotify.ProcessEvent):
  • trunk/packages/invirt-dev/python/invirt/builder.py

    r3035 r3036  
    1818_REPO_DIR = '/srv/git'
    1919_LOG_DIR = '/var/log/invirt/builds'
    20 _HOOKS_DIR = '/usr/share/invirt-dev/build.d'
     20_HOOKS_DIR = '/usr/share/invirt-dev/build-hooks'
    2121
    2222
     
    7575    return changelog.Changelog(getGitFile(package, ref, 'debian/changelog'))
    7676
     77def runHook(hook, args=[], stdin_str=None):
     78    """Run a named hook."""
     79    hook = os.path.join(_HOOKS_DIR, hook)
     80    try:
     81        c.captureOutput([hook] + args, stdin_str=stdin_str)
     82    except OSError:
     83        pass
    7784
    7885def getVersion(package, ref):
Note: See TracChangeset for help on using the changeset viewer.