Example #1
0
 def __init__(self):
     self.rsrc = RepositorySource()
     self.lsrc = RepositorySource()
     self.arch = 'i386'
     self.handler = None
     self._sid_suite = False
     self.options = {}
Example #2
0
 def __init__(self):
     self.rsrc = RepositorySource()
     self.lsrc = RepositorySource()
     self.arch = 'i386'
     self.handler = None
     self._sid_suite = False
     self.options = {}
Example #3
0
 def make_source(self, name, type, remote=False):
     clause = Eq('name', name) & Eq('type', type)
     source = self.sources.select_row(clause=clause)
     repsrc = RepositorySource()
     repsrc.type = source.type
     if remote:
         repsrc.uri = source.remote
     else:
         repsrc.uri = source.uri
     repsrc.suite = source.suite
     repsrc.sections = self.get_sections(name)
     repsrc.set_path()
     return repsrc
def quick_init(rrepos):
    if len(rrepos.repos.tables()) == 4 and len(rrepos.sources.select()) == 0:
        local_uri = 'file:/mirrors/debian'
        remote_uri = 'http://ftp.us.debian.org/debian'
        
        source = RepositorySource('deb %s woody main contrib non-free' % local_uri)
        for suite in ['woody', 'sarge', 'sid']:
            source.suite = suite
            for type in ['deb', 'deb-src']:
                source.type = type
                rrepos.add_source(suite, source)
                source.uri = remote_uri
                rrepos.add_source(suite, source)
                source.uri = local_uri
                rrepos.set_source(suite, type)
                rrepos.update_release()
                rrepos.update_sections()
 def make_source(self, name, type, remote=False):
     clause = Eq('name', name) & Eq('type', type)
     source = self.sources.select_row(clause=clause)
     repsrc = RepositorySource()
     repsrc.type = source.type
     if remote:
         repsrc.uri = source.remote
     else:
         repsrc.uri = source.uri
     repsrc.suite = source.suite
     repsrc.sections = self.get_sections(name)
     repsrc.set_path()
     return repsrc
Example #6
0
def quick_init(rrepos):
    from base import RepositorySource
    if len(rr.repos.tables()) == 4 and len(rr.sources.select()) == 0:
        local_uri = 'file:/mirrors/debian'
        remote_uri = 'http://ftp.us.debian.org/debian'
        
        source = RepositorySource('deb %s woody main contrib non-free' % local_uri)
        for suite in ['woody', 'sarge', 'sid']:
            source.suite = suite
            for type in ['deb', 'deb-src']:
                source.type = type
                rrepos.add_source(suite, source)
                source.uri = remote_uri
                rrepos.add_source(suite, source)
                source.uri = local_uri
                rrepos.set_source(suite, type)
                rrepos.update_release()
                rrepos.update_sections()
Example #7
0
    _update_sources_(remote, local, src=src)


def update_suites(remote=None, local=None, src=True):
    for suite in ['woody', 'sarge', 'sid']:
        update_suite(suite, remote, local, src=src)


def security_updates():
    for suite in ['woody', 'sarge']:
        sections = 'main contrib non-free'
        rline = 'deb http://security.debian.org/ %s/updates %s' % (suite,
                                                                   sections)
        lline = 'deb file:/mirrors/debian/updates %s/updates %s' % (suite,
                                                                    sections)
        _update_sources_(rline, lline, src=True)


if __name__ == '__main__':
    mirror = 'http://jukebox/debian'
    path = '/mirrors/share/Debian/repos/'
    sources = parse_sources_list('/etc/apt/sources.list')
    #rs = RepositorySource(sources[2])
    #ls = RepositorySource(sources[0])
    ls = sources[0]
    rs = RepositorySource('deb %s sid main contrib non-free' % mirror)
    rr = RemoteRepos(rs, ls)
    #rs = RepositorySource('deb http://developer.linuxtag.org/ knoppix/')
    #ls = RepositorySource('deb file:/mirrors/debian/local/ goofy/')
    rr = RemoteRepos(rs, ls)
