summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-03-01 07:03:05 +0000
committerAaron Griffin <aaron@archlinux.org>2007-03-01 07:03:05 +0000
commit3ebd125e1ad9abbf5fbcb4457adb8288750b379e (patch)
tree04e93b6896fd61d86bca280af0ac8bb5448c08a2 /lib/libalpm/add.c
parent6075b677fcdeccf2b39ebbd4a089b4ebe016a62e (diff)
downloadpacman-3ebd125e1ad9abbf5fbcb4457adb8288750b379e.tar.xz
* Switched some functions to alpm_pkg_get_* usage as I came across them
* Added some provision switching hackery. This could probably use some refactoring,.. it solves the following case: pkg1 and pkg2 provide 'foo' and are both installed pkg3 depends on 'foo' and so lists 'pkg1' in the REQUIREDBY db section pkg1 is upgraded and no longer provides 'foo' ** This code ensures that the REQUIREDBY of pkg3 is updated to require pkg2 now instead of pkg1
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 2e40c98e..220c1d8a 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -343,6 +343,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
oldpkg = _alpm_pkg_new(local->name, local->version);
if(oldpkg) {
oldpkg->backup = alpm_list_strdup(alpm_pkg_get_backup(local));
+ oldpkg->provides = alpm_list_strdup(alpm_pkg_get_provides(local));
strncpy(oldpkg->name, local->name, PKG_NAME_LEN);
strncpy(oldpkg->version, local->version, PKG_VERSION_LEN);
} else {
@@ -749,6 +750,35 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
* looking for packages depending on the package to add */
_alpm_pkg_update_requiredby(newpkg);
+ /* special case: if our provides list has changed from oldpkg to newpkg AND
+ * we get here, we need to make sure we find the actual provision that
+ * still satisfies this case, and update its 'requiredby' field... ugh */
+ alpm_list_t *provdiff, *prov;
+ provdiff = alpm_list_diff(alpm_pkg_get_provides(oldpkg),
+ alpm_pkg_get_provides(newpkg),
+ _alpm_str_cmp);
+ for(prov = provdiff; prov; prov = prov->next) {
+ const char *provname = prov->data;
+ _alpm_log(PM_LOG_DEBUG, _("provision '%s' has been removed from package %s (%s => %s)"),
+ provname, oldpkg->name, oldpkg->version, newpkg->version);
+
+ alpm_list_t *p = _alpm_db_whatprovides(handle->db_local, provname);
+ if(p) {
+ /* we now have all the provisions in the local DB for this virtual
+ * package... seeing as we can't really determine which is the 'correct'
+ * provision, we'll use the FIRST for now.
+ * TODO figure out a way to find a "correct" provision */
+ pmpkg_t *provpkg = p->data;
+ _alpm_log(PM_LOG_DEBUG, _("updating '%s' due to provision change (%s)"), provpkg->name, provname);
+ _alpm_pkg_update_requiredby(provpkg);
+ if(_alpm_db_write(db, provpkg, INFRQ_DEPENDS)) {
+ _alpm_log(PM_LOG_ERROR, _("could not update provision '%s' from '%s'"), provname, provpkg->name);
+ alpm_logaction(_("could not update provision '%s' from '%s'"), provname, provpkg->name);
+ RET_ERR(PM_ERR_DB_WRITE, -1);
+ }
+ }
+ }
+
/* make an install date (in UTC) */
time_t t = time(NULL);
strncpy(newpkg->installdate, asctime(gmtime(&t)), PKG_DATE_LEN);