#include "hash_table.h"
#include "libbb/libbb.h"
-static int parseDepends(compound_depend_t * compound_depend, char *depend_str);
+static int parseDepends(compound_depend_t * compound_depend, char *depend_str, enum depend_type type);
static depend_t *depend_init(void);
static char **add_unresolved_dep(pkg_t * pkg, char **the_lost, int ref_ndx);
static char **merge_unresolved(char **oldstuff, char **newstuff);
the_lost = NULL;
/* foreach dependency */
- for (; compound_depend && compound_depend->type; compound_depend++) {
+ for (i = 0; compound_depend && compound_depend->type; compound_depend++, i++) {
depend_t **possible_satisfiers =
compound_depend->possibilities;;
found = 0;
int i;
char *arch1, *arch2;
pkg_t **pkgs = vec->pkgs;
- arch1 = pkg_get_string(pkg, PKG_ARCHITECTURE);
+ arch1 = pkg_get_architecture(pkg);
for (i = 0; i < vec->len; i++) {
- arch2 = pkg_get_string(*(pkgs + i), PKG_ARCHITECTURE);
+ arch2 = pkg_get_architecture(*(pkgs + i));
if ((strcmp(pkg->name, (*(pkgs + i))->name) == 0)
&& (pkg_compare_versions(pkg, *(pkgs + i)) == 0)
return resized;
}
+static void flag_related_packages(pkg_t *pkg, int state_flags)
+{
+ int i, j;
+ compound_depend_t *deps;
+
+ for (deps = pkg_get_ptr(pkg, PKG_DEPENDS), i = 0; deps && deps[i].type; i++)
+ for (j = 0; j < deps[i].possibility_count; j++) {
+ if ((deps[i].possibilities[j]->pkg->state_flag & state_flags) != state_flags) {
+ opkg_msg(DEBUG, "propagating pkg flag to dependent abpkg %s\n",
+ deps[i].possibilities[j]->pkg->name);
+ deps[i].possibilities[j]->pkg->state_flag |= state_flags;
+ }
+ }
+
+ for (deps = pkg_get_ptr(pkg, PKG_CONFLICTS), i = 0; deps && deps[i].type; i++)
+ for (j = 0; j < deps[i].possibility_count; j++) {
+ if ((deps[i].possibilities[j]->pkg->state_flag & state_flags) != state_flags) {
+ opkg_msg(DEBUG, "propagating pkg flag to conflicting abpkg %s\n",
+ deps[i].possibilities[j]->pkg->name);
+ deps[i].possibilities[j]->pkg->state_flag |= state_flags;
+ }
+ }
+}
+
abstract_pkg_t **init_providelist(pkg_t *pkg, int *count)
{
abstract_pkg_t *ab_pkg;
if (!ab_pkg->pkgs)
ab_pkg->pkgs = pkg_vec_alloc();
- abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
+ if (!abstract_pkg_vec_contains(ab_pkg->provided_by, ab_pkg))
+ abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
provides[0] = ab_pkg;
provides[1] = NULL;
pkg_set_ptr(pkg, PKG_PROVIDES, provides);
}
else if (count) {
- for (*count = 1; *provides; provides++)
+ for (*count = 1; *provides; provides++) {
+ if (pkg->state_flag & SF_NEED_DETAIL) {
+ if (!((*provides)->state_flag & SF_NEED_DETAIL)) {
+ opkg_msg(DEBUG, "propagating pkg flag to provided abpkg %s\n",
+ (*provides)->name);
+ (*provides)->state_flag |= SF_NEED_DETAIL;
+ }
+ }
(*count)++;
+ }
}
+ flag_related_packages(pkg, SF_NEED_DETAIL);
+
return provides;
}
provided_abpkg = ensure_abstract_pkg_by_name(item);
- abstract_pkg_vec_insert(provided_abpkg->provided_by, ab_pkg);
+ if (!abstract_pkg_vec_contains(provided_abpkg->provided_by, ab_pkg))
+ abstract_pkg_vec_insert(provided_abpkg->provided_by, ab_pkg);
provides = tmp;
provides[count - 1] = provided_abpkg;
old_abpkg = ensure_abstract_pkg_by_name(item);
+ if (pkg->state_flag & SF_NEED_DETAIL) {
+ if (!(old_abpkg->state_flag & SF_NEED_DETAIL)) {
+ opkg_msg(DEBUG, "propagating pkg flag to replaced abpkg %s\n",
+ old_abpkg->name);
+ old_abpkg->state_flag |= SF_NEED_DETAIL;
+ }
+ }
+
if (!old_abpkg->replaced_by)
old_abpkg->replaced_by = abstract_pkg_vec_alloc();
deps = tmp;
memset(deps + count - 1, 0, sizeof(compound_depend_t));
- parseDepends(deps + count - 1, item);
-
- deps[count - 1].type = type;
+ parseDepends(deps + count - 1, item, type);
}
if (!deps)
return d;
}
-static int parseDepends(compound_depend_t * compound_depend, char *depend_str)
+static int parseDepends(compound_depend_t * compound_depend, char *depend_str, enum depend_type type)
{
int i;
char *depend, *name, *vstr, *rest, *tok = NULL;
depend_t **possibilities = NULL, **tmp;
- compound_depend->type = DEPEND;
+ compound_depend->type = type;
for (i = 0, depend = strtok_r(depend_str, "|", &tok); depend; i++, depend = strtok_r(NULL, "|", &tok)) {
name = strtok(depend, " ");