+
+def _last_commit(f):
+ return local("git rev-list --all --date-order --max-count=1 %s" % f,
+ capture=True).strip()
+
+
+def _diff_from_master(c,f):
+ return local("git log --oneline %s..%s %s" \
+ " | wc -l" % (c, env.upstream, f), capture=True)
+
+
+def dch(p):
+ with co(env.debian_branch):
+ local("git merge %s" % env.upstream)
+ with lcd(package_root(p)):
+ local("if [ ! -d .git ]; then mkdir .git; fi")
+
+ # FIXME:
+ # Checking for new changes in packages
+ # has been removed temporarily.
+ # Always create a new Debian changelog entry.
+ ## Check for new changes in package dir
+ #diff = _diff_from_master(_last_commit("debian/changelog"), ".")
+ #vercmd = "git describe --tags --abbrev=0"\
+ # " | sed -rn '\''s/^v(.*)/\\1/p'\''"
+ #version = local(vercmd, capture=True)
+ #if int(diff) > 0:
+ if True:
+ # Run git-dch in snapshot mode.
+ # TODO: Support a --release mode in fabfile
+ local(("git-dch --debian-branch=%s --auto %s" %
+ (env.debian_branch,
+ "--release" if env.debrelease else "--snapshot")))
+ local(("git commit debian/changelog"
+ " -m 'Updated %s changelog'" % p))
+ notice(("Make sure to tag Debian release in %s" %
+ env.debian_branch))
+
+ local("rmdir .git")
+
+
+def debrelease():
+ env.debrelease = True
+
+
+def signdebs():
+ env.signdebs = True
+
+
+def builddeb(p, master="packaging", branch="debian-0.9"):
+ with co(branch):
+ info("Building debian package for %s" % p)
+ with lcd(package_root(p)):
+ local("git merge %s" % master)
+ local("if [ ! -d .git ]; then mkdir .git; fi")