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))
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))
def make_tarball(self): full_name = '{0}-{1}'.format(self.meta['name'], self.meta['version']) tar_name = '{0}.tar'.format(full_name) tar_path = os.path.join(self.plugin_path, tar_name) if utils.exists(tar_path): utils.exec_cmd('rm -f {0}'.format(tar_path)) tar = tarfile.open(tar_path, 'w') tar.add(self.build_dir, arcname=full_name) tar.close()
def build_ubuntu_repos(self, releases_paths): for repo_path in releases_paths: utils.exec_cmd( 'dpkg-scanpackages . | gzip -c9 > Packages.gz', cwd=repo_path) release_path = join_path(repo_path, 'Release') utils.render_to_file( self.release_tmpl_src, release_path, {'authors': self.meta.get('authors', []), 'plugin_name': self.meta['name'], 'major_version': self.plugin_version})
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)
def make_tarball(self): full_name = '{0}-{1}'.format(self.meta['name'], self.meta['version']) tar_name = '{0}.tar'.format(full_name) tar_path = os.path.join( self.plugin_path, tar_name) if utils.exists(tar_path): utils.exec_cmd('rm -f {0}'.format(tar_path)) tar = tarfile.open(tar_path, 'w') tar.add(self.build_dir, arcname=full_name) tar.close()
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)
def run_pre_build_hook(self): if utils.which(self.pre_build_hook_path): utils.exec_cmd(self.pre_build_hook_path)
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')))
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)
def test_exec_cmd(self): process_mock = self.make_process_mock(return_code=0) with patch.object(subprocess, 'Popen', return_value=process_mock): utils.exec_cmd('some command') process_mock.wait.assert_called_once_with()
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')))