diff options
-rw-r--r-- | libopkg/opkg_install.c | 52 |
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"); |