diff --git a/pisi/build.py b/pisi/build.py index d23950a8..28666a91 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -98,18 +98,33 @@ class PisiBuild: def genMetaDataXml(self, package): #test metadata = MetaData() - d = self.ctx.pkg_install_dir() - metadata.distribution = self.ctx.const.distribution - metadata.distributionRelease = self.ctx.const.distributionRelease - metadata.architecture = "Any" # FIXME + + createElement = metadata.dom.createElement + createTextNode = metadata.dom.createTextNode + + elt = createElement("Distribution") + elt.appendChild(createTextNode(self.ctx.const.distribution)) + metadata.appendElement(elt) + + elt = createElement("DistrubutionRelease") + elt.appendChild(createTextNode(self.ctx.const.distributionRelease)) + metadata.appendElement(elt) + + elt = createElement("Architecture") + elt.appendChild(createTextNode("Any")) # FIXME + metadata.appendElement(elt) # FIXME: Bu hatalı. installsize'ı almak için tüm # pkg_install_dir()'ın boyutunu hesaplayamayız. Bir source # birden fazla kaynak üretebilir. package.paths ile # karşılaştırarak file listesinden boyutları hesaplatmalıyız. - metadata.installSize = util.dir_size(d) + d = self.ctx.pkg_install_dir() + size = util.dir_size(d) + elt = createElement("InstalledSize") + elt.appendChild(createTextNode(str(size))) + metadata.appendElement(elt) + - print d, metadata.installSize metadata.write(os.path.join(self.ctx.pkg_dir(),"metadata.xml")) def genFilesXml(self, package): diff --git a/pisi/metadata.py b/pisi/metadata.py index 987b2b99..d07cf2b8 100644 --- a/pisi/metadata.py +++ b/pisi/metadata.py @@ -7,9 +7,10 @@ from specfile import * class MetaData(XmlFile): """Package metadata. Metadata is composed of Specfile and various -other information.""" + other information.""" def __init__(self): XmlFile.__init__(self, "METADATA") + self.eltList = [] def read(self, filename): self.readxml(filename) @@ -35,9 +36,15 @@ other information.""" if size: self.installedSize = int(size) + def appendElement(self, elt): + self.eltList.append(elt) + def write(self, filename): - ui.info("METADATA WRITE NOT IMPLEMENTED\n") - pass + self.newDOM() + document = self.dom.documentElement + for elt in self.eltList: + document.appendChild(elt) + self.writexml(filename) def verify(): return True