diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-07-16 22:20:23 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-07-16 22:20:23 +0000 |
commit | e7934042a43772f63b4c8c53414e82f9eba89e3d (patch) | |
tree | 98933d8b06808e4f8be195e0c6e76bce4b5ecf96 | |
parent | 01dace4609a3700ebc0fed8327ed47a2419d4d1d (diff) | |
download | portage-e7934042a43772f63b4c8c53414e82f9eba89e3d.tar.gz portage-e7934042a43772f63b4c8c53414e82f9eba89e3d.tar.bz2 portage-e7934042a43772f63b4c8c53414e82f9eba89e3d.zip |
Add ipv6 --sync support for bug #37124. Thanks to Bernhard Schmidt <berni@birkenwald.de> for the initial patch.
svn path=/main/trunk/; revision=3908
-rwxr-xr-x | bin/emerge | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/emerge b/bin/emerge index 9e1ac141e..953d9bb58 100755 --- a/bin/emerge +++ b/bin/emerge @@ -2628,14 +2628,28 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): if port is None: port="" updatecache_flg=True - + all_rsync_opts = set(rsync_opts) + all_rsync_opts.update( + settings.get("PORTAGE_RSYNC_EXTRA_OPTS","").split()) + family = socket.AF_UNSPEC + if "-4" in all_rsync_opts or "--ipv4" in all_rsync_opts: + family = socket.AF_INET + elif socket.has_ipv6 and \ + ("-6" in all_rsync_opts or "--ipv6" in all_rsync_opts): + family = socket.AF_INET6 ips=[] while (1): if ips: del ips[0] if ips==[]: try: - ips=socket.gethostbyname_ex(hostname)[2] + for addrinfo in socket.getaddrinfo( + hostname, None, family, socket.SOCK_STREAM): + if addrinfo[0] == socket.AF_INET6: + # IPv6 addresses need to be enclosed in square brackets + ips.append("[%s]" % addrinfo[4][0]) + else: + ips.append(addrinfo[4][0]) except SystemExit, e: raise # Needed else can't exit except Exception, e: |