@@ -111,6 +111,7 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
111111static int
112112repo_deps (struct xbps_handle * xhp ,
113113 xbps_array_t pkgs , /* array of pkgs */
114+ xbps_array_t queued , /* queued packages */
114115 xbps_dictionary_t pkg_repod , /* pkg repo dictionary */
115116 unsigned short * depth ) /* max recursion depth */
116117{
@@ -182,8 +183,19 @@ repo_deps(struct xbps_handle *xhp,
182183 continue ;
183184 }
184185 /*
185- * Pass 2: check if required dependency has been already
186- * added in the transaction dictionary.
186+ * Pass 2: check if required dependency is currently queued or
187+ * has been already added in the transaction dictionary.
188+ */
189+ if ((curpkgd = xbps_find_pkg_in_array (queued , reqpkg , 0 )) ||
190+ (curpkgd = xbps_find_virtualpkg_in_array (xhp , queued , reqpkg , 0 ))) {
191+ xbps_trans_type_t ttype_q = xbps_transaction_pkg_type (curpkgd );
192+ xbps_dictionary_get_cstring_nocopy (curpkgd , "pkgver" , & pkgver_q );
193+ xbps_dbg_printf_append (" (%s queued %d)\n" , pkgver_q , ttype_q );
194+ continue ;
195+ }
196+ /*
197+ * Pass 3: check if required dependency has been already added
198+ * in the transaction dictionary.
187199 */
188200 if ((curpkgd = xbps_find_pkg_in_array (pkgs , reqpkg , 0 )) ||
189201 (curpkgd = xbps_find_virtualpkg_in_array (xhp , pkgs , reqpkg , 0 ))) {
@@ -195,7 +207,7 @@ repo_deps(struct xbps_handle *xhp,
195207 }
196208 }
197209 /*
198- * Pass 3 : check if required dependency is already installed
210+ * Pass 4 : check if required dependency is already installed
199211 * and its version is fully matched.
200212 */
201213 if ((curpkgd = xbps_pkgdb_get_pkg (xhp , pkgname )) == NULL ) {
@@ -341,7 +353,7 @@ repo_deps(struct xbps_handle *xhp,
341353 continue ;
342354 }
343355 /*
344- * Pass 4 : find required dependency in repository pool.
356+ * Pass 5 : find required dependency in repository pool.
345357 * If dependency does not match add pkg into the missing
346358 * deps array and pass to next one.
347359 */
@@ -431,6 +443,10 @@ repo_deps(struct xbps_handle *xhp,
431443 if (error )
432444 break ;
433445 }
446+
447+ if (!xbps_array_add (queued , repopkgd ))
448+ return - xbps_error_oom ();
449+
434450 pkg_rdeps = xbps_dictionary_get (repopkgd , "run_depends" );
435451 if (xbps_array_count (pkg_rdeps )) {
436452 /*
@@ -444,7 +460,7 @@ repo_deps(struct xbps_handle *xhp,
444460 xbps_dbg_printf_append ("%s: finding dependencies:\n" , pkgver_q );
445461 }
446462 (* depth )++ ;
447- rv = repo_deps (xhp , pkgs , repopkgd , depth );
463+ rv = repo_deps (xhp , pkgs , queued , repopkgd , depth );
448464 if (rv != 0 ) {
449465 xbps_dbg_printf ("Error checking %s for rundeps: %s\n" , reqpkg , strerror (rv ));
450466 break ;
@@ -455,6 +471,9 @@ repo_deps(struct xbps_handle *xhp,
455471 } else if (xbps_dictionary_get (curpkgd , "hold" )) {
456472 ttype = XBPS_TRANS_HOLD ;
457473 }
474+
475+ xbps_array_remove (queued , xbps_array_count (queued ) - 1 );
476+
458477 /*
459478 * All deps were processed, store pkg in transaction.
460479 */
@@ -483,16 +502,27 @@ xbps_transaction_pkg_deps(struct xbps_handle *xhp,
483502{
484503 const char * pkgver ;
485504 unsigned short depth = 0 ;
505+ xbps_array_t queued ;
506+ int rv ;
486507
487508 assert (xhp );
488509 assert (pkgs );
489510 assert (pkg_repod );
490511
491- xbps_dictionary_get_cstring_nocopy (pkg_repod , "pkgver" , & pkgver );
512+ queued = xbps_array_create ();
513+ if (!queued )
514+ return - xbps_error_oom ();
515+
516+ if (!xbps_dictionary_get_cstring_nocopy (pkg_repod , "pkgver" , & pkgver ))
517+ return EINVAL ;
518+
492519 xbps_dbg_printf ("Finding required dependencies for '%s':\n" , pkgver );
520+
493521 /*
494522 * This will find direct and indirect deps, if any of them is not
495523 * there it will be added into the missing_deps array.
496524 */
497- return repo_deps (xhp , pkgs , pkg_repod , & depth );
525+ rv = repo_deps (xhp , pkgs , queued , pkg_repod , & depth );
526+ xbps_object_release (queued );
527+ return rv ;
498528}
0 commit comments