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',
54 'sfatables/processors',
57 initscripts = [ 'sfa' ]
58 if not os.path.isfile('/etc/redhat-release'): initscripts.append('functions.sfa')
60 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
61 'config/registries.xml',
62 'config/default_config.xml',
63 'config/api_versions.xml',
66 'sfa/managers/pl/pl.rng',
67 'sfa/trust/credential.xsd',
71 'sfa/trust/protogeni-rspec-common.xsd',
72 'flashpolicy/sfa_flashpolicy_config.xml',
74 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
75 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
76 ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
77 ('/usr/share/sfa/migrations', glob('sfa/storage/migrations/*.*') ),
78 ('/usr/share/sfa/migrations/versions', glob('sfa/storage/migrations/versions/*') ),
79 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
82 # add sfatables processors as data_files
83 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
84 data_files.append(('/etc/sfatables/processors/', processor_files))
85 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
86 for d in processor_subdirs:
87 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
88 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
89 data_files.append((etc_dir, processor_files))
91 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
92 python_path = sys.path
93 site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
94 site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
95 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
96 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
97 remove_files = remove_bins + [ "/etc/init.d/%s"%x for x in initscripts ]
100 for filepath in remove_files:
101 print "removing", filepath, "...",
105 except: print "failed"
107 for directory in remove_dirs:
108 print "removing", directory, "...",
110 shutil.rmtree(directory)
112 except: print "failed"
114 # avoid repeating what's in the specfile already
117 data_files = data_files,
119 url="http://svn.planet-lab.org/wiki/SFATutorial",
120 author="Thierry Parmentelat, Tony Mack, Scott Baker",
121 author_email="thierry.parmentelat@inria.fr, tmack@princeton.cs.edu, smbaker@gmail.com",