diff options
-rw-r--r-- | lib/libalpm/be_files.c | 8 | ||||
-rw-r--r-- | lib/libalpm/deps.c | 37 | ||||
-rw-r--r-- | lib/libalpm/package.c | 18 |
3 files changed, 22 insertions, 41 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index a6cde689..ed8c8c14 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -44,6 +44,7 @@ #include "handle.h" #include "package.h" #include "delta.h" +#include "deps.h" /* This function is used to convert the downloaded db file to the proper backend @@ -455,7 +456,8 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) _alpm_strtrim(line); if(!strcmp(line, "%DEPENDS%")) { while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { - info->depends = alpm_list_add(info->depends, strdup(line)); + pmdepend_t *dep = alpm_splitdep(line); + info->depends = alpm_list_add(info->depends, dep); } } else if(!strcmp(line, "%OPTDEPENDS%")) { while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { @@ -670,7 +672,9 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) if(info->depends) { fputs("%DEPENDS%\n", fp); for(lp = info->depends; lp; lp = lp->next) { - fprintf(fp, "%s\n", (char *)lp->data); + char *depstring = alpm_dep_get_string(lp->data); + fprintf(fp, "%s\n", depstring); + free(depstring); } fprintf(fp, "\n"); } diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 42ceb743..509c2a67 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -130,9 +130,8 @@ static alpm_list_t *_alpm_graph_init(alpm_list_t *targets) pmpkg_t *p_j = vertex_j->data; int child = 0; for(k = alpm_pkg_get_depends(p_i); k && !child; k = k->next) { - pmdepend_t *depend = alpm_splitdep(k->data); + pmdepend_t *depend = k->data; child = alpm_depcmp(p_j, depend); - free(depend); } if(child) { vertex_i->children = @@ -290,10 +289,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, for(k = alpm_pkg_get_depends(p); k; k = k->next) { /* don't break any existing dependencies (possible provides) */ - pmdepend_t *depend = alpm_splitdep(k->data); - if(depend == NULL) { - continue; - } + pmdepend_t *depend = k->data; /* if oldpkg satisfied this dep, and newpkg doesn't */ if(alpm_depcmp(oldpkg, depend) && !alpm_depcmp(newpkg, depend)) { @@ -305,7 +301,8 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, if(alpm_depcmp(pkg, depend)) { _alpm_log(PM_LOG_DEBUG, "checkdeps: dependency '%s' has moved from '%s' to '%s'\n", - (char*)k->data, alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(pkg)); + depend->name, + alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(pkg)); satisfied = 1; break; } @@ -321,7 +318,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, /* we ignore packages that will be updated because we know * that the updated ones don't satisfy depend */ _alpm_log(PM_LOG_DEBUG, "checkdeps: dependency '%s' satisfied by installed package '%s'\n", - (char*)k->data, alpm_pkg_get_name(pkg)); + depend->name, alpm_pkg_get_name(pkg)); satisfied = 1; break; } @@ -340,7 +337,6 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, } } } - FREE(depend); } } FREELIST(requiredby); @@ -358,11 +354,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, alpm_pkg_get_name(tp), alpm_pkg_get_version(tp)); for(j = alpm_pkg_get_depends(tp); j; j = j->next) { - /* split into name/version pairs */ - pmdepend_t *depend = alpm_splitdep((char*)j->data); - if(depend == NULL) { - continue; - } + pmdepend_t *depend = j->data; found = 0; /* check other targets */ @@ -391,7 +383,6 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, FREE(miss); } } - FREE(depend); } } } else if(op == PM_TRANS_TYPE_REMOVE) { @@ -419,10 +410,8 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, continue; } for(k = alpm_pkg_get_depends(p); k; k = k->next) { - pmdepend_t *depend = alpm_splitdep(k->data); - if(depend == NULL) { - continue; - } + pmdepend_t *depend = k->data; + /* if rmpkg satisfied this dep, try to find an other satisfier * (which won't be removed)*/ if(alpm_depcmp(rmpkg, depend)) { @@ -450,7 +439,6 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op, } } } - FREE(depend); } } FREELIST(requiredby); @@ -626,10 +614,8 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit) for(i = targs; i; i = i->next) { pmpkg_t *pkg = i->data; for(j = alpm_pkg_get_depends(pkg); j; j = j->next) { - pmdepend_t *depend = alpm_splitdep(j->data); - if(depend == NULL) { - continue; - } + pmdepend_t *depend = j->data; + for(k = _alpm_db_get_pkgcache(db); k; k = k->next) { pmpkg_t *deppkg = k->data; if(alpm_depcmp(deppkg,depend) @@ -640,7 +626,6 @@ void _alpm_recursedeps(pmdb_t *db, alpm_list_t *targs, int include_explicit) targs = alpm_list_add(targs, _alpm_pkg_dup(deppkg)); } } - FREE(depend); } } } @@ -799,7 +784,7 @@ pmdepend_t SYMEXPORT *alpm_miss_get_dep(pmdepmissing_t *miss) /* Sanity checks */ ASSERT(miss != NULL, return(NULL)); - return &miss->depend; + return &(miss->depend); } pmdepmod_t SYMEXPORT alpm_dep_get_mod(const pmdepend_t *dep) diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 89785a14..2c6fc29c 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -49,7 +49,7 @@ #include "delta.h" #include "provide.h" #include "handle.h" -#include "alpm.h" +#include "deps.h" /** \addtogroup alpm_packages Package Functions * @brief Functions to manipulate libalpm packages @@ -527,22 +527,13 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg) const char *cachepkgname = alpm_pkg_get_name(cachepkg); for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) { - pmdepend_t *dep; + pmdepend_t *dep = j->data; - if(!j->data) { - continue; - } - dep = alpm_splitdep(j->data); - if(dep == NULL) { - continue; - } - if(alpm_depcmp(pkg, dep)) { _alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'\n", cachepkgname, pkg->name); reqs = alpm_list_add(reqs, strdup(cachepkgname)); } - FREE(dep); } } return(reqs); @@ -684,7 +675,7 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) newpkg->conflicts = alpm_list_strdup(alpm_pkg_get_conflicts(pkg)); newpkg->files = alpm_list_strdup(alpm_pkg_get_files(pkg)); newpkg->backup = alpm_list_strdup(alpm_pkg_get_backup(pkg)); - newpkg->depends = alpm_list_strdup(alpm_pkg_get_depends(pkg)); + newpkg->depends = alpm_list_copy_data(alpm_pkg_get_depends(pkg)); newpkg->optdepends = alpm_list_strdup(alpm_pkg_get_optdepends(pkg)); newpkg->groups = alpm_list_strdup(alpm_pkg_get_groups(pkg)); newpkg->provides = alpm_list_strdup(alpm_pkg_get_provides(pkg)); @@ -851,7 +842,8 @@ static int parse_descfile(const char *descfile, pmpkg_t *info) /* size in the raw package is uncompressed (installed) size */ info->isize = atol(ptr); } else if(!strcmp(key, "depend")) { - info->depends = alpm_list_add(info->depends, strdup(ptr)); + pmdepend_t *dep = alpm_splitdep(ptr); + info->depends = alpm_list_add(info->depends, dep); } else if(!strcmp(key, "optdepend")) { info->optdepends = alpm_list_add(info->optdepends, strdup(ptr)); } else if(!strcmp(key, "conflict")) { |