Esempio n. 1
0
    def build_repos(self):
        # TODO(eli): it really needs to be refactored
        # it was written right before the demo on the fly
        if utils.which(self.pre_build_hook_path):
            utils.exec_cmd(self.pre_build_hook_path)

        utils.create_dir(self.build_dir)
        utils.exec_cmd('rm -rf {0}'.format(os.path.join(self.build_dir, '*')))
        utils.exec_cmd('cp -r {0} {1}'.format(
            os.path.join(self.plugin_path, '*'), self.build_dir))

        releases_paths = {}
        for release in self.meta['releases']:
            releases_paths.setdefault(release['os'], [])
            releases_paths[release['os']].append(
                os.path.join(self.build_dir, release['repository_path']))

        for repo_path in releases_paths.get('centos', []):
            repo_packages = os.path.join(repo_path, 'Packages')
            utils.create_dir(repo_packages)
            rpms = os.path.join(repo_path, '*.rpm')
            if glob.glob(rpms):
                utils.exec_cmd('cp {0} {1}'.format(
                    os.path.join(repo_path, '*.rpm'), repo_packages))
            utils.exec_cmd('createrepo -o {0} {1}'.format(
                repo_path, repo_packages))

        for repo_path in releases_paths.get('ubuntu', []):
            utils.exec_cmd('dpkg-scanpackages {0} | gzip -c9 > {1}'.format(
                repo_path, os.path.join(repo_path, 'Packages.gz')))
Esempio n. 2
0
    def build_repos(self):
        # TODO(eli): it really needs to be refactored
        # it was written right before the demo on the fly
        if utils.which(self.pre_build_hook_path):
            utils.exec_cmd(self.pre_build_hook_path)

        utils.create_dir(self.build_dir)
        utils.exec_cmd('rm -rf {0}'.format(os.path.join(self.build_dir, '*')))
        utils.exec_cmd(
            'cp -r {0} {1}'.format(
                os.path.join(self.plugin_path, '*'),
                self.build_dir))

        releases_paths = {}
        for release in self.meta['releases']:
            releases_paths.setdefault(release['os'], [])
            releases_paths[release['os']].append(
                os.path.join(self.build_dir, release['repository_path']))

        for repo_path in releases_paths.get('centos', []):
            repo_packages = os.path.join(repo_path, 'Packages')
            utils.create_dir(repo_packages)
            rpms = os.path.join(repo_path, '*.rpm')
            if glob.glob(rpms):
                utils.exec_cmd('cp {0} {1}'.format(
                    os.path.join(repo_path, '*.rpm'),
                    repo_packages))
            utils.exec_cmd('createrepo -o {0} {1}'.format(repo_path,
                                                          repo_packages))

        for repo_path in releases_paths.get('ubuntu', []):
            utils.exec_cmd(
                'dpkg-scanpackages {0} | gzip -c9 > {1}'.format(
                    repo_path,
                    os.path.join(repo_path, 'Packages.gz')))
Esempio n. 3
0
    def _check_requirements(self):
        not_found = filter(lambda r: not utils.which(r), self.requires)

        if not_found:
            raise errors.FuelCannotFindCommandError(
                'Cannot find commands "{0}", '
                'install required commands and try again'.format(
                    ', '.join(not_found)))
Esempio n. 4
0
    def check(self):
        not_found = filter(lambda r: not utils.which(r), self.requires)

        if not_found:
            raise errors.FuelCannotFindCommandError(
                'Cannot find commands "{0}", '
                'install required commands and try again'.format(
                    ','.join(not_found)))
Esempio n. 5
0
 def run_pre_build_hook(self):
     if utils.which(self.pre_build_hook_path):
         utils.exec_cmd(self.pre_build_hook_path)
Esempio n. 6
0
 def run_pre_build_hook(self):
     if utils.which(join_path(self.plugin_path, self.pre_build_hook_cmd)):
         utils.exec_cmd(self.pre_build_hook_cmd, self.plugin_path)
Esempio n. 7
0
 def test_which_returns_none(self, _):
     with patch.dict('os.environ', {'PATH': '/usr/bin:/bin'}):
         self.assertIsNone(utils.which('some_exec'))
Esempio n. 8
0
 def test_which_returns_if_exec_in_env_path(self, _):
     # some_exec is in /bin directory
     path = 'some_exec'
     with patch.dict('os.environ', {'PATH': '/usr/bin:/bin'}):
         self.assertEqual(utils.which(path), '/bin/some_exec')
Esempio n. 9
0
 def test_which_returns_for_absolute_path_exec(self, _, os_mock):
     path = '/usr/bin/some_exec'
     os_mock.path.split.return_value = ('/usr/bin/', 'some_exec')
     self.assertEqual(utils.which(path), path)
Esempio n. 10
0
 def run_pre_build_hook(self):
     if utils.which(join_path(self.plugin_path, self.pre_build_hook_cmd)):
         utils.exec_cmd(self.pre_build_hook_cmd, self.plugin_path)
Esempio n. 11
0
 def test_which_returns_none(self, _):
     with patch.dict('os.environ', {'PATH': '/usr/bin:/bin'}):
         self.assertIsNone(utils.which('some_exec'))
Esempio n. 12
0
 def test_which_returns_if_exec_in_env_path(self, _):
     # some_exec is in /bin directory
     path = 'some_exec'
     with patch.dict('os.environ', {'PATH': '/usr/bin:/bin'}):
         self.assertEqual(utils.which(path), '/bin/some_exec')
Esempio n. 13
0
 def test_which_returns_for_absolute_path_exec(self, _, os_mock):
     path = '/usr/bin/some_exec'
     os_mock.path.split.return_value = ('/usr/bin/', 'some_exec')
     self.assertEqual(utils.which(path), path)