add a method to fill the filelist fully
authormsw <devnull@localhost>
Fri, 11 Feb 2000 21:06:10 +0000 (21:06 +0000)
committermsw <devnull@localhost>
Fri, 11 Feb 2000 21:06:10 +0000 (21:06 +0000)
CVS patchset: 3553
CVS date: 2000/02/11 21:06:10

python/rpmmodule.c
python/testhdr

index ba24c64..c010451 100644 (file)
@@ -42,6 +42,7 @@ 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);
+static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args);
 
 void initrpm(void);
 static PyObject * doAddMacro(PyObject * self, PyObject * args);
@@ -210,6 +211,7 @@ static struct PyMethodDef hdrMethods[] = {
        {"verifyFile",  (PyCFunction) hdrVerifyFile,    1 },
        {"expandFilelist",      (PyCFunction) hdrExpandFilelist,        1 },
        {"compressFilelist",    (PyCFunction) hdrCompressFilelist,      1 },
+       {"fullFilelist",        (PyCFunction) hdrFullFilelist,  1 },
        {NULL,          NULL}           /* sentinel */
 };
 
@@ -361,6 +363,28 @@ void initrpm(void) {
                         PyInt_FromLong(RPMPROB_DISKSPACE));
 }
 
+/* make a header with _all_ the tags we need */
+void mungeFilelist(Header h)
+{
+    const char ** fileNames = NULL;
+    int count = 0;
+
+    if (!headerIsEntry (h, RPMTAG_BASENAMES)
+       || !headerIsEntry (h, RPMTAG_DIRNAMES)
+       || !headerIsEntry (h, RPMTAG_DIRINDEXES))
+       compressFilelist(h);
+    
+    rpmBuildFileList(h, &fileNames, &count);
+
+    if (fileNames == NULL || count <= 0)
+       return;
+
+    headerAddEntry(h, RPMTAG_OLDFILENAMES, RPM_STRING_ARRAY_TYPE,
+                       fileNames, count);
+
+    xfree(fileNames);
+}
+
 
 static int psGetArchScore(Header h) {
     void * pkgArch;
@@ -1281,6 +1305,13 @@ static PyObject * hdrExpandFilelist(hdrObject * s, PyObject * args) {
     return Py_None;
 }
 
+static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) {
+    mungeFilelist (s->h);
+
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
 static PyObject * rpmtransCreate(PyObject * self, PyObject * args) {
     rpmtransObject * o;
     rpmdbObject * db = NULL;
index d209bee..f1b8150 100755 (executable)
@@ -21,11 +21,24 @@ rc = db.findbyname('redhat-release')
 h = db[rc[0]]
 printlist (h, 'filenames')
 printlist (h, 'oldfilenames')
-h.expandFilelist()
+
 print "-------------- expand --------------------"
+h.expandFilelist()
 printlist (h, 'oldfilenames')
 printlist (h, 'filenames')
+
 print "-------------- compress --------------------"
 h.compressFilelist()
 printlist (h, 'oldfilenames')
 printlist (h, 'filenames')
+
+print "-------------- expand --------------------"
+h.expandFilelist()
+printlist (h, 'oldfilenames')
+printlist (h, 'filenames')
+
+print "-------------- full --------------------"
+h.fullFilelist()
+printlist (h, 'oldfilenames')
+printlist (h, 'filenames')
+