aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/rpm-python-restore-origin.patch
blob: e6aff52f8c17751c6837ecf7302064181a7f7ce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Fix an issue where the PACKAGEORIGIN is not properly stored.

Restore the rpmtsCallback fdSetOpen call and related code.

Upstream-Status: Pending

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>

Index: rpm/python/rpmts-py.c
===================================================================
--- rpm.orig/python/rpmts-py.c
+++ rpm/python/rpmts-py.c
@@ -672,6 +672,8 @@ rpmtsCallback(const void * hd, const rpm
     Header h = (Header) hd;
     struct rpmtsCallbackType_s * cbInfo = data;
     PyObject * pkgObj = (PyObject *) pkgKey;
+    PyObject * oh = NULL;
+    const char * origin = NULL;
     PyObject * args, * result;
     static FD_t fd;
 
@@ -693,8 +695,16 @@ rpmtsCallback(const void * hd, const rpm
 	    pkgObj = Py_None;
 	    Py_INCREF(pkgObj);
 	}
-    } else
+    } else {
 	Py_INCREF(pkgObj);
+	/* XXX yum has (h, rpmloc) tuple as pkgKey. Extract the path. */
+	if (!(PyTuple_Check(pkgObj) && PyArg_ParseTuple(pkgObj, "|Os", &oh, &origin)))
+	    origin = NULL;
+	/* XXX clean up the path, yum paths start "//..." */
+	if (origin && origin[0] == '/' && origin[1] == '/')
+	    origin++;
+    }
+
 
     PyEval_RestoreThread(cbInfo->_save);
 
@@ -723,6 +733,9 @@ SPEW((stderr, "\t%p = fdDup(%d)\n", fd,
 
 	fcntl(Fileno(fd), F_SETFD, FD_CLOEXEC);
 
+	if (origin != NULL)
+	    (void) fdSetOpen(fd, origin, 0, 0);
+
 	return fd;
     } else
     if (what == RPMCALLBACK_INST_CLOSE_FILE) {