Ticket #158: pkgcore-0.4.3-rsync-proxy.2.patch

File pkgcore-0.4.3-rsync-proxy.2.patch, 2.6 KB (added by Ford_Prefect, 2 years ago)

patch against pkgcore-0.4.3 to enable proxy support for rsync (with a tad more inline documentation)

  • pkgcore/ebuild/portage_conf.py

    diff -urNp pkgcore-0.4.3-orig/pkgcore/ebuild/portage_conf.py pkgcore-0.4.3/pkgcore/ebuild/portage_conf.py
    old new  
    125125    if timeout is not None: 
    126126        base['timeout'] = timeout.strip() 
    127127 
     128    proxy = options.pop('RSYNC_PROXY', None) 
     129    if proxy is not None: 
     130        base['proxy'] = proxy.strip() 
     131 
    128132    excludes = options.pop('RSYNC_EXCLUDEFROM', None) 
    129133    if excludes is not None: 
    130134        extra_opts.extend('--exclude-from=%s' % x 
  • pkgcore/sync/rsync.py

    diff -urNp pkgcore-0.4.3-orig/pkgcore/sync/rsync.py pkgcore-0.4.3/pkgcore/sync/rsync.py
    old new  
    2727 
    2828    default_retries = 5 
    2929    binary = "rsync" 
     30    use_proxy = False 
    3031 
    3132    @classmethod 
    3233    def parse_uri(cls, raw_uri): 
     
    4546 
    4647    pkgcore_config_type = ConfigHint({'basedir':'str', 'uri':'str', 
    4748        'timeout':'str', 'compress':'bool', 'excludes':'list', 
    48         'includes':'list', 'retries':'str', 'extra_opts':'list'}, 
     49        'includes':'list', 'retries':'str', 'extra_opts':'list', 
     50        'proxy':'str'}, 
    4951        typename='syncer') 
    5052 
    5153    def __init__(self, basedir, uri, timeout=default_timeout, 
    5254        compress=False, excludes=(), includes=(), 
    53         retries=default_retries, 
     55        retries=default_retries, proxy=None, 
    5456        extra_opts=[]): 
    5557 
    5658        uri = uri.rstrip(os.path.sep) + os.path.sep 
     
    6769        self.excludes = list(self.default_excludes) + list(excludes) 
    6870        self.includes = list(self.default_includes) + list(includes) 
    6971        self.retries = int(retries) 
     72        if proxy is not None: 
     73            self.use_proxy = True 
     74            self.sets_env = True 
     75            self.env = {'RSYNC_PROXY':proxy} 
    7076        self.is_ipv6 = "--ipv6" in self.opts or "-6" in self.opts 
    7177        self.is_ipv6 = self.is_ipv6 and socket.has_ipv6 
    7278 
     
    7581        return uri[len("rsync://"):].split("@", 1)[-1].split("/", 1)[0] 
    7682 
    7783    def _get_ips(self): 
     84        if self.use_proxy is True: 
     85            # If we're using a proxy, name resolution is best left to the proxy 
     86            yield self.hostname 
     87            return 
     88 
    7889        af_fam = socket.AF_INET 
    7990        if self.is_ipv6: 
    8091            af_fam = socket.AF_INET6