Package: rpmlint
rpmlintrpmlintis a tool for checking common errors in RPM packages.rpmlintcan be used to test individual packages before uploading or to check
an entire distribution.rpmlintcan check binary RPMs, source RPMs, and plain specfiles, but all
checks do not apply to all argument types.
For best check coverage, runrpmlinton source RPMs instead of
plain specfiles.The idea forrpmlintis from the lintian tool of the Debian project.
All the checks reside inrpmlint/checksfolder. Feel free to provide new
checks and suggestions at:https://github.com/rpm-software-management/rpmlintInstallFor installation on your machine you will need the following packages:Mandatory:Python 3.8 or newerpython3-setuptools, python3-tomli (forpython3 < 3.11), python3-tomli-w,
python3-pyxdg, python3-pybeamrpm and its python bindingsbinutils, cpio, gzip, bzip, xz and zstdOptional, for running the test suite:devscriptsdasha 32-bit glibc if on a 64-bit architecturedesktop-file-utilslibmagic and its python bindingsenchant and its python bindings, along with en_US and cs_CZ dictionariesappstream-util, part of appstream-glibrpmlintis part of most distributions and as an user you can simplydnf install rpmlintTestingYou will need to have all the required modules as listed on the Install section above.
You will also needpytest,pytest-covandpytest-xdist,
which you can install individually or by runningpip install -e ".[test]".If all the dependencies are present you can just execute tests using:python3 -m pytestOr even pick one of the tests usingpytest:python3 -m pytest test/test_config.pyBugfixing and contributingAny help is, of course, welcome but honestly most probable cause for your visit
here is thatrpmlintis marking something as invalid while it shouldn't or
it is marking something as correct while it should not either :)Now there is an easy way how to fix that. Our testsuite simply needs an
extension to take the above problem into the account.Primarily we just need the offending rpm file (best the smallest you can
find or we would soon take few GB to take a checkout) and some basic
expectation of what should happen.Example workflowI have rpmfile that should report unreadable zip fileI store this file in git undertest/binary/texlive-codepage-doc-2018.151.svn21126-38.1.noarch.rpmNow I need to figure out whatcheckshould test this, in this casetest_zip.pyFor the testing I will have to devise a small function that validates my expectations:@pytest.mark.parametrize('package', ['binary/texlive-codepage-doc'])
def test_zip2(tmpdir, package, zipcheck):
    output, test = zipcheck
    test.check(get_tested_package(package, tmpdir))
    out = output.print_results(output.results)
    assert 'W: unable-to-read-zip' in outAs you can see it is not so hard and with each added test we get better
coverage on what is really expected from rpmlint and avoid naughty regressions
in the long run.Preferable approach for binary packages is to create artificial testcase (to keep binaries small and trivial).
We are currently using OBS to produce binaries:https://build.opensuse.org/project/show/devel:openSUSE:Factory:rpmlint:testsFor a sample package see:https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint:tests/non-position-independent-execConfigurationIf you want to change configuration options or the list of checks you can
use the following locations:/etc/xdg/rpmlint/*toml$XDG_CONFIG_HOME/rpmlint/*tomlThe configuration itself is atomlfile where for some basic inspiration
you can check uprpmlint/configdefaults.tomlwhich specifies format/defaults.One can also include additional configuration files (or directories) by using the--configoption.
Note that all TOML configuration values are merged and not overridden.
So e.g. values in a list are concatenated. If you need an override,
use*.override.*tomlconfiguration file, where all defined values are selected as default.Additional option to controlrpmlintbehaviour is the addition ofrpmlintrcfile
which uses old syntax for compatibility with oldrpmlintreleases, yet
it can be normaltomlfile if you wish:setBadness('check', 0)
addFilter('test-i-ignore')The location ofrpmlintrccan be set using--rpmlintrcoption.
Or it can load any*.rpmlintrcor*-rpmlintrcthat are located in the same
folder as check RPM file (or a specfile). Note the auto-loading happens only
when one RPM file (or a specfile) is used.
The best practice is to store the name in$PACKAGE_NAME.rpmlintrc.setBadnessoverrides a default badness for a given check andaddFilterignores all errors
that match the given regular expression (one cannot filter out errors that are listed inBlockedFiltersin a configuration file).