@@ -222,80 +222,6 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
222222 return 0 ;
223223}
224224
225- /*
226- * Returns 1 if there's an update, 0 if none or -1 on error.
227- */
228- static int
229- xbps_autoupdate (struct xbps_handle * xhp )
230- {
231- xbps_array_t rdeps ;
232- xbps_dictionary_t pkgd ;
233- const char * pkgver = NULL , * pkgname = NULL ;
234- int rv ;
235-
236- /*
237- * Check if there's a new update for XBPS before starting
238- * another transaction.
239- */
240- if (((pkgd = xbps_pkgdb_get_pkg (xhp , "xbps" )) == NULL ) &&
241- ((pkgd = xbps_pkgdb_get_virtualpkg (xhp , "xbps" )) == NULL ))
242- return 0 ;
243-
244- if (!xbps_dictionary_get_cstring_nocopy (pkgd , "pkgver" , & pkgver )) {
245- return EINVAL ;
246- }
247- if (!xbps_dictionary_get_cstring_nocopy (pkgd , "pkgname" , & pkgname )) {
248- return EINVAL ;
249- }
250-
251- rv = trans_find_pkg (xhp , pkgname , false);
252-
253- xbps_dbg_printf ("%s: trans_find_pkg xbps: %d\n" , __func__ , rv );
254-
255- if (rv == 0 ) {
256- if (xhp -> flags & XBPS_FLAG_DOWNLOAD_ONLY ) {
257- return 0 ;
258- }
259- /* a new xbps version is available, check its revdeps */
260- rdeps = xbps_pkgdb_get_pkg_revdeps (xhp , "xbps" );
261- for (unsigned int i = 0 ; i < xbps_array_count (rdeps ); i ++ ) {
262- const char * curpkgver = NULL ;
263- char curpkgn [XBPS_NAME_SIZE ] = {0 };
264-
265- xbps_array_get_cstring_nocopy (rdeps , i , & curpkgver );
266- xbps_dbg_printf ("%s: processing revdep %s\n" , __func__ , curpkgver );
267-
268- if (!xbps_pkg_name (curpkgn , sizeof (curpkgn ), curpkgver )) {
269- abort ();
270- }
271- rv = trans_find_pkg (xhp , curpkgn , false);
272- xbps_dbg_printf ("%s: trans_find_pkg revdep %s: %d\n" , __func__ , curpkgver , rv );
273- if (rv && rv != ENOENT && rv != EEXIST && rv != ENODEV )
274- return -1 ;
275- }
276- /*
277- * Set XBPS_FLAG_FORCE_REMOVE_REVDEPS to ignore broken
278- * reverse dependencies in xbps_transaction_prepare().
279- *
280- * This won't skip revdeps of the xbps pkg, rather other
281- * packages in rootdir that could be broken indirectly.
282- *
283- * A sysup transaction after updating xbps should fix them
284- * again.
285- */
286- xhp -> flags |= XBPS_FLAG_FORCE_REMOVE_REVDEPS ;
287- return 1 ;
288- } else if (rv == ENOENT || rv == EEXIST || rv == ENODEV ) {
289- /* no update */
290- return 0 ;
291- } else {
292- /* error */
293- return -1 ;
294- }
295-
296- return 0 ;
297- }
298-
299225int
300226xbps_transaction_update_packages (struct xbps_handle * xhp )
301227{
@@ -305,19 +231,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
305231 bool newpkg_found = false;
306232 int rv = 0 ;
307233
308- rv = xbps_autoupdate (xhp );
309- switch (rv ) {
310- case 1 :
311- /* xbps needs to be updated, don't allow any other update */
312- return EBUSY ;
313- case -1 :
314- /* error */
315- return EINVAL ;
316- default :
317- break ;
318- }
319-
320- iter = xbps_dictionary_iterator (xhp -> pkgdb );
234+ iter = xbps_pkgdb_init (xhp ) == 0 ? xbps_dictionary_iterator (xhp -> pkgdb ) : NULL ;
321235 assert (iter );
322236
323237 while ((obj = xbps_object_iterator_next (iter ))) {
@@ -355,22 +269,6 @@ xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkg, bool force
355269 xbps_array_t rdeps ;
356270 int rv ;
357271
358- rv = xbps_autoupdate (xhp );
359- xbps_dbg_printf ("%s: xbps_autoupdate %d\n" , __func__ , rv );
360- switch (rv ) {
361- case 1 :
362- /* xbps needs to be updated, only allow xbps to be updated */
363- if (strcmp (pkg , "xbps" ))
364- return EBUSY ;
365- return 0 ;
366- case -1 :
367- /* error */
368- return EINVAL ;
369- default :
370- /* no update */
371- break ;
372- }
373-
374272 /* update its reverse dependencies */
375273 rdeps = xbps_pkgdb_get_pkg_revdeps (xhp , pkg );
376274 if (xhp -> flags & XBPS_FLAG_DOWNLOAD_ONLY ) {
@@ -406,21 +304,6 @@ xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool forc
406304 xbps_array_t rdeps ;
407305 int rv ;
408306
409- rv = xbps_autoupdate (xhp );
410- switch (rv ) {
411- case 1 :
412- /* xbps needs to be updated, only allow xbps to be updated */
413- if (strcmp (pkg , "xbps" ))
414- return EBUSY ;
415- return 0 ;
416- case -1 :
417- /* error */
418- return EINVAL ;
419- default :
420- /* no update */
421- break ;
422- }
423-
424307 /* update its reverse dependencies */
425308 rdeps = xbps_pkgdb_get_pkg_revdeps (xhp , pkg );
426309 if (xhp -> flags & XBPS_FLAG_DOWNLOAD_ONLY ) {
0 commit comments