From 2b7c4d568a24b4bb53e30a5fbce963a554733403 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 13 Sep 2014 18:14:04 +0200 Subject: [PATCH] Remove pkg self replacement from pkgdb; this must not be propagated. --- bin/xbps-pkgdb/check_pkg_unneeded.c | 15 ++++++++++++--- lib/package_register.c | 10 +++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/bin/xbps-pkgdb/check_pkg_unneeded.c b/bin/xbps-pkgdb/check_pkg_unneeded.c index e56387e1..e7eae18e 100644 --- a/bin/xbps-pkgdb/check_pkg_unneeded.c +++ b/bin/xbps-pkgdb/check_pkg_unneeded.c @@ -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; } diff --git a/lib/package_register.c b/lib/package_register.c index 3f5b5360..db07aef2 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -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);