diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-01-01 18:37:42 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-01-01 18:39:23 +0100 |
commit | 351d45c5e49363c9b5d0f4eb4a3867a7f111a42a (patch) | |
tree | c5dca6c11d2183356a540754b8c7b5ea0cfbc039 | |
parent | c3b62fef33e83931d86e5622e6e4f5deecd67fd6 (diff) |
Deprecate --download in import_srpm too
-rw-r--r-- | docs/manpages/gbp-import-srpm.sgml | 24 | ||||
-rw-r--r-- | gbp/scripts/common/__init__.py | 16 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 17 | ||||
-rwxr-xr-x | gbp/scripts/import_srpm.py | 7 | ||||
-rw-r--r-- | tests/component/rpm/test_import_srpm.py | 8 |
5 files changed, 33 insertions, 39 deletions
diff --git a/docs/manpages/gbp-import-srpm.sgml b/docs/manpages/gbp-import-srpm.sgml index 1beedb9b..94a74d7e 100644 --- a/docs/manpages/gbp-import-srpm.sgml +++ b/docs/manpages/gbp-import-srpm.sgml @@ -25,7 +25,6 @@ <arg><option>--author-is-committer</option></arg> <arg><option>--packaging-branch=</option><replaceable>BRANCH-NAME</replaceable></arg> <arg><option>--packaging-tag=</option><replaceable>TAG-FORMAT</replaceable></arg> - <arg><option>--download</option></arg> <arg><option>--packaging-dir=</option><replaceable>DIRECTORY</replaceable></arg> <arg><option>--filter=</option><replaceable>PATTERN</replaceable></arg> <arg><option>--keyid=</option><replaceable>GPG-KEYID</replaceable></arg> @@ -37,17 +36,17 @@ <arg><option>--native</option></arg> <arg><option>--repo-user=</option><option>[GIT|DEBIAN]</option></arg> <arg><option>--repo-email=</option><option>[GIT|DEBIAN]</option></arg> - <arg choice="plain"><replaceable>SRPM</replaceable></arg> + <group choice="plain"> + <arg><replaceable>SRPM</replaceable></arg> + <arg><replaceable>DIRECTORY</replaceable></arg> + </group> <arg choice="opt"><replaceable>target</replaceable></arg> </cmdsynopsis> <cmdsynopsis> &gbp-import-srpm; <arg><option>options</option></arg> - <arg choice="req"><option>--download</option></arg> <group choice="plain"> <arg><replaceable>URL</replaceable></arg> - <arg><replaceable>SRC.RPM</replaceable></arg> - <arg><replaceable>DIRECTORY</replaceable></arg> </group> <arg choice="opt"><replaceable>target</replaceable></arg> </cmdsynopsis> @@ -61,7 +60,8 @@ automatically detected from the source package but you can override the location of the new repository by optionally specifying the <replaceable>target</replaceable> argument. The tool supports importing - both archived (src.rpm files) or unpacked (directory) source RPMs. + both archived (src.rpm files) or unpacked (directory) source RPMs. It also imports + from http(s)-URLs. </para> </refsect1> <refsect1> @@ -164,18 +164,6 @@ </listitem> </varlistentry> <varlistentry> - <term><option>--download</option> - </term> - <listitem> - <para> - Download the source package instead of looking for it in the local - file system. The argument can either be a plain package name or an - URI. The former uses <command>yumdownloader</command> to download the - source while the later uses &wget;. - </para> - </listitem> - </varlistentry> - <varlistentry> <term><option>--allow-same-version</option> </term> <listitem> diff --git a/gbp/scripts/common/__init__.py b/gbp/scripts/common/__init__.py index dcf91974..e36cc50b 100644 --- a/gbp/scripts/common/__init__.py +++ b/gbp/scripts/common/__init__.py @@ -16,9 +16,25 @@ # <http://www.gnu.org/licenses/> """Parts shared between the deb and rpm commands""" +import re + class ExitCodes(object): ok = 0, failed = 1 # All other errors no_value = 2 # Value does not exist (gbp config only) parse_error = 3 # Failed to parse configuration file + + +def is_download(args): + """ + >>> is_download(["http://foo.example.com"]) + True + >>> is_download([]) + False + >>> is_download(["foo-1.1.orig.tar.gz"]) + False + """ + if args and re.match("https?://", args[0]): + return True + return False diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 8f3cf27f..7013a651 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -18,7 +18,6 @@ """Import a new upstream version into a Git repository""" import os -import re import sys import tempfile import gbp.command_wrappers as gbpc @@ -32,7 +31,7 @@ from gbp.errors import GbpError from gbp.pkg import parse_archive_filename from gbp.format import format_str import gbp.log -from gbp.scripts.common import ExitCodes +from gbp.scripts.common import ExitCodes, is_download from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree, ask_package_name, ask_package_version, repack_source, is_link_target, download_orig) @@ -488,20 +487,6 @@ def parse_args(argv): return options, args -def is_download(args): - """ - >>> is_download(["http://foo.example.com"]) - True - >>> is_download([]) - False - >>> is_download(["foo-1.1.orig.tar.gz"]) - False - """ - if args and re.match("https?://", args[0]): - return True - return False - - def main(argv): ret = 0 tmpdir = '' diff --git a/gbp/scripts/import_srpm.py b/gbp/scripts/import_srpm.py index a472ff81..302c3422 100755 --- a/gbp/scripts/import_srpm.py +++ b/gbp/scripts/import_srpm.py @@ -36,7 +36,7 @@ from gbp.git.modifier import GitModifier from gbp.config import (GbpOptionParserRpm, GbpOptionGroup, no_upstream_branch_msg) from gbp.errors import GbpError -from gbp.scripts.common import ExitCodes +from gbp.scripts.common import ExitCodes, is_download from gbp.scripts.common import repo_setup import gbp.log from gbp.pkg import parse_archive_filename @@ -203,6 +203,11 @@ def parse_args(argv): (options, args) = parser.parse_args(argv[1:]) gbp.log.setup(options.color, options.verbose, options.color_scheme) + + if options.download: + gbp.log.warn("Passing --download explicitly is deprecated.") + + options.download = is_download(args) return options, args diff --git a/tests/component/rpm/test_import_srpm.py b/tests/component/rpm/test_import_srpm.py index 0c9ff67e..3e153f1d 100644 --- a/tests/component/rpm/test_import_srpm.py +++ b/tests/component/rpm/test_import_srpm.py @@ -284,7 +284,7 @@ class TestDownloadImport(ComponentTestBase): import_srpm.urlopen = Mock() import_srpm.urlopen.return_value = open(local_fn, 'r') - eq_(mock_import(['--no-pristine-tar', '--download', srpm]), 0) + eq_(mock_import(['--no-pristine-tar', srpm]), 0) # Check repository state repo = GitRepository('gbp-test') self._check_repo_state(repo, 'master', ['master', 'upstream']) @@ -297,15 +297,15 @@ class TestDownloadImport(ComponentTestBase): import_srpm.urlopen.side_effect = urllib.error.HTTPError(srpm, 404, "Not found", None, None) - eq_(mock_import(['--download', srpm]), 1) + eq_(mock_import([srpm]), 1) self._check_log(-1, "gbp:error: Download failed: HTTP Error 404") self._clear_log() def test_invalid_url(self): """Test graceful failure when trying download from invalid url""" srpm = 'foob://url.does.not.exist.com/foo.src.rpm' - eq_(mock_import(['--download', srpm]), 1) - self._check_log(-1, "gbp:error: Download failed: unknown url type:") + eq_(mock_import([srpm]), 1) + self._check_log(-1, ".*No such file or directory: 'foob://url.does.not.exist.com/foo.src.rpm") self._clear_log() |