rename /etc/geni into /etc/sfa
[sfa.git] / setup.py
1 #!/usr/bin/python
2
3 """
4 Installation script for the geniwrapper module
5 """
6
7 import os, sys
8 import shutil
9 from distutils.core import setup, Extension
10
11 scripts = [ 'geni/gimport.py', 
12             'geni/plc.py', 
13             'config/sfa-config-tty',
14             'cmdline/sfi.py', 
15             'cmdline/getNodes.py',
16             'cmdline/getRecord.py',
17             'cmdline/setRecord.py',
18             'cmdline/genidump.py',
19             ]
20 package_dirs = ['geni', 'geni/util', 'geni/methods']
21 data_files = [ ('/etc/sfa/', ['config/aggregates.xml', 'config/registries.xml', 
22                                'config/sfa_config', 'config/sfi_config']),
23                ('/etc/init.d/', ['geni/init.d/sfa']),
24                ('/var/www/html/wsdl', [ 'wsdl/sfa.wsdl' ] ),
25                ]
26 symlinks = ['/usr/share/geniwrapper']
27 initscripts = ['/etc/init.d/geni']
28         
29 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
30     python_path = sys.path
31     site_packages_path = [ path + os.sep + 'geni' for path in python_path if path.endswith('site-packages')]
32     remove_dirs = ['/etc/sfa/'] + site_packages_path
33     remove_files = ['/usr/bin/gimport.py', '/usr/bin/plc.py', '/usr/bin/sfi.py', '/usr/bin/sfa-config-tty'] + \
34                     symlinks + initscripts
35     
36     # remove files   
37     for filepath in remove_files:
38         print "removing", filepath, "...",
39         try: 
40             os.remove(filepath)
41             print "success"
42         except: print "failed"
43     # remove directories 
44     for directory in remove_dirs: 
45         print "removing", directory, "...",
46         try: 
47             shutil.rmtree(directory)
48             print "success"
49         except: print "failed"
50  
51 else:
52     
53     # avoid repeating what's in the specfile already
54     setup(name='geni',
55           packages = package_dirs, 
56           data_files = data_files,
57           ext_modules = [],
58           py_modules = [],
59           scripts = scripts,   
60           )
61
62     # create symlink to geniwrapper source in /usr/share
63     python_path = sys.path
64     site_packages_path = [ path + os.sep + 'geni' for path in python_path if path.endswith('site-packages')]
65     # python path usualy has /usr/local/lib/ path , filter this out
66     site_packages_path = [x for x in site_packages_path if 'local' not in x]
67
68     # we can not do this here as installation root might change paths
69     # - baris
70     #
71     # for src in site_packages_path:
72     #     for dst in symlinks:
73     #         try: 
74     #             os.symlink(src, dst)
75     #         except: pass
76     # for initscript in initscripts:
77     #     os.chmod(initscript, 00744)