Fixed issue #26 (Replacing an installed pkg multiple times).
This commit is contained in:
@ -37,12 +37,12 @@ int HIDDEN
|
|||||||
xbps_transaction_package_replace(struct xbps_handle *xhp)
|
xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
xbps_array_t replaces, unsorted;
|
xbps_array_t replaces, unsorted;
|
||||||
xbps_dictionary_t instd, reppkgd, filesd;
|
xbps_dictionary_t instd, reppkgd;
|
||||||
xbps_object_t obj, obj2;
|
xbps_object_t obj, obj2;
|
||||||
xbps_object_iterator_t iter;
|
xbps_object_iterator_t iter;
|
||||||
const char *pattern, *pkgver, *curpkgver;
|
const char *tract, *pattern, *pkgver, *curpkgver;
|
||||||
char *buf, *pkgname, *curpkgname;
|
char *pkgname, *curpkgname;
|
||||||
bool instd_auto, sr;
|
bool instd_auto;
|
||||||
|
|
||||||
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
|
unsorted = xbps_dictionary_get(xhp->transd, "unsorted_deps");
|
||||||
|
|
||||||
@ -82,22 +82,24 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
free(curpkgname);
|
free(curpkgname);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
xbps_dbg_printf(xhp,
|
* Make sure to not add duplicates.
|
||||||
"Package `%s' will be replaced by `%s', "
|
*/
|
||||||
"matched with `%s'\n", curpkgver, pkgver, pattern);
|
reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname);
|
||||||
instd_auto = false;
|
if (reppkgd) {
|
||||||
xbps_dictionary_get_bool(instd,
|
xbps_dictionary_get_cstring_nocopy(reppkgd,
|
||||||
"automatic-install", &instd_auto);
|
"transaction", &tract);
|
||||||
|
if (strcmp(tract, "remove") == 0)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Package contains replaces="pkgpattern", but the
|
* Package contains replaces="pkgpattern", but the
|
||||||
* package that should be replaced is also in the
|
* package that should be replaced is also in the
|
||||||
* transaction and it's going to be updated.
|
* transaction and it's going to be updated.
|
||||||
*/
|
*/
|
||||||
|
instd_auto = false;
|
||||||
|
xbps_dictionary_get_bool(instd, "automatic-install", &instd_auto);
|
||||||
if ((reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname))) {
|
if ((reppkgd = xbps_find_pkg_in_array(unsorted, curpkgname))) {
|
||||||
xbps_dbg_printf(xhp,
|
|
||||||
"found replaced pkg "
|
|
||||||
"in transaction\n");
|
|
||||||
xbps_dictionary_set_bool(instd,
|
xbps_dictionary_set_bool(instd,
|
||||||
"remove-and-update", true);
|
"remove-and-update", true);
|
||||||
xbps_dictionary_set_bool(reppkgd,
|
xbps_dictionary_set_bool(reppkgd,
|
||||||
@ -105,7 +107,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
xbps_dictionary_set_bool(reppkgd,
|
xbps_dictionary_set_bool(reppkgd,
|
||||||
"skip-obsoletes", true);
|
"skip-obsoletes", true);
|
||||||
xbps_array_replace_dict_by_name(unsorted,
|
xbps_array_replace_dict_by_name(unsorted,
|
||||||
reppkgd, curpkgname);
|
reppkgd, curpkgname);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* If new package is providing a virtual package to the
|
* If new package is providing a virtual package to the
|
||||||
@ -119,31 +121,9 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
xbps_dictionary_set_bool(obj,
|
xbps_dictionary_set_bool(obj,
|
||||||
"automatic-install", instd_auto);
|
"automatic-install", instd_auto);
|
||||||
}
|
}
|
||||||
sr = false;
|
xbps_dbg_printf(xhp,
|
||||||
xbps_dictionary_get_bool(obj, "softreplace", &sr);
|
"Package `%s' will be replaced by `%s', "
|
||||||
if (sr) {
|
"matched with `%s'\n", curpkgver, pkgver, pattern);
|
||||||
xbps_dictionary_set_bool(obj,
|
|
||||||
"automatic-install", instd_auto);
|
|
||||||
xbps_dictionary_set_bool(instd,
|
|
||||||
"softreplace", true);
|
|
||||||
buf = xbps_xasprintf("%s/.%s.plist",
|
|
||||||
xhp->metadir, curpkgname);
|
|
||||||
filesd = xbps_dictionary_internalize_from_file(buf);
|
|
||||||
free(buf);
|
|
||||||
assert(filesd != NULL);
|
|
||||||
buf = xbps_xasprintf("%s/.%s.plist",
|
|
||||||
xhp->metadir, pkgname);
|
|
||||||
if (!xbps_dictionary_externalize_to_file(filesd, buf)) {
|
|
||||||
free(buf);
|
|
||||||
xbps_object_release(filesd);
|
|
||||||
xbps_object_iterator_release(iter);
|
|
||||||
free(pkgname);
|
|
||||||
free(curpkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
xbps_object_release(filesd);
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Add package dictionary into the transaction and mark
|
* Add package dictionary into the transaction and mark
|
||||||
* it as to be "removed".
|
* it as to be "removed".
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
atf_test_case replace_dups
|
atf_test_case replace_dups
|
||||||
|
|
||||||
replace_dups_head() {
|
replace_dups_head() {
|
||||||
atf_set "descr" "Tests for package replace: verify dup matches"
|
atf_set "descr" "Tests for package replace: replacing multiple times a pkg"
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_dups_body() {
|
replace_dups_body() {
|
||||||
|
Reference in New Issue
Block a user