yeni komutlar, action'lar ayrı ayrı bölünüyor... Bu işi yapan kod epey çirkin şu anda. arayüzün nasıl olacağına karar verelim onu düzeltirim.

This commit is contained in:
Barış Metin
2005-07-29 09:46:54 +00:00
parent ae8feb205a
commit 321f0371dc
4 changed files with 88 additions and 19 deletions
+16 -8
View File
@@ -94,7 +94,9 @@ class PisiBuild:
# apply the patches and prepare a source directory for build. # apply the patches and prepare a source directory for build.
self.applyPatches() self.applyPatches()
self.runActions() self.runSetupAction()
self.runBuildAction()
self.runInstallAction()
# after all, we are ready to build/prepare the packages # after all, we are ready to build/prepare the packages
self.buildPackages() self.buildPackages()
@@ -123,22 +125,20 @@ class PisiBuild:
self.sourceArchive.unpack() self.sourceArchive.unpack()
ui.info(" unpacked (%s)\n" % self.ctx.pkg_work_dir()) ui.info(" unpacked (%s)\n" % self.ctx.pkg_work_dir())
def runActions(self): def runSetupAction(self):
# we'll need our working directory after actionscript
# finished its work in the archive source directory.
curDir = os.getcwd()
os.chdir(self.srcDir)
# Run configure, build and install phase # Run configure, build and install phase
ui.action("Setting up source...\n") ui.action("Setting up source...\n")
self.runActionFunction(const.setup_func) self.runActionFunction(const.setup_func)
def runBuildAction(self):
ui.action("Building source...\n") ui.action("Building source...\n")
self.runActionFunction(const.build_func) self.runActionFunction(const.build_func)
def runInstallAction(self):
ui.action("Intalling...\n") ui.action("Intalling...\n")
# install function is mandatory! # install function is mandatory!
self.runActionFunction(const.install_func, True) self.runActionFunction(const.install_func, True)
os.chdir(curDir)
def compileActionScript(self): def compileActionScript(self):
"""Compiles actions.py and sets the actionLocals and actionGlobals""" """Compiles actions.py and sets the actionLocals and actionGlobals"""
@@ -177,12 +177,20 @@ class PisiBuild:
If mandatory parameter is True, and function is not present in If mandatory parameter is True, and function is not present in
actionLocals PisiBuildError will be raised.""" actionLocals PisiBuildError will be raised."""
# we'll need our working directory after actionscript
# finished its work in the archive source directory.
curDir = os.getcwd()
os.chdir(self.srcDir)
if func in self.actionLocals: if func in self.actionLocals:
self.actionLocals[func]() self.actionLocals[func]()
else: else:
if mandatory: if mandatory:
PisiBuildError, "unable to call function from actions: %s" %func PisiBuildError, "unable to call function from actions: %s" %func
os.chdir(curDir)
def solveBuildDependencies(self): def solveBuildDependencies(self):
"""pre-alpha: fail if dependencies not satisfied""" """pre-alpha: fail if dependencies not satisfied"""
pass pass
+48 -8
View File
@@ -13,7 +13,9 @@ def cmdObject(cmd, fail=False):
commands = {"help": Help, commands = {"help": Help,
"build": Build, "build": Build,
"build-unpack": BuildUnpack, "build-unpack": BuildUnpack,
"build-runactions": BuildRunActions, "build-runsetupaction": BuildRunSetupAction,
"build-runbuildaction": BuildRunBuildAction,
"build-runinstallaction": BuildRunInstallAction,
"info": Info, "info": Info,
"install": Install, "install": Install,
"list-installed": ListInstalled, "list-installed": ListInstalled,
@@ -394,18 +396,16 @@ for you.
for arg in self.args: for arg in self.args:
pisi.toplevel.build_unpack(arg, self.authInfo) pisi.toplevel.build_unpack(arg, self.authInfo)
class BuildRunActions(Command): class BuildRunSetupAction(Command):
"""Unpack source using a pspec.xml file """Unpack source using a pspec.xml file
Usage: Usage:
build-runactions pspec.xml build-runsetupaction pspec.xml
You can give an URI of the pspec.xml file. PISI will fetch all TODO: Some desc.
necessary files and unpack the source, prepare a source directory and
run the functions in actions.py.
""" """
def __init__(self): def __init__(self):
super(BuildRunActions, self).__init__() super(BuildRunSetupAction, self).__init__()
def run(self): def run(self):
if not self.args: if not self.args:
@@ -413,4 +413,44 @@ run the functions in actions.py.
return return
for arg in self.args: for arg in self.args:
pisi.toplevel.build_runactions(arg, self.authInfo) pisi.toplevel.build_runSetupAction(arg, 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)
+3 -1
View File
@@ -5,7 +5,9 @@ where <command> is one of:
help help
build build
build-unpack build-unpack
build-runactions build-runsetupaction
build-runbuildaction
build-runinstallaction
index index
info info
install install
+21 -2
View File
@@ -151,13 +151,32 @@ def build_unpack(pspecfile, authInfo=None):
pb.compileActionScript() pb.compileActionScript()
pb.applyPatches() pb.applyPatches()
def build_runactions(pspecfile, authInfo=None): def build_runSetupAction(pspecfile, authInfo=None):
pb = prepare_for_build(pspecfile, authInfo) pb = prepare_for_build(pspecfile, authInfo)
pb.fetchSourceArchive() pb.fetchSourceArchive()
pb.unpackSourceArchive() pb.unpackSourceArchive()
pb.compileActionScript() pb.compileActionScript()
pb.applyPatches() pb.applyPatches()
pb.runActions() 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)