'Handle mirroring of RHN repos.'

def rhn_sync(self, repo):

    cmd = self.reposync_cmd()
    has_rpm_list = False
    if ((repo.rpm_list != '') and (repo.rpm_list != [])):
        has_rpm_list = True
    dest_path = os.path.join((self.settings.webdir + '/repo_mirror'), repo.name)
    temp_path = os.path.join(dest_path, '.origin')
    if (not os.path.isdir(temp_path)):
        os.makedirs(temp_path)
    if (not repo.mirror_locally):
        utils.die(self.logger, 'rhn://    repos    do    not    work    with    --mirror-locally=1')
    if has_rpm_list:
        self.logger.warning('warning:    --rpm-list    is    not    supported    for    RHN    content')
    rest = repo.mirror[6:]
    cmd = ('%s    %s    --repo=%s    --download_path=%s' % (cmd, self.rflags, rest, (self.settings.webdir + '/repo_mirror')))
    if (repo.name != rest):
        args = {'name': repo.name, 'rest': rest}
        utils.die(self.logger, ('ERROR:    repository    %(name)s    needs    to    be    renamed    %(rest)s    as    the    name    of    the    cobbler    repository    must    match    the    name    of    the    RHN    channel' % args))
    if (repo.arch == 'i386'):
        repo.arch = 'i686'
    if (repo.arch != ''):
        cmd = ('%s    -a    %s' % (cmd, repo.arch))
    if repo.mirror_locally:
        utils.subprocess_call(self.logger, cmd)
    self.create_local_file(temp_path, repo, output=False)
    if repo.mirror_locally:
        os.path.walk(dest_path, self.createrepo_walker, repo)
    self.create_local_file(dest_path, repo)
