def get_repository(self, connection, repository_data, arch, consumer):
        url = utils.normalize_repository_url(repository_data['uri'])
        suite = repository_data['suite']
        components = repository_data.get('section')
        path = repository_data.get('path')
        name = repository_data.get('name')

        # TODO(bgaifullin) implement support for flat repisotory format [1]
        # [1] https://wiki.debian.org/RepositoryFormat#Flat_Repository_Format
        if components is None:
            raise ValueError("The flat format does not supported.")

        for component in components:
            release = self._get_url_of_metafile((url, suite, component, arch),
                                                "Release")
            try:
                deb_release = deb822.Release(connection.open_stream(release))
            except connection.HTTPError as e:
                if e.code != 404:
                    raise
                # some repositories does not contain release file
                deb_release = {"origin": ""}

            consumer(
                Repository(name=name,
                           architecture=arch,
                           origin=deb_release["origin"],
                           url=url,
                           section=(suite, component),
                           path=path,
                           priority=self.get_priority(repository_data)))
    def create_repository(self, connection, repository_data, arch):
        url = utils.normalize_repository_url(repository_data['uri'])
        suite = repository_data['suite']
        component = repository_data.get('section')
        path = repository_data.get('path')
        name = repository_data.get('name')
        origin = repository_data.get('origin')

        if component is None:
            raise ValueError("The flat format does not supported.")
        if isinstance(component, list):
            if len(component) != 1:
                raise ValueError("The only single component is acceptable.")
            component = component[0]

        repository = Repository(name=name,
                                url=url,
                                architecture=arch,
                                origin=origin,
                                section=(suite, component),
                                path=path,
                                priority=self.get_priority(repository_data))
        self._create_repository_structure(repository)
        self.logger.info("Created: %s repository.", repository.name)
        return repository
Пример #3
0
 def get_repository(self, connection, repository_data, arch, consumer):
     consumer(
         Repository(name=repository_data['name'],
                    url=utils.normalize_repository_url(
                        repository_data["uri"]),
                    architecture=arch,
                    path=repository_data.get('path'),
                    origin=""))
Пример #4
0
 def create_repository(self, connection, repository_data, arch):
     repository = Repository(name=repository_data['name'],
                             url=utils.normalize_repository_url(
                                 repository_data["uri"]),
                             architecture=arch,
                             path=repository_data.get('path'),
                             origin=repository_data.get('origin'))
     utils.ensure_dir_exist(utils.get_path_from_url(repository.url))
     self._rebuild_repository(connection, repository, None, None)
     return repository