opkg installs a package's pre-dependencies but does not record them
in the package's status file. Due to this, opkg allows uninstallation
of an installed package's pre-dependency when it should complain.
This patch fixes that by adding the pre-depends print to the
package's status file. It also adds the pre-depends print to the
package's status info dump.
Additionally, this patch also adds a missing break in a switch case
while parsing a package's dependencies. This was causing a package's
pre-dependency to be added twice to the solvable, each time with a
different marker.
Given installed packages 'a' and 'b', where 'a'--'pre-depends'-->'b',
the following is the opkg output (after the patch is applied) when
asked to uninstall package 'b' before uninstalling 'a':
DEBUG cmd: /mnt/workspace/src/opkg -o /tmp/opkg --force-postinstall remove b
DEBUG stdout: * Solver encountered 1 problem(s):
* Problem 1/1:
* - package a-1.0.all requires b, but none of the providers can be installed
* - conflicting requests
* - problem with installed package a-1.0.all
*
* Solution 1:
* - allow deinstallation of a-1.0.all
* Solution 2:
* - do not ask to deinstall b
* - do not ask to deinstall b
Signed-off-by: Shruthi Ravichandran <
shruthi.ra...@ni.com>
---
libopkg/pkg.c | 19 ++++++++++++++++++-
libopkg/solvers/libsolv/opkg_solver_libsolv.c | 1 +
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index db10ccf..88012fa 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -711,7 +711,22 @@ static void pkg_formatted_field(FILE * fp, pkg_t * pkg, const char *field, const
}
fprintf(fp, "\n");
}
- } else {
+ }
+ else if (strcasecmp(field, "Pre-Depends") == 0) {
+ if (pkg->pre_depends_count) {
+ fprintf(fp, "Pre-Depends:");
+ for (j = 0, i = 0; i < depends_count; i++) {
+ if (pkg->depends[i].type != PREDEPEND)
+ continue;
+ str = pkg_depend_str(pkg, i);
+ fprintf(fp, "%s %s", j == 0 ? "" : ",", str);
+ free(str);
+ j++;
+ }
+ fprintf(fp, "\n");
+ }
+ }
+ else {
goto UNKNOWN_FMT_FIELD;
}
break;
@@ -858,6 +873,7 @@ void pkg_formatted_info(FILE * fp, pkg_t * pkg, const char *fields_filter)
pkg_formatted_field(fp, pkg, "Package", NULL);
pkg_formatted_field(fp, pkg, "Version", fields_filter);
pkg_formatted_field(fp, pkg, "Depends", fields_filter);
+ pkg_formatted_field(fp, pkg, "Pre-Depends", fields_filter);
pkg_formatted_field(fp, pkg, "Recommends", fields_filter);
pkg_formatted_field(fp, pkg, "Suggests", fields_filter);
pkg_formatted_field(fp, pkg, "Provides", fields_filter);
@@ -896,6 +912,7 @@ void pkg_print_status(pkg_t * pkg, FILE * file)
pkg_formatted_field(file, pkg, "Package", NULL);
pkg_formatted_field(file, pkg, "Version", NULL);
pkg_formatted_field(file, pkg, "Depends", NULL);
+ pkg_formatted_field(file, pkg, "Pre-Depends", NULL);
pkg_formatted_field(file, pkg, "Recommends", NULL);
pkg_formatted_field(file, pkg, "Suggests", NULL);
pkg_formatted_field(file, pkg, "Provides", NULL);
diff --git a/libopkg/solvers/libsolv/opkg_solver_libsolv.c b/libopkg/solvers/libsolv/opkg_solver_libsolv.c
index d442d3d..936bea7 100644
--- a/libopkg/solvers/libsolv/opkg_solver_libsolv.c
+++ b/libopkg/solvers/libsolv/opkg_solver_libsolv.c
@@ -416,6 +416,7 @@ static void pkg2solvable(pkg_t *pkg, Solvable *solvable_out, int installed)
solvable_out->requires = repo_addid_dep(repo,
solvable_out->requires, dependId,
SOLVABLE_PREREQMARKER);
+ break;
case DEPEND:
opkg_msg(DEBUG2, "%s depends %s\n", pkg->name,
pool_dep2str(pool, dependId));
--
2.20.1