Example #8
0
class ReposMirror(object):
    def __init__(self):
        self.rsrc = RepositorySource()
        self.lsrc = RepositorySource()
        self.arch = 'i386'
        self.handler = None
        self._sid_suite = False
        self.options = {}

    def _set_src_paths(self):
        self.lsrc.set_path()
        self.rsrc.set_path()

    def set_local_root(self, root):
        self.lsrc.root = root
        self._set_src_paths()

    def set_remote_uri(self, uri):
        self.rsrc.uri = uri
        self._set_src_paths()

    def set_arch(self, arch):
        self.arch = arch

    def set_repos_type(self, rtype):
        if rtype in ['deb', 'deb-src']:
            self.lsrc.type = rtype
            self.rsrc.type = rtype
            self._set_src_paths()
        else:
            raise ValueError, '%s not a valid repos type' % rtype

    #sidsuite should be bool
    def set_suite(self, suite, sidsuite=None):
        self.lsrc = suite
        self.rsrc = suite
        self._set_src_paths()
        if sidsuite is not None:
            self._sid_suite = sidsuite

    def init_repos_handler(self):
        self.handler = RemoteRepos(self.rsrc, self.lsrc, self.arch)

    def run_update(self, quick=True):
        self.handler.update()
        if self._sid_suite:
            self.handler.release._zip_ = 'gz'
            self.handler.update_sections()
        self.handler.check(quick=True)
        self.handler.sync()

    def set_config_options(self, config):
        for k in [
                'official_main', 'official_security', 'official_nonus',
                'repos_root'
        ]:
            self.options[k] = config.get('debrepos', k)
        for kl in ['official_suites', 'default_archs', 'updated_suites']:
            self.options[kl] = config.get_list(kl, section='debrepos')
        for suite in self.options['official_suites']:
            opt = '%s_archs' % suite
            if config.has_option('debrepos', opt):
                self.options[opt] = config.get_list(opt, section='debrepos')

    def _mirror_suite(self, archs, quick):
        self.set_type('deb')
        for arch in archs:
            self.set_arch(arch)
            self.init_repos_handler()
            self.run_update(quick=quick)
        self.set_type('deb-src')
        self.init_repos_handler()
        self.run_update(quick=quick)

    def mirror_suite(self, suite, quick=False):
        self.set_remote_uri(self.options['official_main'])
        self.set_suite(suite)
        self.set_type('deb')
        sname = '%s_archs' % suite
        if self.options.has_key(sname):
            archs = self.options[sname]
        else:
            archs = self.options['default_archs']
        self._mirror_suite(archs, quick)
        if suite in self.options['updated_suites']:
            self.set_remote_uri(self.options['official_security'])
            self.set_suite('%s/updates' % suite)
            self._mirror_suite(archs, quick)
Example #9
0
class ReposMirror(object):
    def __init__(self):
        self.rsrc = RepositorySource()
        self.lsrc = RepositorySource()
        self.arch = 'i386'
        self.handler = None
        self._sid_suite = False
        self.options = {}
        
    def _set_src_paths(self):
        self.lsrc.set_path()
        self.rsrc.set_path()
        
    def set_local_root(self, root):
        self.lsrc.root = root
        self._set_src_paths()

    def set_remote_uri(self, uri):
        self.rsrc.uri = uri
        self._set_src_paths()

    def set_arch(self, arch):
        self.arch = arch

    def set_repos_type(self, rtype):
        if rtype in ['deb', 'deb-src']:
            self.lsrc.type = rtype
            self.rsrc.type = rtype
            self._set_src_paths()
        else:
            raise ValueError, '%s not a valid repos type' % rtype

    #sidsuite should be bool
    def set_suite(self, suite, sidsuite=None):
        self.lsrc = suite
        self.rsrc = suite
        self._set_src_paths()
        if sidsuite is not None:
            self._sid_suite = sidsuite
            
    def init_repos_handler(self):
        self.handler = RemoteRepos(self.rsrc, self.lsrc, self.arch)

    def run_update(self, quick=True):
        self.handler.update()
        if self._sid_suite:
            self.handler.release._zip_ = 'gz'
            self.handler.update_sections()
        self.handler.check(quick=True)
        self.handler.sync()

    def set_config_options(self, config):
        for k in ['official_main', 'official_security',
                  'official_nonus', 'repos_root']:
            self.options[k] = config.get('debrepos', k)
        for kl in ['official_suites', 'default_archs',
                   'updated_suites']:
            self.options[kl] = config.get_list(kl, section='debrepos')
        for suite in self.options['official_suites']:
            opt = '%s_archs' % suite
            if config.has_option('debrepos',opt):
                self.options[opt] = config.get_list(opt, section='debrepos')
                

    def _mirror_suite(self, archs, quick):
        self.set_type('deb')
        for arch in archs:
            self.set_arch(arch)
            self.init_repos_handler()
            self.run_update(quick=quick)
        self.set_type('deb-src')
        self.init_repos_handler()
        self.run_update(quick=quick)
        
    def mirror_suite(self, suite, quick=False):
        self.set_remote_uri(self.options['official_main'])
        self.set_suite(suite)
        self.set_type('deb')
        sname = '%s_archs' % suite
        if self.options.has_key(sname):
            archs = self.options[sname]
        else:
            archs = self.options['default_archs']
        self._mirror_suite(archs, quick)
        if suite in self.options['updated_suites']:
            self.set_remote_uri(self.options['official_security'])
            self.set_suite('%s/updates' % suite)
            self._mirror_suite(archs, quick)