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 # check for the correct version of python
19 major,minor = sys.version_info [0:2]
20 if (major,minor) != (2,7):
21 print ("Sorry, the SFA package is currently available only with python-2.7")
25 # while cleaning up we might not have this..
27 from sfa.util.version import version_tag
29 version_tag='cleaningup'
31 scripts = glob("clientbin/*.py") + \
33 'config/sfa-config-tty',
35 # 'config/gen-sfa-cm-config.py',
36 'sfa/server/sfa-start.py',
37 # 'sfa/server/sfa_component_setup.py',
38 'sfatables/sfatables',
39 'keyconvert/keyconvert.py',
40 'flashpolicy/sfa_flashpolicy.py',
54 'sfa/rspecs/elements',
55 'sfa/rspecs/elements/versions',
56 'sfa/rspecs/versions',
66 'sfatables/processors',
69 initscripts = [ 'sfa' ]
70 if not os.path.isfile('/etc/redhat-release'): initscripts.append('functions.sfa')
72 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
73 'config/registries.xml',
74 'config/default_config.xml',
75 'config/api_versions.xml',
78 'sfa/managers/pl/pl.rng',
79 'sfa/trust/credential.xsd',
83 'sfa/trust/protogeni-rspec-common.xsd',
84 'flashpolicy/sfa_flashpolicy_config.xml',
86 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
87 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
88 ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
89 ('/usr/share/sfa/migrations', glob('sfa/storage/migrations/*.*') ),
90 ('/usr/share/sfa/migrations/versions', glob('sfa/storage/migrations/versions/*') ),
91 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
94 # add sfatables processors as data_files
95 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
96 data_files.append(('/etc/sfatables/processors/', processor_files))
97 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
98 for d in processor_subdirs:
99 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
100 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
101 data_files.append((etc_dir, processor_files))
103 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
104 python_path = sys.path
105 site_packages_path = [ os.path.join(p,'sfa') for p in python_path if p.endswith('site-packages')]
106 site_packages_path += [ os.path.join(p,'sfatables') for p in python_path if p.endswith('site-packages')]
107 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
108 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
109 remove_files = remove_bins + [ "/etc/init.d/%s"%x for x in initscripts ]
112 def feedback (file, msg): print ("removing", file, "...",msg)
113 for filepath in remove_files:
116 feedback(filepath,"success")
118 feedback(filepath,"failed")
120 for directory in remove_dirs:
122 shutil.rmtree(directory)
123 feedback (directory,"success")
125 feedback (directory, "failed")
127 # avoid repeating what's in the specfile already
129 with open("LICENSE.txt") as l:
132 license = "Could not open file LICENSE.txt"
134 with open("index.html") as r:
135 long_description = r.read()
137 long_description = "Unable to read index.html"
142 data_files = data_files,
143 version = version_tag,
144 keywords = ['federation','testbeds','SFA','SfaWrap'],
145 url = "http://svn.planet-lab.org/wiki/SFATutorial",
146 author = "Thierry Parmentelat, Tony Mack, Scott Baker",
147 author_email = "thierry.parmentelat@inria.fr, tmack@princeton.cs.edu, smbaker@gmail.com",
148 download_url = "http://build.onelab.eu/sfa/{v}/sfa-{v}.tar.gz".format(v=version_tag),
149 description = "SFA Wrapper with drivers for PlanetLab and IotLab and others",
151 long_description = long_description,