Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/remove.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/remove.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/remove.c')
-rw-r--r--lib/libalpm/remove.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index d4e3b94a..5fba0b07 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -298,10 +298,12 @@ static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove,
}
}
-int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *trans)
+int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg,
+ pmtrans_t *trans)
{
alpm_list_t *skip_remove, *b;
alpm_list_t *newfiles, *lp;
+ size_t filenum;
alpm_list_t *files = alpm_pkg_get_files(oldpkg);
const char *pkgname = alpm_pkg_get_name(oldpkg);
@@ -315,8 +317,9 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra
}
/* copy the remove skiplist over */
- skip_remove =
- alpm_list_join(alpm_list_strdup(trans->skip_remove),alpm_list_strdup(handle->noupgrade));
+ skip_remove = alpm_list_join(
+ alpm_list_strdup(trans->skip_remove),
+ alpm_list_strdup(handle->noupgrade));
/* Add files in the NEW backup array to the skip_remove array
* so this removal operation doesn't kill them */
/* old package backup list */
@@ -340,6 +343,9 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra
}
}
+ filenum = alpm_list_count(files);
+ _alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
+
/* iterate through the list backwards, unlinking files */
newfiles = alpm_list_reverse(files);
for(lp = newfiles; lp; lp = alpm_list_next(lp)) {
@@ -406,6 +412,9 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
alpm_list_t *files = alpm_pkg_get_files(info);
+ alpm_list_t *newfiles;
+ size_t filenum;
+
for(lp = files; lp; lp = lp->next) {
if(!can_remove_file(lp->data, NULL)) {
_alpm_log(PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
@@ -414,8 +423,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db)
}
}
- size_t filenum = alpm_list_count(files);
- alpm_list_t *newfiles;
+ filenum = alpm_list_count(files);
_alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
/* init progress bar */