Commit Graph

2674 Commits

Author SHA1 Message Date
Martin Liska 2d3f1aea25 Implement config overwrite and proper merging.
One can use *.override.* config files that are applied at the very
end and override values instead of merging.
2020-10-23 09:28:32 +02:00
Martin Liska e7b6aa3711 Support multiple regex expressions in PieExecutables. 2020-10-21 11:43:23 +02:00
Martin Liska 651cc53452 Remove useless 'manual-page-warning' warning. 2020-10-21 11:35:08 +02:00
Martin Liska ee284f650f Fix parsing of DanglingSymlinkExceptions.
Document better DanglingSymlinkExceptions in configdefaults.toml.
2020-10-20 13:30:35 +02:00
Martin Liska b369e7e9fc rpmlint does not depend on elfutils, but binutils. 2020-10-05 11:34:28 +02:00
Martin Liska 59860e119e Make tests stable.
Right now, get_tested_spec_package and get_tested_package use
glob(...)[0] which is unstable when there are multiple rpm candidates.
2020-10-05 11:18:35 +02:00
Martin Liska 7527873e01 Remove man, perl and elfutils from Docker files. 2020-10-05 11:12:30 +02:00
Martin Liska 1473fab69d Fix coveralls reporting.
coverage.py switched to sqlite and so that we need to fix
paths in the generated .coverage database.

