From 685a85a4662356c319caafa942080441091a2705 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Fri, 5 Sep 2014 13:10:50 +0200
Subject: [PATCH] xbps_find_pkg_orphans: also take into account virtual pkgs.

---
 lib/package_orphans.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/package_orphans.c b/lib/package_orphans.c
index 9f9ae21a..95fb73e3 100644
--- a/lib/package_orphans.c
+++ b/lib/package_orphans.c
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2009-2013 Juan Romero Pardines.
+ * Copyright (c) 2009-2014 Juan Romero Pardines.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -122,7 +122,8 @@ find_orphans:
 		for (unsigned int x = 0; x < xbps_array_count(rdeps); x++) {
 			cnt = 0;
 			xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
-			if (xbps_find_pkg_in_array(array, deppkgver))
+			if (xbps_find_pkg_in_array(array, deppkgver) ||
+			    xbps_find_virtualpkg_in_array(xhp, array, deppkgver))
 				continue;
 			reqby = xbps_pkgdb_get_pkg_revdeps(xhp, deppkgver);
 			if (reqby == NULL)
@@ -130,7 +131,8 @@ find_orphans:
 			reqbycnt = xbps_array_count(reqby);
 			for (unsigned int j = 0; j < reqbycnt; j++) {
 				xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
-				if (xbps_find_pkg_in_array(array, reqbydep))
+				if (xbps_find_pkg_in_array(array, reqbydep) ||
+				    xbps_find_virtualpkg_in_array(xhp, array, reqbydep))
 					cnt++;
 			}
 			if (cnt == reqbycnt) {