#533 Parse spec once SRPM sources are available
Closed 4 months ago by dridi. Opened 4 months ago by dridi.
dridi/FedoraReview spec_sourcedir  into  master

file modified
+6 -1
@@ -23,12 +23,16 @@ 

  import os

  import sys

  import time

+ 

+ import rpm

+ 

  from operator import attrgetter

  

  from straight.plugin import load  # pylint: disable=F0401

  

  from .datasrc import BuildFilesSource, RpmDataSource, SourcesDataSource

  from .reports import write_template, write_xml_report, write_json

+ from .review_dirs import ReviewDirs

  from .review_error import ReviewError

  from .settings import Settings

  from .spec_file import SpecFile
@@ -284,9 +288,10 @@ 

          unless invoked from ChecksLister.

          """

          _ChecksLoader.__init__(self)

-         self.spec = SpecFile(spec_file, self.flags)

          self.srpm = SRPMFile(srpm_file)

          self.srpm.unpack()

+         rpm.addMacro('_sourcedir', ReviewDirs.srpm_unpacked)

+         self.spec = SpecFile(spec_file, self.flags)

          self.data = self.Data()

          self.data.rpms = RpmDataSource(self.spec)

          self.data.buildsrc = BuildFilesSource()

Parsing the spec first is impossible when macros involving sources like %load are present. Waiting for the SRPM unpacking and telling the rpm module where sources can be found enables the review of such packages.

This would allow the hare package pending a review in Fedora to keep its single-pass bootstrap and still be reviewable with the help of fedora-review.

https://bugzilla.redhat.com/show_bug.cgi?id=2385991

Part of your commit is similar to mine [1] but I add addMacro in spec_file.py , I think it is a better place

[1]
https://pagure.io/FedoraReview/pull-request/532#request_diff

You are covering more ground than I do and while I applied due diligence when I first tried to address this problem, I did not notice your pull request on my second attempt. Sorry about that.

I don't really care about which one is better, I just want to make the %load macro reviewable. I couldn't find documentation on the python rpm module and between navigating the fedora-review code and trying to figure how this module works I spent a lot of time reading code before I could write this handful of lines...

I will give your branch a try and happily close this pull request if it produces a review template for the hare package submission.

Closing in favor of #532 , thanks!

Pull-Request has been closed by dridi

4 months ago
Metadata