Move chroot-updating logic to separate function

This commit is contained in:
Jakub Kadlčík
2017-04-06 18:02:11 +02:00
parent 3b7108dc07
commit 70185edad4

View File

@@ -163,11 +163,7 @@ class CoprModuleBuilder(GenericBuilder):
# We are using same hack as mock builder does
for artifact in artifacts:
if artifact and artifact.startswith("module-build-macros"):
chroot = self.client.get_chroot(self.copr.projectname, self.copr.username, "fedora-24-x86_64")
packages = (chroot.data["chroot"]["buildroot_pkgs"] or "").split()
self.client.edit_chroot(self.copr.projectname, "fedora-24-x86_64",
ownername=self.copr.username,
packages=" ".join(set(["module-build-macros"] + packages)))
self._update_chroot(packages=["module-build-macros"])
break
# Start of a new batch of builds is triggered by buildsys.repo.done message.
@@ -181,6 +177,13 @@ class CoprModuleBuilder(GenericBuilder):
repos = [self._dependency_repo(d, "x86_64") for d in dependencies]
self.client.modify_project(self.copr.projectname, username=self.copr.username, repos=repos)
def _update_chroot(self, packages=None):
chroot = self.client.get_chroot(self.copr.projectname, self.copr.username, "fedora-24-x86_64")
current_packages = (chroot.data["chroot"]["buildroot_pkgs"] or "").split()
self.client.edit_chroot(self.copr.projectname, "fedora-24-x86_64",
ownername=self.copr.username,
packages=" ".join(set(packages + current_packages)))
def _dependency_repo(self, module, arch, backend="copr"):
try:
repo = GenericBuilder.tag_to_repo(backend, self.config, module, arch)