summaryrefslogtreecommitdiffstats
path: root/libopkg
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-07-05 13:50:41 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-07-06 14:57:54 (EDT)
commitbf1876555b4149c335a1d7f3e8a419c562f774bc (patch)
treef79139061170a1d0eeb07ff2b46430a83a903672 /libopkg
parentbcffa93c4be3ea93d3126cca608e7dc0dcbdca6a (diff)
opkg_install_by_name: Support multiarch coinstallationfeature/multiarch-coinstallation
Signed-off-by: P. J. McDermott <pj@pehjota.net>
Diffstat (limited to 'libopkg')
-rw-r--r--libopkg/opkg_install.c52
1 files changed, 43 insertions, 9 deletions
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index f850b4c..66ad211 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -1184,24 +1184,33 @@ int
opkg_install_by_name(const char *pkg_name)
{
int cmp;
+ pkg_vec_t *old_vec;
pkg_t *old, *new;
char *old_version, *new_version;
+ int i;
- old = pkg_hash_fetch_installed_by_name(pkg_name);
- if (old)
- opkg_msg(DEBUG2, "Old versions from pkg_hash_fetch %s.\n",
- old->version);
+ old_vec = pkg_hash_fetch_installed_by_name_vec(pkg_name);
+ old = (old_vec->len > 0) ? old_vec->pkgs[0] : NULL;
+ for (i = 0; i < old_vec->len; i++) {
+ if (old_vec->pkgs[i] == NULL) continue;
+ opkg_msg(DEBUG2, "Old versions/arches from pkg_hash_fetch %s/%s.\n",
+ old_vec->pkgs[i]->version,
+ old_vec->pkgs[i]->architecture);
+ }
new = pkg_hash_fetch_best_installation_candidate_by_name(pkg_name);
if (new == NULL) {
opkg_msg(NOTICE, "Unknown package '%s'.\n", pkg_name);
+ pkg_vec_free(old_vec);
return -1;
}
- opkg_msg(DEBUG2, "Versions from pkg_hash_fetch:");
- if ( old )
- opkg_message(DEBUG2, " old %s ", old->version);
- opkg_message(DEBUG2, " new %s\n", new->version);
+ opkg_msg(DEBUG2, "Versions/arches from pkg_hash_fetch:");
+ for (i = 0; i < old_vec->len; i++) {
+ opkg_message(DEBUG2, " old %s/%s ", old_vec->pkgs[i]->version,
+ old_vec->pkgs[i]->architecture);
+ }
+ opkg_message(DEBUG2, " new %s/%s\n", new->version, new->architecture);
new->state_flag |= SF_USER;
if (old) {
@@ -1221,25 +1230,50 @@ opkg_install_by_name(const char *pkg_name)
"\n\t%d was comparison result\n",
pkg_name, old_version, new_version, cmp);
if (cmp == 0) {
+#ifdef HAVE_MULTIARCH
+ for (i = 0; i < old_vec->len; i++) {
+ if (strcmp(new->architecture, old_vec->pkgs[i]->architecture) == 0) {
+ opkg_msg(NOTICE,
+ "Package %s:%s (%s) installed in %s is up to date.\n",
+ old->name, old_vec->pkgs[i]->architecture, old_version, old->dest->name);
+ free(old_version);
+ free(new_version);
+ pkg_vec_free(old_vec);
+ return 0;
+ }
+ }
+ new->dest = old->dest;
+#else
opkg_msg(NOTICE,
"Package %s (%s) installed in %s is up to date.\n",
old->name, old_version, old->dest->name);
free(old_version);
free(new_version);
+ pkg_vec_free(old_vec);
return 0;
+#endif
} else if (cmp > 0) {
opkg_msg(NOTICE,
"Not downgrading package %s on %s from %s to %s.\n",
old->name, old->dest->name, old_version, new_version);
free(old_version);
free(new_version);
+ pkg_vec_free(old_vec);
return 0;
} else if (cmp < 0) {
new->dest = old->dest;
- old->state_want = SW_DEINSTALL;
+ for (i = 0; i < old_vec->len; i++) {
+ if (strcmp(new->architecture, old_vec->pkgs[i]->architecture) == 0) {
+ /* TODO: This needs to add a compound_depend_t with
+ * version and architecture restrictions to
+ * new->depends. */
+ old_vec->pkgs[i]->state_want = SW_DEINSTALL;
+ }
+ }
}
free(old_version);
free(new_version);
+ pkg_vec_free(old_vec);
}
opkg_msg(DEBUG2,"Calling opkg_install_pkg.\n");