4 Installation script for the sfa module
7 import sys, os, os.path
10 from distutils.core import setup
12 scripts = glob("sfa/clientbin/*.py") + \
14 'config/sfa-config-tty',
15 'config/gen-sfa-cm-config.py',
16 'sfa/importer/sfa-import-plc.py',
17 'sfa/importer/sfa-nuke-plc.py',
18 'sfa/server/sfa-ca.py',
19 'sfa/server/sfa-start.py',
20 'sfa/server/sfa-clean-peer-records.py',
21 'sfa/server/sfa_component_setup.py',
22 'sfatables/sfatables',
23 'keyconvert/keyconvert.py',
24 'flashpolicy/sfa_flashpolicy.py',
41 'sfa/rspecs/elements',
42 'sfa/rspecs/elements/versions',
43 'sfa/rspecs/versions',
46 'sfatables/processors',
49 initscripts = [ 'sfa', 'sfa-cm' ]
51 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
52 'config/registries.xml',
53 'config/default_config.xml',
56 'sfa/managers/pl/pl.rng',
57 'sfa/trust/credential.xsd',
61 'sfa/trust/protogeni-rspec-common.xsd',
62 'flashpolicy/sfa_flashpolicy_config.xml',
64 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
65 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
66 ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
67 ('/usr/share/sfa/', [ 'sfa/storage/sfa.sql' ] ),
68 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
71 # add sfatables processors as data_files
72 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
73 data_files.append(('/etc/sfatables/processors/', processor_files))
74 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
75 for d in processor_subdirs:
76 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
77 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
78 data_files.append((etc_dir, processor_files))
80 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
81 python_path = sys.path
82 site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
83 site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
84 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
85 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
86 remove_files = remove_bins + [ "/etc/init.d/%s"%x for x in initscripts ]
89 for filepath in remove_files:
90 print "removing", filepath, "...",
94 except: print "failed"
96 for directory in remove_dirs:
97 print "removing", directory, "...",
99 shutil.rmtree(directory)
101 except: print "failed"
103 # avoid repeating what's in the specfile already
106 data_files = data_files,