* extend specfile a bit
This commit is contained in:
+3
-2
@@ -19,10 +19,11 @@ class PisiBuild:
|
|||||||
def __init__(self, pspecfile):
|
def __init__(self, pspecfile):
|
||||||
self.pspecfile = pspecfile
|
self.pspecfile = pspecfile
|
||||||
pspec = SpecFile(pspecfile)
|
pspec = SpecFile(pspecfile)
|
||||||
|
pspec.read()
|
||||||
|
|
||||||
self.packageName = pspec.getFirstChildText("PSPEC/Source/Name")
|
self.packageName = pspec.getFirstChildText("Source/Name")
|
||||||
|
|
||||||
archiveNode = pspec.getFirstNode("PSPEC/Source/Archive")
|
archiveNode = pspec.getFirstNode("Source/Archive")
|
||||||
self.archiveUri = pspec.getNodeText(archiveNode).strip()
|
self.archiveUri = pspec.getNodeText(archiveNode).strip()
|
||||||
self.archiveName = basename(self.archiveUri)
|
self.archiveName = basename(self.archiveUri)
|
||||||
self.archiveType = pspec.getNodeAttribute(archiveNode, "archType")
|
self.archiveType = pspec.getNodeAttribute(archiveNode, "archType")
|
||||||
|
|||||||
+3
-2
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
db_dir = "/var/db/pisi/"
|
db_dir = "/var/db/pisi/"
|
||||||
archives_dir = "/var/cache/pisi/archives"
|
archives_dir = "/var/cache/pisi/archives/"
|
||||||
build_dir = "/var/tmp/pisi/"
|
tmp_dir = "/var/tmp/pisi/"
|
||||||
|
build_dir = tmp_dir + "build/"
|
||||||
|
|||||||
+24
-4
@@ -6,15 +6,33 @@ class SpecFile:
|
|||||||
"""SpecFile: A class for extracting specific information
|
"""SpecFile: A class for extracting specific information
|
||||||
from a PSPEC file"""
|
from a PSPEC file"""
|
||||||
def __init__(self, specfile):
|
def __init__(self, specfile):
|
||||||
self.dom = xml.dom.minidom.parse(specfile)
|
self.filename = specfile
|
||||||
|
|
||||||
|
def read():
|
||||||
|
self.dom = xml.dom.minidom.parse(filename)
|
||||||
|
# fill in fields
|
||||||
|
|
||||||
|
self.packageName = pspec.getFirstChildText("Source/Name")
|
||||||
|
|
||||||
|
archiveNode = pspec.getFirstNode("Source/Archive")
|
||||||
|
self.archiveUri = pspec.getNodeText(archiveNode).strip()
|
||||||
|
self.archiveName = basename(self.archiveUri)
|
||||||
|
self.archiveType = pspec.getNodeAttribute(archiveNode, "archType")
|
||||||
|
self.archiveHash = pspec.getNodeAttribute(archiveNode,
|
||||||
|
"md5sum")
|
||||||
|
patchesnode = pspec.getFirstNode("Source/Patches")
|
||||||
|
|
||||||
|
def write(outfn):
|
||||||
|
f = file(outfn, 'w')
|
||||||
|
xml.dom.minidom.writexml(f)
|
||||||
|
|
||||||
def getNodes(self, nodepath):
|
def getNodes(self, nodepath):
|
||||||
"""getNodes function return nodes for given path of the node.
|
"""getNodes function return nodes for given path of the node.
|
||||||
getNodes("PSPEC/Source/Name")
|
getNodes("Source/Name")
|
||||||
returns an array of Name tags in PSPEC/Source"""
|
returns a list of nodes in PSPEC/Source"""
|
||||||
|
nodepath = "PSPEC/" + nodepath
|
||||||
nodeArray=nodepath.split('/')
|
nodeArray=nodepath.split('/')
|
||||||
|
|
||||||
|
|
||||||
# get DOM for top node
|
# get DOM for top node
|
||||||
nodelist = self.dom.getElementsByTagName(nodeArray[0])
|
nodelist = self.dom.getElementsByTagName(nodeArray[0])
|
||||||
# iterate over
|
# iterate over
|
||||||
@@ -24,6 +42,7 @@ from a PSPEC file"""
|
|||||||
return nodelist
|
return nodelist
|
||||||
|
|
||||||
def getFirstNode(self, nodepath):
|
def getFirstNode(self, nodepath):
|
||||||
|
nodepath = "PSPEC/" + nodepath
|
||||||
try:
|
try:
|
||||||
return self.getNodes(nodepath)[0]
|
return self.getNodes(nodepath)[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@@ -40,6 +59,7 @@ from a PSPEC file"""
|
|||||||
return child.data
|
return child.data
|
||||||
|
|
||||||
def getFirstChildText(self, nodepath):
|
def getFirstChildText(self, nodepath):
|
||||||
|
nodepath = "PSPEC/" + nodepath
|
||||||
node = self.getFirstNode(nodepath)
|
node = self.getFirstNode(nodepath)
|
||||||
if not node:
|
if not node:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user