4 Installation script for the sfa module
7 import sys, os, os.path
10 from distutils.core import setup
13 'config/sfa-config-tty',
14 'config/gen-sfa-cm-config.py',
15 'sfa/plc/sfa-import-plc.py',
16 'sfa/plc/sfa-nuke-plc.py',
17 'sfa/server/sfa-server.py',
18 'sfa/server/sfa-clean-peer-records.py',
19 'sfa/server/sfa_component_setup.py',
21 'sfa/client/getNodes.py',
22 'sfa/client/getRecord.py',
23 'sfa/client/setRecord.py',
24 'sfa/client/sfadump.py',
25 'sfatables/sfatables',
38 'sfa/rspecs/aggregates',
41 'sfatables/processors',
45 data_files = [('/etc/sfa/', [ 'config/aggregates.xml',
46 'config/registries.xml',
47 'config/default_config.xml',
48 'config/sfi_config']),
49 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
50 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
51 ('/etc/init.d/', ['sfa/init.d/sfa', 'sfa/init.d/sfa_cm'])]
53 # add sfatables processors as data_files
54 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
55 data_files.append(('/etc/sfatables/processors/', processor_files))
56 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
57 for d in processor_subdirs:
58 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
59 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
60 data_files.append((etc_dir, processor_files))
62 initscripts = [ '/etc/init.d/sfa', '/etc/init.d/sfa_cm' ]
64 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
65 python_path = sys.path
66 site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
67 site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
68 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
69 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in bins ]
70 remove_files = remove_bins + initscripts
73 for filepath in remove_files:
74 print "removing", filepath, "...",
78 except: print "failed"
80 for directory in remove_dirs:
81 print "removing", directory, "...",
83 shutil.rmtree(directory)
85 except: print "failed"
87 # avoid repeating what's in the specfile already
89 packages = package_dirs,
90 data_files = data_files,