Skip to content

Commit

Permalink
Merge pull request #14 from jpopelka/20
Browse files Browse the repository at this point in the history
2.0
  • Loading branch information
jpopelka authored Nov 14, 2023
2 parents 4ca2c1e + 227ead6 commit 6c4dac4
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 63 deletions.
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@
# pre-commit install -t pre-commit -t pre-push

repos:
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
rev: v0.1.5
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -29,11 +22,15 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.7.0
hooks:
- id: mypy
additional_dependencies: [types-requests, types-six]
exclude: docs/conf.py
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
- repo: https://github.com/packit/pre-commit-hooks
rev: v1.2.0
hooks:
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
---------

2.0
~~~~~~

* Make metalinks work on CentOS Stream 9

2.0rc3
~~~~~~

Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
copyright = "2016, Red Hat"
author = "rpmdeplint contributors"

version = "1.0"
release = "1.0"
version = "2.0"
release = "2.0"

language = None

Expand Down Expand Up @@ -47,7 +47,7 @@
(
"rpmdeplint",
"rpmdeplint",
"a tool to find errors in RPM packages in the context of their dependency graph",
"a tool to find errors in RPM packages in the context of their dependency graph", # noqa: E501
[author],
1,
)
Expand Down
13 changes: 6 additions & 7 deletions docs/rpmdeplint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Synopsis
Description
~~~~~~~~~~~

The :program:`rpmdeplint` command will test dependency satisfiability of given
RPM packages against given repositories.
The :program:`rpmdeplint` command tests the dependency satisfiability of
specified RPM packages against given repositories.

Options
~~~~~~~
Expand All @@ -22,13 +22,13 @@ Options
Load yum repository specified by name or by URL/path.

If the repo is already configured in :file:`/etc/yum.repos.d/{*}.repo`
you can just specify its name, like::
simply specify its name like::

--repo=fedora

Otherwise, specify a name and the baseurl or metalink. The NAME is for
Otherwise, specify a name and the base URL or metalink. The NAME is for
descriptive purposes only in this case. It has no impact on dependency
resolution. If rpmdeplint finds a dependency problem relating to a package
resolution. If rpmdeplint identifies a dependency issue relating to a package
in this repo, the NAME will appear in the error message. Examples::

--repo=fedora,https://download.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/
Expand Down Expand Up @@ -99,8 +99,7 @@ check-repoclosure

check-conflicts
Checks for undeclared file conflicts in the given RPM packages: that is, when
one of the given package contains a file which is also contained in some
other package.
a given package contains a file also contained in another package.

