- Notifications
You must be signed in to change notification settings - Fork127
Tool for checking common errors in rpm packages
License
rpm-software-management/rpmlint
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
rpmlint is a tool for checking common errors in RPM packages.rpmlint can be used to test individual packages before uploading or to checkan entire distribution.
rpmlint can check binary RPMs, source RPMs, and plain specfiles, but allchecks do not apply to all argument types.For best check coverage, runrpmlint on source RPMs instead ofplain specfiles.
The idea forrpmlint is from the lintian tool of the Debian project.All the checks reside inrpmlint/checks folder. Feel free to provide newchecks and suggestions at:
https://github.com/rpm-software-management/rpmlint
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 rpmlintYou will need to have all the required modules as listed on the Install section above.You will also needpytest,pytest-cov andpytest-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 pytestOr even pick one of the tests usingpytest:
python3 -m pytest test/test_config.pyAny help is, of course, welcome but honestly most probable cause for your visithere is thatrpmlint is marking something as invalid while it shouldn't orit is marking something as correct while it should not either :)
Now there is an easy way how to fix that. Our testsuite simply needs anextension to take the above problem into the account.
Primarily we just need the offending rpm file (best the smallest you canfind or we would soon take few GB to take a checkout) and some basicexpectation of what should happen.
This section focuses on how to build the tool as you develop it.
To build the tool, we'll use a tool calledpackit. First, installpackit on your system:
dnf install packitThen, build the project using:
packit build locallyIf 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 thenoarch directory. To install the package on your system, run:
dnf install <the_rpm_you_just_built>Alternatively, the built binary can be found in therpmlint directory under the.packit directory, which you can run directly.
- I have rpmfile that should report unreadable zip file
- I store this file in git under
test/binary/texlive-codepage-doc-2018.151.svn21126-38.1.noarch.rpm - Now I need to figure out what
checkshould test this, in this casetest_zip.py - 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 outAs you can see it is not so hard and with each added test we get bettercoverage on what is really expected from rpmlint and avoid naughty regressionsin 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
If you want to change configuration options or the list of checks you canuse the following locations:
/etc/xdg/rpmlint/*toml
$XDG_CONFIG_HOME/rpmlint/*toml
The configuration itself is atoml file where for some basic inspirationyou can check uprpmlint/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 controlrpmlint behaviour is the addition ofrpmlintrc filewhich uses old syntax for compatibility with oldrpmlint releases, yetit can be normaltoml file if you wish:
setBadness('check', 0)addFilter('test-i-ignore')The location ofrpmlintrc can be set using--rpmlintrc option.Or it can load any*.rpmlintrc or*-rpmlintrc that are located in the samefolder as check RPM file (or a specfile). Note the auto-loading happens onlywhen 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 andaddFilter ignores all errorsthat match the given regular expression (one cannot filter out errors that are listed inBlockedFiltersin a configuration file).
About
Tool for checking common errors in rpm packages
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.