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") ui.error("PSPEC file is not valid")
raise PisiBuildError, "invalid PSPEC file %s" % self.ctx.pspecfile 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): def build(self):
"""Build the package in one shot.""" """Build the package in one shot."""
@@ -166,11 +176,8 @@ class PisiBuild:
except KeyError: except KeyError:
workdir = self.spec.source.name + "-" + self.spec.source.version workdir = self.spec.source.name + "-" + self.spec.source.version
path = os.path.join(self.ctx.pkg_work_dir(), workdir) return 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
def runActionFunction(self, func, mandatory=False): def runActionFunction(self, func, mandatory=False):
"""Calls the corresponding function in actions.py. """Calls the corresponding function in actions.py.
+13 -66
View File
@@ -12,10 +12,7 @@ import pisi.toplevel
def cmdObject(cmd, fail=False): def cmdObject(cmd, fail=False):
commands = {"help": Help, commands = {"help": Help,
"build": Build, "build": Build,
"build-unpack": BuildUnpack, "build-until": BuildUntil,
"build-runsetupaction": BuildRunSetupAction,
"build-runbuildaction": BuildRunBuildAction,
"build-runinstallaction": BuildRunInstallAction,
"info": Info, "info": Info,
"install": Install, "install": Install,
"list-installed": ListInstalled, "list-installed": ListInstalled,
@@ -375,82 +372,32 @@ TODO: Some description...
# Partial build commands # Partial build commands
class BuildUnpack(Command): class BuildUntil(Command):
"""Unpack source using a pspec.xml file """Run the build process partially
Usage: 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 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 necessary files and unpack the source and prepare a source directory
for you. for you.
""" """
def __init__(self): 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): def run(self):
if not self.args: if not self.args:
self.help() self.help()
return return
for arg in self.args: state = self.options.state
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
for arg in self.args: 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 help
build build
build-unpack build-until
build-runsetupaction
build-runbuildaction
build-runinstallaction
index index
info info
install install
+76 -34
View File
@@ -144,43 +144,85 @@ def prepare_for_build(pspecfile, authInfo=None):
pb = PisiBuild(url.uri) pb = PisiBuild(url.uri)
return pb 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): def build(pspecfile, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo) pb = prepare_for_build(pspecfile, authInfo)
pb.build() 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)