_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):
"""Return the path to the git repo for a given package."""
return os.path.join(_REPO_DIR, 'invirt/packages', '%s.git' % package)
-def ensureValidRepo(package):
+def ensureValidPackage(package):
"""Perform some basic sanity checks that the requested repo is in a
subdirectory of _REPO_DIR/invirt/packages. This prevents weirdness
such as submitting a package like '../prod/...git'. Also ensures that
elif not os.path.exists(repo):
raise InvalidBuild('Nonexisting package %s' % package)
+def canonicalize_commit(package, commit, shorten=False):
+ if shorten:
+ flags = ['--short']
+ else:
+ flags = []
+ return c.captureOutput(['git', 'rev-parse'] + flags + [commit],
+ cwd=getRepo(package)).strip()
+
def pocketToGit(pocket):
"""Map a pocket in the configuration to a git branch."""
return getattr(getattr(config.build.pockets, pocket), 'git', pocket)
"""
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."""
another pocket, then this function returns that pocket. Otherwise,
it returns True.
"""
- ensureValidRepo(package)
+ ensureValidPackage(package)
package_repo = getRepo(package)
new_version = getVersion(package, commit)