+ int count = 0;
+ char *item, *tok;
+ abstract_pkg_t *ab_pkg, *provided_abpkg, **tmp, **provides;
+
+ provides = init_providelist(pkg, &count);
+ ab_pkg = ensure_abstract_pkg_by_name(pkg->name);
+
+ if (!provides || !ab_pkg)
+ return;
+
+ for (item = strtok_r(list, ", ", &tok); item;
+ count++, item = strtok_r(NULL, ", ", &tok)) {
+ tmp = realloc(provides, sizeof(abstract_pkg_t *) * (count + 1));
+
+ if (!tmp)
+ break;
+
+ provided_abpkg = ensure_abstract_pkg_by_name(item);
+
+ 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;
+ }
+
+ provides[count - 1] = NULL;
+
+ pkg_set_ptr(pkg, PKG_PROVIDES, provides);
+}
+
+void parse_replacelist(pkg_t *pkg, char *list)
+{
+ int count;
+ char *item, *tok;
+ abstract_pkg_t *ab_pkg, *old_abpkg, **tmp, **replaces = NULL;
+
+ ab_pkg = ensure_abstract_pkg_by_name(pkg->name);
+
+ if (!ab_pkg->pkgs)
+ ab_pkg->pkgs = pkg_vec_alloc();
+
+ abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
+
+ for (count = 1, item = strtok_r(list, ", ", &tok);
+ item;
+ count++, item = strtok_r(NULL, ", ", &tok), count++) {
+ tmp = realloc(replaces, sizeof(abstract_pkg_t *) * (count + 1));
+
+ if (!tmp)
+ break;
+
+ 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();
+
+ /* if a package pkg both replaces and conflicts old_abpkg,
+ * then add it to the replaced_by vector so that old_abpkg
+ * will be upgraded to ab_pkg automatically */
+ if (pkg_conflicts_abstract(pkg, old_abpkg))
+ abstract_pkg_vec_insert(old_abpkg->replaced_by, ab_pkg);
+
+ replaces = tmp;
+ replaces[count - 1] = old_abpkg;
+ }
+
+ if (!replaces)
+ return;
+
+ replaces[count - 1] = NULL;
+
+ pkg_set_ptr(pkg, PKG_REPLACES, replaces);
+}
+
+void buildProvides(abstract_pkg_t * ab_pkg, pkg_t * pkg)
+{
+#if 0
+ int i;
+
+ /* every pkg provides itself */
+ pkg->provides_count++;
+ abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
+ pkg->provides = xcalloc(pkg->provides_count, sizeof(abstract_pkg_t *));
+ pkg->provides[0] = ab_pkg;
+ for (i = 1; i < pkg->provides_count; i++) {
+ abstract_pkg_t *provided_abpkg =
+ ensure_abstract_pkg_by_name(pkg->provides_str[i - 1]);
+ free(pkg->provides_str[i - 1]);
+
+ pkg->provides[i] = provided_abpkg;
+
+ abstract_pkg_vec_insert(provided_abpkg->provided_by, ab_pkg);
+ }
+ if (pkg->provides_str)
+ free(pkg->provides_str);
+#endif
+}
+
+void buildConflicts(pkg_t * pkg)
+{
+ /*
+ int i;
+ compound_depend_t *conflicts, *conflict;
+
+ if (!pkg->conflicts_count)
+ return;
+
+ conflicts = pkg->conflicts =
+ xcalloc(pkg->conflicts_count, sizeof(compound_depend_t));
+ for (i = 0; i < pkg->conflicts_count; i++) {
+ conflicts->type = CONFLICTS;
+ parseDepends(conflicts, pkg->conflicts_str[i]);
+ free(pkg->conflicts_str[i]);
+ conflicts++;
+ }
+ if (pkg->conflicts_str)
+ free(pkg->conflicts_str);
+ */
+}
+
+void buildReplaces(abstract_pkg_t * ab_pkg, pkg_t * pkg)
+{
+#if 0
+ int i;
+
+ if (!pkg->replaces_count)
+ return;
+
+ pkg->replaces = xcalloc(pkg->replaces_count, sizeof(abstract_pkg_t *));
+
+ for (i = 0; i < pkg->replaces_count; i++) {
+ abstract_pkg_t *old_abpkg =
+ ensure_abstract_pkg_by_name(pkg->replaces_str[i]);
+
+ pkg->replaces[i] = old_abpkg;
+ free(pkg->replaces_str[i]);
+
+ if (!old_abpkg->replaced_by)
+ old_abpkg->replaced_by = abstract_pkg_vec_alloc();
+ /* if a package pkg both replaces and conflicts old_abpkg,
+ * then add it to the replaced_by vector so that old_abpkg
+ * will be upgraded to ab_pkg automatically */
+ if (pkg_conflicts_abstract(pkg, old_abpkg))
+ abstract_pkg_vec_insert(old_abpkg->replaced_by, ab_pkg);
+ }
+
+ if (pkg->replaces_str)
+ free(pkg->replaces_str);
+#endif