From c5d6556c50cc2ba8a525ea6ffd3db1724531ae95 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 6 May 2015 17:21:13 +0200 Subject: [PATCH] xbps-remove: fix #95 (xbps-remove -R pkg lists/removes orphans) --- NEWS | 6 ++++++ lib/package_orphans.c | 4 ++++ tests/xbps/libxbps/find_pkg_orphans/main.c | 3 --- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 11450e69..f2c4237e 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ xbps-0.45 (???): + * xbps-remove(8): fixed regression while removing recursively packages, don't remove + all package orphans, this task belongs to -o not -R. + + This closes #95 (xbps-remove -R pkg lists/removes orphans): + https://github.com/voidlinux/xbps/issues/95 + * xbps-uunshare(8): replaced -D, -H and -S with -b src:dest. This bind mounts src into dir/dest and allows unlimited mounts. diff --git a/lib/package_orphans.c b/lib/package_orphans.c index f1419242..4a31fe1d 100644 --- a/lib/package_orphans.c +++ b/lib/package_orphans.c @@ -85,6 +85,9 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user _unused continue; xbps_array_add(array, pkgd); } + if (orphans_user) + goto add_orphans; + iter = xbps_dictionary_iterator(xhp->pkgdb); assert(iter); /* @@ -113,6 +116,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user _unused } xbps_object_iterator_release(iter); +add_orphans: for (i = 0; i < xbps_array_count(array); i++) { pkgd = xbps_array_get(array, i); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver); diff --git a/tests/xbps/libxbps/find_pkg_orphans/main.c b/tests/xbps/libxbps/find_pkg_orphans/main.c index eec72f20..9ce5909e 100644 --- a/tests/xbps/libxbps/find_pkg_orphans/main.c +++ b/tests/xbps/libxbps/find_pkg_orphans/main.c @@ -28,11 +28,8 @@ static const char expected_output[] = "xbps-git-20130310_2\n" - "unexistent-pkg-0_1\n" "xbps-triggers-1.0_1\n" "libxbps-git-20130310_2\n" - "orphan1-0_1\n" - "orphan0-0_1\n" "confuse-2.7_2\n" "proplib-0.6.3_1\n" "libarchive-3.1.2_1\n"