teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.13.0-elem-progress-callback.patch

Lubos Kardos 761a0d
From 448db68ceb5be3c7171b7ec0ea908d905792dc2f Mon Sep 17 00:00:00 2001
Lubos Kardos 761a0d
From: Michal Domonkos <mdomonko@redhat.com>
Lubos Kardos 761a0d
Date: Mon, 7 Dec 2015 17:13:26 +0100
Lubos Kardos 761a0d
Subject: [PATCH] Add RPMCALLBACK_ELEM_PROGRESS callback type
Lubos Kardos 761a0d
Lubos Kardos 761a0d
Currently, there's no callback type that would be issued per each
Lubos Kardos 761a0d
transaction element.  RPMCALLBACK_TRANS_PROGRESS is only issued during
Lubos Kardos 761a0d
the prepare phase but not when packages are actually installed or
Lubos Kardos 761a0d
erased.  Likewise, RPMCALLBACK_INST_ST* and RPMCALLBACK_UNINST_ST* won't
Lubos Kardos 761a0d
be issued if an install or erase operation is skipped for some reason (a
Lubos Kardos 761a0d
script or package upgrade failure).
Lubos Kardos 761a0d
Lubos Kardos 761a0d
Having such a callback would allow the Python API consumers to always
Lubos Kardos 761a0d
know upfront which element is about to be processed, before any other
Lubos Kardos 761a0d
callbacks are issued.  This is important since not every callback type
Lubos Kardos 761a0d
carries enough data about the subject package; while the INST types
Lubos Kardos 761a0d
provide the user object passed to a former addInstall call, the UNINST
Lubos Kardos 761a0d
types only provide the package name (which may not be unique within the
Lubos Kardos 761a0d
transaction set).
Lubos Kardos 761a0d
Lubos Kardos 761a0d
This commit adds such a callback.
Lubos Kardos 761a0d
---
Lubos Kardos 761a0d
 lib/rpmcallback.h  | 1 +
Lubos Kardos 761a0d
 lib/transaction.c  | 4 ++++
Lubos Kardos 761a0d
 python/rpmmodule.c | 1 +
Lubos Kardos 761a0d
 3 files changed, 6 insertions(+)
Lubos Kardos 761a0d
Lubos Kardos 761a0d
diff --git a/lib/rpmcallback.h b/lib/rpmcallback.h
Lubos Kardos 761a0d
index dfc22ab..f07892d 100644
Lubos Kardos 761a0d
--- a/lib/rpmcallback.h
Lubos Kardos 761a0d
+++ b/lib/rpmcallback.h
Lubos Kardos 761a0d
@@ -37,6 +37,7 @@ typedef enum rpmCallbackType_e {
Lubos Kardos 761a0d
     RPMCALLBACK_SCRIPT_START	= (1 << 16),
Lubos Kardos 761a0d
     RPMCALLBACK_SCRIPT_STOP	= (1 << 17),
Lubos Kardos 761a0d
     RPMCALLBACK_INST_STOP	= (1 << 18),
Lubos Kardos 761a0d
+    RPMCALLBACK_ELEM_PROGRESS	= (1 << 19),
Lubos Kardos 761a0d
 } rpmCallbackType;
Lubos Kardos 761a0d
 
Lubos Kardos 761a0d
 /** \ingroup rpmts
Lubos Kardos 761a0d
diff --git a/lib/transaction.c b/lib/transaction.c
Lubos Kardos 761a0d
index 66888af..4f90782 100644
Lubos Kardos 761a0d
--- a/lib/transaction.c
Lubos Kardos 761a0d
+++ b/lib/transaction.c
Lubos Kardos 761a0d
@@ -1345,12 +1345,16 @@ exit:
Lubos Kardos 761a0d
 static int rpmtsProcess(rpmts ts)
Lubos Kardos 761a0d
 {
Lubos Kardos 761a0d
     rpmtsi pi;	rpmte p;
Lubos Kardos 761a0d
+    tsMembers tsmem = rpmtsMembers(ts);
Lubos Kardos 761a0d
     int rc = 0;
Lubos Kardos 761a0d
+    int i = 0;
Lubos Kardos 761a0d
 
Lubos Kardos 761a0d
     pi = rpmtsiInit(ts);
Lubos Kardos 761a0d
     while ((p = rpmtsiNext(pi, 0)) != NULL) {
Lubos Kardos 761a0d
 	int failed;
Lubos Kardos 761a0d
 
Lubos Kardos 761a0d
+	rpmtsNotify(ts, NULL, RPMCALLBACK_ELEM_PROGRESS, i++,
Lubos Kardos 761a0d
+		tsmem->orderCount);
Lubos Kardos 761a0d
 	rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
Lubos Kardos 761a0d
 		rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
Lubos Kardos 761a0d
 
Lubos Kardos 761a0d
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
Lubos Kardos 761a0d
index 0e3ab18..29753fd 100644
Lubos Kardos 761a0d
--- a/python/rpmmodule.c
Lubos Kardos 761a0d
+++ b/python/rpmmodule.c
Lubos Kardos 761a0d
@@ -512,6 +512,7 @@ static int initModule(PyObject *m)
Lubos Kardos 761a0d
     REGISTER_ENUM(RPMCALLBACK_SCRIPT_START);
Lubos Kardos 761a0d
     REGISTER_ENUM(RPMCALLBACK_SCRIPT_STOP);
Lubos Kardos 761a0d
     REGISTER_ENUM(RPMCALLBACK_INST_STOP);
Lubos Kardos 761a0d
+    REGISTER_ENUM(RPMCALLBACK_ELEM_PROGRESS);
Lubos Kardos 761a0d
 
Lubos Kardos 761a0d
     REGISTER_ENUM(RPMPROB_BADARCH);
Lubos Kardos 761a0d
     REGISTER_ENUM(RPMPROB_BADOS);
Lubos Kardos 761a0d
-- 
Lubos Kardos 761a0d
1.9.3
Lubos Kardos 761a0d