Example #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')))
Example #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')))
Example #3
0
 def build_centos_repos(cls, releases_paths):
     for repo_path in releases_paths:
         repo_packages = join_path(repo_path, 'Packages')
         utils.create_dir(repo_packages)
         utils.move_files_in_dir(join_path(repo_path, '*.rpm'),
                                 repo_packages)
         utils.exec_cmd('createrepo -o {0} {0}'.format(repo_path))
Example #4
0
 def build_centos_repos(cls, releases_paths):
     for repo_path in releases_paths:
         repo_packages = join_path(repo_path, 'Packages')
         utils.create_dir(repo_packages)
         utils.move_files_in_dir(
             join_path(repo_path, '*.rpm'),
             repo_packages)
         utils.exec_cmd('createrepo -o {0} {0}'.format(repo_path))
Example #5
0
    def make_package(self):
        """Builds rpm package
        """
        utils.create_dir(self.rpm_src_path)

        utils.make_tar_gz(self.build_src_dir, self.tar_path, self.full_name)
        utils.render_to_file(self.spec_src, self.spec_dst,
                             self._make_data_for_template())

        utils.exec_cmd('rpmbuild -vv --nodeps --define "_topdir {0}" '
                       '-bb {1}'.format(self.rpm_path, self.spec_dst))
        utils.copy_files_in_dir(self.rpm_packages_mask, self.plugin_path)
Example #6
0
    def build_repos(self):
        utils.create_dir(self.build_src_dir)

        utils.copy_files_in_dir(join_path(self.plugin_path, '*'),
                                self.build_src_dir)

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

        self.build_ubuntu_repos(releases_paths.get('ubuntu', []))
        self.build_centos_repos(releases_paths.get('centos', []))
Example #7
0
    def build_repos(self):
        utils.create_dir(self.build_src_dir)

        utils.copy_files_in_dir(
            join_path(self.plugin_path, '*'),
            self.build_src_dir)

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

        self.build_ubuntu_repos(releases_paths.get('ubuntu', []))
        self.build_centos_repos(releases_paths.get('centos', []))
Example #8
0
    def make_package(self):
        """Builds rpm package
        """
        utils.create_dir(self.rpm_src_path)

        utils.make_tar_gz(self.build_src_dir, self.tar_path, self.full_name)
        utils.render_to_file(
            self.spec_src,
            self.spec_dst,
            self._make_data_for_template())

        utils.exec_cmd(
            'rpmbuild -vv --nodeps --define "_topdir {0}" '
            '-bb {1}'.format(self.rpm_path, self.spec_dst))
        utils.copy_files_in_dir(self.rpm_packages_mask, self.plugin_path)
Example #9
0
    def run(self):
        utils.create_dir(self.plugin_path)

        for conf in self.plugin_structure:
            if conf['action'] == 'render':
                utils.render_to_file(
                    os.path.join(self.template_dir, conf['from']),
                    os.path.join(self.plugin_path, conf['path']),
                    self.render_ctx)
                utils.copy_file_permissions(
                    os.path.join(self.template_dir, conf['from']),
                    os.path.join(self.plugin_path, conf['path']))
            elif conf['action'] == 'mkdir':
                utils.create_dir(os.path.join(self.plugin_path, conf['path']))
            elif conf['action'] == 'copy':
                utils.copy_file(os.path.join(self.template_dir, conf['from']),
                                os.path.join(self.plugin_path, conf['path']))
Example #10
0
    def run(self):
        utils.create_dir(self.plugin_path)

        for conf in self.plugin_structure:
            if conf['action'] == 'render':
                utils.render_to_file(
                    os.path.join(self.template_dir, conf['from']),
                    os.path.join(self.plugin_path, conf['path']),
                    self.render_ctx)
                utils.copy_file_permissions(
                    os.path.join(self.template_dir, conf['from']),
                    os.path.join(self.plugin_path, conf['path']))
            elif conf['action'] == 'mkdir':
                utils.create_dir(os.path.join(
                    self.plugin_path,
                    conf['path']))
            elif conf['action'] == 'copy':
                utils.copy_file(
                    os.path.join(self.template_dir, conf['from']),
                    os.path.join(self.plugin_path, conf['path']))
Example #11
0
 def test_create_dir_dont_create_if_created(self, os_mock):
     path = '/dir/path'
     os_mock.path.isdir.return_value = True
     utils.create_dir(path)
     os_mock.path.isdir.assert_called_once_with(path)
     self.method_was_not_called(os_mock.makedirs)
Example #12
0
 def clean(self):
     utils.remove(self.build_dir)
     utils.create_dir(self.build_dir)
     utils.remove_by_mask(self.result_package_mask)
Example #13
0
 def clean(self):
     utils.remove(self.build_dir)
     utils.create_dir(self.build_dir)
Example #14
0
 def test_create_dir(self, os_mock):
     path = '/dir/path'
     os_mock.path.isdir.return_value = False
     utils.create_dir(path)
     os_mock.path.isdir.assert_called_once_with(path)
     os_mock.makedirs.assert_called_once_with(path)
Example #15
0
 def clean(self):
     utils.remove(self.build_dir)
     utils.create_dir(self.build_dir)
     utils.remove_by_mask(self.result_package_mask)
Example #16
0
 def test_create_dir_dont_create_if_created(self, os_mock):
     path = '/dir/path'
     os_mock.path.isdir.return_value = True
     utils.create_dir(path)
     os_mock.path.isdir.assert_called_once_with(path)
     self.method_was_not_called(os_mock.makedirs)
Example #17
0
 def test_create_dir(self, os_mock):
     path = '/dir/path'
     os_mock.path.isdir.return_value = False
     utils.create_dir(path)
     os_mock.path.isdir.assert_called_once_with(path)
     os_mock.makedirs.assert_called_once_with(path)