[pacman-dev] CVS update of pacman-lib/lib/libalpm (6 files)

Aaron Griffin aaron at archlinux.org
Sun Feb 18 17:07:12 EST 2007


    Date: Sunday, February 18, 2007 @ 17:07:12
  Author: aaron
    Path: /home/cvs-pacman/pacman-lib/lib/libalpm

Modified: add.c (1.115 -> 1.116) package.c (1.71 -> 1.72)
          package.h (1.30 -> 1.31) remove.c (1.64 -> 1.65)
          trans.c (1.34 -> 1.35) trans.h (1.22 -> 1.23)

Moved the update_depends function to trans.c, as it depends on a transaction
object


-----------+
 add.c     |    3 -
 package.c |   87 --------------------------------------------------------
 package.h |    1 
 remove.c  |    2 -
 trans.c   |   93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 trans.h   |    1 
 6 files changed, 96 insertions(+), 91 deletions(-)


Index: pacman-lib/lib/libalpm/add.c
diff -u pacman-lib/lib/libalpm/add.c:1.115 pacman-lib/lib/libalpm/add.c:1.116
--- pacman-lib/lib/libalpm/add.c:1.115	Sat Feb 17 03:55:06 2007
+++ pacman-lib/lib/libalpm/add.c	Sun Feb 18 17:07:11 2007
@@ -790,7 +790,6 @@
 		 * looking for packages depending on the package to add */
 		_alpm_pkg_update_requiredby(newpkg);
 
-
 		/* make an install date (in UTC) */
 		time_t t = time(NULL);
 		strncpy(newpkg->installdate, asctime(gmtime(&t)), PKG_DATE_LEN);
@@ -813,7 +812,7 @@
 		}
 
 		/* update dependency packages' REQUIREDBY fields */
-		_alpm_pkg_update_depends(newpkg, 0 /*is an add*/);
+		_alpm_trans_update_depends(trans, newpkg);
 
 		PROGRESS(trans, (is_upgrade ? PM_TRANS_PROGRESS_UPGRADE_START : PM_TRANS_PROGRESS_ADD_START),
 						 newpkg->name, 100, pkg_count, (pkg_count - targ_count +1));
Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.71 pacman-lib/lib/libalpm/package.c:1.72
--- pacman-lib/lib/libalpm/package.c:1.71	Sat Feb 17 03:55:06 2007
+++ pacman-lib/lib/libalpm/package.c	Sun Feb 18 17:07:11 2007
@@ -551,93 +551,6 @@
 	}
 }
 
