#295 Grab the correct line in case of rpm output
Merged 6 years ago by cqi. Opened 6 years ago by eclipseo.

file modified
+2 -2
@@ -690,7 +690,7 @@

          # We make sure there is a space at the end of our query so that

          # we can split it later.  When there are subpackages, we get a

          # listing for each subpackage.  We only care about the first.

-         cmd.extend(['-q', '--qf', '"%{NAME} %{EPOCH} %{VERSION} %{RELEASE}??"',

+         cmd.extend(['-q', '--qf', '"??%{NAME} %{EPOCH} %{VERSION} %{RELEASE}??"',

                      '--specfile', '"%s"' % os.path.join(self.path, self.spec)])

          joined_cmd = ' '.join(cmd)

          try:
@@ -712,7 +712,7 @@

              self.log.error(err)

          # Get just the output, then split it by ??, grab the first and split

          # again to get ver and rel

-         first_line_output = output.split('??')[0]

+         first_line_output = output.split('??')[1]

          parts = first_line_output.split()

          if len(parts) != 4:

              raise rpkgError('Could not get n-v-r-e from %r'

Signed-off-by: Robert-André Mauchin zebob.m@gmail.com

If the rpm build process output some text (like with rpm.expand("%{echo:Some text}") notably used in the new Go packaging), the following code in load_nameverrel grabs the RPM output before %{NAME} %{EPOCH} %{VERSION} %{RELEASE}??:

        # Get just the output, then split it by ??, grab the first and split
        # again to get ver and rel
        first_line_output = output.split('??')[0]
        parts = first_line_output.split()
        if len(parts) != 4:
            raise rpkgError('Could not get n-v-r-e from %r'
                            % first_line_output)
        (self._module_name_spec,
         self._epoch,
         self._ver,
         self._rel) = parts

output.split('??')[0] does not then contain the 4 parts variables and thus fails.
This patch simply add a split point ?? before %{NAME} %{EPOCH} %{VERSION} %{RELEASE} to separate the RPM output from the rest and then grab the second split instead of the first.

Hi @eclipseo

Can you give a specific example? Which go package can be used to test and verify this change?

Can you also write a test for the issue this change to solve? There is a test case LoadNameVerRelTest in test_commands.py and you can write the new test inside that test case class.

pretty please pagure-ci rebuild

I'm going to merge this solution. The failure test is relative to a different issue and I'll make a patch to propose a fix. Thank you very much.

Commit 6900c2e fixes this pull-request

Pull-Request has been merged by cqi

6 years ago

Pull-Request has been merged by cqi

6 years ago
Metadata