@@ -107,6 +107,7 @@ xbps_transaction_commit(struct xbps_handle *xhp)
107107 xbps_object_t obj ;
108108 xbps_object_iterator_t iter ;
109109 xbps_trans_type_t ttype ;
110+ struct xbps_hooks * hooks = NULL ;
110111 const char * pkgver = NULL , * pkgname = NULL ;
111112 int rv = 0 ;
112113 bool update ;
@@ -146,6 +147,12 @@ xbps_transaction_commit(struct xbps_handle *xhp)
146147 if (iter == NULL )
147148 return EINVAL ;
148149
150+ hooks = xbps_hooks_init (xhp );
151+ if (!hooks ) {
152+ rv = errno ;
153+ goto out ;
154+ }
155+
149156 /*
150157 * Download and verify binary packages.
151158 */
@@ -299,6 +306,14 @@ xbps_transaction_commit(struct xbps_handle *xhp)
299306 }
300307 xbps_object_iterator_reset (iter );
301308
309+ /*
310+ * Run pre-transaction hooks
311+ */
312+ rv = xbps_hooks_pre_transaction (xhp , hooks );
313+ if (rv < 0 ) {
314+ rv = - rv ;
315+ goto out ;
316+ }
302317
303318 while ((obj = xbps_object_iterator_next (iter )) != NULL ) {
304319 xbps_dictionary_get_cstring_nocopy (obj , "pkgver" , & pkgver );
@@ -429,7 +444,25 @@ xbps_transaction_commit(struct xbps_handle *xhp)
429444 }
430445 }
431446
447+ /*
448+ * Re-read hooks after packages have been unpackaed so we can run new
449+ * post-transaction hooks.
450+ */
451+ xbps_hooks_free (hooks );
452+ hooks = xbps_hooks_init (xhp );
453+ if (!hooks ) {
454+ rv = errno ;
455+ goto out ;
456+ }
457+
458+ rv = xbps_hooks_post_transaction (xhp , hooks );
459+ if (rv < 0 ) {
460+ rv = - rv ;
461+ goto out ;
462+ }
463+
432464out :
465+ xbps_hooks_free (hooks );
433466 xbps_object_release (remove_scripts );
434467 xbps_object_iterator_release (iter );
435468 if (rv == 0 ) {
0 commit comments