chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
5523e9
Move RPMCALLBACK_ELEM_PROGRESS to rpmteProcess to have header available
5523e9
5523e9
The header of the rpmte is only available after rpmteOpen().
5523e9
Added num param to rpmteProcess to be able to signal the progress to the
5523e9
callback.
5523e9
5523e9
(cherry picked from commit 124ed29259b05fdf574d5e3e145bc1201b24ae4d)
5523e9
---
5523e9
diff -uNr rpm-4.11.3.orig/lib/rpmte.c rpm-4.11.3/lib/rpmte.c
5523e9
--- rpm-4.11.3.orig/lib/rpmte.c	2017-08-23 15:39:18.195927789 +0200
5523e9
+++ rpm-4.11.3/lib/rpmte.c	2017-08-23 15:40:12.857349575 +0200
5523e9
@@ -939,7 +939,7 @@
5523e9
     return rc;
5523e9
 }
5523e9
 
5523e9
-int rpmteProcess(rpmte te, pkgGoal goal)
5523e9
+int rpmteProcess(rpmte te, pkgGoal goal, int num)
5523e9
 {
5523e9
     /* Only install/erase resets pkg file info */
5523e9
     int scriptstage = (goal != PKG_INSTALL && goal != PKG_ERASE);
5523e9
@@ -959,6 +959,11 @@
5523e9
     }
5523e9
 
5523e9
     if (rpmteOpen(te, reset_fi)) {
5523e9
+	if (!scriptstage) {
5523e9
+	    rpmtsNotify(te->ts, te, RPMCALLBACK_ELEM_PROGRESS, num,
5523e9
+			rpmtsMembers(te->ts)->orderCount);
5523e9
+	}
5523e9
+
5523e9
 	failed = rpmpsmRun(te->ts, te, goal);
5523e9
 	rpmteClose(te, reset_fi);
5523e9
     }
5523e9
diff -uNr rpm-4.11.3.orig/lib/rpmte_internal.h rpm-4.11.3/lib/rpmte_internal.h
5523e9
--- rpm-4.11.3.orig/lib/rpmte_internal.h	2013-11-22 11:31:31.000000000 +0100
5523e9
+++ rpm-4.11.3/lib/rpmte_internal.h	2017-08-23 15:40:24.654440605 +0200
5523e9
@@ -56,7 +56,7 @@
5523e9
 FD_t rpmtePayload(rpmte te);
5523e9
 
5523e9
 RPM_GNUC_INTERNAL
5523e9
-int rpmteProcess(rpmte te, pkgGoal goal);
5523e9
+int rpmteProcess(rpmte te, pkgGoal goal, int num);
5523e9
 
5523e9
 RPM_GNUC_INTERNAL
5523e9
 void rpmteAddProblem(rpmte te, rpmProblemType type,
5523e9
diff -uNr rpm-4.11.3.orig/lib/transaction.c rpm-4.11.3/lib/transaction.c
5523e9
--- rpm-4.11.3.orig/lib/transaction.c	2017-08-23 15:39:18.257928268 +0200
5523e9
+++ rpm-4.11.3/lib/transaction.c	2017-08-23 15:42:24.986369126 +0200
5523e9
@@ -1170,10 +1170,11 @@
5523e9
 static int runTransScripts(rpmts ts, pkgGoal goal) 
5523e9
 {
5523e9
     int rc = 0;
5523e9
+    int i = 0;
5523e9
     rpmte p;
5523e9
     rpmtsi pi = rpmtsiInit(ts);
5523e9
     while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
5523e9
-	rc += rpmteProcess(p, goal);
5523e9
+	rc += rpmteProcess(p, goal, i++);
5523e9
     }
5523e9
     rpmtsiFree(pi);
5523e9
     return rc;
5523e9
@@ -1415,7 +1416,6 @@
5523e9
 static int rpmtsProcess(rpmts ts)
5523e9
 {
5523e9
     rpmtsi pi;	rpmte p;
5523e9
-    tsMembers tsmem = rpmtsMembers(ts);
5523e9
     int rc = 0;
5523e9
     int i = 0;
5523e9
 
5523e9
@@ -1423,8 +1423,6 @@
5523e9
     while ((p = rpmtsiNext(pi, 0)) != NULL) {
5523e9
 	int failed;
5523e9
 
5523e9
-	rpmtsNotify(ts, NULL, RPMCALLBACK_ELEM_PROGRESS, i++,
5523e9
-		tsmem->orderCount);
5523e9
 	rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
5523e9
 		rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
5523e9
 
5523e9
@@ -1432,7 +1430,7 @@
5523e9
 	    rpmtsSELabelInit(ts, 0);
5523e9
 	}
5523e9
 
5523e9
-	failed = rpmteProcess(p, rpmteType(p));
5523e9
+	failed = rpmteProcess(p, rpmteType(p), i++);
5523e9
 	if (failed) {
5523e9
 	    rpmlog(RPMLOG_ERR, "%s: %s %s\n", rpmteNEVRA(p),
5523e9
 		   rpmteTypeString(p), failed > 1 ? _("skipped") : _("failed"));