Bug 1019204

Summary: SpecCheck is hardcoded to be the only check to run on spec files
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: rpmlintAssignee: Michael S. <misc>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: a.badger, manuel.wolfshant, tcallawa, tmz, twoerner, ville.skytta
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-31 20:46:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miro Hrončok 2013-10-15 09:44:33 UTC
Although rpmlint comes with variety of checks and allows the user to configure whatever to run a certain check or not, when it comes to checking spec files, only SpecCheck is hardcoded to run.

Even if SpecCheck is disabled, it will be run on spec files. Even if other checks provide spec checks, and are enabled, they will not run on spec files.

This is certainly an upstream bug, however the upstream bug tracker at SourceForge won't let me file a bug.

We've been discussing this via e-mail with Michael Scherer and Ville Skyttä, however the discussion seems stalled. Other people are asking me about it, so this is created mainly for the reason of public discussion.

What I proposed:

Let all checks implement three methods:

 * check_spec(self, pkg)
 * check_binary(self, pkg)
 * check_sources(self, pkg)

pkg should than contain some structures: spec_file, files, doc_files..., sources (without spec files)

If the check is not interested in a certain category is either doesn't implement the method or implement it doing nothing (pass).

All around rpmlint, where SpecCheck is called directly, all check_spec()s from allowed checks are called instead - similar to how runChecks() works but calling check_spec (and setting pkg.spec_file) instead of just check().

That is:

 * when input is from stdin
 * when input is a filename that ends with .spec
 * when input is a directory and file in it ends with .spec

Later on, where runChecks() comes in game, we can keep the things as they are, but we have to be sure, that check() is only in AbstractCheck and it determines whenever to call certain methods form above list. E.g. something like this:

    def check(self, pkg):
        '''Determine what checks to run on what'''
        if not pkg.isSource():
            self.check_binary(pkg)
            return
        for fname, pkgfile in pkg.files().items():
            if fname.endswith('.spec'):
                if pkg.spec_file:
                    printError(pkg, 'multiple-specfiles', spec_file, fname)
                else:
                    pkg.spec_file = fname
                    self.check_spec(pkg)
                    pkg.remove_from_sources(pkg.spec_file)
        self.check_sources(pkg)

[This is just very rough draft]

And again: I'm willing to send patches, just give me blessing or speak against that approach.

Comment 1 Miro Hrončok 2013-10-31 20:46:07 UTC
since upstream bug tracker is now open for strangers, I've moved this thing there, where it belongs.

https://sourceforge.net/p/rpmlint/tickets/24/