[Frugalware-darcs] pacman-g2: new test: upgrade052.py

VMiklos vmiklos at frugalware.org
Sat Jun 9 22:43:56 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=pacman-g2;a=darcs_commitdiff;h=20070609203718-e2957-289f2ef2ed5676754d9d6d746b6dcf15e0686b04.gz;

[new test: upgrade052.py
VMiklos <vmiklos at frugalware.org>**20070609203718
 closes #2148
 most of the code pulled from pacman-g1
 FIXME: need to move _pacman_depcmp to deps.c
] {
addfile ./pactest/tests/upgrade052.py
hunk ./lib/libpacman/add.c 47
+#include "deps.h"
hunk ./lib/libpacman/add.c 57
-#include "deps.h"
hunk ./lib/libpacman/deps.c 215
-				char *ver;
+				//char *ver;
hunk ./lib/libpacman/deps.c 226
-				for(k = _pacman_pkg_getinfo(p, PM_PKG_DEPENDS); k && !found; k = k->next) {
-					/* find the dependency info in p->depends */
+				for(k = _pacman_pkg_getinfo(p, PM_PKG_DEPENDS); k; k = k->next) {
+					/* don't break any existing dependencies (possible provides) */
hunk ./lib/libpacman/deps.c 229
-					if(!strcmp(depend.name, oldpkg->name)) {
-						found = 1;
-					}
-				}
-				if(found == 0) {
-					/* look for packages that list depend.name as a "provide" */
-					pmlist_t *provides = _pacman_db_whatprovides(db, depend.name);
-					if(provides == NULL) {
-						/* not found */
-						continue;
-					}
-					/* we found an installed package that provides depend.name */
-					FREELISTPTR(provides);
-				}
-				found = 0;
-				if(depend.mod == PM_DEP_MOD_ANY) {
-					found = 1;
-				} else {
-					/* note that we use the version from the NEW package in the check */
-					ver = strdup(tp->version);
-					if(!index(depend.version,'-')) {
-						char *ptr;
-						for(ptr = ver; *ptr != '-'; ptr++);
-						*ptr = '\0';
-					}
-					cmp = _pacman_versioncmp(ver, depend.version);
-					switch(depend.mod) {
-						case PM_DEP_MOD_EQ: found = (cmp == 0); break;
-						case PM_DEP_MOD_GE: found = (cmp >= 0); break;
-						case PM_DEP_MOD_LE: found = (cmp <= 0); break;
-					}
-					FREE(ver);
-				}
-				if(!found) {
-					_pacman_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"), depend.name, p->name);
-					miss = _pacman_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
-					if(!_pacman_depmiss_isin(miss, baddeps)) {
-						baddeps = _pacman_list_add(baddeps, miss);
-					} else {
-						FREE(miss);
+					if(_pacman_depcmp(oldpkg, &depend) && !_pacman_depcmp(tp, &depend)) {
+						_pacman_log(PM_LOG_DEBUG, _("checkdeps: updated '%s' won't satisfy a dependency of '%s'"),
+								oldpkg->name, p->name);
+						miss = _pacman_depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod,
+								depend.name, depend.version);
+						if(!_pacman_depmiss_isin(miss, baddeps)) {
+							baddeps = _pacman_list_add(baddeps, miss);
+						} else {
+							FREE(miss);
+						}
hunk ./lib/libpacman/pacman.c 42
+#include "deps.h"
hunk ./lib/libpacman/pacman.c 52
-#include "deps.h"
hunk ./lib/libpacman/remove.c 47
+#include "deps.h"
hunk ./lib/libpacman/remove.c 56
-#include "deps.h"
hunk ./lib/libpacman/versioncmp.c 29
+#include <libintl.h>
hunk ./lib/libpacman/versioncmp.c 31
+#include "config.h"
+#include "deps.h"
hunk ./lib/libpacman/versioncmp.c 34
+#include "log.h"
+#include "util.h"
hunk ./lib/libpacman/versioncmp.c 246
+int _pacman_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
+{
+	int equal = 0;
+
+  if(strcmp(pkg->name, dep->name) == 0
+	    || _pacman_list_is_strin(dep->name, _pacman_pkg_getinfo(pkg, PM_PKG_PROVIDES))) {
+		if(dep->mod == PM_DEP_MOD_ANY) {
+			equal = 1;
+		} else {
+			int cmp = _pacman_versioncmp(_pacman_pkg_getinfo(pkg, PM_PKG_VERSION), dep->version);
+			switch(dep->mod) {
+				case PM_DEP_MOD_EQ: equal = (cmp == 0); break;
+				case PM_DEP_MOD_GE: equal = (cmp >= 0); break;
+				case PM_DEP_MOD_LE: equal = (cmp <= 0); break;
+				default: equal = 1; break;
+			}
+		}
+
+		char *mod = "~=";
+		switch(dep->mod) {
+			case PM_DEP_MOD_EQ: mod = "=="; break;
+			case PM_DEP_MOD_GE: mod = ">="; break;
+			case PM_DEP_MOD_LE: mod = "<="; break;
+			default: break;
+		}
+
+		if(strlen(dep->version) > 0) {
+			_pacman_log(PM_LOG_DEBUG, _("depcmp: %s-%s %s %s-%s => %s"),
+								_pacman_pkg_getinfo(pkg, PM_PKG_NAME), _pacman_pkg_getinfo(pkg, PM_PKG_NAME),
+								mod, dep->name, dep->version,
+								(equal ? "match" : "no match"));
+		} else {
+			_pacman_log(PM_LOG_DEBUG, _("depcmp: %s-%s %s %s => %s"),
+								_pacman_pkg_getinfo(pkg, PM_PKG_NAME), _pacman_pkg_getinfo(pkg, PM_PKG_VERSION),
+								mod, dep->name, 
+								(equal ? "match" : "no match"));
+		}
+	}
+
+	return equal;
+}
hunk ./lib/libpacman/versioncmp.h 27
+int _pacman_depcmp(pmpkg_t *pkg, pmdepend_t *dep);
hunk ./pactest/tests/upgrade052.py 1
+self.description = "Upgrade to a package that provides less than before"
+
+lp1 = pmpkg("pkg1")
+lp1.depends = ["imaginary"]
+self.addpkg2db("local", lp1)
+
+lp2 = pmpkg("pkg2")
+lp2.provides = ["imaginary", "real"]
+lp2.requiredby = [ "pkg1" ]
+self.addpkg2db("local", lp2)
+
+p = pmpkg("pkg2", "1.0-2")
+p.provides = ["real"]
+self.addpkg(p)
+
+self.args = "-U %s" % p.filename()
+
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_EXIST=pkg1")
+self.addrule("PKG_VERSION=pkg2|1.0-1")
+self.addrule("PKG_PROVIDES=pkg2|imaginary")
}


More information about the Frugalware-darcs mailing list