summaryrefslogtreecommitdiffstats
path: root/createprestorepo/dumpMetadata.py
diff options
context:
space:
mode:
authorJonathan Dieter <jdieter@gmail.com>2007-04-03 16:26:09 +0300
committerJonathan Dieter <jdieter@gmail.com>2007-04-03 16:26:09 +0300
commitbdfb4037667c6af7d0537f9bc36b33d55d86e059 (patch)
tree7a437ab002f05fe3a6cb8421a4137757fd01df2c /createprestorepo/dumpMetadata.py
parent20a630be934db6374ace720e473beb1ec05e31fc (diff)
downloadpresto-bdfb4037667c6af7d0537f9bc36b33d55d86e059.zip
presto-bdfb4037667c6af7d0537f9bc36b33d55d86e059.tar.gz
presto-bdfb4037667c6af7d0537f9bc36b33d55d86e059.tar.xz
Add Ahmed's patch to rebuild rpms in separate thread.
Complete rebuild of createprestorepo Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
Diffstat (limited to 'createprestorepo/dumpMetadata.py')
-rwxr-xr-xcreateprestorepo/dumpMetadata.py105
1 files changed, 71 insertions, 34 deletions
diff --git a/createprestorepo/dumpMetadata.py b/createprestorepo/dumpMetadata.py
index 2f074da..5ad9cf5 100755
--- a/createprestorepo/dumpMetadata.py
+++ b/createprestorepo/dumpMetadata.py
@@ -233,7 +233,8 @@ class RpmMetaData:
self.pkgid = self.doChecksumCache(fo)
fo.seek(0)
(self.rangestart, self.rangeend) = byteranges(fo)
- fo.close()
+ fo.seek(self.rangeend)
+ self._getOldInfo(fo)
del fo
del fd
@@ -243,29 +244,40 @@ class RpmMetaData:
else:
return self.tagByName('arch')
- def _correctVersion(self, vers):
- returnvers = []
- vertuple = (None, None, None)
- if vers is None:
- returnvers.append(vertuple)
- return returnvers
+ def _stringToNEVR(self, string):
+ i = string.rfind("-", 0, string.rfind("-")-1)
+ name = string[:i]
+ (epoch, ver, rel) = self._stringToVersion(string[i+1:])
+ return (name, epoch, ver, rel)
+
+ def _getLength(self, in_data):
+ length = 0
+ for val in in_data:
+ length = length * 256
+ length += ord(val)
+ return length
+
+ def _getOldInfo(self, fo):
+ try:
+ compobj = gzip.GzipFile("", "rb", 9, fo)
+ except:
+ raise zlibError("Data not stored in gzip format")
- if type(vers) is not types.ListType:
- if vers is not None:
- vertuple = self._stringToVersion(vers)
- else:
- vertuple = (None, None, None)
- returnvers.append(vertuple)
- else:
- for ver in vers:
- if ver is not None:
- vertuple = self._stringToVersion(ver)
- else:
- vertuple = (None, None, None)
- returnvers.append(vertuple)
- return returnvers
+ if compobj.read(4)[:3] != "DLT":
+ raise Exception("Not a deltarpm")
+
+ nevr_length = self._getLength(compobj.read(4))
+ nevr = compobj.read(nevr_length).strip("\x00")
+ seq_length = self._getLength(compobj.read(4))
+ seq = compobj.read(seq_length)
+ hex_seq = ""
+ for char in seq:
+ hex_seq += str("%02x" % ord(char))
+ self.oldnevrstring = nevr
+ self.oldnevr = self._stringToNEVR(nevr)
+ self.sequence = hex_seq
+ compobj.close()
-
def _stringToVersion(self, strng):
i = strng.find(':')
if i != -1:
@@ -400,7 +412,7 @@ class RpmMetaData:
if not self.options['cache']:
return getChecksum(self.options['sumtype'], fo)
- csumtag = '%s-%s' % (self.hdr['name'] , self.hdr[rpm.RPMTAG_SHA1HEADER])
+ csumtag = os.path.basename(self.relativepath) + ".cache"
csumfile = '%s/%s' % (self.options['cachedir'], csumtag)
if os.path.exists(csumfile) and self.mtime <= os.stat(csumfile)[8]:
csumo = open(csumfile, 'r')
@@ -417,19 +429,44 @@ class RpmMetaData:
-def generateXML(doc, node, formatns, drpmObj, sumtype):
+def generateXML(doc, node, formatns, drpmObj, sumtype, pkgDeltas):
"""takes an xml doc object and a package metadata entry node, populates a
package node with the md information"""
- ns = node.ns()
- pkgNode = node.newChild(None, "package", None)
- pkgNode.newProp('type', 'rpm')
- pkgNode.newChild(None, 'name', drpmObj.tagByName('name'))
- pkgNode.newChild(None, 'arch', drpmObj.arch())
- version = pkgNode.newChild(None, 'version', None)
- version.newProp('epoch', str(drpmObj.epoch()))
- version.newProp('ver', str(drpmObj.tagByName('version')))
- version.newProp('rel', str(drpmObj.tagByName('release')))
- return pkgNode
+ name = drpmObj.tagByName('name')
+ arch = drpmObj.arch()
+ epoch = str(drpmObj.epoch())
+ ver = str(drpmObj.tagByName('version'))
+ rel = str(drpmObj.tagByName('release'))
+ if not pkgDeltas.has_key('%s-%s:%s-%s.%s' % (name, epoch, ver, rel, arch)):
+ pkgNode = node.newChild(None, "package", None)
+ pkgNode.newProp('type', 'rpm')
+ pkgNode.newChild(None, 'name', name)
+ pkgNode.newChild(None, 'arch', arch)
+ version = pkgNode.newChild(None, 'version', None)
+ version.newProp('epoch', epoch)
+ version.newProp('ver', ver)
+ version.newProp('rel', rel)
+ deltas = pkgNode.newChild(None, 'deltas', None)
+ pkgDeltas['%s-%s:%s-%s.%s' % (name, epoch, ver, rel, arch)] = deltas
+ else:
+ deltas = pkgDeltas['%s-%s:%s-%s.%s' % (name, epoch, ver, rel, arch)]
+ (oldname, oldepoch, oldver, oldrel) = drpmObj.oldnevr
+ drpmNode = deltas.newChild(None, "oldrpm", None)
+ if name != oldname:
+ drpmNode.newChild(None, 'name', oldname)
+ # oldrpm arch is not stored in drpm, so we can only work within same arch
+ version = drpmNode.newChild(None, 'version', None)
+ if epoch != oldepoch:
+ version.newProp('epoch', oldepoch)
+ if ver != oldver:
+ version.newProp('ver', oldver)
+ version.newProp('rel', oldrel)
+ drpmNode.newChild(None, 'drpm_filename', drpmObj.relativepath)
+ drpmNode.newChild(None, 'size', str(drpmObj.size))
+ drpmNode.newChild(None, 'sequence', '%s-%s' % (drpmObj.oldnevrstring, drpmObj.sequence))
+ checksum = drpmNode.newChild(None, 'checksum', drpmObj.pkgid)
+ checksum.newProp('type', drpmObj.options['sumtype'])
+
def repoXML(node, cmds):
"""generate the repomd.xml file that stores the info on the other files"""