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