Go to file
Daniel Garcia Moreno 511fe0ea4f Add new warning about the usage of %suse_update_desktop_file
https://lists.opensuse.org/archives/list/packaging@lists.opensuse.org/message/TF4QO7ECOSEDHBFI5YDEA3OF4RNSI7D7/
2024-09-11 13:04:50 +02:00
.github/workflows Merge branch 'main' into opensuse 2024-07-03 10:06:38 +02:00
.packit Merge branch 'main' into opensuse 2024-08-02 08:23:28 +02:00
.vscode Remove unused VS code settings. 2021-10-20 08:43:51 +02:00
configs configs/openSUSE/users-groups.toml: add nqptp (boo#1213060) 2024-09-03 11:52:33 +02:00
rpmlint Add new warning about the usage of %suse_update_desktop_file 2024-09-11 13:04:50 +02:00
test Add new warning about the usage of %suse_update_desktop_file 2024-09-11 13:04:50 +02:00
tools Merge branch 'main' into opensuse 2023-10-20 09:12:26 +02:00
.dockerignore Adjust the docker script to run the setuptools 2018-07-12 14:46:13 +02:00
.editorconfig Set indent size for yaml to 2 in .editorconfig 2021-08-19 14:59:40 +02:00
.gitignore Introduce Packit CI to enable easy local testing of PRs 2021-05-15 15:42:48 -04:00
.packit.yaml CI: Reenable mageia-cauldron in packit 2024-02-22 07:05:30 -05:00
.pre-commit-hooks.yaml Releasing rpmlint as pre-commit hook 2023-03-20 10:09:11 +01:00
COPYING Update GPL-2.0 with the current text from GNU, whitespace fixes. 2018-08-21 16:11:55 +02:00
MANIFEST.in Add conftest.py in order to fix pytest loading issues. 2021-08-15 18:36:03 +02:00
Makefile Add back Makefile generating the isocodes 2018-07-12 14:46:13 +02:00
README.md readme: More specific title for building section 2024-03-05 08:01:51 +01:00
diff.py Add diff.py wrapper script. 2021-11-26 11:36:03 +01:00
lint.py Move the rpmlint CLI logic into its own module file 2020-02-17 10:00:00 -05:00
pyproject.toml Release 2.6.1 2024-08-02 08:11:44 +02:00
pytest.ini Remove trailing whitespace. 2023-04-24 10:34:08 +02:00
rpmlint.svg Add rpmlint.svg with the new rpmlint logo 2023-04-20 13:35:46 +02:00
setup.cfg remove comment in setup.cfg 2024-03-25 22:17:01 +01:00
setup.py Move metadata from setup.py to pyproject.toml 2023-06-29 22:57:22 -03:00

README.md

rpmlint

Build and Test Build and Test 2 build result repology Coverage Status

rpmlint is a tool for checking common errors in RPM packages. rpmlint can be used to test individual packages before uploading or to check an entire distribution.

rpmlint can check binary RPMs, source RPMs, and plain specfiles, but all checks do not apply to all argument types. For best check coverage, run rpmlint on source RPMs instead of plain specfiles.

The idea for rpmlint is from the lintian tool of the Debian project. All the checks reside in rpmlint/checks folder. Feel free to provide new checks and suggestions at:

https://github.com/rpm-software-management/rpmlint

Install

For installation on your machine you will need the following packages:

Mandatory:

  • Python 3.8 or newer
  • python3-setuptools, python3-tomli (for python3 < 3.11), python3-tomli-w, python3-pyxdg, python3-pybeam
  • rpm and its python bindings
  • binutils, cpio, gzip, bzip, xz and zstd

Optional, for running the test suite:

  • devscripts
  • dash
  • a 32-bit glibc if on a 64-bit architecture
  • desktop-file-utils
  • libmagic and its python bindings
  • enchant and its python bindings, along with en_US and cs_CZ dictionaries
  • appstream-util, part of appstream-glib

rpmlint is part of most distributions and as an user you can simply

dnf install rpmlint

Testing

You will need to have all the required modules as listed on the Install section above. You will also need pytest,pytest-cov and pytest-xdist, which you can install individually or by running:

pip install -e ".[test]"

If all the dependencies are present you can just execute tests using:

python3 -m pytest

Or even pick one of the tests using pytest:

python3 -m pytest test/test_config.py

Bugfixing and contributing

Any help is, of course, welcome but honestly most probable cause for your visit here is that rpmlint is 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.

Building the installable rpm and installing

This section focuses on how to build the tool as you develop it.

To build the tool, we'll use a tool called packit. First, install packit on your system:

dnf install packit

Then, build the project using:

packit build locally

If you encounter any errors, install the missing dependencies and run the same command again. Once the build is successful, you'll find a RPM file under the noarch directory. To install the package on your system, run:

dnf install <the_rpm_you_just_built>

Alternatively, the built binary can be found in the rpmlint directory under the .packit directory, which you can run directly.

Example workflow for testing a functionality

  1. I have rpmfile that should report unreadable zip file
  2. I store this file in git under test/binary/texlive-codepage-doc-2018.151.svn21126-38.1.noarch.rpm
  3. Now I need to figure out what check should test this, in this case test_zip.py
  4. For 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 out

As 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:tests

For a sample package see: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint:tests/non-position-independent-exec

Configuration

If 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/*toml

The configuration itself is a toml file where for some basic inspiration you can check up rpmlint/configdefaults.toml which specifies format/defaults.

One can also include additional configuration files (or directories) by using the --config option. 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.*toml configuration file, where all defined values are selected as default.

Additional option to control rpmlint behaviour is the addition of rpmlintrc file which uses old syntax for compatibility with old rpmlint releases, yet it can be normal toml file if you wish:

setBadness('check', 0)
addFilter('test-i-ignore')

The location of rpmlintrc can be set using --rpmlintrc option. Or it can load any *.rpmlintrc or *-rpmlintrc that 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.

setBadness overrides a default badness for a given check and addFilter ignores all errors that match the given regular expression (one cannot filter out errors that are listed in BlockedFilters in a configuration file).