'Handle copying of http:// and ftp:// debian repos.'

def apt_sync(self, repo):

    mirror_program = '/usr/bin/debmirror'
    if (not os.path.exists(mirror_program)):
        utils.die(self.logger, ('no    %s    found,    please    install    it' % mirror_program))
    cmd = ''
    if ((repo.rpm_list != '') and (repo.rpm_list != [])):
        utils.die(self.logger, 'has_rpm_list    not    yet    supported    on    apt    repos')
    if (not repo.arch):
        utils.die(self.logger, 'Architecture    is    required    for    apt    repositories')
    dest_path = os.path.join('/var/www/cobbler/repo_mirror', repo.name)
    if repo.mirror_locally:
        mirror = repo.mirror
        idx = mirror.find('://')
        method = mirror[:idx]
        mirror = mirror[(idx + 3):]
        idx = mirror.find('/')
        host = mirror[:idx]
        mirror = mirror[idx:]
        dists = ','.join(repo.apt_dists)
        components = ','.join(repo.apt_components)
        mirror_data = ('--method=%s    --host=%s    --root=%s    --dist=%s    --section=%s' % (method, host, mirror, dists, components))
        rflags = '--nocleanup'
        for x in repo.yumopts:
            if repo.yumopts[x]:
                rflags += ('    %s    %s' % (x, repo.yumopts[x]))
            else:
                rflags += ('    %s' % x)
        cmd = ('%s    %s    %s    %s' % (mirror_program, rflags, mirror_data, dest_path))
        if (repo.arch == 'src'):
            cmd = ('%s    --source' % cmd)
        else:
            arch = repo.arch
            if (arch == 'x86'):
                arch = 'i386'
            if (arch == 'x86_64'):
                arch = 'amd64'
            cmd = ('%s    --nosource    -a    %s' % (cmd, arch))
        os.putenv('HOME', '/var/lib/cobbler')
        rc = utils.subprocess_call(self.logger, cmd)
        if (rc != 0):
            utils.die(self.logger, 'cobbler    reposync    failed')
