import-orig-rpm: implement automatic downloading
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 13 Feb 2014 10:41:39 +0000 (12:41 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Mar 2015 08:07:47 +0000 (10:07 +0200)
Automatically try to download the archive if the archive filename points
to a remote location.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/import_orig_rpm.py

index 0c7703998bbc500bf2fa0abf1ed7642cfa96f230..7df7cc020355d2e7df93190805d9e1fbe775f8b2 100755 (executable)
@@ -22,6 +22,7 @@ import ConfigParser
 import os
 import sys
 import gbp.command_wrappers as gbpc
+import re
 import string
 from gbp.pkg import parse_archive_filename
 from gbp.rpm import (RpmUpstreamSource, SpecFile, NoSpecError, guess_spec,
@@ -34,6 +35,7 @@ import gbp.log
 from gbp.scripts.common.import_orig import (ask_package_name,
                                             ask_package_version,
                                             prepare_sources)
+from gbp.scripts.import_srpm import download_file
 from gbp.tmpfile import init_tmpdir, del_tmpdir, tempfile
 
 
@@ -99,7 +101,10 @@ def find_source(options, args):
     elif len(args) == 0:
         raise GbpError, "No archive to import specified. Try --help."
     else:
-        return RpmUpstreamSource(args[0])
+        path = args[0]
+    if re.match(r'[a-z]{1,5}://', path):
+        path = download_file('..', path)
+    return RpmUpstreamSource(path)
 
 
 def pristine_tarball_name(source, pkg_name, pkg_version, pristine_name):