aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-07-24 13:23:51 +0200
committerGuido Günther <agx@sigxcpu.org>2011-07-24 14:32:31 +0200
commit7b1f34c1f1d3315b2449d1a7e5fe9560301a0252 (patch)
tree489819fef625d782ab000126d01b9baa6a3159c9
parent0ecd9f70aef51e26c13a0fcc241a3dcb934aeaaf (diff)
Use target element of newer uscan
and move uscan parsing into a separate function. Git-Dch: Ignore
-rw-r--r--gbp/deb.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/gbp/deb.py b/gbp/deb.py
index 930e626..3dc708f 100644
--- a/gbp/deb.py
+++ b/gbp/deb.py
@@ -336,16 +336,32 @@ def symlink_orig(cp, compression, orig_dir, output_dir, force=False):
return True
-def do_uscan():
- """invoke uscan to fetch a new upstream version"""
- p = subprocess.Popen(['uscan', '--symlink', '--destdir=..', '--dehs'], stdout=subprocess.PIPE)
- out = p.communicate()[0].split('\n')
+def parse_uscan(out):
+ """
+ Parse the uscan output return (True, tarball) if a new version was
+ downloaded and could be located. If the tarball can't be located it returns
+ (True, None). Returns (False, None) if the current version is up to date.
+
+ @param out: uscan output
+ @param type: string
+ @return: status and tarball name
+ @rtype: tuple
+ >>> parse_uscan("<status>up to date</status>")
+ (False, None)
+ >>> parse_uscan("<target>virt-viewer_0.4.0.orig.tar.gz</target>")
+ (True, '../virt-viewer_0.4.0.orig.tar.gz')
+ """
if "<status>up to date</status>" in out:
# nothing to do.
return (False, None)
else:
- for row in out:
- if row.startswith('<messages>'):
+ for row in out.split("\n"):
+ # uscan >= 2.10.70 has a target element:
+ m = re.match("<target>(.*)</target>", row)
+ if m:
+ tarball = '../%s' % m.group(1)
+ break
+ elif row.startswith('<messages>'):
tarball = "../%s" % re.match(".*symlinked ([^\s]*) to it.*", row).group(1)
break
else:
@@ -365,6 +381,13 @@ def do_uscan():
return (True, tarball)
+def do_uscan():
+ """invoke uscan to fetch a new upstream version"""
+ p = subprocess.Popen(['uscan', '--symlink', '--destdir=..', '--dehs'], stdout=subprocess.PIPE)
+ out = p.communicate()[0]
+ return parse_uscan(out)
+
+
def unpack_orig(archive, tmpdir, filters):
"""
unpack a .orig.tar.gz to tmpdir, leave the cleanup to the caller in case of