Fix previous, so that only tries to replace packages if they
are installed! heh --HG-- extra : convert_revision : xtraeme%40gmail.com-20091017025959-4k8ciftjglkbao91
This commit is contained in:
parent
cacb34147a
commit
058b882037
@ -337,11 +337,48 @@ out:
|
|||||||
cleanup(rv);
|
cleanup(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
replace_packages(prop_object_iterator_t iter, const char *pkgname,
|
||||||
|
const char *version)
|
||||||
|
{
|
||||||
|
prop_dictionary_t instd;
|
||||||
|
prop_object_t obj;
|
||||||
|
const char *reppkgn;
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This package replaces other package(s), so we remove
|
||||||
|
* them before upgrading or installing new one.
|
||||||
|
*/
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
reppkgn = prop_string_cstring_nocopy(obj);
|
||||||
|
instd = xbps_find_pkg_installed_from_plist(reppkgn);
|
||||||
|
if (instd == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
printf("Replacing package '%s' with '%s-%s' ...\n",
|
||||||
|
reppkgn, pkgname, version);
|
||||||
|
if ((rv = xbps_remove_pkg(reppkgn, NULL, false)) != 0) {
|
||||||
|
printf("Couldn't remove %s (%s)\n",
|
||||||
|
reppkgn, strerror(rv));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
if ((rv = xbps_purge_pkg(reppkgn, false)) != 0) {
|
||||||
|
printf("Couldn't purge %s (%s)\n",
|
||||||
|
reppkgn, strerror(rv));
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
exec_transaction(struct transaction *trans)
|
exec_transaction(struct transaction *trans)
|
||||||
{
|
{
|
||||||
prop_dictionary_t instpkgd;
|
prop_dictionary_t instpkgd;
|
||||||
prop_object_t obj, obj2;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t replaces_iter;
|
prop_object_iterator_t replaces_iter;
|
||||||
const char *pkgname, *version, *instver, *filename, *tract;
|
const char *pkgname, *version, *instver, *filename, *tract;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
@ -402,33 +439,15 @@ exec_transaction(struct transaction *trans)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This package replaces other package(s), so we remove
|
* Replace package(s) if necessary.
|
||||||
* them before upgrading or installing new one.
|
|
||||||
*/
|
*/
|
||||||
if (replaces_iter != NULL) {
|
if (replaces_iter != NULL) {
|
||||||
while ((obj2 =
|
rv = replace_packages(replaces_iter, pkgname, version);
|
||||||
prop_object_iterator_next(replaces_iter))) {
|
if (rv != 0) {
|
||||||
printf("Replacing package '%s' with '%s-%s' "
|
printf("Couldn't replace some packages! "
|
||||||
"...\n", prop_string_cstring(obj2),
|
"(%s)\n", strerror(rv));
|
||||||
pkgname, version);
|
return rv;
|
||||||
rv = xbps_remove_pkg(prop_string_cstring(obj2),
|
|
||||||
NULL, false);
|
|
||||||
if (rv != 0) {
|
|
||||||
printf("Couldn't remove %s (%s)\n",
|
|
||||||
prop_string_cstring(obj2),
|
|
||||||
strerror(rv));
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
rv = xbps_purge_pkg(prop_string_cstring(obj2),
|
|
||||||
false);
|
|
||||||
if (rv != 0) {
|
|
||||||
printf("Couldn't purge %s (%s)\n",
|
|
||||||
prop_string_cstring(obj2),
|
|
||||||
strerror(rv));
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
prop_object_iterator_release(replaces_iter);
|
|
||||||
replaces_iter = NULL;
|
replaces_iter = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user