#1872 pkgset: Allow scratch tasks to override real builds
Opened 4 months ago by lsedlar. Modified 4 months ago
lsedlar/pungi rhelcmp-14814  into  master

@@ -650,7 +650,28 @@ 

                  builds_by_id.setdefault(build_id, build_info)

  

          # Get extra RPMs from tasks.

-         rpms += self.get_extra_rpms_from_tasks()

+         scratch_rpms = self.get_extra_rpms_from_tasks()

+         # We need to merge the scratch RPMs into the existing package set.

+         # There is no guarantee that the NVR of the scratch task is going to be

+         # unique. If there is a conflict, we want to prioritize the scratch

+         # task.

+         seen_nvras = set(

+             (r["name"], r["version"], r["release"], r["arch"]) for r in scratch_rpms

+         )

+         merged_rpms = scratch_rpms[:]

+         for rpm in rpms:

+             nvra = (rpm["name"], rpm["version"], rpm["release"], rpm["arch"])

+             if nvra in seen_nvras:

+                 self.log_warning(

+                     "Skipping %(name)s-%(version)s-%(release)s.%(arch)s due to "

+                     "conflict with scratch build",

+                     rpm,

+                 )

+             else:

+                 seen_nvras.add(nvra)

+                 merged_rpms.append(rpm)

+ 

+         rpms = merged_rpms

  

          skipped_arches = []

          skipped_packages_count = 0

If user explicitly wants to include a scratch build, we should allow that even if the same NVR is already taken by a real build.

It is a rather unusual situation, as the scratch build could never be rebuilt as a real build with the same NVR, but this gets us more consistency with how extra builds are handled.

Metadata