3 from __future__ import print_function
6 Installation script for the sfa module
9 # as fas as pushing onto pypi, I have been using this page
10 # http://peterdowns.com/posts/first-time-with-pypi.html
11 # for setting up the whole business
13 import sys, os, os.path
16 from distutils.core import setup
18 # while cleaning up we might not have this..
20 from sfa.util.version import version_tag
22 version_tag='cleaningup'
24 scripts = glob("clientbin/*.py") + \
26 'config/sfa-config-tty',
28 # 'config/gen-sfa-cm-config.py',
29 'sfa/server/sfa-start.py',
30 # 'sfa/server/sfa_component_setup.py',
31 'sfatables/sfatables',
32 'keyconvert/keyconvert.py',
33 'flashpolicy/sfa_flashpolicy.py',
47 'sfa/rspecs/elements',
48 'sfa/rspecs/elements/versions',
49 'sfa/rspecs/versions',
60 'sfatables/processors',
63 initscripts = [ 'sfa' ]
64 if not os.path.isfile('/etc/redhat-release'): initscripts.append('functions.sfa')
66 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
67 'config/registries.xml',
68 'config/default_config.xml',
69 'config/api_versions.xml',
72 'sfa/managers/pl/pl.rng',
73 'sfa/trust/credential.xsd',
77 'sfa/trust/protogeni-rspec-common.xsd',
78 'flashpolicy/sfa_flashpolicy_config.xml',
80 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
81 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
82 ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
83 ('/usr/share/sfa/migrations', glob('sfa/storage/migrations/*.*') ),
84 ('/usr/share/sfa/migrations/versions', glob('sfa/storage/migrations/versions/*') ),
85 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
88 # add sfatables processors as data_files
89 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
90 data_files.append(('/etc/sfatables/processors/', processor_files))
91 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
92 for d in processor_subdirs:
93 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
94 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
95 data_files.append((etc_dir, processor_files))
97 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
98 python_path = sys.path
99 site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
100 site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
101 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
102 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
103 remove_files = remove_bins + [ "/etc/init.d/%s"%x for x in initscripts ]
106 def feedback (file, msg): print ("removing", file, "...",msg)
107 for filepath in remove_files:
110 feedback(filepath,"success")
112 feedback(filepath,"failed")
114 for directory in remove_dirs:
116 shutil.rmtree(directory)
117 feedback (directory,"success")
119 feedback (directory, "failed")
121 # avoid repeating what's in the specfile already
122 with open("LICENSE.txt") as l:
124 long_description = "Could not open README.html"
125 with open("readme.html") as r:
126 long_description = r.read()
130 data_files = data_files,
132 keywords = ['federation','testbeds','SFA','SfaWrap'],
133 url="http://svn.planet-lab.org/wiki/SFATutorial",
134 author="Thierry Parmentelat, Tony Mack, Scott Baker",
135 author_email="thierry.parmentelat@inria.fr, tmack@princeton.cs.edu, smbaker@gmail.com",
136 download_url = "http://build.onelab.eu/sfa/{v}/sfa-{v}.tar.gz".format(v=version_tag),
137 description="SFA Wrapper with drivers for PlanetLab and IotLab and others",
139 long_description = long_description,