summaryrefslogtreecommitdiffstats
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-05 13:53:23 (EDT)
commit642d138526654c4e7f3366e3b9027207a479ce91 (patch)
tree7cbc667d648f9a94fb53ea8f20fab6c25fc93129
parentb3947aab31c9a43b308bd414dfa1ece3fae1d3c9 (diff)
opkg_install_by_name: Support multiarch coinstallationfeature/multiarch-coinstallation-v0.1
-rw-r--r--libopkg/opkg_install.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index f850b4c..fa7e936 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -1184,24 +1184,38 @@ 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_vec = pkg_hash_fetch_installed_by_name_vec(pkg_name);
old = pkg_hash_fetch_installed_by_name(pkg_name);
- if (old)
- opkg_msg(DEBUG2, "Old versions from pkg_hash_fetch %s.\n",
- old->version);
+ if (old_vec) {
+ 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:");
+ if ( old_vec ) {
+ for (i = 0; i < old_vec->len; i++) {
+ if (old_vec->pkgs[i] == NULL) continue;
+ 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 +1235,36 @@ 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) {
- 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);
- return 0;
+ 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;
+ }
+ }
} 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) {
+ 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");