Remove pkg self replacement from pkgdb; this must not be propagated.

This commit is contained in:
Juan RP 2014-09-13 18:14:04 +02:00
parent dea31f0a15
commit 2b7c4d568a
2 changed files with 21 additions and 4 deletions

View File

@ -43,20 +43,29 @@
* and remove them if that was true.
*/
int
check_pkg_unneeded(struct xbps_handle *xhp _unused, const char *pkgname _unused, void *arg)
check_pkg_unneeded(struct xbps_handle *xhp _unused, const char *pkgname, void *arg)
{
xbps_array_t replaces;
xbps_dictionary_t pkgd = arg;
const char *repo = NULL;
char *buf;
xbps_dictionary_remove(pkgd, "download");
xbps_dictionary_remove(pkgd, "remove-and-update");
xbps_dictionary_remove(pkgd, "transaction");
xbps_dictionary_remove(pkgd, "skip-obsoletes");
xbps_dictionary_get_cstring_nocopy(pkgd, "repository-origin", &repo);
if (repo) {
if (xbps_dictionary_get_cstring_nocopy(pkgd, "repository-origin", &repo)) {
xbps_dictionary_set_cstring(pkgd, "repository", repo);
xbps_dictionary_remove(pkgd, "repository-origin");
}
/*
* Remove self replacement when applicable.
*/
if ((replaces = xbps_dictionary_get(pkgd, "replaces"))) {
buf = xbps_xasprintf("%s>=0", pkgname);
xbps_remove_string_from_array(replaces, buf);
free(buf);
}
return 0;
}

View File

@ -34,6 +34,7 @@
int HIDDEN
xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
{
xbps_array_t replaces;
xbps_dictionary_t pkgd;
char outstr[64];
time_t t;
@ -102,7 +103,14 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
xbps_dictionary_remove(pkgd, "skip-obsoletes");
xbps_dictionary_remove(pkgd, "pkgname");
xbps_dictionary_remove(pkgd, "version");
/*
* Remove self replacement when applicable.
*/
if ((replaces = xbps_dictionary_get(pkgd, "replaces"))) {
buf = xbps_xasprintf("%s>=0", pkgname);
xbps_remove_string_from_array(replaces, buf);
free(buf);
}
if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
xbps_dbg_printf(xhp,
"%s: failed to set pkgd for %s\n", __func__, pkgver);