4 Installation script for the sfa module
7 import sys, os, os.path
10 from distutils.core import setup
12 scripts = glob("clientbin/*.py") + \
14 'config/sfa-config-tty',
16 'config/gen-sfa-cm-config.py',
17 'sfa/server/sfa-start.py',
18 'sfa/server/sfa_component_setup.py',
19 'sfatables/sfatables',
20 'keyconvert/keyconvert.py',
21 'flashpolicy/sfa_flashpolicy.py',
44 'sfa/rspecs/elements',
45 'sfa/rspecs/elements/versions',
46 'sfa/rspecs/versions',
54 'sfatables/processors',
57 initscripts = [ 'sfa', 'sfa-cm' ]
59 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
60 'config/registries.xml',
61 'config/default_config.xml',
64 'sfa/managers/pl/pl.rng',
65 'sfa/trust/credential.xsd',
69 'sfa/trust/protogeni-rspec-common.xsd',
70 'flashpolicy/sfa_flashpolicy_config.xml',
72 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
73 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
74 ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
75 ('/usr/share/sfa/migrations', glob('sfa/storage/migrations/*.*') ),
76 ('/usr/share/sfa/migrations/versions', glob('sfa/storage/migrations/versions/*') ),
77 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
80 # add sfatables processors as data_files
81 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
82 data_files.append(('/etc/sfatables/processors/', processor_files))
83 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
84 for d in processor_subdirs:
85 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
86 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
87 data_files.append((etc_dir, processor_files))
89 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
90 python_path = sys.path
91 site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
92 site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
93 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
94 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
95 remove_files = remove_bins + [ "/etc/init.d/%s"%x for x in initscripts ]
98 for filepath in remove_files:
99 print "removing", filepath, "...",
103 except: print "failed"
105 for directory in remove_dirs:
106 print "removing", directory, "...",
108 shutil.rmtree(directory)
110 except: print "failed"
112 # avoid repeating what's in the specfile already
115 data_files = data_files,