From: Seth Vidal Date: Wed, 30 Jun 2004 07:08:22 +0000 (+0000) Subject: - include xmlns:rpm in main metadata tag rather than per-format node X-Git-Tag: upstream/0.9.9~303 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=281fa90ed5553204fdbdbfb96c8da7cb4599d933;p=tools%2Fcreaterepo.git - include xmlns:rpm in main metadata tag rather than per-format node - fix output for sorta-list, sorta-string rpm header tags --- diff --git a/dumpMetadata.py b/dumpMetadata.py index 9ee2bad..446faa8 100644 --- a/dumpMetadata.py +++ b/dumpMetadata.py @@ -338,7 +338,14 @@ class RpmMetaData: return u def tagByName(self, tag): - return self.hdr[tag] + data = self.hdr[tag] + if type(data) is types.ListType: + if len(data) > 0: + return data[0] + else: + return '' + else: + return data def listTagByName(self, tag): """take a tag that should be a list and make sure it is one""" @@ -456,7 +463,7 @@ class RpmMetaData: return lst -def generateXML(doc, node, rpmObj, sumtype): +def generateXML(doc, node, formatns, rpmObj, sumtype): """takes an xml doc object and a package metadata entry node, populates a package node with the md information""" ns = node.ns() @@ -490,8 +497,9 @@ def generateXML(doc, node, rpmObj, sumtype): if rpmObj.localurl is not None: location.newProp('xml:base', rpmObj.localurl) location.newProp('href', rpmObj.relativepath) - format = pkgNode.newChild(None, 'format', None) - formatns = format.newNs('http://linux.duke.edu/metadata/rpm', 'rpm') + format = pkgNode.newChild(ns, 'format', None) + #formatns = format.newNs('http://linux.duke.edu/metadata/rpm', 'rpm') + #format.setNs(ns) for tag in ['license', 'vendor', 'group', 'buildhost', 'sourcerpm']: value = rpmObj.tagByName(tag) value = utf8String(value) diff --git a/genpkgmetadata.py b/genpkgmetadata.py index a9d0ddb..cc847fa 100755 --- a/genpkgmetadata.py +++ b/genpkgmetadata.py @@ -231,11 +231,12 @@ def doPkgMetadata(cmds, ts): basedoc = libxml2.newDoc("1.0") baseroot = basedoc.newChild(None, "metadata", None) basens = baseroot.newNs('http://linux.duke.edu/metadata/common', None) + formatns = baseroot.newNs('http://linux.duke.edu/metadata/rpm', 'rpm') baseroot.setNs(basens) basefilepath = os.path.join(cmds['tempdir'], cmds['primaryfile']) basefile = _gzipOpen(basefilepath, 'w') basefile.write('\n') - basefile.write('\n' % + basefile.write('\n' % pkgcount) # setup the file list doc @@ -279,7 +280,7 @@ def doPkgMetadata(cmds, ts): continue else: try: - node = dumpMetadata.generateXML(basedoc, baseroot, mdobj, cmds['sumtype']) + node = dumpMetadata.generateXML(basedoc, baseroot, formatns, mdobj, cmds['sumtype']) except dumpMetadata.MDError, e: errorprint(_('\nAn error occurred creating primary metadata: %s') % e) continue