4 Installation script for the sfa module
7 import sys, os, os.path
10 from distutils.core import setup
12 # while cleaning up we might not have this..
14 from sfa.util.version import version_tag
16 version_tag='cleaningup'
18 scripts = glob("clientbin/*.py") + \
20 'config/sfa-config-tty',
22 # 'config/gen-sfa-cm-config.py',
23 'sfa/server/sfa-start.py',
24 # 'sfa/server/sfa_component_setup.py',
25 'sfatables/sfatables',
26 'keyconvert/keyconvert.py',
27 'flashpolicy/sfa_flashpolicy.py',
41 'sfa/rspecs/elements',
42 'sfa/rspecs/elements/versions',
43 'sfa/rspecs/versions',
53 'sfatables/processors',
56 initscripts = [ 'sfa' ]
57 if not os.path.isfile('/etc/redhat-release'): initscripts.append('functions.sfa')
59 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
60 'config/registries.xml',
61 'config/default_config.xml',
62 'config/api_versions.xml',
65 'sfa/managers/pl/pl.rng',
66 'sfa/trust/credential.xsd',
70 'sfa/trust/protogeni-rspec-common.xsd',
71 'flashpolicy/sfa_flashpolicy_config.xml',
73 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
74 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
75 ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
76 ('/usr/share/sfa/migrations', glob('sfa/storage/migrations/*.*') ),
77 ('/usr/share/sfa/migrations/versions', glob('sfa/storage/migrations/versions/*') ),
78 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
81 # add sfatables processors as data_files
82 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
83 data_files.append(('/etc/sfatables/processors/', processor_files))
84 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
85 for d in processor_subdirs:
86 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
87 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
88 data_files.append((etc_dir, processor_files))
90 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
91 python_path = sys.path
92 site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
93 site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
94 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
95 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
96 remove_files = remove_bins + [ "/etc/init.d/%s"%x for x in initscripts ]
99 for filepath in remove_files:
100 print "removing", filepath, "...",
104 except: print "failed"
106 for directory in remove_dirs:
107 print "removing", directory, "...",
109 shutil.rmtree(directory)
111 except: print "failed"
113 # avoid repeating what's in the specfile already
116 data_files = data_files,
118 url="http://svn.planet-lab.org/wiki/SFATutorial",
119 author="Thierry Parmentelat, Tony Mack, Scott Baker",
120 author_email="thierry.parmentelat@inria.fr, tmack@princeton.cs.edu, smbaker@gmail.com",