Link to schema:
https://coverage.readthedocs.io/en/latest/dbschema.html
2020-09-30 15:25:27 +02:00
Martin Liska d711374b79 Fix misc package as it contained \r in Summary name:
$ rpm -qip ./test/binary/misc-0-1.x86_64.rpm
Name        : misc
Version     : 0
Release     : 1
Architecture: x86_64
Install Date: (not installed)
Group       : Unspecified
Size        : 0
License     : MIT
Signature   : (none)
Source RPM  : misc-0-1.src.rpm
Build Date  : Wed 29 Jul 2020 01:24:22 PM CEST
Build Host  : localhost.localdomain
URL         : https://build.opensuse.org
nemmary     : no
Description :
2020-09-30 13:02:45 +02:00
Martin Liska 860d1f253b Remove impossible tag-not-utf8 error.
Fixes #454.
2020-09-30 11:10:58 +02:00
Martin Liska 0e6c7c7f17 Add test for summary-on-multiple-lines (#454). 2020-09-30 09:26:40 +02:00
Martin Liska 80d4375f17 Fix %changelog in one spec file.
rpm package in Leap 15 fails to parse the spec file due to:
error: %changelog entries must start with *
2020-09-28 19:59:10 -04:00
Martin Liska 121dc51175 Add missing byte_to_string to AlternativesCheck.
It fixes #444.
2020-09-28 19:59:10 -04:00
Martin Liska 6de0b04937 Add zstd to Install section of README.md. 2020-09-28 09:24:28 -04:00
thisisshub 7f96b89639 Add tests in test_tags & description in TagsCheck.toml
This commit contains,
- Add test in test_tags.py
    - test_check_requires_on_release
    - test_check_invalid_license
    - test_package_not_std_release_extension
    - test_check_non_standard_group
    - test_package_dev_dependency
- Add description of non-standard-group check in
TagsCheck.toml
- Add packages in test/binary/
2020-09-14 14:18:26 +02:00
thisisshub 22d5323877 Fix LGTM alert 2020-09-14 14:17:44 +02:00
thisisshub 1dd7b6be69 Modify docstrings and methods in TagsCheck.py
Drop checks no-packager, invalid-packager

This commit contains,
- Modified docstrings to google-style-docstrings
- Deletion of no-packager and invalid-packager

- Why were these checks dropped?
These check are no longer used in openSUSE(tw, lp), Rhel
systems(Fedora), Arch, Mageia, Rosalab or are either frowned upon for
usage by packagers

-

- Fix typo in line 575 confifdefaults.toml -> configdefaults.toml

Fix lgtm unused variable warning
2020-09-14 14:17:44 +02:00
thisisshub 12a6365ebd Refactor checks to individual methods in TagsCheck
This commit contains,
- Conversion of checks to individual methods
    - self._check_invalid_packager
    - self._check_invalid_version_and_no_version_tag
    - self._check_non_standard_release_extension
    - self._check_no_epoch_tag
    - self._check_no_epoch_in_tags
    - self._check_no_epoch_in_dependency
    - self._check_no_name_tag
    - self._check_summary_tag
    - self._check_description_tag
    - self._check_group_tag
    - self._check_buildhost_tag
    - self._check_changelog_tag
    - self._check_license
    - self._check_url
    - self._check_obsolete_not_provided
    - self._check_useless_provides
    - self._check_forbidden_controlchar_one
    - self._check_forbidden_controlchar_two
    - self._check_self_obsoletion
    - self._check_non_coherent_filename
- Rename of variables to snake-case-naming style
    - x -> var (_check_no_epoch_in_tags)
    - d -> dep (_check_no_epoch_in_dependency)
    - r -> req (_check_no_epoch_in_dependency)
    - d -> deptoken (_check_no_name_tag)
    - x -> var (_check_no_name_tag)
    - p -> pep (_check_no_name_tag)
    - x -> var (for pep in (var[0] for var in pkg.provides):)
    - x -> var (ignored_words.update((var[0] for var in pkg.provides)
    - s -> deptoken (_check_changelog_tag)
    - e -> dep (_check_changelog_tag)
    - o -> dep_token (_check_obsolete_not_provided)
    - x -> var (_check_obsolete_not_provided)
    - 0 -> dep_token [for dep_token in pkg.obsoletes:]
    - p -> prov (_check_useless_provides)
    - p -> item (_check_forbidden_controlchar_one)
    - e -> dep (_check_forbidden_controlchar_one)
    - p -> pkg_token(_check_forbidden_controlchar_two)
    - e -> dep (_check_forbidden_controlchar_two)
- Conversion of %s string format to {}.format method
    - %s to .format in (_check_no_epoch_in_tags)
    - %s to .format in [self._unexpanded_macros(pkg, 'dependency {}'.format(value,), value)]
    - %s to .format in [if hasattr(rpm, 'RPMTAG_{}'.format(tag.upper())):]
    - %s to .format in [self._unexpanded_macros(pkg, 'Obsoletes {}'.format(value,), value]
    - %s to .format in [{}: {}'.format(tagname, dep)]
    - %s to .format in [self._unexpanded_macros(pkg, '{} {}'.format(tagname, value), value)]
    - %s to .format in ['Requires: {}'.format(dep))]
    - %s to .format in ['{} obsoletes {}'.format(Pkg.formatRequire(*obs), Pkg.formatRequire(*prov))]
2020-09-14 14:17:44 +02:00
Tomáš Chvátal 61d47ec125 Fix the zstd compression detection
As it needs the zstd import we are passing we need the new dep
(not detected by tests as we don't have anything zstd compressed there).

Also fix other flake8 errors.
2020-08-25 10:05:17 +02:00
tpgxyz 1b224163c4 add support for ZSTD compressed files 2020-08-19 10:45:26 +02:00
thisisshub 344d415121 Change single line toml statement to multiline
This commit contains,
Modified no-changelogname-tag toml in TagsCheck.toml
from single line statement to multiline statement.
2020-08-17 07:43:04 +02:00
thisisshub 8dca0d4eff Modify no-changelogname-tag toml
This commit contains,
- Modified no-changelogname-tag toml

- Reason:
    The check is triggered when either the %changelog is empty or
    %changelog tag is not present.

- Tested with:
    (error in stdout)
        - invalid-version-0pre-3.1.x86_64.rpm (no %changelog section)
        - invalid-dependency-0-0.x86_64.rpm (empty %changelog section)
    (error not in stdout)
        - hello-2.0-1.x86_64-signed.rpm (non-empty %changelog section)
2020-08-17 07:43:04 +02:00
thisisshub 17d23330c0 Add tests in test_tags & modify TagsCheck.toml
This commit contains tests for checks,
- description-line-too-long
- description-shorter-than-summary
- invalid-dependency
- invalid-url
- invalid-version
- name-repeated-in-summary
- no-description-tag
- obsolete-not-provided
- self-obsoletion
- summary-ended-with-dot
- summary-has-leading-spaces
- summary-not-capitalized
- summary-too-long
- tag-in-description
- unexpanded-macro
- unreasonable-epoch
2020-08-16 15:41:21 +02:00
thisisshub 67bf89b8b2 Fix non-coherent-filename check in TagsCheck.py
This commit contains,
- Fixed non-coherent-filename check,
    - Path(pkg.filename).parent -> Path(pkg.filename).name
    - Detailed explanation: https://gist.github.com/thisisshub/7423c6a71d75f191ef6b5cf363f5d231
2020-08-16 15:40:34 +02:00
Kristyna Streitova f6de07414b Remove broken-syntax-in-scriptlet-requires check
This check is outdated since the mentioned bug in rpm was fixed in
rpm 4.7.1 (see https://bugzilla.redhat.com/show_bug.cgi?id=1053075).
2020-07-24 15:54:42 +02:00
Kristyna Streitova 8c13ee71f5 Support overriding error descriptions in config
Now we will allow adding new descriptions strings for the rpmlint
errors in configuration files. The new error descriptions can be
defined in TOML syntax as [Descriptions] table with key/value pairs,
where key is the rpmlint error name and value is the new text for
that error.

Example:

[Descriptions]
no-binary = """
A new text for no-binary error.
"""
2020-07-23 10:11:46 +02:00
Kristyna Streitova aeb25da708 Support loading a directory with config files
Add support for loading not only one configuration file but also
a directory with multiple *.toml configs with '-c' or '--config'
parameter.

Parametrize test_run_full_rpm and test_run_full_specs tests so they
will test multiple configuration files located in 'configs' directory.
2020-07-23 10:11:46 +02:00
Kristyna Streitova 825fcc7d39 filter.py: Add/improve comments and rename vars
Add missing docstrings and adjust the current ones to be more
explanatory. Also rename few variables and use better names for
them.
2020-07-23 10:11:46 +02:00
Kristyna Streitova b409b2115d config.py: Enhance and add missing comments 2020-07-23 10:11:46 +02:00
thisisshub 4026f90830 Change checks to distinct methods & rename variables
This commit contains
- Refactored checks into individual methods,
    - _check_no_cleaning_of_buildroot
    - _check_no_buildroot_tag
    - _check_no_s_section
    - _check_more_than_one_s_section
    - _check_lib_package_without_mklibname
    - _check_descript_without_disabling_depgen
    - _check_patch_fuzz_is_changed
    - _check_mixed_use_of_space_and_tabs
    - _check_if_arch_applied_patch
    - _check_patch_not_applied
    - _check_specfile_error
    - _check_invalid_url
- Renamed variables in SpecCheck snake-case-naming style
    - r -> rpm_tag
    - ts -> transaction_set
    - hashPos -> hash_pos
    - e -> deptoken
    - cfgPos -> cfg_pos
2020-07-22 11:14:44 +02:00
thisisshub a77923124e Add tests in test_speccheck
This commit contains tests added in the test_speccheck,
- test_check_prereq_use
- test_check_patch_fuzz_is_changed
2020-07-22 08:23:37 +02:00
Tomáš Chvátal e485305ad0 Fix alternatives check with old rpm 2020-07-10 08:55:43 +02:00
thisisshub cb9e34e79d Modify check_source() in checks/Speccheck.py 2020-07-02 10:14:30 +02:00
thisisshub bfc766774d renamed source/no-spec-file-0.0-0.src.rpm -> source/no-spec-file-0-0.src.rpm 2020-07-02 10:14:30 +02:00
thisisshub ef922c56a0 Add test/source/no-spec-file-0-0.src.rpm 2020-07-02 10:14:30 +02:00
thisisshub c3954a5c89 Add test in test_speccheck, modified SpecCheck.py
This commit contains,
1. Refactored check in SpecCheck.py
2. Source-rpms in test/source
3. Tests in test_speccheck which are named with test_check_*
4. Specfile in test/spec listed as,
- %autopatch-not-in-prep.spec
- %autosetup-not-in-prep.spec
- broken-syntax-in-scriptlet-requires.spec
- buildarch-instead-of-exclusivearch-tag.spec
- buildprereq-use.spec
- comparison-operator-in-deptoken.spec
- configure-without-libdir-spec.spec
- deprecated-grep.spec
- depscript-without-disabling-depgen.spec
- forbidden-controlchar-found.spec
- hardcoded-library-path.spec
- hardcoded-packager-tag.spec
- hardcoded-path-in-buildroot-tag.spec
- hardcoded-prefix-tag.spec
- %ifarch-applied-patch.spec
- invalid-url.spec
- libdir-macro-in-noarch-package.spec
- lib-package-without-%mklibname.spec
- macro-in-changelog.spec
- macro-in-comment.spec
- make-check-outside-check-section.spec
- mixed-use-of-spaces-and-tabs.spec
- more-than-one-%changelog.spec
- no-buildroot-tag.spec
- non-break-space.spec
- non-standard-group.spec
- non-utf8-spec-file.spec
- no-%%%s-section.spec
- obsolete-tag.spec
- rpm-buildroot-usage.spec
- setup-not-in-prep.spec
- setup-not-quiet.spec
- SpecCheck2.spec
- SpecCheck3.spec
- SpecCheck4.spec
- SpecCheck.spec
- SpecCheckTemp.spec
- unversioned-explicit-obsoletes.spec
- unversioned-explicit-version.spec
- use-of-RPM-SOURCE-DIR.spec
2020-07-02 10:14:30 +02:00
Tomáš Chvátal ad7aedd1b5 Switch from F31 to F32 2020-06-23 11:51:57 +02:00
Tomáš Chvátal f8a0674010 Terminate TOML strings properly 2020-06-23 11:51:57 +02:00
Tomáš Chvátal fdd73c063f Fixes for new flake8 2020-06-23 11:51:57 +02:00
Tomáš Chvátal 22e6713676 Do not require pytest twice in openSUSE Dockerfiles 2020-06-23 11:51:57 +02:00
Kristyna Streitova 031859b8ff Update .gitignore and sort it in categories
Also add .idea file and virtual environment files and dirs.
2020-05-13 13:40:20 +02:00
Kristyna Streitova 0a3ec9ade8 Update systemd-tmpfiles test to cover more cases 2020-04-22 06:36:19 -04:00
Kristyna Streitova 15cea2c871 _check_tmpfile_in_filelist: Be clear about %ghost
Improve the docstring so it's obvious now that we want
tmpfiles to be marked as %ghost. Also add a test rpm for
a usecase where tmpfiles are packaged correctly and no
rpmlint errors are printed.

fix #326
2020-04-22 06:36:19 -04:00
Kristyna Streitova 297f09e745 Rewrite SignatureCheck and add tests
Separate SignatureCheck to functions and add tests. Also, rewrite the
logic as SignatureCheck was obsolete and didn't work properly
(e.g. it searched for "MISSING KEYS" and "pgp|gpg" strings that are no
longer used in 'rpm -K' output).

Now it checks the output of 'rpm -Kv' which provides more detailed output.
Thanks to that we could add another check ('E: invalid-signature' that
checks if the signature is corrupted or not).

The test_signature.py file was added so now all 3 signature checks are
tested properly.
2020-04-09 07:46:44 +02:00
Tomáš Chvátal aa433df1ce Remove unused pytest-runner from Dockerfiles 2020-04-03 05:40:07 -04:00
Tomáš Chvátal 331d4ef5e7 Enable MixedOwnershipCheck by default 2020-04-02 09:39:40 -04:00
Tomáš Chvátal 5de55f96b4 Add MixedOwnershipCheck #371 2020-04-02 09:39:40 -04:00
Tomáš Chvátal 4396a99585 Set english locale for subprocess runs. Fixes #415 2020-04-01 10:04:27 +02:00
Tomáš Chvátal 91a23456c6 We support python 3.8 2020-03-30 21:11:29 +02:00
Tomáš Chvátal 9bb8c8f277 Fix importlib usage if the rpmlint is not installed yet 2020-03-30 21:11:29 +02:00