summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaakov M. Nemoy <loupgaroublond@gmail.com>2009-01-05 13:50:32 -0500
committerYaakov M. Nemoy <loupgaroublond@gmail.com>2009-01-05 13:50:32 -0500
commitde3320e82e5a14fe54ebb27a0ef0c0cb381128f4 (patch)
tree131e399b7a1391fcb368396c2c931c2d11b9ac04
parent5cada39e063281f8f0be7a55f4ce2d30ae5432a9 (diff)
downloadfedora-devshell-de3320e82e5a14fe54ebb27a0ef0c0cb381128f4.tar.gz
fedora-devshell-de3320e82e5a14fe54ebb27a0ef0c0cb381128f4.tar.xz
fedora-devshell-de3320e82e5a14fe54ebb27a0ef0c0cb381128f4.zip
fixed package to differentiate between canonical name and rpm name
-rw-r--r--base/profiles.py7
-rw-r--r--base/util.py4
-rw-r--r--modules/build.py22
-rw-r--r--modules/package.py32
-rw-r--r--modules/sourceball.py3
5 files changed, 46 insertions, 22 deletions
diff --git a/base/profiles.py b/base/profiles.py
index 14ba17e..83bfe25 100644
--- a/base/profiles.py
+++ b/base/profiles.py
@@ -58,13 +58,18 @@ def dir_defines(some_dir):
defs.append(define('_rpmdir', join(some_dir, 'RPMS')))
return join_defines(defs)
-def ver_rel(spec_file, defines):
+def ver_rel(spec_file, defines=''):
rpm_p = Popen('rpm %s -q --qf "%%{VERSION} %%{RELEASE}\n" --specfile %s' % \
(defines, spec_file), stdout=PIPE, shell=True)
verrels = rpm_p.communicate()[0]
verrel = verrels.split('\n')[0]
return verrel.split(' ')
+def name(spec_file, defines=''):
+ rpm_p = Popen('rpm %s -q --qf "%%{NAME}\n" --specfile %s' % \
+ (defines, spec_file), stdout=PIPE, shell=True)
+ return rpm_p.communicate()[0].split('\n')[0]
+
#taken from CVS for now
distro = [{'RHL-7':('rhl7','.rhl7','rhl','7'),
'RHL-8':('rhl8','.rhl8','rhl','8'),
diff --git a/base/util.py b/base/util.py
index d24755e..5b68c3b 100644
--- a/base/util.py
+++ b/base/util.py
@@ -44,7 +44,7 @@ def log_file(fname):
fout.write("-- Beginning log of %s at %s --\n" % (fname, datetime.now().isoformat(' ')))
fout.flush()
yield fout
- fout.write("-- Ending log of %s at %s --\n" % (fname, datetime.now().isoformat(' ')))
+ fout.write("-- Ending log of %s at %s --\n\n" % (fname, datetime.now().isoformat(' ')))
def rm(tgt):
if isdir(tgt):
@@ -69,11 +69,13 @@ def symlink(src, dst):
if lexists(dst):
rm(dst)
sym(abspath(src), abspath(dst))
+ return dst
def move(src, dst):
if lexists(dst):
rm(dst)
mv(src, dst)
+ return dst
def one(l, f):
for x in l:
diff --git a/modules/build.py b/modules/build.py
index 5481507..f5f7e66 100644
--- a/modules/build.py
+++ b/modules/build.py
@@ -39,20 +39,20 @@ class Build(Directory):
def setup_source(self, package):
pkg = DirFactory(package)
with pwd(pkg.dir):
- symlink(pkg.spec_file,
+ symlink(pkg.spec_file,
join(self.dir, 'SPECS', pkg.spec_file()))
sball = pkg.cfg['sourceball']
symlink(sball, join(self.dir, 'SOURCES', sball))
patches = [f for f in listdir(getcwd()) if f.endswith('.patch')]
for patch in patches:
symlink(patch, join(self.dir, 'SOURCES', patch))
-
+
def build_quick_rpm(self):
self.rpmbuild('-ba')
def build_source_rpm(self):
self.rpmbuild('-bs')
-
+
def rpmbuild(self, param, package, profile=None):
pkg = DirFactory(package)
if profile:
@@ -63,14 +63,14 @@ class Build(Directory):
with pwd(pkg.dir):
with log_file('rpmbuild.log') as rpm_out:
with pwd(join(self.dir, 'SPECS')):
- p = Popen(['rpmbuild',
- defines, param,
- pkg.spec_file],
+ p = Popen(['rpmbuild',
+ defines, param,
+ pkg.spec_file],
stdout=rpm_out, stderr=rpm_out)
- log.info('building %s... please wait'
+ log.info('building %s... please wait'
% pkg.spec_file)
- p.wait()
-
+ p.wait()
+
def fetch_rpms(self):
with pwd(self.dir):
for path, dirs, files in walk('.'):
@@ -79,11 +79,11 @@ class Build(Directory):
#TODO: Gotta figure out what should be FEDORA_DIR
# Probably something involving "Project" or i dunno what
move(join(path, f), join(FEDORA_DIR, f))
-
+
def fetch_build(self, package):
pkg = DirFactory(package)
with pwd(self.dir):
source = pkg.cfg['source']
move(join('BUILD', source), join(pkg.dir, 'results'))
-
+
__all__ = ['Build']
diff --git a/modules/package.py b/modules/package.py
index 8d61091..f7b875c 100644
--- a/modules/package.py
+++ b/modules/package.py
@@ -18,45 +18,59 @@
from __future__ import with_statement
+from os.patch import split
from base.base import log
from base.exceptions import ExecutionException
-from base.util import pwd, copy
-from base.profiles import ver_rel
+from base.util import pwd, copy, mv
+from base.profiles import ver_rel, name
from modules.directory import Directory
class Package(Directory):
_type = 'package'
+ # These two methods are here as examples.
def load_dir(self, dir):
super(Package, self).load_dir(dir)
- # this is a hack for some refactoring backwards compatibility
- #TODO: replace code_dir with just dir
- self.code_dir = self.cfg['dir']
def make_dir(self, dir):
super(Package, self).make_dir(dir)
- self.code_dir = dir
def add_spec(self, spec_file):
log.debug('spec_file is %s' % spec_file)
log.debug('spec_file_name is %s' % self.name + '.spec')
+ #TODO: get the spec file name, copy
+ # Then get the actual package name and set pkg_name to the right one
+ spec_fname = split(spec_file)[1]
with pwd(self.code_dir):
try:
- copy(spec_file, self.name)
+ copy(spec_file, spec_fname)
+ self.cfg['pkg_name'] = name(spec_fname)
+ if not spec_fname == self.spec_file:
+ mv(spec_fname, self.spec_file)
except IOError, e:
log.error(str(e))
raise ExecutionException(e, 'spec-file could not be added')
@property
def spec_file(self):
- return self.name + '.spec'
+ return self.pkg_name + '.spec'
+
+ @property
+ def code_dir(self):
+ # this is a hack for some refactoring backwards compatibility
+ #TODO: replace code_dir with just dir
+ return self.cfg['dir']
+
+ @property
+ def pkg_dir(self):
+ return self.cfg['pkg_dir']
def get_srpm_name(self, profile):
with pwd(self.code_dir):
ver, rel = ver_rel(self.spec_file, profile.dist_defines())
- return '%s-%s-%s.src.rpm' % (self.name, ver, rel)
+ return '%s-%s-%s.src.rpm' % (self.pkg_name, ver, rel)
def source_dir(self, *args):
raise NotImplementedError
diff --git a/modules/sourceball.py b/modules/sourceball.py
index 8364eda..5213433 100644
--- a/modules/sourceball.py
+++ b/modules/sourceball.py
@@ -65,5 +65,8 @@ class SourceBall(Package):
raise ExecutionException(e, 'something went wrong')
#TODO: figure out what exceptions TarFile will throw
+ @property
+ def sourceball(self):
+ return self.cfg['sourceball']
__all__ = ['SourceBall']