From 7fc837af0f9ca97d8f20307ff3a1046eab63006a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Sun, 24 Jul 2011 14:27:33 +0200 Subject: [PATCH] git-import-orig: Better support uscan of non tar.gz tarballs Closes: #629538 --- gbp/deb.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/gbp/deb.py b/gbp/deb.py index 3dc708f..846bbbd 100644 --- a/gbp/deb.py +++ b/gbp/deb.py @@ -351,34 +351,44 @@ def parse_uscan(out): >>> parse_uscan("virt-viewer_0.4.0.orig.tar.gz") (True, '../virt-viewer_0.4.0.orig.tar.gz') """ + source = None if "up to date" in out: - # nothing to do. return (False, None) else: + # Check if uscan downloaded something for row in out.split("\n"): # uscan >= 2.10.70 has a target element: - m = re.match("(.*)", row) + m = re.match(r"(.*)", row) if m: - tarball = '../%s' % m.group(1) + source = '../%s' % m.group(1) break elif row.startswith(''): - tarball = "../%s" % re.match(".*symlinked ([^\s]*) to it.*", row).group(1) - break + m = re.match(r".*symlinked ([^\s]+) to it", row) + if m: + source = "../%s" % m.group(1) + break + m = re.match(r"Successfully downloaded updated package ([^<]+)", row) + if m: + source = "../%s" % m.group(1) + break + # try to determine the already downloaded sources name else: d = {} - for row in out: + for row in out.split("\n"): for n in ('package', 'upstream-version', 'upstream-url'): m = re.match("<%s>(.*)" % (n,n), row) if m: d[n] = m.group(1) - else: - continue d["ext"] = os.path.splitext(d['upstream-url'])[1] - tarball = "../%(package)s_%(upstream-version)s.orig.tar%(ext)s" % d - - if not os.path.exists(tarball): - return (True, None) - return (True, tarball) + # We want the name of the orig tarball if possible + source = "../%(package)s_%(upstream-version)s.orig.tar%(ext)s" % d + if not os.path.exists(source): + # Fall back to the sources name otherwise + source = "../%s" % d['upstream-url'].rsplit('/',1)[1] + print source + if not os.path.exists(source): + source = None + return (True, source) def do_uscan(): -- 2.7.4