summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-09-23 21:43:03 +0200
committerDan McGee <dan@archlinux.org>2007-09-24 03:48:04 +0200
commit843d368ef60a74719dfc74a27de3fe3ef441951f (patch)
treee33e186ecf4ee8e86f31bea9f9aa028b0a362810 /lib/libalpm/add.c
parent105fd40a4a9b221df0186e7500fe491b3b96d823 (diff)
downloadpacman-843d368ef60a74719dfc74a27de3fe3ef441951f.tar.gz
pacman-843d368ef60a74719dfc74a27de3fe3ef441951f.tar.xz
libalpm/add.c: fix backup array issue
As seen with the recent upgrade of pacman and the removal of the pacman.d/current mirrorlist, files that were formerly in the backup array get deleted upon their removal, which could be dangerous. Instead, we should use the combined backup array of the old and new package. This fix should address this issue in a relatively straightforward way. In addition, old files should be moved to pacsave locations as expected. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index e9225da1..86e80778 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -295,18 +295,26 @@ static int upgrade_remove(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *trans, pm
tr->skip_remove = alpm_list_strdup(trans->skip_remove);
const alpm_list_t *b;
- /* Add files in the NEW package's backup array to the noupgrade array
+ /* Add files in the OLD and NEW backup array to the NoUpgrade array
* so this removal operation doesn't kill them */
- /* TODO if we add here, all backup=() entries for all targets, new and
- * old, we cover all bases, including backup=() locations changing hands.
- * But is this viable? */
alpm_list_t *old_noupgrade = alpm_list_strdup(handle->noupgrade);
- for(b = alpm_pkg_get_backup(newpkg); b; b = b->next) {
+ /* old package backup list */
+ for(b = alpm_pkg_get_backup(oldpkg); b; b = b->next) {
const char *backup = b->data;
_alpm_log(PM_LOG_DEBUG, "adding %s to the NoUpgrade array temporarily\n",
backup);
handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(backup));
}
+ /* new package backup list */
+ for(b = alpm_pkg_get_backup(newpkg); b; b = b->next) {
+ const char *backup = b->data;
+ /* make sure we don't add duplicate entries */
+ if(!alpm_list_find(handle->noupgrade, backup)) {
+ _alpm_log(PM_LOG_DEBUG, "adding %s to the NoUpgrade array temporarily\n",
+ backup);
+ handle->noupgrade = alpm_list_add(handle->noupgrade, strdup(backup));
+ }
+ }
int ret = _alpm_remove_commit(tr, db);