summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaakov M. Nemoy <loupgaroublond@gmail.com>2008-10-05 03:36:59 -0400
committerYaakov M. Nemoy <loupgaroublond@gmail.com>2008-10-05 03:36:59 -0400
commitc304da3ab83ece610fb75cd9b9bedca8f30eaa47 (patch)
treeade3fb147170f900a88395efae22b4643d57d15e
parent9b80ff4d4def847d9aaeaf3bf88bddcb35ef8ea2 (diff)
downloadfedora-devshell-c304da3ab83ece610fb75cd9b9bedca8f30eaa47.tar.gz
fedora-devshell-c304da3ab83ece610fb75cd9b9bedca8f30eaa47.tar.xz
fedora-devshell-c304da3ab83ece610fb75cd9b9bedca8f30eaa47.zip
Adds some more builder functions
-rw-r--r--base/util.py15
-rw-r--r--base/vars.py2
-rw-r--r--modules/build.py61
3 files changed, 68 insertions, 10 deletions
diff --git a/base/util.py b/base/util.py
index ec0a47b..87da8af 100644
--- a/base/util.py
+++ b/base/util.py
@@ -2,7 +2,10 @@ from __future__ import with_statement
from contextlib import contextmanager
from os import chdir, getcwd
-from shutil import copyfileobj
+from os import symlink as sym
+from os.path import abspath, lexists
+from shutil import copyfileobj, rmtree
+from shutil import move as mv
from base import log
@@ -22,5 +25,15 @@ def copy(src, dst):
copyfileobj(src, dst)
src.close()
dst.close()
+
+def symlink(src, dst):
+ if lexists(dst):
+ remove(dst)
+ sym(abspath(src), abspath(dst))
+
+def move(src, dst):
+ if lexists(dst):
+ rmtree(dst)
+ mv(src, dst)
__all__ = ['pwd', 'copy'] \ No newline at end of file
diff --git a/base/vars.py b/base/vars.py
index 232432b..1e8ec20 100644
--- a/base/vars.py
+++ b/base/vars.py
@@ -3,7 +3,7 @@ from os.path import join, expanduser
__version__ = '0.0.1'
__description__ = 'A shell for hacking on the Fedora project'
-FEDORA_DIR = join(expanduser('~'), 'code', 'fedora')
+FEDORA_DIR = join(expanduser('~'), 'code')
DEVSHELL_DIR = join(expanduser('~'), '.devshell')
header = lambda x: "%s %s %s" % ('=' * 2, x, '=' * (76 - len(x)))
diff --git a/modules/build.py b/modules/build.py
index 5787674..99c05ea 100644
--- a/modules/build.py
+++ b/modules/build.py
@@ -1,13 +1,15 @@
from __future__ import with_statement
from shutil import copyfileobj
-from os.path import join
-from os import listdir, getcwd
+from os.path import join, abspath
+from os import listdir, getcwd, walk
+from subprocess import Popen
from base.base import log
from base.module import Module
-from base.util import pwd, copy
+from base.util import pwd, copy, symlink, move
from base.exceptions import ExecutionException
+from base.vars import FEDORA_DIR
from modules.package import Package
@@ -26,13 +28,56 @@ class Build(Module):
raise ExecutionException(None, 'no Target Dir specified')
log.debug('target dir is %s' % target_dir)
with pwd(self.pkg.code_dir):
- copy(self.name + '.spec',
- join(self.target_dir, 'SPECS', self.name + '.spec'))
+ symlink(self.name + '.spec',
+ join(self.target_dir, 'SPECS', self.name + '.spec'))
sball = self.pkg.pkg_cfg['sourceball']
- copy(sball, join(self.target_dir, 'SOURCES', sball))
+ symlink(sball, join(self.target_dir, 'SOURCES', sball))
patches = [f for f in listdir(getcwd()) if f.endswith('.patch')]
for p in patches:
- copy(patch, join(self.target_dir, 'SOURCES', p))
+ symlink(patch, join(self.target_dir, 'SOURCES', p))
+ def build_quick_rpm(self, target_dir=None):
+ self.rpmbuild('-ba', target_dir)
+
+ def build_source_rpm(self, target_dir=None):
+ self.rpmbuild('-bs', target_dir)
+
+ def rpmbuild(self, param, target_dir=None):
+ if not target_dir:
+ if self.target_dir:
+ target_dir = self.target_dir
+ else:
+ raise ExecutionException(None, 'no Target Dir specified')
+ with pwd(self.pkg.code_dir):
+ rpm_out = file('rpmbuild.log', 'w')
+ with pwd(join(target_dir, 'SPECS')):
+ p = Popen(['rpmbuild', param, self.name + '.spec'],
+ stdout=rpm_out, stderr=rpm_out)
+ log.info('quick compiling %s... please wait' % self.name)
+ p.wait()
+ rpm_out.close()
+
+ def fetch_rpms(self, target_dir=None):
+ if not target_dir:
+ if self.target_dir:
+ target_dir = self.target_dir
+ else:
+ raise ExecutionException(None, 'no Target Dir specified')
+ with pwd(target_dir):
+ for path, dirs, files in walk('.'):
+ for f in files:
+ if f.endswith('.rpm'):
+ move(join(path, f), join(FEDORA_DIR, f))
+
+ def fetch_build(self, target_dir=None):
+ if not target_dir:
+ if self.target_dir:
+ target_dir = self.target_dir
+ else:
+ raise ExecutionException(None, 'no Target Dir specified')
+ with pwd(target_dir):
+ source = self.pkg.pkg_cfg['source']
+ move(join('BUILD', source), join(self.pkg.code_dir, 'results'))
+
def close(self):
- pass \ No newline at end of file
+ self.pkg.close()