This command will not report a file as conflicting between two packages if:

Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,7 @@ select = [
ignore = [
"SIM115", # open-file-with-context-handler
]
line-length = 100
target-version = "py39"

[tool.mypy]
python_version = "3.9"
6 changes: 2 additions & 4 deletions rpmdeplint.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
%global upstream_version 2.0rc3

Name: rpmdeplint
Version: 2.0~rc3
Version: 2.0
Release: %autorelease
Summary: Tool to find errors in RPM packages in the context of their dependency graph
License: GPL-2.0-or-later
Expand Down Expand Up @@ -37,7 +35,7 @@ dependency graph.
This package provides a Python 3 API for performing the checks.

%prep
%autosetup -n rpmdeplint-%{upstream_version}
%autosetup -n rpmdeplint-%{version}

%generate_buildrequires
# The -w flag is required for EPEL 9's older hatchling
Expand Down
23 changes: 14 additions & 9 deletions rpmdeplint/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def packages_with_problems(self) -> list[str]:
@property
def package_dependencies(self) -> dict[str, dict[str, list]]:
"""
Dict in the form {package: {'dependencies': list of packages, 'problems': list of problems}}
Dict in the form {package: {'dependencies': list of packages,
'problems': list of problems}}
"""
return dict(self._packagedeps)

Expand Down Expand Up @@ -141,7 +142,8 @@ def __init__(
self.pool = Pool()
self.pool.setarch(arch)

#: List of :py:class:`solv.Solvable` to be tested (corresponding to *packages* parameter)
# List of :py:class:`solv.Solvable` to be tested
# (corresponding to *packages* parameter)
self.solvables: list[XSolvable] = []
self.commandline_repo = self.pool.add_repo("@commandline")
for rpmpath in packages:
Expand All @@ -153,9 +155,8 @@ def __init__(
)
self.solvables.append(solvable)

self.repos_by_name = (
{}
) #: Mapping of {repo name: :py:class:`rpmdeplint.repodata.Repo`}
# Mapping of {repo name: :py:class:`rpmdeplint.repodata.Repo`}
self.repos_by_name = {}
for repo in repos:
try:
repo.download_repodata()
Expand Down Expand Up @@ -236,7 +237,8 @@ def _select_obsoleted_by(self, solvables: Iterable[XSolvable]) -> Selection:
sel = self.pool.Selection()
for solvable in solvables:
# Select every solvable with the same name and lower EVR.
# XXX are there some special cases with arch-noarch upgrades which this does not handle?
# XXX are there some special cases with arch-noarch upgrades
# which this does not handle?
sel.add(
self.pool.select(
f"{solvable.name}.{solvable.arch} < {solvable.evr}",
Expand Down Expand Up @@ -268,7 +270,8 @@ def find_repoclosure_problems(self) -> list[str]:
solver = self.pool.Solver()
# This selection matches packages obsoleted by our packages under test.
obs_sel = self._select_obsoleted_by(self.solvables)
# This selection matches packages obsoleted by other existing packages in the repo.
# This selection matches packages obsoleted
# by other existing packages in the repo.
existing_obs_sel = self._select_obsoleted_by(
s for s in self.pool.solvables if s.repo.name != "@commandline"
)
Expand Down Expand Up @@ -491,11 +494,13 @@ def find_upgrade_problems(self) -> list[str]:
continue # it's kept, so no problem here
if action == transaction.SOLVER_TRANSACTION_UPGRADED:
problems.append(
f"{solvable} would be upgraded by {other} from repo {other.repo.name}"
f"{solvable} would be upgraded by {other} "
f"from repo {other.repo.name}"
)
elif action == transaction.SOLVER_TRANSACTION_OBSOLETED:
problems.append(
f"{solvable} would be obsoleted by {other} from repo {other.repo.name}"
f"{solvable} would be obsoleted by {other} "
f"from repo {other.repo.name}"
)
else:
raise RuntimeError(f"Unrecognised transaction step type {action}")
Expand Down
3 changes: 2 additions & 1 deletion rpmdeplint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def add_common_dependency_analyzer_args(parser):
action="append",
dest="repos",
default=[],
help="Name and optional (baseurl or metalink or local path) of a repo to test against",
help="Name and optional (baseurl or metalink or local path) "
"of a repo to test against",
)
parser.add_argument(
"-R",
Expand Down
21 changes: 12 additions & 9 deletions tests/acceptance/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,18 @@ def cleanUp():
+ [p.get_built_rpm("i386") for p in test_packages]
)
assert exitcode == 3
assert err == (
"Problems with dependency set:\n"
"nothing provides doesnotexist needed by e-1.0-1.i386\n"
"Dependency problems with repos:\n"
"package d-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n"
"Undeclared file conflicts:\n"
"f-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n"
"Upgrade problems:\n"
"a-4.0-1.i386 would be upgraded by a-5.0-1.i386 from repo base\n"
assert (
err
== (
"Problems with dependency set:\n"
"nothing provides doesnotexist needed by e-1.0-1.i386\n"
"Dependency problems with repos:\n"
"package d-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n" # noqa: E501
"Undeclared file conflicts:\n"
"f-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"Upgrade problems:\n"
"a-4.0-1.i386 would be upgraded by a-5.0-1.i386 from repo base\n"
)
)


Expand Down
34 changes: 19 additions & 15 deletions tests/acceptance/test_check_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def cleanUp():
assert exitcode == 3
assert err == (
"Undeclared file conflicts:\n"
"a-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n"
"a-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
)


Expand Down Expand Up @@ -87,7 +87,7 @@ def cleanUp():
assert exitcode == 3
assert err == (
"Undeclared file conflicts:\n"
"a-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n"
"a-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
)


Expand Down Expand Up @@ -258,17 +258,20 @@ def cleanUp():
]
)
assert exitcode == 3
assert err == (
"Undeclared file conflicts:\n"
"x-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n"
"x-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n"
"x-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n"
"y-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n"
"y-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n"
"y-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n"
"z-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n"
"z-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n"
"z-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n"
assert (
err
== (
"Undeclared file conflicts:\n"
"x-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"x-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n" # noqa: E501
"x-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n" # noqa: E501
"y-0.1-1.i386 provides /usr/share/thing which is also provided by z-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by b-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by x-0.1-1.i386\n" # noqa: E501
"z-0.1-1.i386 provides /usr/share/thing which is also provided by y-0.1-1.i386\n" # noqa: E501
)
)


Expand Down Expand Up @@ -343,7 +346,7 @@ def cleanUp():
assert exitcode == 3
assert err == (
"Undeclared file conflicts:\n"
"b-0.1-1.i386 provides /usr/share/thing which is also provided by a-0.1-1.x86_64\n"
"b-0.1-1.i386 provides /usr/share/thing which is also provided by a-0.1-1.x86_64\n" # noqa: E501
)


Expand Down Expand Up @@ -399,7 +402,8 @@ def test_finds_conflicts_in_installonly_packages(request, dir_server):
installPath="usr/share/licenses/kernel-core/COPYING",
sourceFile=SourceFile("COPYING", "content\n"),
)
# The modern mechanism for telling DNF a package is installonly is to add this virtual provide.
# The modern mechanism for telling DNF a package is installonly
# is to add this virtual provide.
kernel1.add_provides("installonlypkg(kernel)")
baserepo = YumRepoBuild([kernel1])
baserepo.make("i386")
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/test_check_repoclosure.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def cleanUp():
assert exitcode == 3
assert err == (
"Dependency problems with repos:\n"
"package b-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n"
"package b-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n" # noqa: E501
)


Expand Down Expand Up @@ -84,7 +84,7 @@ def cleanUp():
assert exitcode == 3
assert err == (
"Dependency problems with repos:\n"
"package b-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n"
"package b-0.1-1.i386 requires libfoo.so.4, but none of the providers can be installed\n" # noqa: E501
)


Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/test_check_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def cleanUp():
assert exitcode == 3
assert (
err
== "Problems with dependency set:\nnothing provides doesnotexist needed by a-0.1-1.i386\n"
== "Problems with dependency set:\nnothing provides doesnotexist needed by a-0.1-1.i386\n" # noqa: E501
)
assert out == ""

Expand Down

0 comments on commit 6c4dac4

Please sign in to comment.