From eebe8047cced799ccff013be9318756349777ad0 Mon Sep 17 00:00:00 2001 From: msw Date: Fri, 11 Feb 2000 21:06:10 +0000 Subject: [PATCH] add a method to fill the filelist fully CVS patchset: 3553 CVS date: 2000/02/11 21:06:10 --- python/rpmmodule.c | 31 +++++++++++++++++++++++++++++++ python/testhdr | 15 ++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/python/rpmmodule.c b/python/rpmmodule.c index ba24c64..c010451 100644 --- a/python/rpmmodule.c +++ b/python/rpmmodule.c @@ -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; diff --git a/python/testhdr b/python/testhdr index d209bee..f1b8150 100755 --- a/python/testhdr +++ b/python/testhdr @@ -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') + -- 2.7.4