65        xbps_array_t array = NULL;
 
   67        xbps_object_iterator_t iter;
 
   69        if (xbps_pkgdb_init(xhp) != 0)
 
   72        if ((array = xbps_array_create()) == NULL)
 
   77                iter = xbps_dictionary_iterator(xhp->
pkgdb);
 
   84                        while ((obj = xbps_object_iterator_next(iter))) {
 
   86                                xbps_dictionary_t pkgd;
 
   87                                unsigned int cnt = 0, revdepscnt = 0;
 
   88                                const char *pkgver = NULL;
 
   89                                bool automatic = 
false;
 
   91                                pkgd = xbps_dictionary_get_keysym(xhp->
pkgdb, obj);
 
   92                                if (!xbps_dictionary_get_cstring_nocopy(pkgd, 
"pkgver", &pkgver)) {
 
   97                                xbps_dictionary_get_bool(pkgd, 
"automatic-install", &automatic);
 
  102                                if (xbps_find_pkg_in_array(array, pkgver, 0)) {
 
  107                                revdepscnt = xbps_array_count(revdeps);
 
  109                                if (revdepscnt == 0) {
 
  111                                        xbps_array_add(array, pkgd);
 
  116                                for (
unsigned int i = 0; i < revdepscnt; i++) {
 
  117                                        const char *revdepver = NULL;
 
  119                                        xbps_array_get_cstring_nocopy(revdeps, i, &revdepver);
 
  120                                        if (xbps_find_pkg_in_array(array, revdepver, 0))
 
  123                                if (cnt == revdepscnt) {
 
  125                                        xbps_array_add(array, pkgd);
 
  130                        xbps_dbg_printf(
"orphans pkgdb iter: added %s\n", added ? 
"true" : 
"false");
 
  131                        xbps_object_iterator_reset(iter);
 
  135                xbps_object_iterator_release(iter);
 
  143        for (
unsigned int i = 0; i < xbps_array_count(orphans_user); i++) {
 
  144                xbps_dictionary_t pkgd;
 
  145                const char *pkgver = NULL;
 
  147                xbps_array_get_cstring_nocopy(orphans_user, i, &pkgver);
 
  151                xbps_array_add(array, pkgd);
 
  154        for (
unsigned int i = 0; i < xbps_array_count(array); i++) {
 
  156                xbps_dictionary_t pkgd;
 
  157                const char *pkgver = NULL;
 
  158                unsigned int cnt = 0, reqbycnt = 0;
 
  160                pkgd = xbps_array_get(array, i);
 
  161                xbps_dictionary_get_cstring_nocopy(pkgd, 
"pkgver", &pkgver);
 
  163                if (xbps_array_count(rdeps) == 0) {
 
  168                for (
unsigned int x = 0; x < xbps_array_count(rdeps); x++) {
 
  170                        xbps_dictionary_t deppkgd;
 
  171                        const char *deppkgver = NULL;
 
  172                        bool automatic = 
false;
 
  175                        xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);
 
  176                        if (xbps_find_pkg_in_array(array, deppkgver, 0)) {
 
  181                        xbps_dictionary_get_bool(deppkgd, 
"automatic-install", &automatic);
 
  188                        reqbycnt = xbps_array_count(reqby);
 
  189                        for (
unsigned int j = 0; j < reqbycnt; j++) {
 
  190                                const char *reqbydep = NULL;
 
  192                                xbps_array_get_cstring_nocopy(reqby, j, &reqbydep);
 
  194                                if (xbps_find_pkg_in_array(array, reqbydep, 0))
 
  197                        if (cnt == reqbycnt) {
 
  198                                xbps_array_add(array, deppkgd);