-void _alpm_pkg_update_depends(pmpkg_t *pkg, int remove)
-{
-	alpm_list_t *i, *j;
-	if(pkg->depends) {
-		_alpm_log(PM_LOG_DEBUG, _("updating dependency packages 'requiredby' fields"));
-	}
-
-	pmdb_t *localdb = alpm_option_get_localdb();
-	for(i = pkg->depends; i; i = i->next) {
-		pmdepend_t dep;
-		if(_alpm_splitdep(i->data, &dep) != 0) {
-			continue;
-		}
-
-		/* XXX: this is a hack...if this dependency is in the transaction targets
-		 * of a remove transaction no need to update its requiredby info:
-		 * it is in the process of being removed (if not already done!) */
-		/* TODO I wonder if we can just skip this, the few extra operations won't be
-		 * a huge deal either way */
-		if(handle->trans && handle->trans->packages
-			 && handle->trans->type == PM_TRANS_TYPE_REMOVE) {
-			if(_alpm_pkg_isin(dep.name, handle->trans->packages)) {
-				continue;
-			}
-		}
-
-		pmpkg_t *deppkg = _alpm_db_get_pkgfromcache(localdb, dep.name);
-		if(!deppkg) {
-			int found_provides = 0;
-			/* look for a provides package */
-			alpm_list_t *provides = _alpm_db_whatprovides(localdb, dep.name);
-			for(j = provides; j; j = j->next) {
-				if(!j->data) {
-					continue;
-				}
-				pmpkg_t *provpkg = j->data;
-				deppkg = _alpm_db_get_pkgfromcache(localdb, provpkg->name);
-
-				if(!deppkg) {
-					continue;
-				}
-
-				found_provides = 1;
-
-				/* Ensure package has the right newpkg */
-				_alpm_db_read(localdb, INFRQ_DEPENDS, deppkg);
-
-				_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), deppkg->name);
-				if(remove) {
-					void *data = NULL;
-					deppkg->requiredby = alpm_list_remove(deppkg->requiredby, pkg->name, _alpm_str_cmp, &data);
-					FREE(data);
-				} else {
-					deppkg->requiredby = alpm_list_add(deppkg->requiredby, strdup(pkg->name));
-				}
-
-				if(_alpm_db_write(localdb, deppkg, INFRQ_DEPENDS)) {
-					_alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"), deppkg->name, deppkg->version);
-				}
-			}
-			FREELISTPTR(provides);
-
-			if(!found_provides) {
-				_alpm_log(PM_LOG_DEBUG, _("could not find dependency '%s'"), dep.name);
-				continue;
-			}
-		}
-
-		/* Ensure package has the right newpkg */
-		_alpm_db_read(localdb, INFRQ_DEPENDS, deppkg);
-
-		_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), deppkg->name);
-		if(remove) {
-			void *data = NULL;
-			deppkg->requiredby = alpm_list_remove(deppkg->requiredby, pkg->name, _alpm_str_cmp, &data);
-			FREE(data);
-		} else {
-			deppkg->requiredby = alpm_list_add(deppkg->requiredby, strdup(pkg->name));
-		}
-
-		if(_alpm_db_write(localdb, deppkg, INFRQ_DEPENDS)) {
-			_alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"), deppkg->name, deppkg->version);
-		}
-	}
-
-}
-
 const char *alpm_pkg_get_filename(pmpkg_t *pkg)
 {
 	ALPM_LOG_FUNC;
Index: pacman-lib/lib/libalpm/package.h
diff -u pacman-lib/lib/libalpm/package.h:1.30 pacman-lib/lib/libalpm/package.h:1.31
--- pacman-lib/lib/libalpm/package.h:1.30	Sat Feb 17 03:55:06 2007
+++ pacman-lib/lib/libalpm/package.h	Sun Feb 18 17:07:11 2007
@@ -108,7 +108,6 @@
 int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch);
 int _alpm_pkg_istoonew(pmpkg_t *pkg);
 void _alpm_pkg_update_requiredby(pmpkg_t *pkg);
-void _alpm_pkg_update_depends(pmpkg_t *pkg, int remove);
 
 #endif /* _ALPM_PACKAGE_H */
 
Index: pacman-lib/lib/libalpm/remove.c
diff -u pacman-lib/lib/libalpm/remove.c:1.64 pacman-lib/lib/libalpm/remove.c:1.65
--- pacman-lib/lib/libalpm/remove.c:1.64	Sat Feb 17 03:55:06 2007
+++ pacman-lib/lib/libalpm/remove.c	Sun Feb 18 17:07:11 2007
@@ -335,7 +335,7 @@
 		}
 
 		/* update dependency packages' REQUIREDBY fields */
