Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-12 09:17:22 -0600
committerDan McGee <dan@archlinux.org>2011-01-12 09:17:22 -0600
commit30f53cfe8d3f07bc9f350387b55ddf8579dd75e3 (patch)
treea0104cf68f6ed413e9cbbff37b53d3521194539a
parentcae2bdafec93381284ba487010738d72d0992aab (diff)
Fix double read issue in maint releases
This is essentially a backport/cherry-pick of commit 33240e87b99e from master, but has to be done by hand because the DB format has diverged. Read more in the commit message used there, which follows. 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. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/be_files.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 1c9aaeec..0ee8a3bb 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -396,14 +396,16 @@ int _alpm_db_populate(pmdb_t *db)
continue;
}
+ pkg->origin = PKG_FROM_CACHE;
+ pkg->origin_data.db = db;
+
/* explicitly read with only 'BASE' data, accessors will handle the rest */
if(_alpm_db_read(db, pkg, INFRQ_BASE) == -1) {
_alpm_log(PM_LOG_ERROR, _("corrupted database entry '%s'\n"), name);
_alpm_pkg_free(pkg);
continue;
}
- pkg->origin = PKG_FROM_CACHE;
- 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);
@@ -460,7 +462,7 @@ int _alpm_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",
@@ -479,7 +481,7 @@ int _alpm_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));
@@ -623,7 +625,7 @@ int _alpm_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));
@@ -650,7 +652,7 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
}
/* DEPENDS */
- if(inforeq & INFRQ_DEPENDS) {
+ if(inforeq & INFRQ_DEPENDS && !(info->infolevel & INFRQ_DEPENDS)) {
snprintf(path, PATH_MAX, "%sdepends", pkgpath);
if((fp = fopen(path, "r")) == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno));
@@ -689,7 +691,7 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
}
/* DELTAS */
- if(inforeq & INFRQ_DELTAS) {
+ if(inforeq & INFRQ_DELTAS && !(info->infolevel & INFRQ_DELTAS)) {
snprintf(path, PATH_MAX, "%sdeltas", pkgpath);
if((fp = fopen(path, "r"))) {
while(!feof(fp)) {
@@ -710,7 +712,7 @@ int _alpm_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;