Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/be_local.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-11 18:46:10 -0600
committerDan McGee <dan@archlinux.org>2011-01-11 21:16:39 -0600
commit33240e87b99e5aebd0e64a672ea307a698edb32f (patch)
treed7fbdc34b44c2cf003d35c6e39c360012be51138 /lib/libalpm/be_local.c
parentb04a56dbe90f43622158410234fabea96d0d7f07 (diff)
Fix double filelist issue when upgrading a package
Due to the way we funk around with package data loading, we had a condition where the filelist got doubled up because it was loaded twice. Packages are originally loaded with INFRQ_BASE. In an upgrade/sync, the package is checked for file conflicts next, leaving us in an "INFRQ_BASE | INFRQ_FILES" state. Later, when committing a single package, we have an explicit call to _alpm_local_db_read() with INFRQ_ALL as the level. Because the package's level did not match this, we skipped over our previous "does the incoming level match where I'm at" shortcut, and continued to load things again, because of a lack of fine-grained checking for each of DESC, FILES, and INSTALL. The end result is we loaded the filelist twice, causing our remove logic to iterate twice over the installed files, spewing a bunch of "cannot find file X" messages. Fix the problem by doing a bit more bitmasking logic throughout the load method, and also fix the sanity check at the beginning of the function- this should *only* be used for local packages as opposed to the "not a package" check that was there before. A debug log message was added to upgraderemove as well to match the one already in the normal remove codepath. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_local.c')
-rw-r--r--lib/libalpm/be_local.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index d0662d91..5471fee4 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -424,6 +424,10 @@ static int local_db_populate(pmdb_t *db)
continue;
}
+ pkg->origin = PKG_FROM_LOCALDB;
+ pkg->origin_data.db = db;
+ pkg->ops = &local_pkg_ops;
+
/* explicitly read with only 'BASE' data, accessors will handle the rest */
if(_alpm_local_db_read(db, pkg, INFRQ_BASE) == -1) {
_alpm_log(PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name);
@@ -431,10 +435,6 @@ static int local_db_populate(pmdb_t *db)
continue;
}
- pkg->origin = PKG_FROM_LOCALDB;
- pkg->ops = &local_pkg_ops;
-
- pkg->origin_data.db = db;
/* add to the collection */
_alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
pkg->name, db->treename);
@@ -480,8 +480,10 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
return(-1);
}
- if(info->origin == PKG_FROM_FILE) {
- _alpm_log(PM_LOG_DEBUG, "request to read database info for a file-based package '%s', skipping...\n", info->name);
+ if(info->origin != PKG_FROM_LOCALDB) {
+ _alpm_log(PM_LOG_DEBUG,
+ "request to read info for a non-local package '%s', skipping...\n",
+ info->name);
return(-1);
}
@@ -491,7 +493,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
* & result: 00000100
* == to inforeq? nope, we need to load more info. */
if((info->infolevel & inforeq) == inforeq) {
- /* already loaded this info, do nothing */
+ /* already loaded all of this info, do nothing */
return(0);
}
_alpm_log(PM_LOG_FUNCTION, "loading package data for %s : level=0x%x\n",
@@ -510,7 +512,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
}
/* DESC */
- if(inforeq & INFRQ_DESC) {
+ if(inforeq & INFRQ_DESC && !(info->infolevel & INFRQ_DESC)) {
snprintf(path, PATH_MAX, "%sdesc", pkgpath);
if((fp = fopen(path, "r")) == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
@@ -639,7 +641,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
}
/* FILES */
- if(inforeq & INFRQ_FILES) {
+ if(inforeq & INFRQ_FILES && !(info->infolevel & INFRQ_FILES)) {
snprintf(path, PATH_MAX, "%sfiles", pkgpath);
if((fp = fopen(path, "r")) == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
@@ -666,7 +668,7 @@ int _alpm_local_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
}
/* INSTALL */
- if(inforeq & INFRQ_SCRIPTLET) {
+ if(inforeq & INFRQ_SCRIPTLET && !(info->infolevel & INFRQ_SCRIPTLET)) {
snprintf(path, PATH_MAX, "%sinstall", pkgpath);
if(access(path, F_OK) == 0) {
info->scriptlet = 1;