summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaakov M. Nemoy <loupgaroublond@gmail.com>2009-01-18 21:12:09 -0500
committerYaakov M. Nemoy <loupgaroublond@gmail.com>2009-01-18 21:12:09 -0500
commit104b3c4262fa3cb6b24ed0e1cd5402b14f4eab8f (patch)
tree9606a60155e93229b50a9011bf5d0dae7e848c9a
parent8bbbcbd2cdad36e27c127c888897395cefcff3d0 (diff)
downloadfedora-devshell-104b3c4262fa3cb6b24ed0e1cd5402b14f4eab8f.tar.gz
fedora-devshell-104b3c4262fa3cb6b24ed0e1cd5402b14f4eab8f.tar.xz
fedora-devshell-104b3c4262fa3cb6b24ed0e1cd5402b14f4eab8f.zip
Fixes up HaskellPort to work with the new refactoring.
Also adds some close code for ports Also mistakenly stuck some code in HaskellPort that really belongs to the build system
-rw-r--r--TODO3
-rw-r--r--modules/buildsystem.py7
-rw-r--r--modules/cabal.py16
-rw-r--r--modules/darcs.py2
-rw-r--r--modules/fetcher.py2
-rw-r--r--modules/hackage.py2
-rw-r--r--modules/haskellport.py89
-rw-r--r--modules/port.py15
8 files changed, 96 insertions, 40 deletions
diff --git a/TODO b/TODO
index ef3bbb6..faefc20 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,3 @@
* Implement Interface metaclasses to do type checking to make sure certain functions get implemented
-* Implement auto property detection somehow \ No newline at end of file
+* Implement auto property detection somehow
+* Rewrite the documentation \ No newline at end of file
diff --git a/modules/buildsystem.py b/modules/buildsystem.py
index 2c5a3a5..254b726 100644
--- a/modules/buildsystem.py
+++ b/modules/buildsystem.py
@@ -18,7 +18,7 @@
from base.module import Module
-class BuildSystem(Module): pass
+class BuildSystem(Module):
def configure(self, target='home', *args):
'''runs the configure stage of cabal
@@ -47,3 +47,8 @@ class BuildSystem(Module): pass
must do this on their own.
'''
raise NotImplementedError
+
+ def install_source(self, target='home', *args):
+ '''perform configure, build, and install steps in one
+ '''
+ raise NotImplementedError
diff --git a/modules/cabal.py b/modules/cabal.py
index 4b118d6..4ddea87 100644
--- a/modules/cabal.py
+++ b/modules/cabal.py
@@ -47,8 +47,12 @@ class Cabal(BuildSystem):
name is a Package (Directory) that uses cabal for its build system
'''
- self.name = name
- self.pkg_src = DirFactory(name)
+ if type(name) is string:
+ self.pkg_src = DirFactory(name)
+ self.name = name
+ else:
+ self.pkg_src = name
+ self.name = name.name
self.compiler = haskell_compiler
def find_setup(self):
@@ -126,6 +130,14 @@ class Cabal(BuildSystem):
log.info('Building %s, please wait...' % self.name)
p.wait()
+ def install_source(self, target='home', *args):
+ '''perform configure, build, and install steps in one
+ '''
+ with self.pkg_src.src(*args):
+ self.configure(target, orig)
+ self.build(orig)
+ self.install(orig)
+
def close(self):
self.pkg_src.close()
diff --git a/modules/darcs.py b/modules/darcs.py
index 7c6eda4..189da60 100644
--- a/modules/darcs.py
+++ b/modules/darcs.py
@@ -95,7 +95,7 @@ class Darcs(RevisionControl):
handling, we may ask the user to commit all the changes to darcs,
and then have devshell generate .patch files automatically instead
'''
- with pwd(self.cfg['source']):
+ with pwd(self.source_dir):
p = Popen(['darcs', 'changes', '--xml-output', '--last=1'],
stdout = PIPE, stderr = PIPE)
change = p.communicate()[0]
diff --git a/modules/fetcher.py b/modules/fetcher.py
index 6f52fe8..cbba8c7 100644
--- a/modules/fetcher.py
+++ b/modules/fetcher.py
@@ -18,7 +18,7 @@
from base.module import Module
-class Fetcher(Module): pass
+class Fetcher(Module):
def latest_version(self, pkg):
'''download information from hackage to find out the latest version of a package
'''
diff --git a/modules/hackage.py b/modules/hackage.py
index b08299c..5b704ee 100644
--- a/modules/hackage.py
+++ b/modules/hackage.py
@@ -39,3 +39,5 @@ class Hackage(Fetcher):
return 'http://hackage.haskell.org/packages/archive/' + \
pkg + '/' + ver + '/' + pkg + '-' + ver + '.tar.gz'
+ def darcs_url(self, pkg):
+ return 'http://darcs.haskell.org/' + pkg
diff --git a/modules/haskellport.py b/modules/haskellport.py
index eff0d70..b585788 100644
--- a/modules/haskellport.py
+++ b/modules/haskellport.py
@@ -15,28 +15,50 @@
#
# Authors: Yaakov M. Nemoy <ynemoy@redhat.com>
#
+from __future__ import with_statement
-from modules.dirfactory import DirFactory
+from os import getcwd
+
+from base.base import log
+from base.exceptions import ExecutionException
+from base.dirfactory import DirFactory
+from base.util import pwd
+
+from modules.darcs import Darcs
+from modules.hackage import Hackage
from modules.port import Port
+from modules.sourceball import SourceBall
class HaskellPort(Port):
- def __init__(self, package):
+ def __init__(self, package=None):
+ super(HaskellPort, self).__init__()
+ if not package:
+ package = getcwd()
self.pkg = DirFactory(package)
+ self.hackage = Hackage()
- def copy_in(self, tarball):
+ def add_sourceball(self, sourceball):
'''copies a tarball into the package
tarball is a path to some tarball
'''
- self.package.add_sourceball(tarball)
+ with pwd(self.pkg.dir):
+ pkg_src = SourceBall('', sourceball)
+ name = pkg_src.name
+ self.pkg.add_source(name)
+ return self.close_later(pkg_src)
- def darcs_get(self, url, tgt):
+ def add_darcs(self, url, tgt, *args):
'''creates a darcs variant of a cabal package using darcs source
url is a url to some darcs repo
tgt is the local name of the darcs repo
'''
- self.package.checkout(tgt, url)
+ with pwd(self.pkg.dir):
+ pkg_src = Darcs(tgt, url, *args)
+ name = pkg_src.name
+ self.pkg.add_source(name)
+ return self.close_later(pkg_src)
def install_tag(self, tag):
'''assuming a package that supports tagging, install a specific tag
@@ -47,50 +69,53 @@ class HaskellPort(Port):
with self.package.tag(tag):
self.install()
- def install_source(self, target='home', *args):
- '''perform configure, build, and install steps in one
- '''
- with self.pkg_src.src(*args):
- self.configure(target, orig)
- self.build(orig)
- self.install(orig)
-
- def install_sourceball(self, tarball, target='home'):
+ def install_sourceball(self, tarball, target='home', *args):
'''given a tarball, copy it in and install it
'''
- self.copy_in(tarball)
- self.install_source(target, '')
-
- def install_latest(self, pkg, target='home'):
- '''get and install the latest version of a package from hackage'''
- self.get_latest(pkg)
- self.install_source(target, '')
+ pkg_src = self.add_sourceball(tarball)
+ Cabal(pkg_src).install_source(target, *args)
- def get_from_hackage(self, pkg, ver):
+ def add_from_hackage(self, pkg, ver):
'''get a specific package from hackage
pkg is the name of the package desired
ver is the version wanted
'''
- sb_file = self.hackage_url(pkg, ver)
- self.copy_in(sb_file)
+ sb_loc = self.hackage.url(pkg, ver)
+ return self.add_sourceball(sb_loc)
- def get_latest(self, pkg):
+ def add_latest(self, pkg):
'''get the latest version of a package from hackage
pkg is the package desired
'''
- ver = self.latest_version(pkg)
- self.get_from_hackage(pkg, ver)
+ ver = self.hackage.latest_version(pkg)
+ return self.add_from_hackage(pkg, ver)
- def install_from_hackage(self, pkg, ver, target='home'):
+ def install_from_hackage(self, pkg, ver, target='home', *args):
'''get and install a specific package from hackage
pkg is the desired package
ver is the version wanted
target is the location to install to, either 'home' or 'root'
'''
- self.get_from_hackage(pkg, ver)
- self.install_source(target, '')
+ sb_loc = self.hackage.url(pkg, ver)
+ self.install_sourceball(sb_loc, target, *args)
+
+ def install_latest(self, pkg, target='home', *args):
+ '''get and install the latest version of a package from hackage'''
+ ver = self.hackage.latest_version(pkg)
+ self.install_from_hackage(pkg, ver, target, *args)
+
+ def add_upstream(self, pkg, tgt=None, *args):
+ if not tgt:
+ tgt = pkg
+ return self.add_darcs(self.hackage.darcs_url(pkg), tgt, *args)
+
+ def install_upstream(self, pkg, tgt=None, target='home', *args):
+ pkg_src = self.add_upstream(pkg, tgt, *args)
+ Cabal(pkg_src).install_source(target)
- pass
+ def close(self):
+ super(HaskellPort, self).close()
+ self.pkg.close()
diff --git a/modules/port.py b/modules/port.py
index c447f83..fe3083d 100644
--- a/modules/port.py
+++ b/modules/port.py
@@ -16,6 +16,17 @@
# Authors: Yaakov M. Nemoy <ynemoy@redhat.com>
#
-from base.modules import Module
+from base.module import Module
-class Port(Module): pass
+class Port(Module):
+ def __init__(self):
+ self._to_close = list()
+
+ def close_later(self, directory):
+ if directory not in self._to_close:
+ self._to_close.append(directory)
+ return directory
+
+ def close(self):
+ for directory in self._to_close:
+ directory.close()