summaryrefslogtreecommitdiff
path: root/lib/libalpm/deps.c
diff options
context:
space:
mode:
authorNagy Gabor <ngaba@bibl.u-szeged.hu>2007-11-16 22:37:57 +0100
committerDan McGee <dan@archlinux.org>2007-11-18 20:05:51 -0600
commit84ebf8231985ff285f7995cd7ecaceb750a3c78b (patch)
treed42dd444a5b0e70d39a7a69de469fdef9111ac25 /lib/libalpm/deps.c
parent23b4e0270b1a1881b2daf362a398a3bdc20fab43 (diff)
downloadpacman-84ebf8231985ff285f7995cd7ecaceb750a3c78b.tar.xz
Versioned provisions.
This patch introduces versioned provisions in "provision 1.0-1" format. _alpm_db_whatprovides was modified accordingly (added sync500.py), alpm_depcmp was modified accordingly (add043.py passes now; added add044.py and add045.py). Notes: alpm_db_search now uses the whole versioned %PROVIDES% string in its search. debug logging was simplified in alpm_depcmp. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Xavier: fixed a few typos, duplicate const strings with strdup before modifying them, put some debugging back in alpm_depcmp, minor code cleanups (var/function renaming), added a note in PKGBUILD man page.] Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: made strcmp checks clearer, added a comment] Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 5d88c37d..0c79a25b 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -369,8 +369,10 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
/* else if still not found... */
if(!found) {
+ char *depstring = alpm_dep_get_string(depend);
_alpm_log(PM_LOG_DEBUG, "missing dependency '%s' for package '%s'\n",
- (char*)j->data, alpm_pkg_get_name(tp));
+ depstring, alpm_pkg_get_name(tp));
+ free(depstring);
miss = _alpm_depmiss_new(alpm_pkg_get_name(tp), depend->mod,
depend->name, depend->version);
if(!_alpm_depmiss_isin(miss, baddeps)) {
@@ -415,8 +417,10 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
for(l = _alpm_db_get_pkgcache(db); l; l = l->next) {
pmpkg_t *pkg = l->data;
if(alpm_depcmp(pkg, depend) && !_alpm_pkg_find(alpm_pkg_get_name(pkg), packages)) {
+ char *depstring = alpm_dep_get_string(depend);
_alpm_log(PM_LOG_DEBUG, "checkdeps: dependency '%s' satisfied by installed package '%s'\n",
- (char*)k->data, alpm_pkg_get_name(pkg));
+ depstring, alpm_pkg_get_name(pkg));
+ free(depstring);
satisfied = 1;
break;
}
@@ -464,38 +468,41 @@ static int dep_vercmp(const char *version1, pmdepmod_t mod,
int SYMEXPORT alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
{
- int equal = 0;
+ alpm_list_t *i;
ALPM_LOG_FUNC;
const char *pkgname = alpm_pkg_get_name(pkg);
const char *pkgversion = alpm_pkg_get_version(pkg);
+ int satisfy = 0;
- if(strcmp(pkgname, dep->name) == 0
- || alpm_list_find_str(alpm_pkg_get_provides(pkg), dep->name)) {
+ /* check (pkg->name, pkg->version) */
+ satisfy = (strcmp(pkgname, dep->name) == 0
+ && dep_vercmp(pkgversion, dep->mod, dep->version));
- equal = dep_vercmp(pkgversion, dep->mod, dep->version);
+ /* check provisions, format : "name version" */
+ for(i = alpm_pkg_get_provides(pkg); i && !satisfy; i = i->next) {
+ char *provname = strdup(i->data);
+ char *provver = strchr(provname, ' ');
- 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) {
- _alpm_log(PM_LOG_DEBUG, "depcmp: %s-%s %s %s-%s => %s\n",
- pkgname, pkgversion,
- mod, dep->name, dep->version, (equal ? "match" : "no match"));
+ if(provver == NULL) { /* no provision version */
+ satisfy = (dep->mod == PM_DEP_MOD_ANY
+ && strcmp(provname, dep->name) == 0);
} else {
- _alpm_log(PM_LOG_DEBUG, "depcmp: %s-%s %s %s => %s\n",
- pkgname, pkgversion,
- mod, dep->name, (equal ? "match" : "no match"));
+ /* replace the space with a NULL byte, and advance ptr the version */
+ *provver = '\0';
+ provver += 1;
+ satisfy = (strcmp(provname, dep->name) == 0
+ && dep_vercmp(provver, dep->mod, dep->version));
}
+ free(provname);
}
- return(equal);
+ char *depstring = alpm_dep_get_string(dep);
+ _alpm_log(PM_LOG_DEBUG, "alpm_depcmp %s-%s %s : %s\n",
+ pkgname, pkgversion, depstring, satisfy ? "match" : "no match");
+ free(depstring);
+ return(satisfy);
}
pmdepend_t SYMEXPORT *alpm_splitdep(const char *depstring)