Parçalı ve stateli build işlemi.

Şimdi, build için iki komutumuz var.

build: normal build işlemini uygular

build-until: belirli bir state'e kadar build eder. Kullanımı için
"pisi-cli help build-until" komutunun çıktısına bakın.

Dikkat! -sStateName pisi-cli'dan hemen sonra verilmeli, yoksa ilk
parse etme işlemi sapıtıyor. Bunu düzeltmek için bazı kısıtlamalar
getirmeyi planlıyorum. Sonra açıklarım.
This commit is contained in:
Barış Metin
2005-07-29 13:06:21 +00:00
parent 321f0371dc
commit bfc25e05ff
4 changed files with 102 additions and 109 deletions
+12 -5
View File
@@ -78,6 +78,16 @@ class PisiBuild:
ui.error("PSPEC file is not valid")
raise PisiBuildError, "invalid PSPEC file %s" % self.ctx.pspecfile
def setState(self, state):
stateFile = os.path.join(self.srcDir, "pisiBuildState")
open(stateFile, "w").write(state)
def getState(self):
stateFile = os.path.join(self.srcDir, "pisiBuildState")
if not os.path.exists(stateFile): # no state
return None
return open(stateFile, "r").read()
def build(self):
"""Build the package in one shot."""
@@ -166,11 +176,8 @@ class PisiBuild:
except KeyError:
workdir = self.spec.source.name + "-" + self.spec.source.version
path = os.path.join(self.ctx.pkg_work_dir(), workdir)
if not os.path.exists(path):
ui.error ("No such file or directory: %s\n" % path)
sys.exit(1)
return path
return os.path.join(self.ctx.pkg_work_dir(), workdir)
def runActionFunction(self, func, mandatory=False):
"""Calls the corresponding function in actions.py.
+13 -66
View File
@@ -12,10 +12,7 @@ import pisi.toplevel
def cmdObject(cmd, fail=False):
commands = {"help": Help,
"build": Build,
"build-unpack": BuildUnpack,
"build-runsetupaction": BuildRunSetupAction,
"build-runbuildaction": BuildRunBuildAction,
"build-runinstallaction": BuildRunInstallAction,
"build-until": BuildUntil,
"info": Info,
"install": Install,
"list-installed": ListInstalled,
@@ -375,82 +372,32 @@ TODO: Some description...
# Partial build commands
class BuildUnpack(Command):
"""Unpack source using a pspec.xml file
class BuildUntil(Command):
"""Run the build process partially
Usage:
build-unpack pspec.xml
-sStateName build-until <pspec file>
Where states are:
unpack, setupaction, buildaction, installaction, buildpackages
You can give an URI of the pspec.xml file. PISI will fetch all
necessary files and unpack the source and prepare a source directory
for you.
"""
def __init__(self):
super(BuildUnpack, self).__init__()
super(BuildUntil, self).__init__()
def options(self):
self.parser.add_option("-s", action="store", dest="state")
def run(self):
if not self.args:
self.help()
return
for arg in self.args:
pisi.toplevel.build_unpack(arg, self.authInfo)
class BuildRunSetupAction(Command):
"""Unpack source using a pspec.xml file
Usage:
build-runsetupaction pspec.xml
TODO: Some desc.
"""
def __init__(self):
super(BuildRunSetupAction, self).__init__()
def run(self):
if not self.args:
self.help()
return
state = self.options.state
for arg in self.args:
pisi.toplevel.build_runSetupAction(arg, self.authInfo)
pisi.toplevel.build_until(arg, state, self.authInfo)
class BuildRunBuildAction(Command):
"""Unpack source using a pspec.xml file
Usage:
build-runbuildaction pspec.xml
TODO: Some desc.
"""
def __init__(self):
super(BuildRunBuildAction, self).__init__()
def run(self):
if not self.args:
self.help()
return
for arg in self.args:
pisi.toplevel.build_runBuildAction(arg, self.authInfo)
class BuildRunInstallAction(Command):
"""Unpack source using a pspec.xml file
Usage:
build-runsetupactions pspec.xml
TODO: Some desc.
"""
def __init__(self):
super(BuildRunInstallAction, self).__init__()
def run(self):
if not self.args:
self.help()
return
for arg in self.args:
pisi.toplevel.build_runInstallAction(arg, self.authInfo)
+1 -4
View File
@@ -4,10 +4,7 @@ where <command> is one of:
help
build
build-unpack
build-runsetupaction
build-runbuildaction
build-runinstallaction
build-until
index
info
install
+76 -34
View File
@@ -144,43 +144,85 @@ def prepare_for_build(pspecfile, authInfo=None):
pb = PisiBuild(url.uri)
return pb
def build_unpack(pspecfile, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo)
pb.fetchSourceArchive()
pb.unpackSourceArchive()
pb.compileActionScript()
pb.applyPatches()
def build_runSetupAction(pspecfile, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo)
pb.fetchSourceArchive()
pb.unpackSourceArchive()
pb.compileActionScript()
pb.applyPatches()
pb.runSetupAction()
def build_runBuildAction(pspecfile, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo)
pb.fetchSourceArchive()
pb.unpackSourceArchive()
pb.compileActionScript()
pb.applyPatches()
pb.runSetupAction()
pb.runBuildAction()
def build_runInstallAction(pspecfile, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo)
pb.fetchSourceArchive()
pb.unpackSourceArchive()
pb.compileActionScript()
pb.applyPatches()
pb.runSetupAction()
pb.runBuildAction()
pb.runInstallAction()
def build(pspecfile, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo)
pb.build()
def __buildState_unpack(pb):
# unpack is the first state to run.
pb.fetchSourceArchive()
pb.unpackSourceArchive()
pb.applyPatches()
pb.setState("unpack")
def __buildState_setupAction(pb, lastState):
if lastState != "unpack":
__buildState_unpack(pb)
pb.runSetupAction()
pb.setState("setupaction")
def __buildState_buildAction(pb, lastState):
if lastState != "setupaction":
__buildState_setupAction(pb, lastState)
pb.runBuildAction()
pb.setState("buildaction")
def __buildState_installAction(pb, lastState):
if lastState != "buildaction":
__buildState_buildAction(pb, lastState)
pb.runInstallAction()
pb.setState("installaction")
def __buildState_package(pb, lastState):
if lastState != "installaction":
__buildState_installAction(pb, lastState)
pb.buildPackages()
pb.setState("buildpackages")
def build_until(pspecfile, state, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo)
pb.compileActionScript()
last = pb.getState()
ui.info("Last state is %s\n"%last)
if not last: last = "none"
elif last == state: return # allready there
order = {"none": 0,
"unpack": 1,
"setupaction": 2,
"buildaction": 3,
"installaction": 4,
"buildpackages": 5}
if last != "unpack" or order[last] < order["unpack"]:
__buildState_unpack(pb)
if state == "unpack": return
if last != "setupaction" or order[last] < order["setupaction"]:
__buildState_setupAction(pb, last)
if state == "setupaction": return
if last != "buildaction" or order[last] < order["buildaction"]:
__buildState_buildAction(pb, last)
if state == "buildaction": return
if last != "installaction" or order[last] < order["installaction"]:
__buildState_installAction(pb, last)
if state == "installaction": return
__buildState_package(pb, last)