From 9d06b341952ff641d4e82734c3df302e464f4ce5 Mon Sep 17 00:00:00 2001 From: "Yaakov M. Nemoy" Date: Tue, 3 Feb 2009 18:54:48 +0100 Subject: Refactors HaskellPort and Port to be more generic --- modules/haskellport.py | 88 +++----------------------------------------------- 1 file changed, 4 insertions(+), 84 deletions(-) (limited to 'modules/haskellport.py') diff --git a/modules/haskellport.py b/modules/haskellport.py index 3ca6555..1121dab 100644 --- a/modules/haskellport.py +++ b/modules/haskellport.py @@ -30,38 +30,11 @@ from modules.port import Port from modules.sourceball import SourceBall class HaskellPort(Port): - def __init__(self, package=None): - super(HaskellPort, self).__init__() - if not package: - package = getcwd() - self.pkg = DirFactory(package) - self.hackage = Hackage() - - def add_sourceball(self, sourceball): - '''copies a tarball into the package - - tarball is a path to some tarball - ''' - with pwd(self.pkg.dir): - pkg_src = SourceBall('', sourceball) - pkg_src.set_buildsystem('cabal') - name = pkg_src.name - self.pkg.add_source(name) - return self.close_later(pkg_src) + sourceball = SourceBall + revision_control = Darcs + builder = Cabal + fetcher = Hackage - 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 - ''' - with pwd(self.pkg.dir): - pkg_src = Darcs(tgt, url, *args) - pkg_src.set_buildsystem('cabal') - 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 @@ -71,56 +44,3 @@ class HaskellPort(Port): with self.package.tag(tag): self.install() - def install_sourceball(self, tarball, target='home', *args): - '''given a tarball, copy it in and install it - ''' - pkg_src = self.add_sourceball(tarball) - Cabal(pkg_src).install_source(target, *args) - - 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_loc = self.hackage.url(pkg, ver) - sb = self.add_sourceball(sb_loc) - sb.cfg['hackage_name'] = pkg - return sb - - def add_latest(self, pkg): - '''get the latest version of a package from hackage - - pkg is the package desired - ''' - ver = self.hackage.latest_version(pkg) - return self.add_from_hackage(pkg, ver) - - 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' - ''' - 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) - - - def close(self): - super(HaskellPort, self).close() - self.pkg.close() -- cgit