Ejemplo n.º 1
0
    def prepare_repositories(self):
        """ Prepare repositories for build time injection. """
        if 'packages' not in self.image:
            return

        if self.image.get('packages').get('content_sets'):
            LOGGER.warning(
                'The image has ContentSets repositories specified, all other repositories are removed!')
            self.image['packages']['repositories'] = []
        repos = self.image.get('packages').get('repositories', [])

        injected_repos = []

        for repo in repos:
            if self._handle_repository(repo):
                injected_repos.append(repo)

        if self.image.get('packages').get('content_sets'):
            url = self._prepare_content_sets(self.image.get('packages').get('content_sets'))
            if url:
                repo = Repository({'name': 'content_sets_odcs',
                                   'url': {'repository': url}})
                injected_repos.append(repo)
                self._fetch_repos = True

        if self._fetch_repos:
            for repo in injected_repos:
                repo.fetch(os.path.join(self.target, 'image', 'repos'))
            self.image['packages']['repositories_injected'] = injected_repos
        else:
            self.image['packages']['set_url'] = injected_repos
Ejemplo n.º 2
0
def test_packages(mocker):
    mocker.patch.object(Repository, '_get_repo_url', return_value='foo')
    pkg = Packages(yaml.safe_load("""
      repositories:
          - repo-foo
          - repo-bar
      install:
          - pkg-foo"""))

    assert Repository('repo-foo') in pkg['repositories']
    assert Repository('repo-bar') in pkg['repositories']
    assert 'pkg-foo' in pkg['install']