aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-07-25 16:04:02 +0000
committerlloyd <[email protected]>2012-07-25 16:04:02 +0000
commit84c31975154e805c6a2ac75a79b550e5cac9ddb3 (patch)
tree71d84cd8a0fd992d506d06d2c231bf9f73d40f14 /src
parentcfc78ac532e94d64a02b39b93d69fc1b2cf558ec (diff)
Have the release script pull the datestamp from monotone, so it does
not need to be manually set before a release.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/build-data/scripts/dist.py51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/build-data/scripts/dist.py b/src/build-data/scripts/dist.py
index 8a81f17fe..b32edd73f 100755
--- a/src/build-data/scripts/dist.py
+++ b/src/build-data/scripts/dist.py
@@ -8,14 +8,16 @@ Release script for botan (http://botan.randombit.net/)
Distributed under the terms of the Botan license
"""
-import optparse
-import subprocess
+import errno
import logging
+import optparse
import os
-import sys
+import shlex
+import StringIO
import shutil
+import subprocess
+import sys
import tarfile
-import errno
def check_subprocess_results(subproc, name):
(stdout, stderr) = subproc.communicate()
@@ -42,6 +44,45 @@ def run_monotone(db, args):
return check_subprocess_results(mtn, 'mtn')
+def get_certs(db, rev_id):
+ tokens = shlex.split(run_monotone(db, ['automate', 'certs', rev_id]))
+
+ def usable_cert(cert):
+ if 'signature' not in cert or cert['signature'] != 'ok':
+ return False
+ if 'trust' not in cert or cert['trust'] != 'trusted':
+ return False
+ if 'name' not in cert or 'value' not in cert:
+ return False
+ return True
+
+ def cert_builder(tokens):
+ pairs = zip(tokens[::2], tokens[1::2])
+ current_cert = {}
+ for pair in pairs:
+ if pair[0] == 'key':
+ if usable_cert(current_cert):
+ name = current_cert['name']
+ value = current_cert['value']
+ current_cert = {}
+
+ logging.debug('Cert %s "%s" for rev %s' % (name, value, rev_id))
+ yield (name, value)
+
+ current_cert[pair[0]] = pair[1]
+
+ certs = dict(cert_builder(tokens))
+ return certs
+
+def datestamp(db, rev_id):
+ certs = get_certs(db, rev_id)
+
+ if 'date' in certs:
+ return int(certs['date'].replace('-','')[0:8])
+
+ logging.info('Could not retreive date for %s' % (rev_id))
+ return 0
+
def gpg_sign(file, keyid):
logging.info('Signing %s using PGP id %s' % (file, keyid))
@@ -141,6 +182,8 @@ def main(args = None):
for line in contents:
if line == 'release_vc_rev = None\n':
yield 'release_vc_rev = \'mtn:%s\'\n' % (rev_id)
+ elif line == 'release_datestamp = 0\n':
+ yield 'release_vc_rev = %d\n' % (datestamp(rev_iv))
else:
yield line