Skip to content

Commit

Permalink
Add prereq_ignoreinst & regular_requires properties for pkg (RhBug:15…
Browse files Browse the repository at this point in the history
…43449)

Property prereq_ignoreinst of an installed pkg is used
by dnf check --dependencies to get which requires_pre are safe
to ignore (remove) after installation without breaking
dependencies (its %pre and %post dependencies that are not
used in %postun nor %preun).

Property regular_requires is also needed for check --dependencies,
these are requires without (%pre, %post, %postun, %preun).
This is needed because any require returned from prereq_ignoreinst
can be marked as safe to remove, but this is only valid in the
context of requires_pre, the same require may be needed in regular
requires, so it cannot be safely removed. Already present
dnf_package_get_requires cannot be used because it merges
regular_requires + requires_pre and therefore its not clear
whether the output from prereq_ignoreinst can be applied to any
specific require.

https://bugzilla.redhat.com/show_bug.cgi?id=1543449
  • Loading branch information
kontura authored and j-mracek committed Mar 5, 2020
1 parent b4c8d7a commit ddf5adf
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set (DEFAULT_LIBDNF_MAJOR_VERSION 0)
set (DEFAULT_LIBDNF_MINOR_VERSION 45)
set (DEFAULT_LIBDNF_MICRO_VERSION 0)
set (DEFAULT_LIBDNF_MICRO_VERSION 1)

if(DEFINED LIBDNF_MAJOR_VERSION)
if(NOT ${DEFAULT_LIBDNF_MAJOR_VERSION} STREQUAL ${LIBDNF_MAJOR_VERSION})
Expand Down
2 changes: 1 addition & 1 deletion libdnf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%global swig_version 3.0.12
%global libdnf_major_version 0
%global libdnf_minor_version 45
%global libdnf_micro_version 0
%global libdnf_micro_version 1

# set sphinx package name according to distro
%global requires_python2_sphinx python2-sphinx
Expand Down
45 changes: 43 additions & 2 deletions libdnf/hy-package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,14 +854,19 @@ dnf_package_get_recommends(DnfPackage *pkg)
DnfReldepList *
dnf_package_get_requires(DnfPackage *pkg)
{
return reldeps_for(pkg, SOLVABLE_REQUIRES);

DnfReldepList * l = reldeps_for(pkg, SOLVABLE_REQUIRES);
l->extend(reldeps_for(pkg, SOLVABLE_PREREQMARKER));
return l;
}

/**
* dnf_package_get_requires_pre:
* @pkg: a #DnfPackage instance.
*
* Gets the Requires(pre) for the package.
* If the package is not installed gets the Requires(pre) and Requires(post).
* If the package is installed it gets Requires(pre), Requires(post),
* Requies(preun) and Requires(postun).
*
* Returns: A #DnfReldepList
*
Expand Down Expand Up @@ -905,6 +910,42 @@ dnf_package_get_supplements(DnfPackage *pkg)
return reldeps_for(pkg, SOLVABLE_SUPPLEMENTS);
}

/**
* dnf_package_get_prereq_ignoreinst
* @pkg: a #DnfPackage instance.
*
* Returns safe to remove Requires(pre) and Requires(post) dependencies
* of the package. Safe to remove means that the dependency is not needed by
* Requires(preun) nor by Requires(postun).
* The package must be installed otherwise empty list is returned.
*
* Returns: A #DnfReldepList
*
* Since: 0.45.1
*/
DnfReldepList *
dnf_package_get_prereq_ignoreinst(DnfPackage *pkg)
{
return reldeps_for(pkg, SOLVABLE_PREREQ_IGNOREINST);
}

/**
* dnf_package_get_regular_requires
* @pkg: a #DnfPackage instance.
*
* Get the requires for the package without Requires(pre), Requires(post)
* Requires(preun) and Requires(postun).
*
* Returns: A #DnfReldepList
*
* Since: 0.45.1
*/
DnfReldepList *
dnf_package_get_regular_requires(DnfPackage *pkg)
{
return reldeps_for(pkg, SOLVABLE_REQUIRES);
}

/**
* dnf_package_get_files:
* @pkg: a #DnfPackage instance.
Expand Down
2 changes: 2 additions & 0 deletions libdnf/hy-package.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ DnfReldepList *dnf_package_get_requires (DnfPackage *pkg);
DnfReldepList *dnf_package_get_requires_pre (DnfPackage *pkg);
DnfReldepList *dnf_package_get_suggests (DnfPackage *pkg);
DnfReldepList *dnf_package_get_supplements (DnfPackage *pkg);
DnfReldepList *dnf_package_get_prereq_ignoreinst(DnfPackage *pkg);
DnfReldepList *dnf_package_get_regular_requires(DnfPackage *pkg);
char **dnf_package_get_files (DnfPackage *pkg);
GPtrArray *dnf_package_get_advisories (DnfPackage *pkg, int cmp_type);

Expand Down
4 changes: 4 additions & 0 deletions python/hawkey/package-py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ static PyGetSetDef package_getsetters[] = {
(void *)dnf_package_get_suggests},
{(char*)"supplements", (getter)get_reldep, NULL, NULL,
(void *)dnf_package_get_supplements},
{(char*)"prereq_ignoreinst", (getter)get_reldep, NULL, NULL,
(void *)dnf_package_get_prereq_ignoreinst},
{(char*)"regular_requires", (getter)get_reldep, NULL, NULL,
(void *)dnf_package_get_regular_requires},
{NULL} /* sentinel */
};

Expand Down

0 comments on commit ddf5adf

Please sign in to comment.