def test_recursive(self): self.setup_directory() self.assertTrue(os.path.isdir(self.dir1_path)) self.assertTrue(os.path.isdir(self.dir3_path)) ops.rm(self.dir1_path, recursive=True) self.assertFalse(os.path.exists(self.dir1_path)) self.assertFalse(os.path.exists(self.dir3_path))
def run(self): if os.path.exists(self.build_path): ops.rm(self.build_path, recursive=True) ops.mkdir(self.build_path) # Build repository directories for arch in ["SRPMS"] + self.options.arch: path = os.path.join(self.repo_path, "build", self.dist_name, self.dist_version, arch) ops.mkdir(path) if not os.path.exists(os.path.join(path, "repodata")): ops.run("createrepo --update ${dst}", dst=path, **self.ops_run) # Try to get source files if they don't exist locally self.sources() # Build SRPM result = self.srpm() if result: self.srpm_path = result.stdout.strip()[7:] else: ops.exit(code=result.code) srpm_dst_path = os.path.join(self.repo_path, "build", self.dist_name, self.dist_version, "SRPMS") # Build RPMs for arch in self.options.arch: result = self.rpm(arch) if not result: ops.exit(code=result.code, text=result.stderr) arch_dst_path = os.path.join(self.repo_path, "build", self.dist_name, self.dist_version, arch) ops.mkdir(arch_dst_path) # TODO(silas): don't build multiple times on noarch ops.run("mv ${src}/*.noarch.rpm ${dst}", src=self.build_path, dst=arch_dst_path, **self.ops_run) arch_list = [arch] if arch == "i386": arch_list.append("i686") for a in arch_list: ops.run("mv ${src}/*${arch}.rpm ${dst}", src=self.build_path, arch=a, dst=arch_dst_path, **self.ops_run) # Find and move distribution srpm srpms = glob.glob(os.path.join(self.build_path, "*.src.rpm")) srpms = [os.path.basename(path) for path in srpms] srpm_name = os.path.basename(self.srpm_path) if srpm_name in srpms: srpms.remove(srpm_name) srpm_path = os.path.join(self.build_path, srpms[0]) if srpms else self.srpm_path ops.run("mv ${src} ${dst}", src=srpm_path, dst=srpm_dst_path, **self.ops_run) # Update repository ops.run("createrepo --update ${dst}", dst=arch_dst_path, **self.ops_run)
def test_directory(self): self.setup_directory() self.assertTrue(os.path.isdir(self.dir1_path)) self.assertTrue(os.path.isdir(self.dir2_path)) self.assertTrue(os.path.isdir(self.dir3_path)) ops.rm(self.dir3_path) self.assertFalse(os.path.exists(self.dir3_path)) self.assertTrue(os.path.exists(self.dir2_path)) ops.rm(self.dir2_path) self.assertFalse(os.path.exists(self.dir2_path)) self.assertTrue(os.path.exists(self.dir1_path)) ops.rm(self.dir1_path) self.assertFalse(os.path.exists(self.dir1_path))
def test_file(self): self.setup_file() self.assertTrue(os.path.isfile(self.path)) ops.rm(self.path) self.assertFalse(os.path.exists(self.path))