commit:     95ba3ca5e8db2a6b360e4abdcee026076652551d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 13 05:00:33 2019 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Jul 13 05:09:20 2019 +0000
URL:        https://gitweb.gentoo.org/proj/mirrorselect.git/commit/?id=95ba3ca5

netselect: make netselect ipv6 support optional

Since netselect with ipv6 support does not work on a system where
ipv6 is disabled, use a NETSELECT_SUPPORTS_IPV4_IPV6 variable to
optionally enable the use of netselect -4/-6 options. The ebuild
will use sed to set NETSELECT_SUPPORTS_IPV4_IPV6 = True when
USE=ipv6 is enabled, and will have a dependency like
RDEPEND=">=net-analyzer/netselect-0.4[ipv6(+)?]".

Bug: https://bugs.gentoo.org/688214
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 mirrorselect/selectors.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py
index e3f718c..4564f11 100644
--- a/mirrorselect/selectors.py
+++ b/mirrorselect/selectors.py
@@ -61,6 +61,11 @@ else:
 from mirrorselect.output import encoder, get_encoding, decode_selection
 
 
+# The netselect --ipv4 and --ipv6 options are supported only
+# with >=net-analyzer/netselect-0.4[ipv6(+)].
+NETSELECT_SUPPORTS_IPV4_IPV6 = False
+
+
 class Shallow(object):
        """handles rapid server selection via netselect"""
 
@@ -96,10 +101,12 @@ class Shallow(object):
                host_string = ' '.join(hosts)
 
                cmd = ['netselect', '-s%d' % (number,)]
-               if self._options.ipv4:
-                       cmd.append('-4')
-               elif self._options.ipv6:
-                       cmd.append('-6')
+
+               if NETSELECT_SUPPORTS_IPV4_IPV6:
+                       if self._options.ipv4:
+                               cmd.append('-4')
+                       elif self._options.ipv6:
+                               cmd.append('-6')
 
                cmd.extend(hosts)
 

Reply via email to