[PATCH 2/3] opkg_solver_libsolv: blacklist excluded packages instead of ignoring them

3 views
Skip to first unread message

Brandon Streiff

unread,
Jul 13, 2021, 2:39:19 PM7/13/21
to opkg-...@googlegroups.com, Brandon Streiff
Currently, packages specified with --add-exclude aren't registered at all
with libsolv. Because as far as libsolv is concerned they don't exist, if
an installation requires an excluded package, you get a less-than-ideal
message that "nothing provides" the excluded package.

Instead of pretending that they don't exist, instead utilize libsolv's
recent support for "blacklisted" packages. This changes the error output
to indicate that the excluded package "can only be installed by a direct
request"

Signed-off-by: Brandon Streiff <brandon...@ni.com>
---
libopkg/solvers/libsolv/opkg_solver_libsolv.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libopkg/solvers/libsolv/opkg_solver_libsolv.c b/libopkg/solvers/libsolv/opkg_solver_libsolv.c
index 941c1e3..a343033 100644
--- a/libopkg/solvers/libsolv/opkg_solver_libsolv.c
+++ b/libopkg/solvers/libsolv/opkg_solver_libsolv.c
@@ -567,10 +567,6 @@ static void populate_available_repos(libsolv_solver_t *libsolv_solver)
for (i = 0; i < available_pkgs->len; i++) {
pkg_t *pkg = available_pkgs->pkgs[i];

- /* if the package is marked as excluded, skip it */
- if (str_list_contains(&opkg_config->exclude_list, pkg->name, 1))
- continue;
-
/* if the package is installed or unpacked, skip it */
if (pkg->state_status == SS_INSTALLED ||
pkg->state_status == SS_UNPACKED ||
@@ -636,6 +632,15 @@ static void populate_available_repos(libsolv_solver_t *libsolv_solver)
| SOLVER_DISFAVOR, what);
}

