From 165dfb09ab54a5baaf8d656b0a8137a8355411fb Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Fri, 26 Jun 2026 21:32:34 +0200 Subject: [PATCH 1/3] lib: remove automatic self replacement Packages previously automatically added a replacemnet on their own package name so that they can easily replace virtual packages providing that same package name. This causes some unexpected behaviour where util-linux added to hostmakedepends in xbps-src will automatically replace chroot-util-linux and destroy the build chroot doing that. In general this might have been a bit more useful previously before alternatives allowed to install some virtual packages in parallel. --- lib/package_register.c | 12 ------------ lib/transaction_store.c | 18 ------------------ 2 files changed, 30 deletions(-) diff --git a/lib/package_register.c b/lib/package_register.c index 5ea2f6f9f..3e1923bed 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -23,7 +23,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #include #include @@ -34,7 +33,6 @@ int HIDDEN xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) { - xbps_array_t replaces; xbps_dictionary_t pkgd; time_t t; struct tm tm, *tmp; @@ -90,16 +88,6 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256); } free(buf); - /* - * 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_array_count(replaces)) - xbps_dictionary_remove(pkgd, "replaces"); - } /* * Remove unneeded objs from pkg dictionary. */ diff --git a/lib/transaction_store.c b/lib/transaction_store.c index 89d7c1fc5..fe4f98bd5 100644 --- a/lib/transaction_store.c +++ b/lib/transaction_store.c @@ -23,10 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include -#include -#include #include "xbps_api_impl.h" @@ -35,9 +32,7 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs, xbps_dictionary_t pkgrd, bool autoinst) { xbps_dictionary_t d, pkgd; - xbps_array_t replaces; const char *pkgver, *pkgname, *curpkgver, *repo; - char *self_replaced; int rv; assert(xhp); @@ -81,19 +76,6 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs, if (autoinst && !xbps_dictionary_set_bool(pkgd, "automatic-install", true)) goto err; - /* - * Set a replaces to itself, so that virtual packages are always replaced. - */ - if ((replaces = xbps_dictionary_get(pkgd, "replaces")) == NULL) - replaces = xbps_array_create(); - - self_replaced = xbps_xasprintf("%s>=0", pkgname); - xbps_array_add_cstring(replaces, self_replaced); - free(self_replaced); - - if (!xbps_dictionary_set(pkgd, "replaces", replaces)) - goto err; - /* * Add the dictionary into the unsorted queue. */ From f6397a7dac30bfdf4ea2aba56253604240b807d0 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Fri, 26 Jun 2026 21:55:53 +0200 Subject: [PATCH 2/3] bin/xbps-pkgdb: remove self replacement removal --- bin/xbps-pkgdb/check_pkg_unneeded.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/bin/xbps-pkgdb/check_pkg_unneeded.c b/bin/xbps-pkgdb/check_pkg_unneeded.c index e4d1d1f9c..7f8e0fee5 100644 --- a/bin/xbps-pkgdb/check_pkg_unneeded.c +++ b/bin/xbps-pkgdb/check_pkg_unneeded.c @@ -25,10 +25,7 @@ #include -#include #include -#include -#include #include #include @@ -43,11 +40,9 @@ * and remove them if that was true. */ int -check_pkg_unneeded(struct xbps_handle *xhp UNUSED, const char *pkgname, xbps_dictionary_t pkgd) +check_pkg_unneeded(struct xbps_handle *xhp UNUSED, const char *pkgname UNUSED, xbps_dictionary_t pkgd) { - xbps_array_t replaces; const char *repo = NULL; - char *buf; xbps_dictionary_remove(pkgd, "download"); xbps_dictionary_remove(pkgd, "remove-and-update"); @@ -58,16 +53,6 @@ check_pkg_unneeded(struct xbps_handle *xhp UNUSED, const char *pkgname, xbps_dic 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); - if (!xbps_array_count(replaces)) - xbps_dictionary_remove(pkgd, "replaces"); - } return 0; } From b3e4d942f958ed7eef300c7e7363f508b8c9a9d7 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Fri, 26 Jun 2026 21:57:10 +0200 Subject: [PATCH 3/3] tests: change self replacement test to be explict --- tests/xbps/libxbps/shell/replace_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/xbps/libxbps/shell/replace_test.sh b/tests/xbps/libxbps/shell/replace_test.sh index 9d02067f3..c2a8bfd93 100644 --- a/tests/xbps/libxbps/shell/replace_test.sh +++ b/tests/xbps/libxbps/shell/replace_test.sh @@ -87,7 +87,7 @@ self_replace_body() { echo "A-1.0_1" > pkg_A/usr/bin/foo echo "B-1.0_1" > pkg_B/usr/bin/foo cd some_repo - atf_check -o ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A + atf_check -o ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" --replaces "A>=0" ../pkg_A atf_check -o ignore -- xbps-create -A noarch -n B-1.0_1 -s "B pkg" --replaces "A>=0" --provides="A-1.0_1" ../pkg_B atf_check -o ignore -- xbps-rindex -a $PWD/*.xbps cd ..