X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/blobdiff_plain/7bc450adac529e07b594f2b38d268c056563ac9e..831c3571b0d8e86049b0b9ec5e27c3c2e5f49b1a:/python/invirt/builder.py diff --git a/python/invirt/builder.py b/python/invirt/builder.py index 68d56c8..b4a7abf 100644 --- a/python/invirt/builder.py +++ b/python/invirt/builder.py @@ -6,9 +6,9 @@ and the remctl submission scripts that insert items into its queue. import os +import subprocess from debian_bundle import changelog -from debian_bundle import deb822 import invirt.common as c from invirt.config import structs as config @@ -17,7 +17,7 @@ from invirt.config import structs as config _QUEUE_DIR = '/var/lib/invirt-dev/queue' _REPO_DIR = '/srv/git' _LOG_DIR = '/var/log/invirt/builds' -_HOOKS_DIR = '/usr/share/invirt-dev/build.d' +_HOOKS_DIR = '/usr/share/invirt-dev/build-hooks' class InvalidBuild(ValueError): @@ -74,6 +74,13 @@ def getChangelog(package, ref): """ return changelog.Changelog(getGitFile(package, ref, 'debian/changelog')) +def runHook(hook, args=[], stdin_str=None): + """Run a named hook.""" + hook = os.path.join(_HOOKS_DIR, hook) + try: + c.captureOutput([hook] + args, stdin_str=stdin_str) + except OSError: + pass def getVersion(package, ref): """Get the version of a given package at a particular ref.""" @@ -117,8 +124,13 @@ def validateBuild(pocket, package, commit): continue b = pocketToGit(p) - current_commit = c.captureOutput(['git', 'rev-parse', b], - cwd=package_repo).strip() + try: + current_commit = c.captureOutput(['git', 'rev-parse', b], + cwd=package_repo).strip() + except subprocess.CalledProcessError: + # Guess we haven't created this pocket yet + continue + current_version = getVersion(package, b) if current_version == new_version: @@ -139,7 +151,8 @@ def validateBuild(pocket, package, commit): # Almost by definition, A is a fast-forward of B if B..A is # empty - if not c.captureOutput(['git', 'rev-list', '%s..%s' % (commit, branch)]): + if not c.captureOutput(['git', 'rev-list', '%s..%s' % (commit, branch)], + cwd=package_repo): raise InvalidBuild('New commit %s of %s is not a fast-forward of' 'commit currently in pocket %s' % (commit, package, pocket))