diff options
author | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-02 15:29:56 -0500 |
---|---|---|
committer | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-02 15:29:56 -0500 |
commit | 9779e186a5cf6adb3dd5bc1b7f7fee2f5d328e9e (patch) | |
tree | 3ef9250faf12a98634f8124d32d2609ed1b28f5d /modules | |
parent | 91f29794cdaa848de34b58321b8b47a52bfa1695 (diff) | |
download | fedora-devshell-9779e186a5cf6adb3dd5bc1b7f7fee2f5d328e9e.tar.gz fedora-devshell-9779e186a5cf6adb3dd5bc1b7f7fee2f5d328e9e.tar.xz fedora-devshell-9779e186a5cf6adb3dd5bc1b7f7fee2f5d328e9e.zip |
Replaces package as an entity for tarballs with sourceball.
Coming up is SCM which is an alternate form of package.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/cabal.py | 6 | ||||
-rw-r--r-- | modules/package.py | 32 | ||||
-rw-r--r-- | modules/sourceball.py | 61 |
3 files changed, 65 insertions, 34 deletions
diff --git a/modules/cabal.py b/modules/cabal.py index faa01cd..0fd0e94 100644 --- a/modules/cabal.py +++ b/modules/cabal.py @@ -32,14 +32,14 @@ from base.exceptions import ExecutionException from base.util import pwd, one from base.vars import orig_src_dir, haskell_compiler -from modules.package import Package +from modules.sourceball import SourceBall class Cabal(Module): def __init__(self, name, root='~/haskell'): self.name = name self.root = expanduser(root) with pwd(self.root): - self.package = Package(name) + self.package = SourceBall(name) self.original = orig_src_dir self.compiler = haskell_compiler @@ -136,7 +136,7 @@ class Cabal(Module): match = hackage_title.search(page) groups = match.groups() print groups - if pkg = groups[0]: + if pkg == groups[0]: return groups[1] else: raise ExecutionException("package does not match package name, can't determine version, sorry") diff --git a/modules/package.py b/modules/package.py index a47d965..b548c58 100644 --- a/modules/package.py +++ b/modules/package.py @@ -19,8 +19,7 @@ from __future__ import with_statement import tarfile -from os import makedirs, getcwd, chdir, listdir -from shutil import copyfileobj, copytree +from os import makedirs, getcwd from os.path import abspath, join, split, splitext, basename, exists from configobj import ConfigObj from subprocess import Popen, PIPE @@ -97,35 +96,6 @@ class Package(Module): log.error(str(e)) raise ExecutionException(e, 'spec-file could not be added') - def orig_dir(self, dir): - return dir + '_orig' - - def add_sourceball(self, sourceball_name, extract_dir=None): - log.debug('addincg sourceball with code_dir ' + self.code_dir) - with pwd(self.code_dir): - try: - sourceball_name = urlretrieve(sourceball_name, - split(sourceball_name)[1])[0] - - self.cfg['sourceball'] = sourceball_name - sourceball = tarfile.open(sourceball_name) - if not extract_dir: - extract_dir = min([(x.name, x) for x in sourceball])[0] - extract_dir = basename(abspath(extract_dir)) - log.debug('extract_dir is %s' % extract_dir) - log.debug('config is of ' + str(self.cfg)) - self.cfg['source'] = extract_dir - log.debug('cfg[\'source\'] is ' + self.cfg['source']) - log.debug('set source') - orig_extract_dir = self.orig_dir(extract_dir) - sourceball.extractall() - copytree(abspath(extract_dir), abspath(orig_extract_dir)) - except OSError, e: - #TODO: Fill this in with something better - #Chances are the _orig dir already exists - raise ExecutionException(e, 'something went wrong') - #TODO: figure out what exceptions TarFile will throw - def close(self): log.debug('writing self.cfg for package') with pwd(self.code_dir): diff --git a/modules/sourceball.py b/modules/sourceball.py new file mode 100644 index 0000000..5a840d3 --- /dev/null +++ b/modules/sourceball.py @@ -0,0 +1,61 @@ +# Fedora Developer Shell +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# Authors: Yaakov M. Nemoy <ynemoy@redhat.com> +# +from __future__ import with_statement + +import tarfile + +from os.path import abspath, split, basename +from shutil import copytree +from subprocess import Popen, PIPE + +from base.base import log +from base.exceptions import ExecutionException +from base.util import pwd, copy + +from modules.package import Package + +class SourceBall(Package): + def orig_dir(self, dir): + return dir + '_orig' + + def add_sourceball(self, sourceball_name, extract_dir=None): + log.debug('addincg sourceball with code_dir ' + self.code_dir) + with pwd(self.code_dir): + try: + sourceball_name = copy(sourceball_name, + split(sourceball_name)[1]) + + self.cfg['sourceball'] = sourceball_name + sourceball = tarfile.open(sourceball_name) + if not extract_dir: + extract_dir = min([(x.name, x) for x in sourceball])[0] + extract_dir = basename(abspath(extract_dir)) + log.debug('extract_dir is %s' % extract_dir) + log.debug('config is of ' + str(self.cfg)) + self.cfg['source'] = extract_dir + log.debug('cfg[\'source\'] is ' + self.cfg['source']) + log.debug('set source') + orig_extract_dir = self.orig_dir(extract_dir) + sourceball.extractall() + copytree(abspath(extract_dir), abspath(orig_extract_dir)) + except OSError, e: + #TODO: Fill this in with something better + #Chances are the _orig dir already exists + raise ExecutionException(e, 'something went wrong') + #TODO: figure out what exceptions TarFile will throw + |