From 810bf1247ed325c8b7d49cb35aea1bbd50fcf625 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 05 2017 02:48:52 +0000 Subject: support mixing noarch and archful packages in a yum repo build Currently the YumRepoBuild class assumes that *every* package you pass to it was built for the requested architecture. But this makes it impossible to put noarch packages into the repository, because YumRepoBuild will look for an arch-specific package when only a noarch package was produced. Change YumRepoBuild to only copy over packages if they actually produced the requested arch, otherwise skip them. --- diff --git a/rpmfluff.py b/rpmfluff.py index c0958d9..b5c112a 100644 --- a/rpmfluff.py +++ b/rpmfluff.py @@ -1218,8 +1218,9 @@ class YumRepoBuild: # Now assemble into a yum repo: for pkg in self.rpmBuilds: for arch in arches: - for subpackage in pkg.get_subpackage_names(): - shutil.copy(pkg.get_built_rpm(arch, name=subpackage), self.repoDir) + if arch in pkg.get_build_archs(): + for subpackage in pkg.get_subpackage_names(): + shutil.copy(pkg.get_built_rpm(arch, name=subpackage), self.repoDir) try: subprocess.check_output(["createrepo_c", self.repoDir], stderr=subprocess.STDOUT) @@ -1879,6 +1880,21 @@ class YumRepoBuildTests(unittest.TestCase): self.assert_is_file(os.path.join(repo.repoDir, 'test-multilib-package-0.1-1.i386.rpm')) self.assert_is_file(os.path.join(repo.repoDir, 'test-multilib-package-0.1-1.x86_64.rpm')) + @unittest.skipIf(not shutil.which('createrepo_c'), 'createrepo_c not found in PATH') + def test_arch_with_noarch(self): + archful_package = SimpleRpmBuild('test-package', '0.1', '1') + noarch_package = SimpleRpmBuild('python-package', '0.1', '1', ['noarch']) + repo = YumRepoBuild([archful_package, noarch_package]) + self.addCleanup(shutil.rmtree, archful_package.get_base_dir()) + self.addCleanup(shutil.rmtree, noarch_package.get_base_dir()) + self.addCleanup(shutil.rmtree, repo.repoDir) + + repo.make(expectedArch, 'noarch') + + self.assert_is_dir(os.path.join(repo.repoDir, 'repodata')) + self.assert_is_file(os.path.join(repo.repoDir, 'test-package-0.1-1.%s.rpm' % expectedArch)) + self.assert_is_file(os.path.join(repo.repoDir, 'python-package-0.1-1.noarch.rpm')) + if __name__ == "__main__": unittest.main()