From 7b1f34c1f1d3315b2449d1a7e5fe9560301a0252 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 24 Jul 2011 13:23:51 +0200 Subject: Use target element of newer uscan and move uscan parsing into a separate function. Git-Dch: Ignore --- gbp/deb.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'gbp') diff --git a/gbp/deb.py b/gbp/deb.py index 930e6264..3dc708f1 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("up to date") + (False, None) + >>> parse_uscan("virt-viewer_0.4.0.orig.tar.gz") + (True, '../virt-viewer_0.4.0.orig.tar.gz') + """ if "up to date" in out: # nothing to do. return (False, None) else: - for row in out: - if row.startswith(''): + for row in out.split("\n"): + # uscan >= 2.10.70 has a target element: + m = re.match("(.*)", row) + if m: + tarball = '../%s' % m.group(1) + break + elif row.startswith(''): 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 -- cgit v1.2.3