summaryrefslogtreecommitdiffstats
path: root/modules/cabal.py
diff options
context:
space:
mode:
authorYaakov M. Nemoy <loupgaroublond@gmail.com>2009-01-03 15:41:24 -0500
committerYaakov M. Nemoy <loupgaroublond@gmail.com>2009-01-03 15:41:24 -0500
commit36953f9c563700d4ef67149c2c13c1df70b02c96 (patch)
tree06c39559b2e66f6467f95fcdafc88d60d47d78b3 /modules/cabal.py
parente427d02a7693c395d26c03f6a12a09ca504009bc (diff)
downloadfedora-devshell-36953f9c563700d4ef67149c2c13c1df70b02c96.tar.gz
fedora-devshell-36953f9c563700d4ef67149c2c13c1df70b02c96.tar.xz
fedora-devshell-36953f9c563700d4ef67149c2c13c1df70b02c96.zip
Add directory factory autodetect powers
Diffstat (limited to 'modules/cabal.py')
-rw-r--r--modules/cabal.py62
1 files changed, 32 insertions, 30 deletions
diff --git a/modules/cabal.py b/modules/cabal.py
index 0fd0e94..ecb0f6b 100644
--- a/modules/cabal.py
+++ b/modules/cabal.py
@@ -32,6 +32,7 @@ from base.exceptions import ExecutionException
from base.util import pwd, one
from base.vars import orig_src_dir, haskell_compiler
+from modules.dirfactory import DirFactory
from modules.sourceball import SourceBall
class Cabal(Module):
@@ -39,7 +40,7 @@ class Cabal(Module):
self.name = name
self.root = expanduser(root)
with pwd(self.root):
- self.package = SourceBall(name)
+ self.package = DirFactory(name)
self.original = orig_src_dir
self.compiler = haskell_compiler
@@ -48,65 +49,66 @@ class Cabal(Module):
with pwd(self.root):
self.package.add_sourceball(tarball)
- def find_setup(self, original=False):
+ def find_setup(self, orig=''):
setup_re = compile("Setup\.l?hs")
- with pwd(self.source_dir(original)):
- setup_f = one(listdir(getcwd()), setup_re.search)
- log.debug(setup_f)
- return setup_f
+ return one(listdir(getcwd()), setup_re.search)
- def compile_setup(self, original=False):
- with pwd(self.pkg.code_dir):
+ def compile_setup(self, orig=''):
+ log.debug('code_dir is ' + self.package.code_dir)
+ with pwd(self.package.code_dir):
with file('ghc.log', 'a') as ghc_out:
- with pwd(self.source_dir(original)):
- setup_f = self.find_setup(original)
+ log.debug('ghc.log file is ' + str(ghc_out))
+ log.debug('source_dir is ' + self.package.source_dir(orig))
+ with pwd(self.package.source_dir(orig)):
+ setup_f = self.find_setup(orig)
p = Popen([self.compiler, '--make', setup_f],
stdout = ghc_out, stderr = ghc_out)
log.info('Building %s, please wait...' % setup_f)
p.wait()
- def configure(self, target='home', original=False):
+ def configure(self, target='home', orig=''):
user = True if target == 'home' else False
- self.compile_setup(original)
- with pwd(self.pkg.code_dir):
+ self.compile_setup(orig)
+ with pwd(self.package.code_dir):
with file('cabal.log', 'a') as cabal_out:
- with pwd(self.source_dir(original)):
+ log.debug('source_dir is ' + self.package.source_dir(orig))
+ with pwd(self.package.source_dir(orig)):
args = [abspath('Setup'), 'configure'] + \
(['--user', '--prefix=' + expanduser('~')] if user else [])
p = Popen(args, stdout=cabal_out, stderr=cabal_out)
log.info('Configuring %s, please wait...' % self.name)
p.wait()
- def build(self, original=False):
+ def build(self, orig=''):
'''This is not safe to run on an unconfigured source dir'''
- self.compile_setup(original)
- with pwd(self.pkg.code_dir):
+ self.compile_setup(orig)
+ with pwd(self.package.code_dir):
with file('cabal.log', 'a') as cabal_out:
- with pwd(self.source_dir(original)):
+ with pwd(self.package.source_dir(orig)):
args = [abspath('Setup'), 'build']
p = Popen(args, stdout=cabal_out, stderr=cabal_out)
log.info('Building %s, please wait...' % self.name)
p.wait()
- def install(self, original=False):
+ def install(self, orig=''):
'''This is not safe to run on an unconfigured source dir'''
- self.compile_setup(original)
- with pwd(self.pkg.code_dir):
+ self.compile_setup(orig)
+ with pwd(self.package.code_dir):
with file('cabal.log', 'a') as cabal_out:
- with pwd(self.source_dir(original)):
+ with pwd(self.package.source_dir(orig)):
args = [abspath('Setup'), 'install']
p = Popen(args, stdout=cabal_out, stderr=cabal_out)
log.info('Building %s, please wait...' % self.name)
p.wait()
- def install_source(self, target='home', original=False):
- self.configure(target, original)
- self.build(original)
- self.install(original)
+ def install_source(self, target='home', orig=''):
+ self.configure(target, orig)
+ self.build(orig)
+ self.install(orig)
def install_sourceball(self, tarball, target='home'):
self.copy_in(tarball)
- self.install_source(target, False)
+ self.install_source(target, '')
def get_from_hackage(self, pkg, ver):
sb_file = self.hackage_url(pkg, ver)
@@ -118,13 +120,13 @@ class Cabal(Module):
def install_from_hackage(self, pkg, ver, target='home'):
self.get_from_hackage(pkg, ver)
- self.install_source(target, False)
+ self.install_source(target, '')
def install_latest(self, pkg, target='home'):
self.get_latest(pkg)
- self.install_source(target, False)
+ self.install_source(target, '')
- def source_dir(self, original=False):
+ def source_dir(self, *args):
with pwd(self.package.code_dir):
return abspath(self.package.cfg['source'] + (self.orig_src_dir if original else ""))