-		_alpm_pkg_update_depends(info, 1 /*is a remove*/);
+		_alpm_trans_update_depends(trans, info);
 
 		PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 100, alpm_list_count(trans->packages), (alpm_list_count(trans->packages) - alpm_list_count(targ) +1));
 		if(trans->type != PM_TRANS_TYPE_UPGRADE) {
Index: pacman-lib/lib/libalpm/trans.c
diff -u pacman-lib/lib/libalpm/trans.c:1.34 pacman-lib/lib/libalpm/trans.c:1.35
--- pacman-lib/lib/libalpm/trans.c:1.34	Tue Jan 30 03:14:11 2007
+++ pacman-lib/lib/libalpm/trans.c	Sun Feb 18 17:07:11 2007
@@ -38,6 +38,9 @@
 #include "remove.h"
 #include "sync.h"
 #include "alpm.h"
+#include "deps.h"
+#include "cache.h"
+#include "provide.h"
 
 pmtrans_t *_alpm_trans_new()
 {
@@ -242,6 +245,96 @@
 	return(0);
 }
 
+int _alpm_trans_update_depends(pmtrans_t *trans, pmpkg_t *pkg)
+{
+	alpm_list_t *i, *j;
+	pmdb_t *localdb;
+
+	ALPM_LOG_FUNC;
+		
+	/* Sanity checks */
+	ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
+	ASSERT(pkg != NULL, RET_ERR(PM_ERR_PKG_INVALID, -1));
+
+	if(pkg->depends) {
+		_alpm_log(PM_LOG_DEBUG, _("updating dependency packages 'requiredby' fields"));
+	}
+
+	localdb = alpm_option_get_localdb();
+	for(i = pkg->depends; i; i = i->next) {
+		pmdepend_t dep;
+		if(_alpm_splitdep(i->data, &dep) != 0) {
+			continue;
+		}
+
+		if(trans->packages && trans->type == PM_TRANS_TYPE_REMOVE) {
+			if(_alpm_pkg_isin(dep.name, handle->trans->packages)) {
+				continue;
+			}
+		}
+
+		pmpkg_t *deppkg = _alpm_db_get_pkgfromcache(localdb, dep.name);
+		if(!deppkg) {
+			int found_provides = 0;
+			/* look for a provides package */
+			alpm_list_t *provides = _alpm_db_whatprovides(localdb, dep.name);
+			for(j = provides; j; j = j->next) {
+				if(!j->data) {
+					continue;
+				}
+				pmpkg_t *provpkg = j->data;
+				deppkg = _alpm_db_get_pkgfromcache(localdb, provpkg->name);
+
+				if(!deppkg) {
+					continue;
+				}
+
+				found_provides = 1;
+
+				/* Ensure package has the right newpkg */
+				_alpm_db_read(localdb, INFRQ_DEPENDS, deppkg);
+
+				_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), deppkg->name);
+				if(trans->type == PM_TRANS_TYPE_REMOVE) {
+					void *data = NULL;
+					deppkg->requiredby = alpm_list_remove(deppkg->requiredby, pkg->name, _alpm_str_cmp, &data);
+					FREE(data);
+				} else {
+					deppkg->requiredby = alpm_list_add(deppkg->requiredby, strdup(pkg->name));
+				}
+
+				if(_alpm_db_write(localdb, deppkg, INFRQ_DEPENDS)) {
+					_alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"), deppkg->name, deppkg->version);
+				}
+			}
+			FREELISTPTR(provides);
+
+			if(!found_provides) {
+				_alpm_log(PM_LOG_DEBUG, _("could not find dependency '%s'"), dep.name);
+				continue;
+			}
+		}
+
+		/* Ensure package has the right newpkg */
+		_alpm_db_read(localdb, INFRQ_DEPENDS, deppkg);
+
+		_alpm_log(PM_LOG_DEBUG, _("updating 'requiredby' field for package '%s'"), deppkg->name);
+		if(trans->type == PM_TRANS_TYPE_REMOVE) {
+			void *data = NULL;
+			deppkg->requiredby = alpm_list_remove(deppkg->requiredby, pkg->name, _alpm_str_cmp, &data);
+			FREE(data);
+		} else {
+			deppkg->requiredby = alpm_list_add(deppkg->requiredby, strdup(pkg->name));
+		}
+
+		if(_alpm_db_write(localdb, deppkg, INFRQ_DEPENDS)) {
+			_alpm_log(PM_LOG_ERROR, _("could not update 'requiredby' database entry %s-%s"), deppkg->name, deppkg->version);
+		}
+	}
+	return(0);
+}
+
+
 pmtranstype_t alpm_trans_get_type()
 {
 	/* Sanity checks */
Index: pacman-lib/lib/libalpm/trans.h
diff -u pacman-lib/lib/libalpm/trans.h:1.22 pacman-lib/lib/libalpm/trans.h:1.23
--- pacman-lib/lib/libalpm/trans.h:1.22	Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/trans.h	Sun Feb 18 17:07:11 2007
@@ -84,6 +84,7 @@
 int _alpm_trans_addtarget(pmtrans_t *trans, char *target);
 int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data);
 int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data);
+int _alpm_trans_update_depends(pmtrans_t *trans, pmpkg_t *pkg);
 
 #endif /* _ALPM_TRANS_H */
 




More information about the pacman-dev mailing list