summaryrefslogtreecommitdiff
path: root/lib/libalpm/deps.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-11-12 19:40:08 -0600
committerDan McGee <dan@archlinux.org>2007-11-14 18:49:50 -0600
commit7219326dd4d01d7e49b8a40746f5495c1c329c9c (patch)
tree01cefb7c433105ba88850dc272ea7791d9954c0b /lib/libalpm/deps.c
parentf5fcaf0b3c8d05e94d08d6357324cfa69d8ceae7 (diff)
downloadpacman-7219326dd4d01d7e49b8a40746f5495c1c329c9c.tar.xz
Remove REQUIREDBY usage from libalpm
Instead of using the often-busted REQUIREDBY entries in the pacman database, compute them each time they are required. This should help many things: 1. Simplify the codebase 2. Prevent future database corruption 3. Ensure when we do use requiredby, it is always correct 4. Shrink the pmpkg_t memory overhead Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 63775d20..42ceb743 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -254,12 +254,13 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
}
if(op == PM_TRANS_TYPE_UPGRADE) {
- /* PM_TRANS_TYPE_UPGRADE handles the backwards dependencies, ie, the packages
- * listed in the requiredby field.
+ /* PM_TRANS_TYPE_UPGRADE handles the backwards dependencies, ie,
+ * the packages listed in the requiredby field.
*/
for(i = packages; i; i = i->next) {
pmpkg_t *newpkg = i->data;
pmpkg_t *oldpkg;
+ alpm_list_t *requiredby;
if(newpkg == NULL) {
_alpm_log(PM_LOG_DEBUG, "null package found in package list\n");
continue;
@@ -272,7 +273,9 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
alpm_pkg_get_name(newpkg));
continue;
}
- for(j = alpm_pkg_get_requiredby(oldpkg); j; j = j->next) {
+
+ requiredby = alpm_pkg_compute_requiredby(oldpkg);
+ for(j = requiredby; j; j = j->next) {
pmpkg_t *p;
found = 0;
@@ -340,6 +343,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
FREE(depend);
}
}
+ FREELIST(requiredby);
}
}
if(op == PM_TRANS_TYPE_ADD || op == PM_TRANS_TYPE_UPGRADE) {
@@ -394,12 +398,15 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
/* check requiredby fields */
for(i = packages; i; i = i->next) {
pmpkg_t *rmpkg = alpm_list_getdata(i);
+ alpm_list_t *requiredby;
if(rmpkg == NULL) {
_alpm_log(PM_LOG_DEBUG, "null package found in package list\n");
continue;
}
- for(j = alpm_pkg_get_requiredby(rmpkg); j; j = j->next) {
+
+ requiredby = alpm_pkg_compute_requiredby(rmpkg);
+ for(j = requiredby; j; j = j->next) {
pmpkg_t *p;
found = 0;
if(_alpm_pkg_find(j->data, packages)) {
@@ -446,6 +453,7 @@ alpm_list_t *_alpm_checkdeps(pmdb_t *db, pmtranstype_t op,
FREE(depend);
}
}
+ FREELIST(requiredby);
}
}
@@ -559,7 +567,7 @@ pmdepend_t SYMEXPORT *alpm_splitdep(const char *depstring)
static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
int include_explicit)
{
- alpm_list_t *i;
+ alpm_list_t *i, *requiredby;
if(_alpm_pkg_find(alpm_pkg_get_name(pkg), targets)) {
return(0);
@@ -581,12 +589,15 @@ static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets,
* if checkdeps detected it would break something */
/* see if other packages need it */
- for(i = alpm_pkg_get_requiredby(pkg); i; i = i->next) {
+ requiredby = alpm_pkg_compute_requiredby(pkg);
+ for(i = requiredby; i; i = i->next) {
pmpkg_t *reqpkg = _alpm_db_get_pkgfromcache(db, i->data);
if(reqpkg && !_alpm_pkg_find(alpm_pkg_get_name(reqpkg), targets)) {
+ FREE(requiredby);
return(0);
}
}
+ FREELIST(requiredby);
/* it's ok to remove */
return(1);