[Rpm-metadata] createrepo/__init__.py createrepo/utils.py createrepo/yumbased.py

Seth Vidal skvidal at linux.duke.edu
Fri Aug 8 19:44:01 UTC 2008


 createrepo/__init__.py |   30 +++++++++++++++++++-----------
 createrepo/utils.py    |    1 +
 createrepo/yumbased.py |    6 +++---
 3 files changed, 23 insertions(+), 14 deletions(-)

New commits:
commit 4abe8ecfca8c0e1c63f53b561c48c176d75f9e38
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Fri Aug 8 15:40:46 2008 -0400

    minor changes for handling a packagesack and/or list of package objects as the pkglist to create
    the repo from also rename the xml_dump functions - eventually going to remove them.

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 93d094a..bebea27 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -27,6 +27,8 @@ import tempfile
 
 from yum import misc, Errors
 from yum.sqlutils import executeSQL
+from yum.packageSack import MetaSack
+from yum.packages import YumAvailablePackage
 
 import rpmUtils.transaction
 from utils import _, errorprint, MDError
@@ -320,8 +322,9 @@ class MetaDataGenerator:
             packages = self.conf.pkglist
         else:
             packages = self.getFileList(self.package_dir, '.rpm')
-            
-        packages = self.trimRpms(packages)
+        
+        if not isinstance(packages, MetaSack):
+            packages = self.trimRpms(packages)
         self.pkgcount = len(packages)
         self.openMetadataDocs()
         self.writeMetadataDocs(packages)
@@ -450,19 +453,24 @@ class MetaDataGenerator:
                     reldir = os.path.join(self.conf.basedir, directory)
                 else:
                     reldir = pkgpath
+                
+                if not isinstance(pkg, YumAvailablePackage):
+
+                    try:
+                        po = self.read_in_package(pkg, pkgpath=pkgpath, reldir=reldir)
+                    except MDError, e:
+                        # need to say something here
+                        self.callback.errorlog("\nError %s: %s\n" % (pkg, e))
+                        continue
+                else:
+                    po = pkg
 
-                try:
-                    po = self.read_in_package(pkg, pkgpath=pkgpath, reldir=reldir)
-                except MDError, e:
-                    # need to say something here
-                    self.callback.errorlog("\nError %s: %s\n" % (pkg, e))
-                    continue
                 if self.conf.database_only:
                     po.do_sqlite_dump(self.md_sqlite)
                 else:
-                    self.primaryfile.write(po.do_primary_xml_dump())
-                    self.flfile.write(po.do_filelists_xml_dump())
-                    self.otherfile.write(po.do_other_xml_dump())
+                    self.primaryfile.write(po.xml_dump_primary_metadata())
+                    self.flfile.write(po.xml_dump_filelists_metadata())
+                    self.otherfile.write(po.xml_dump_other_metadata())
             else:
                 if self.conf.verbose:
                     self.callback.log(_("Using data from old metadata for %s") % pkg)
diff --git a/createrepo/utils.py b/createrepo/utils.py
index 1dc3b0c..3dd349b 100644
--- a/createrepo/utils.py
+++ b/createrepo/utils.py
@@ -156,6 +156,7 @@ def encodefiletypelist(filetypelist):
     return result
 
 
+
 class MDError(Exception):
     def __init__(self, value=None):
         Exception.__init__(self)
diff --git a/createrepo/yumbased.py b/createrepo/yumbased.py
index 6c462c6..09f7a8c 100644
--- a/createrepo/yumbased.py
+++ b/createrepo/yumbased.py
@@ -389,14 +389,14 @@ class CreateRepoPackage(YumLocalPackage):
             del c
         return msg                                                 
 
-    def do_primary_xml_dump(self):
+    def xml_dump_primary_metadata(self):
         msg = """\n<package type="rpm">"""
         msg += self._dump_base_items()
         msg += self._dump_format_items()
         msg += """\n</package>"""
         return msg
 
-    def do_filelists_xml_dump(self):
+    def xml_dump_filelists_metadata(self):
         msg = """\n<package pkgid="%s" name="%s" arch="%s">
     <version epoch="%s" ver="%s" rel="%s"/>\n""" % (self.checksum, self.name, 
                                      self.arch, self.epoch, self.ver, self.rel)
@@ -404,7 +404,7 @@ class CreateRepoPackage(YumLocalPackage):
         msg += "</package>\n"
         return msg
 
-    def do_other_xml_dump(self):   
+    def xml_dump_other_metadata(self):   
         msg = """\n<package pkgid="%s" name="%s" arch="%s">
     <version epoch="%s" ver="%s" rel="%s"/>\n""" % (self.checksum, self.name, 
                                      self.arch, self.epoch, self.ver, self.rel)



More information about the Rpm-metadata mailing list