createrepo/__init__.py createrepo/readMetadata.py

[email protected] (Seth Vidal)
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
 createrepo/__init__.py     |    6 +-----
 createrepo/readMetadata.py |   18 +++++++++++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

New commits:
commit 05d2efbadbbeb3cc9957a8bc0c41b05ceda08d57
Author: Seth Vidal <[email protected]>
Date:   Mon Jan 28 21:28:17 2008 -0500

    make readMetadata.py take its metadata file locations from
    repomd.xml using the yum parser for it.
    complete --unique-md-filenames implementation

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 429bb07..e26961f 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -297,9 +297,6 @@ class MetaDataGenerator:
         # the files WERE to pass in the right fns.
         if self.conf.update:
             #build the paths
-            primaryfile = os.path.join(self.conf.outputdir, self.conf.finaldir, self.conf.primaryfile)
-            flfile = os.path.join(self.conf.outputdir, self.conf.finaldir, self.conf.filelistsfile)
-            otherfile = os.path.join(self.conf.outputdir, self.conf.finaldir, self.conf.otherfile)
             opts = {
                 'verbose' : self.conf.verbose,
                 'pkgdir'  : os.path.normpath(self.package_dir)
@@ -308,8 +305,7 @@ class MetaDataGenerator:
                 opts['do_stat'] = False
                 
             #and scan the old repo
-            self.oldData = readMetadata.MetadataIndex(self.conf.outputdir,
-                                                      primaryfile, flfile, otherfile, opts)
+            self.oldData = readMetadata.MetadataIndex(self.conf.outputdir, opts)
            
     def doPkgMetadata(self):
         """all the heavy lifting for the package metadata"""
diff --git a/createrepo/readMetadata.py b/createrepo/readMetadata.py
index 72ac845..ea2c400 100644
--- a/createrepo/readMetadata.py
+++ b/createrepo/readMetadata.py
@@ -21,14 +21,25 @@ import libxml2
 import stat
 from utils import errorprint, _
 
+from yum import repoMDObject
+
 
 class MetadataIndex(object):
 
-    def __init__(self, outputdir, basefile, filelistfile, otherfile, opts=None):
+    def __init__(self, outputdir, opts=None):
         if opts is None:
             opts = {}
         self.opts = opts
         self.outputdir = outputdir
+        repodatadir = self.outputdir + '/repodata'
+        myrepomdxml = repodatadir + '/repomd.xml'
+        repomd = repoMDObject.RepoMD('garbageid', myrepomdxml)
+        b = repomd.getData('primary').location[1]
+        f = repomd.getData('filelists').location[1]
+        o = repomd.getData('other').location[1]
+        basefile = os.path.join(self.outputdir, b)
+        filelistfile = os.path.join(self.outputdir, f)
+        otherfile = os.path.join(self.outputdir, o)
         self.files = {'base' : basefile,
                       'filelist' : filelistfile,
                       'other' : otherfile}
@@ -191,13 +202,10 @@ class MetadataIndex(object):
 
 if __name__ == "__main__":
     cwd = os.getcwd()
-    p = os.path.join(cwd, "repodata/primary.xml.gz")     
-    f = os.path.join(cwd, "repodata/filelists.xml.gz")
-    o = os.path.join(cwd, "repodata/other.xml.gz")
     opts = {'verbose':1, 
             'pkgdir': cwd}
             
-    idx = MetadataIndex(".", p, f, o, opts)
+    idx = MetadataIndex(cwd, opts)
     for fn in idx.basenodes.keys():
        a,b,c, = idx.getNodes(fn)
        a.serialize()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.