From: Guido Günther Date: Sun, 24 Jul 2011 12:27:33 +0000 (+0200) Subject: git-import-orig: Better support uscan of non tar.gz tarballs X-Git-Tag: debian/0.5.27~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fc837af0f9ca97d8f20307ff3a1046eab63006a;p=tools%2Fgit-buildpackage.git git-import-orig: Better support uscan of non tar.gz tarballs Closes: #629538 --- 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():