summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/rpmmodule.c19
-rwxr-xr-xpython/testhdr31
2 files changed, 50 insertions, 0 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 888adc9f2..ba24c6449 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -9,6 +9,7 @@
#include "Python.h"
#include "rpmlib.h"
+#include "misc.h"
#include "rpmmacro.h"
#include "upgrade.h"
@@ -39,6 +40,8 @@ static PyObject * hdrSubscript(hdrObject * s, PyObject * item);
static PyObject * hdrKeyList(hdrObject * s, PyObject * args);
static PyObject * hdrUnload(hdrObject * s, PyObject * args);
static PyObject * hdrVerifyFile(hdrObject * s, PyObject * args);
+static PyObject * hdrCompressFilelist(hdrObject * s, PyObject * args);
+static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args);
void initrpm(void);
static PyObject * doAddMacro(PyObject * self, PyObject * args);
@@ -205,6 +208,8 @@ static struct PyMethodDef hdrMethods[] = {
{"keys", (PyCFunction) hdrKeyList, 1 },
{"unload", (PyCFunction) hdrUnload, 1 },
{"verifyFile", (PyCFunction) hdrVerifyFile, 1 },
+ {"expandFilelist", (PyCFunction) hdrExpandFilelist, 1 },
+ {"compressFilelist", (PyCFunction) hdrCompressFilelist, 1 },
{NULL, NULL} /* sentinel */
};
@@ -1262,6 +1267,20 @@ static PyObject * hdrVerifyFile(hdrObject * s, PyObject * args) {
return list;
}
+static PyObject * hdrCompressFilelist(hdrObject * s, PyObject * args) {
+ compressFilelist (s->h);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args) {
+ expandFilelist (s->h);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyObject * rpmtransCreate(PyObject * self, PyObject * args) {
rpmtransObject * o;
rpmdbObject * db = NULL;
diff --git a/python/testhdr b/python/testhdr
new file mode 100755
index 000000000..d209bee38
--- /dev/null
+++ b/python/testhdr
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import rpm
+
+def printlist(h, tag):
+ print "####### %s tag contains:" % tag
+ i = 0
+ list = h[tag]
+ if not list:
+ print "NO SUCH TAG"
+ return
+
+ for file in list:
+ print file
+ i = i + 1
+ print "******** %d files" % i
+
+
+db = rpm.opendb(0)
+rc = db.findbyname('redhat-release')
+h = db[rc[0]]
+printlist (h, 'filenames')
+printlist (h, 'oldfilenames')
+h.expandFilelist()
+print "-------------- expand --------------------"
+printlist (h, 'oldfilenames')
+printlist (h, 'filenames')
+print "-------------- compress --------------------"
+h.compressFilelist()
+printlist (h, 'oldfilenames')
+printlist (h, 'filenames')