[pacman-dev] CVS update of pacman-lib/lib/libalpm (package.c package.h sync.c)

Aaron Griffin aaron at archlinux.org
Wed Feb 7 00:57:28 EST 2007


    Date: Wednesday, February 7, 2007 @ 00:57:28
  Author: aaron
    Path: /home/cvs-pacman/pacman-lib/lib/libalpm

Modified: package.c (1.61 -> 1.62) package.h (1.26 -> 1.27)
          sync.c (1.99 -> 1.100)

Cleanup and more debug info for alpm_pkg_compare_versions


-----------+
 package.c |   29 ++++++++++++++++++-----------
 package.h |    1 +
 sync.c    |    3 +--
 3 files changed, 20 insertions(+), 13 deletions(-)


Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.61 pacman-lib/lib/libalpm/package.c:1.62
--- pacman-lib/lib/libalpm/package.c:1.61	Tue Feb  6 16:28:29 2007
+++ pacman-lib/lib/libalpm/package.c	Wed Feb  7 00:57:28 2007
@@ -123,39 +123,46 @@
 }
 
 /* Is pkgB an upgrade for pkgA ? */
-int alpm_pkg_compare_versions(pmpkg_t *pkgA, pmpkg_t *pkgB)
+int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
 {
-	if(pkgB->origin == PKG_FROM_CACHE) {
+	int cmp = 0;
+
+	ALPM_LOG_FUNC;
+
+	if(pkg->origin == PKG_FROM_CACHE) {
 		/* ensure we have the /desc file, which contains the 'force' option */
-		_alpm_db_read(pkgB->data, INFRQ_DESC, pkgB);
+		_alpm_db_read(pkg->data, INFRQ_DESC, pkg);
 	}
 
-	if(pkgB->force) {
+	if(pkg->force) {
 		/* skip the version compare call if this is a 'force' package */
 		return(1);
 	}
 
 	/* compare versions and see if we need to upgrade */
-	int cmp = alpm_versioncmp(pkgA->version, pkgB->version);
+	cmp = alpm_versioncmp(local_pkg->version, pkg->version);
 
 	if(cmp > 0) {
 		/* local version is newer */
-		pmdb_t *db = pkgB->data;
+		pmdb_t *db = pkg->data;
 		_alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)"),
-							pkgA->name, pkgA->version, db->treename, pkgB->version);
+							local_pkg->name, local_pkg->version, db->treename, pkg->version);
 		cmp = 0;
-	} else if(alpm_list_find_str(handle->ignorepkg, pkgB->name)) {
+	} else if(alpm_list_find_str(handle->ignorepkg, pkg->name)) {
 		/* package should be ignored (IgnorePkg) */
 		_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
-							pkgA->name, pkgA->version, pkgB->version);
+							local_pkg->name, local_pkg->version, pkg->version);
 		cmp = 0;
-	} else if(_alpm_pkg_istoonew(pkgB)) {
+	} else if(_alpm_pkg_istoonew(pkg)) {
 		/* package too new (UpgradeDelay) */
 		_alpm_log(PM_LOG_DEBUG, _("%s-%s: delaying upgrade of package (%s)"),
-							pkgA->name, pkgA->version, pkgB->version);
+							local_pkg->name, local_pkg->version, pkg->version);
 		cmp = 0;
 	}
 
+  _alpm_log(PM_LOG_DEBUG, _("compare versions for %s: %s vs %s, result=%d"),
+						local_pkg->name, local_pkg->version, pkg->version, cmp);
+
 	return(cmp);
 }
 
Index: pacman-lib/lib/libalpm/package.h
diff -u pacman-lib/lib/libalpm/package.h:1.26 pacman-lib/lib/libalpm/package.h:1.27
--- pacman-lib/lib/libalpm/package.h:1.26	Tue Feb  6 15:57:17 2007
+++ pacman-lib/lib/libalpm/package.h	Wed Feb  7 00:57:28 2007
@@ -94,6 +94,7 @@
 pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg);
 void _alpm_pkg_free(void *data);
 int _alpm_pkg_cmp(const void *p1, const void *p2);
+int alpm_pkg_compare_versions(pmpkg_t *pkgA, pmpkg_t *pkgB);
 pmpkg_t *_alpm_pkg_load(char *pkgfile);
 pmpkg_t *_alpm_pkg_isin(char *needle, alpm_list_t *haystack);
 int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch);
Index: pacman-lib/lib/libalpm/sync.c
diff -u pacman-lib/lib/libalpm/sync.c:1.99 pacman-lib/lib/libalpm/sync.c:1.100
--- pacman-lib/lib/libalpm/sync.c:1.99	Tue Feb  6 12:39:32 2007
+++ pacman-lib/lib/libalpm/sync.c	Wed Feb  7 00:57:28 2007
@@ -199,7 +199,6 @@
 		/* match installed packages with the sync dbs and compare versions */
 		_alpm_log(PM_LOG_DEBUG, _("checking for package upgrades"));
 		for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) {
-			int cmp;
 			int replace=0;
 			pmpkg_t *local = i->data;
 			pmpkg_t *spkg = NULL;
@@ -262,7 +261,7 @@
 	pmpkg_t *local;
 	pmpkg_t *spkg = NULL;
 	pmsyncpkg_t *sync;
-	int cmp, repo_found = 0;
+	int repo_found = 0;
 
 	ALPM_LOG_FUNC;
 




More information about the pacman-dev mailing list