From 0cb6e545b308e79a5d4aa6c36b7366f2b0fc30fd Mon Sep 17 00:00:00 2001 From: "Yaakov M. Nemoy" Date: Mon, 29 Dec 2008 23:11:55 -0500 Subject: Mass commit, i should be cleaner in the future. --- base/profiles.py | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 base/profiles.py (limited to 'base/profiles.py') diff --git a/base/profiles.py b/base/profiles.py new file mode 100644 index 0000000..2490b3f --- /dev/null +++ b/base/profiles.py @@ -0,0 +1,110 @@ + +from os.path import join +from subprocess import Popen, PIPE + +from vars import FEDORA_DIR + +TARGET = 0 +DIST = 1 +DISTVAR = 2 +DISTVAL = 3 + +def distdef(dist): + return dist.replace('.', '') + +def define(key, value): + return '--define "%s %s"' % (key, value) + +def join_defines(*defines): + return " ".join(defines) + +def dist_defines(dist, distvar, distval): + dist = define('dist', dist) + distvar = define(distvar, distval) + distdef = define(distdef(dist), 1) + return join_defines([dist, distvar, distdef]) + +head_branch = 'devel' + +def get_mock_cfg(distvar, distval, buildarch): + if distvar == 'fedora' and distval in [4, 5, 6]: + return '%s-%s-%s-core' % (distvar, distval, buildarch) + else: + return '%s-%s-%s' % (distvar, distval, buildarch) + +def dir_defines(some_dir): + defs = list() + defs.append(define('_sourcedir', join(some_dir, 'SOURCES'))) + defs.append(define('_specdir', join(some_dir, 'SPECS'))) + defs.append(define('_builddir', join(some_dir, 'BUILD'))) + defs.append(define('_srcrpmdir', join(some_dir, 'SRPMS'))) + defs.append(define('_rpmdir', join(some_dir, 'RPMS'))) + return join_defines(defs) + +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(' ') + +#taken from CVS for now +distro = [{'RHL-7':('rhl7','.rhl7','rhl','7'), + 'RHL-8':('rhl8','.rhl8','rhl','8'), + 'RHL-9':('rhl9','.rhl9','rhl','9'), + 'OLPC-2':('dist-olpc2','.olpc2','olpc','2'), + 'OLPC-3':('dist-olpc3','.olpc3','olpc','3'), + 'EL-4':('el4','.el4','epel','4'), + 'EL-5':('el5','.el5','epel','5'), + 'FC-1':('fc1','.fc1','fedora','1'), + 'FC-2':('fc2','.fc2','fedora','2'), + 'FC-3':('fc3','.fc3','fedora','3'), + 'FC-4':('fc4','.fc4','fedora','4'), + 'FC-5':('fc5','.fc5','fedora','5'), + 'FC-6':('fc6','.fc6','fedora','6'), + 'F-7':('dist-fc7','.fc7','fedora','7'), + 'F-8':('dist-f8','.fc8','fedora','8'), + 'F-9':('dist-f9','.fc9','fedora','9'), + 'F-10':('dist-f10','.fc10','fedora','10'), + 'F-11':('dist-f11','.fc11','fedora','11'), + 'devel':('dist-devel','.devel','fedora','10')}] + +# this class is temporary, it's only for mimickng CVS for now +# later we'll come up with a better way to do custom profiles +class Profile(object): + def __init__(self, branch): + self.branch = branch + self.distro = distro[branch] + + @property + def dist_defines(self): + d = self.distro + return dist_defines(d[DIST], d[DISTVAR], d[DISTVAL]) + + @property + def mock_cfg(self): + d = self.distro + # TODO: buildarchs need to be handled somehow + # yes i'm lame and i did this i386 only for now + return get_mock_cfg(d[DISTVAR], d[DISTVAL], 'i386') + + @property + def config_dir(self): + return '/etc/mock' + + @property + def result_dir(self): + return FEDORA_DIR + + +def main(): + print distdef('.fc9') + print ver_rel('ghc-X11.spec', '') + +if __name__ == '__main__': + main() + +__all__ = ['TARGET', 'DISTVAR', 'distdef', 'DISTVAL', 'head_branch', + 'DIST', 'join_defines', 'ver_rel', 'define', + 'dir_defines', 'get_mock_cfg', 'dist_defines', + 'Profile'] \ No newline at end of file -- cgit