* xmlfile: GetChildText'i class'siz bicimde de ekle
* <Source> tag'inin altindakileri guzel bicimde SpecFile.source da tut
This commit is contained in:
+10
-8
@@ -33,10 +33,11 @@ class PisiBuild:
|
||||
self.spec = spec
|
||||
|
||||
def build(self):
|
||||
ui.info("Building PISI source package: %s\n" % self.spec.sourceName)
|
||||
ui.info("Fetching source from: %s\n" % self.spec.archiveUri)
|
||||
ui.info("Building PISI source package: %s\n" % self.spec.source.name)
|
||||
ui.info("Fetching source from: %s\n" % self.spec.source.archiveUri)
|
||||
self.fetchArchive(displayProgress)
|
||||
ui.info("Source archive is stored: %s/%s\n" %(config.archives_dir(), self.spec.archiveName))
|
||||
ui.info("Source archive is stored: %s/%s\n"
|
||||
%(config.archives_dir(), self.spec.source.archiveName))
|
||||
# unpackArchive()
|
||||
# applyPatches()
|
||||
# buildSource()
|
||||
@@ -46,13 +47,14 @@ class PisiBuild:
|
||||
def fetchArchive(self, percentHook=None):
|
||||
"""fetch an archive and store to config.archives_dir()
|
||||
using fether.Fetcher"""
|
||||
fetch = Fetcher(self.spec.archiveUri, self.spec.archiveName)
|
||||
fetch = Fetcher(self.spec.source.archiveUri,
|
||||
self.spec.source.archiveName)
|
||||
|
||||
# check if source already cached
|
||||
destpath = fetch.filedest + "/" + fetch.filename
|
||||
if os.access(destpath, os.R_OK):
|
||||
if util.md5_file(destpath)==self.spec.archiveMD5:
|
||||
ui.info('%s [cached]\n' % self.spec.archiveName)
|
||||
if util.md5_file(destpath)==self.spec.source.archiveMD5:
|
||||
ui.info('%s [cached]\n' % self.spec.source.archiveName)
|
||||
return
|
||||
|
||||
if percentHook:
|
||||
@@ -60,8 +62,8 @@ class PisiBuild:
|
||||
fetch.fetch()
|
||||
|
||||
def unpackArchive(self):
|
||||
type = self.spec.archiveType
|
||||
filename = self.spec.archiveName
|
||||
type = self.spec.source.archiveType
|
||||
filename = self.spec.source.archiveName
|
||||
archive = Archive(type, filename)
|
||||
archive.unpack()
|
||||
pass
|
||||
|
||||
+14
-9
@@ -30,6 +30,10 @@ class PathInfo:
|
||||
self.pathname = getNodeText(node)
|
||||
self.fileType = getNodeAttribute(node, "fileType")
|
||||
|
||||
# a structure to hold source information
|
||||
class SourceInfo:
|
||||
pass
|
||||
|
||||
class PackageInfo:
|
||||
def __init__(self, node):
|
||||
self.name = getNodeText(getNode(node, "Name"))
|
||||
@@ -42,7 +46,6 @@ class PackageInfo:
|
||||
self.runtimeDeps = [DepInfo(x) for x in rtDepElts]
|
||||
self.paths = [PathInfo(x) for x in getAllNodes(node, "Files/Path")]
|
||||
|
||||
|
||||
class SpecFile(XmlFile):
|
||||
"""A class for reading/writing from/to a PSPEC (PISI SPEC) file."""
|
||||
|
||||
@@ -53,20 +56,22 @@ class SpecFile(XmlFile):
|
||||
"""Read PSPEC file"""
|
||||
|
||||
self.readxml(filename)
|
||||
self.sourceName = self.getChildText("Source/Name")
|
||||
|
||||
self.source = SourceInfo()
|
||||
self.source.name = self.getChildText("Source/Name")
|
||||
archiveNode = self.getNode("Source/Archive")
|
||||
self.archiveUri = getNodeText(archiveNode).strip()
|
||||
self.archiveName = basename(self.archiveUri)
|
||||
self.archiveType = getNodeAttribute(archiveNode, "archType")
|
||||
self.archiveMD5 = getNodeAttribute(archiveNode, "md5sum")
|
||||
self.source.archiveUri = getNodeText(archiveNode).strip()
|
||||
self.source.archiveName = basename(self.source.archiveUri)
|
||||
self.source.archiveType = getNodeAttribute(archiveNode, "archType")
|
||||
self.source.archiveMD5 = getNodeAttribute(archiveNode, "md5sum")
|
||||
patchElts = self.getChildElts("Source/Patches")
|
||||
self.patches = [ PatchInfo(p) for p in patchElts ]
|
||||
self.source.patches = [ PatchInfo(p) for p in patchElts ]
|
||||
|
||||
buildDepElts = self.getChildElts("Source/BuildDependencies")
|
||||
self.buildDeps = [DepInfo(d) for d in buildDepElts]
|
||||
self.source.buildDeps = [DepInfo(d) for d in buildDepElts]
|
||||
|
||||
historyElts = self.getAllNodes("History/Update")
|
||||
self.history = [HistoryInfo(x) for x in historyElts]
|
||||
self.source.history = [HistoryInfo(x) for x in historyElts]
|
||||
|
||||
# find all binary packages
|
||||
packageElts = self.getAllNodes("Package")
|
||||
|
||||
@@ -25,6 +25,12 @@ def getNodeText(node):
|
||||
else:
|
||||
raise XmlError("getNodeText: Expected text node, got something else!")
|
||||
|
||||
def getChildText(node_s, tagpath):
|
||||
node = getNode(node_s, tagpath)
|
||||
if not node:
|
||||
return None
|
||||
return getNodeText(node)
|
||||
|
||||
def getChildElts(node):
|
||||
"""get only child elements"""
|
||||
return filter(lambda x:x.nodeType==x.ELEMENT_NODE, node.childNodes)
|
||||
|
||||
Reference in New Issue
Block a user