+ /* if the package is marked as excluded, blacklist it */
+ if (str_list_contains(&opkg_config->exclude_list, pkg->name, 1)) {
+ opkg_message(DEBUG2, "Blacklist package due to exclusion: %s\n",
+ pkg->name);
+ what = pool_str2id(libsolv_solver->pool, pkg->name, 1);
+ queue_push2(&libsolv_solver->solver_jobs, SOLVER_SOLVABLE_NAME
+ | SOLVER_BLACKLIST, what);
+ }
+
/* if the --force-depends option is specified make dependencies weak */
if (opkg_config->force_depends)
queue_push2(&libsolv_solver->solver_jobs, SOLVER_SOLVABLE
--
2.20.1

Brandon Streiff

unread,
Jul 13, 2021, 2:39:19 PM7/13/21
to opkg-...@googlegroups.com, Brandon Streiff
When using the libsolv implementation, the current approach with the
--add-exclude option is to simply not tell libsolv about the packages
that have been excluded. This achieves the desired result, but gives
an error that is no different from the excluded package being typoed
or completely nonexistant:

Solver encountered 1 problem(s):
Problem 1/1:
- conflicting requests
- nothing provides <excludedpkg> needed by <pkg>-1.0.all

Solution 1:
- do not ask to install a package providing <pkg>

In cases where the end user is quite a distance from the opkg CLI (for
example, if it is specified by a PACKAGE_EXCLUDE in a recipe in
OpenEmbedded), the user may not be aware that it has been excluded.

libsolv supports the notion of "blacklisted" dependencies; by adding
opkg-excluded packages as blacklisted, we get error output from libsolv
that acknowledges that the excluded package does exist but is prevented
from installation.

Solver encountered 1 problem(s):
Problem 1/1:
- package <pkg>-1.0.all requires <excludedpkg>, but none of the
providers can be installed
- package <excludedpkg>-1.0.all can only be installed by a direct
request
- conflicting requests

Solution 1:
- install <excludedpkg>-1.0.all

Solution 2:
- do not ask to install a package providing <pkg>

"installed by a direct request" is still not the most ideal message for
this situation, but it does make clear that opkg/libsolv is aware of the
package in question and that its installation is inhibited.

This patch set implements support for using libsolv's blacklist feature.

Brandon Streiff (3):
configure.ac: update minimum required libsolv version
opkg_solver_libsolv: blacklist excluded packages instead of ignoring
them
tests: expand the 'exclude' test to look at the error message

configure.ac | 2 +-
libopkg/solvers/libsolv/opkg_solver_libsolv.c | 13 +++++++++----
tests/core/20_exclude.py | 15 +++++++++++++++
3 files changed, 25 insertions(+), 5 deletions(-)

--
2.20.1

Brandon Streiff

unread,
Jul 13, 2021, 2:39:19 PM7/13/21
to opkg-...@googlegroups.com, Brandon Streiff
When excluding a package that is required for installation, the error
output should give a reasonable message indicating the excluded
package. Add a check for this in the 'exclude' test.

Signed-off-by: Brandon Streiff <brandon...@ni.com>
---
tests/core/20_exclude.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/tests/core/20_exclude.py b/tests/core/20_exclude.py
index 92ef3d5..fd85eb4 100755
--- a/tests/core/20_exclude.py
+++ b/tests/core/20_exclude.py
@@ -7,10 +7,14 @@
#

import os
+import re
import opk, cfg, opkgcl

opk.regress_init()

+_, version = opkgcl.opkgcl("--version")
+libsolv = True if "libsolv" in version else False
+
o = opk.OpkGroup()
o.add(Package="a1")
o.add(Package="b", Recommends="a1, a2")
@@ -37,6 +41,17 @@ if opkgcl.is_installed("a1"):
if opkgcl.is_installed("c"):
opk.fail("Package 'c' installed despite required package being excluded.")

+# Re-do 'c' install, but capture stdout this time to make sure that we have a
+# message indicating that 'a1' being excluded is preventing 'c' installation.
+# The solvers indicate this case with different messages.
+status, stdout = opkgcl.opkgcl("--force-postinstall install c --add-exclude a1")
+if libsolv:
+ if not re.search(r"package a1-([^ ]*) can only be installed by a direct request", stdout):
+ opk.fail("[libsolv] Package 'c' install should indicate 'a1' only installable by direct request")
+else:
+ if not re.search(r"exclude required package a1 at users request", stdout):
+ opk.fail("[internalsolv] Package 'c' install should indicate 'a1' was excluded")
+
opkgcl.install("b", "--add-exclude 'a*'")
if not opkgcl.is_installed("b"):
opk.fail("Package 'b' not installed, excluded pacakge was only a recommendation.")
--
2.20.1

Brandon Streiff

unread,
Jul 13, 2021, 2:39:19 PM7/13/21
to opkg-...@googlegroups.com, Brandon Streiff
libsolv 0.7.8 adds support for blacklisted packages (with 0.7.14
expanding that support), which allow us to specify package exclusions
in such a way that libsolv can report on them.

Signed-off-by: Brandon Streiff <brandon...@ni.com>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index c608182..e4aaeff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -191,7 +191,7 @@ if test "x$with_libsolv" != "xno"; then

AC_MSG_CHECKING([for solver])
AC_MSG_RESULT(libsolv)
- PKG_CHECK_MODULES(SOLVER, [libsolv >= 0.6.25])
+ PKG_CHECK_MODULES(SOLVER, [libsolv >= 0.7.14])
AC_DEFINE(HAVE_SOLVER_LIBSOLV,1,[Define if you want to use libsolv])
AC_SUBST(SOLVER_CFLAGS)
AC_SUBST(SOLVER_LIBS)
--
2.20.1

Alex Stewart

unread,
Jul 13, 2021, 4:07:56 PM7/13/21
to opkg-...@googlegroups.com, Brandon Streiff
Looks good to me. And thanks for updating the tests.

I'll pull tomorrow, unless there are other objections.

Thanks,
Alex Stewart
Software Engineer - NI Real-Time OS
NI (National Instruments)

alex.s...@ni.com

Alex Stewart

unread,
Jul 14, 2021, 12:36:28 PM7/14/21
to opkg-...@googlegroups.com, Brandon Streiff
Merged to master, beginning with commit
25fa52ee009ecb4e80c1a3dbdbe0e8e08db9ff90.

https://git.yoctoproject.org/cgit/cgit.cgi/opkg/commit/?id=25fa52ee009ecb4e80c1a3dbdbe0e8e08db9ff90

Thanks,

On 7/13/21 1:38 PM, Brandon Streiff wrote:
Reply all
Reply to author
Forward
0 new messages