trans_prepare: always sort trans->remove by deps
Packages can be removed during a sync transaction either directly or due to conflicts and need to be sorted. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
714609639f
commit
2f8be5f8db
5 changed files with 46 additions and 12 deletions
|
@ -240,13 +240,6 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-order w.r.t. dependencies */
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "sorting by dependencies\n");
|
|
||||||
lp = _alpm_sortbydeps(handle, trans->remove, NULL, 1);
|
|
||||||
/* free the old alltargs */
|
|
||||||
alpm_list_free(trans->remove);
|
|
||||||
trans->remove = lp;
|
|
||||||
|
|
||||||
/* -Rcs == -Rc then -Rs */
|
/* -Rcs == -Rc then -Rs */
|
||||||
if((trans->flags & ALPM_TRANS_FLAG_CASCADE)
|
if((trans->flags & ALPM_TRANS_FLAG_CASCADE)
|
||||||
&& (trans->flags & ALPM_TRANS_FLAG_RECURSE)) {
|
&& (trans->flags & ALPM_TRANS_FLAG_RECURSE)) {
|
||||||
|
|
|
@ -630,11 +630,6 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
}
|
}
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-order w.r.t. dependencies */
|
|
||||||
alpm_list_t *add_orig = trans->add;
|
|
||||||
trans->add = _alpm_sortbydeps(handle, add_orig, trans->remove, 0);
|
|
||||||
alpm_list_free(add_orig);
|
|
||||||
}
|
}
|
||||||
for(i = trans->add; i; i = i->next) {
|
for(i = trans->add; i; i = i->next) {
|
||||||
/* update download size field */
|
/* update download size field */
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "remove.h"
|
#include "remove.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "alpm.h"
|
#include "alpm.h"
|
||||||
|
#include "deps.h"
|
||||||
|
|
||||||
/** \addtogroup alpm_trans Transaction Functions
|
/** \addtogroup alpm_trans Transaction Functions
|
||||||
* @brief Functions to manipulate libalpm transactions
|
* @brief Functions to manipulate libalpm transactions
|
||||||
|
@ -134,6 +135,21 @@ int SYMEXPORT alpm_trans_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
|
||||||
|
_alpm_log(handle, ALPM_LOG_DEBUG, "sorting by dependencies\n");
|
||||||
|
if(trans->add) {
|
||||||
|
alpm_list_t *add_orig = trans->add;
|
||||||
|
trans->add = _alpm_sortbydeps(handle, add_orig, trans->remove, 0);
|
||||||
|
alpm_list_free(add_orig);
|
||||||
|
}
|
||||||
|
if(trans->remove) {
|
||||||
|
alpm_list_t *rem_orig = trans->remove;
|
||||||
|
trans->remove = _alpm_sortbydeps(handle, rem_orig, NULL, 1);
|
||||||
|
alpm_list_free(rem_orig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
trans->state = STATE_PREPARED;
|
trans->state = STATE_PREPARED;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -158,6 +158,7 @@ TESTS += test/pacman/tests/sync042.py
|
||||||
TESTS += test/pacman/tests/sync043.py
|
TESTS += test/pacman/tests/sync043.py
|
||||||
TESTS += test/pacman/tests/sync044.py
|
TESTS += test/pacman/tests/sync044.py
|
||||||
TESTS += test/pacman/tests/sync045.py
|
TESTS += test/pacman/tests/sync045.py
|
||||||
|
TESTS += test/pacman/tests/sync046.py
|
||||||
TESTS += test/pacman/tests/sync050.py
|
TESTS += test/pacman/tests/sync050.py
|
||||||
TESTS += test/pacman/tests/sync051.py
|
TESTS += test/pacman/tests/sync051.py
|
||||||
TESTS += test/pacman/tests/sync052.py
|
TESTS += test/pacman/tests/sync052.py
|
||||||
|
|
29
test/pacman/tests/sync046.py
Normal file
29
test/pacman/tests/sync046.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
self.description = "Install a sync package with interdependent conflicts"
|
||||||
|
|
||||||
|
sp = pmpkg("pkg1")
|
||||||
|
sp.conflicts = ["pkg2", "pkg3", "pkg4"]
|
||||||
|
self.addpkg2db("sync", sp);
|
||||||
|
|
||||||
|
lp1 = pmpkg("pkg2")
|
||||||
|
lp1.depends = ["pkg3"]
|
||||||
|
lp1.install['pre_remove'] = "[ -f pkg3file ] && echo '' > pkg2ok"
|
||||||
|
self.addpkg2db("local", lp1);
|
||||||
|
|
||||||
|
lp2 = pmpkg("pkg3")
|
||||||
|
lp2.files = ["pkg3file"]
|
||||||
|
self.addpkg2db("local", lp2);
|
||||||
|
|
||||||
|
lp3 = pmpkg("pkg4")
|
||||||
|
lp3.depends = ["pkg3"]
|
||||||
|
lp3.install['pre_remove'] = "[ -f pkg3file ] && echo '' > pkg4ok"
|
||||||
|
self.addpkg2db("local", lp3);
|
||||||
|
|
||||||
|
self.args = "-S %s --ask=4" % sp.name
|
||||||
|
|
||||||
|
self.addrule("PACMAN_RETCODE=0")
|
||||||
|
self.addrule("PKG_EXIST=pkg1")
|
||||||
|
self.addrule("!PKG_EXIST=pkg2")
|
||||||
|
self.addrule("!PKG_EXIST=pkg3")
|
||||||
|
self.addrule("!PKG_EXIST=pkg4")
|
||||||
|
self.addrule("FILE_EXIST=pkg2ok")
|
||||||
|
self.addrule("FILE_EXIST=pkg4ok")
|
Loading…
Add table
Reference in a new issue