#81 compose-has-build: check any epoch for an NVR
Merged 5 years ago by lsedlar. Opened 5 years ago by ktdreyer.
ktdreyer/compose-utils has-build-ignore-epoch  into  master

file modified
+12 -4
@@ -13,14 +13,22 @@ 

  

  

  def look_for_build(compose, nvr):

+     """

+     Look for a build NVR with any epoch.

+     """

      parts = kobo.rpmlib.parse_nvr(nvr)

-     parts["epoch"] = parts["epoch"] or "0"

-     srpm_name = "{name}-{epoch}:{version}-{release}.src".format(**parts)

+     name = parts['name']

+     version = parts['version']

+     release = parts['release']

  

      for variant in compose.rpms.rpms:

          for arch in compose.rpms.rpms[variant]:

-             if srpm_name in compose.rpms.rpms[variant][arch]:

-                 return True

+             for srpm_nevra in compose.rpms.rpms[variant][arch]:

+                 srpm = kobo.rpmlib.parse_nvr(srpm_nevra)

+                 if srpm['name'] == name and \

+                    srpm['version'] == version and \

+                    srpm['release'] == release + '.src':

This looks a little surprising. Can you switch the call above to parse_nvra? Then the release will be parsed correctly and there will be no need to add the '.src'.

+                     return True

  

      return False

  

file modified
-8
@@ -26,14 +26,6 @@ 

          compose = get_compose("DP-1.0-20160315.t.0")

          self.assertFalse(compose_utils.look_for_build(compose, "dummy-bash-4.2.37-1"))

  

-     def test_missing_nevr(self):

-         compose = get_compose("DP-1.0-20160315.t.0")

-         self.assertFalse(compose_utils.look_for_build(compose, "dummy-bash-0:4.2.37-1"))

- 

-     def test_missing_nevr_bad_epoch(self):

-         compose = get_compose("DP-1.0-20160315.t.0")

-         self.assertFalse(compose_utils.look_for_build(compose, "dummy-bash-1:4.2.37-6"))

- 

  

  class HasBuildTest(unittest.TestCase):

      def setUp(self):

Prior to this change, if a user specified a build NVR without an epoch
to compose-has-build, then compose-has-build would assume an epoch value
of "0". If the compose contained the build with a non-zero epoch, then
compose-has-build would fail to find it.

The problem is that Koji's BuildStateChange messages do not contain the
epoch at all. Koji announces builds with plain NVRs, so we don't know
what epoch value use. This means we cannot use compose-has-build with
Koji's build announcement messages if the build has a non-zero epoch.

Make compose-has-build match any epoch value in the compose.

This looks a little surprising. Can you switch the call above to parse_nvra? Then the release will be parsed correctly and there will be no need to add the '.src'.

With this patch, the epoch is ignored even if there is one specified in the input (if you ask about 1:1.0, it will find 0:1.0). I'm fine with that change, but the manual page (man/compose-has-build.1) should be updated to match this behaviour.

I opened #82 that addresses my comment above.

Great! I will close this one and we can continue with #82

Pull-Request has been closed by ktdreyer

5 years ago

Commit 96923fe fixes this pull-request

Pull-Request has been merged by lsedlar

5 years ago