diff options
author | David Paleino <dapal@debian.org> | 2010-04-11 12:16:42 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2010-04-12 19:52:34 +0200 |
commit | 49e31b1c5a5c3256cfd54b0e3e19fc2cea81c0d6 (patch) | |
tree | 937c65a1571d7491c599f17f77ddf5e4b2817cae | |
parent | 4cb8d7fa0d1d1e572caf37855dd12382392295a9 (diff) |
Add --uscan command-line option
Launch uscan and use the tarball, if there's a new upstream version.
Closes: #577394
-rw-r--r-- | gbp/deb.py | 27 | ||||
-rwxr-xr-x | git-import-orig | 23 |
2 files changed, 49 insertions, 1 deletions
@@ -206,6 +206,33 @@ def symlink_orig(cp, compression, orig_dir, output_dir, force=False): return False return True +def do_uscan(): + p = subprocess.Popen(['uscan', '--dehs'], stdout=subprocess.PIPE) + out = p.communicate()[0].split('\n') + if "<status>up to date</status>" in out: + # nothing to do. + return (False, None) + else: + for row in out: + if row.startswith('<messages>'): + tarball = "../%s" % re.match(".*symlinked ([^\s]*) to it.*", row).group(1) + break + else: + d = {} + for row in out: + for n in ('package', 'upstream-version', 'upstream-url'): + m = re.match("<%s>(.*)</%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) + def unpack_orig(archive, tmpdir, filters): """ unpack a .orig.tar.gz to tmpdir, leave the cleanup to the caller in case of diff --git a/git-import-orig b/git-import-orig index 6ee6228b..a3a58fc5 100755 --- a/git-import-orig +++ b/git-import-orig @@ -30,7 +30,7 @@ import tempfile import gbp.command_wrappers as gbpc from gbp.deb import (parse_changelog, unpack_orig, repack_orig, NoChangelogError, has_epoch, tar_toplevel, - guess_upstream_version) + guess_upstream_version, do_uscan) from gbp.git import (FastImport, GitRepositoryError, GitRepository, build_tag) from gbp.config import GbpOptionParser, GbpOptionGroup from gbp.errors import (GbpError, GbpNothingImported) @@ -202,6 +202,8 @@ def main(argv): # Accepted for compatibility parser.add_option("--no-dch", dest='no_dch', action="store_true", default=False, help="deprecated - don't use.") + parser.add_option("--uscan", dest='uscan', action="store_true", + default=False, help="use uscan(1) to download the new tarball.") (options, args) = parser.parse_args(argv[1:]) @@ -214,6 +216,25 @@ def main(argv): if options.filters: turn_off_fastimport(options, "Import filters currently not supported with fastimport.") + if options.uscan: + # use uscan + print >>sys.stderr, "Launching uscan... ", + status, tarball = do_uscan() + + if not status: + print >>sys.stderr, "package is up to date, nothing to do." + sys.exit(0) + elif status and not tarball: + print >>sys.stderr, "uscan didn't download anything, and no tarball was found in ../" + sys.exit(1) + elif status and tarball: + print >>sys.stderr, "using %s" % tarball + + if args: + raise GbpError, "you can't pass both --uscan and a filename." + else: + args.append(tarball) + try: if len(args) != 1: parser.print_help() |