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'):
71 initscripts.append('functions.sfa')
73 data_files = [ ('/etc/sfa/', [ 'config/aggregates.xml',
74 'config/registries.xml',
75 'config/default_config.xml',
76 'config/api_versions.xml',
79 'sfa/managers/pl/pl.rng',
80 'sfa/trust/credential.xsd',
84 'sfa/trust/protogeni-rspec-common.xsd',
85 'flashpolicy/sfa_flashpolicy_config.xml',
87 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
88 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
89 ('/etc/init.d/', [ "init.d/%s"%x for x in initscripts ]),
90 ('/usr/share/sfa/migrations', glob('sfa/storage/migrations/*.*') ),
91 ('/usr/share/sfa/migrations/versions', glob('sfa/storage/migrations/versions/*') ),
92 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
95 # add sfatables processors as data_files
96 processor_files = [f for f in glob('sfatables/processors/*') if os.path.isfile(f)]
97 data_files.append(('/etc/sfatables/processors/', processor_files))
98 processor_subdirs = [d for d in glob('sfatables/processors/*') if os.path.isdir(d)]
99 for d in processor_subdirs:
100 etc_dir = os.path.join("/etc/sfatables/processors", os.path.basename(d))
101 d_files = [f for f in glob(d + '/*') if os.path.isfile(f)]
102 data_files.append((etc_dir, processor_files))
104 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
105 python_path = sys.path
106 site_packages_path = [ os.path.join(p, 'sfa') for p in python_path if p.endswith('site-packages')]
107 site_packages_path += [ os.path.join(p, 'sfatables') for p in python_path if p.endswith('site-packages')]
108 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
109 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
110 remove_files = remove_bins + [ "/etc/init.d/%s"%x for x in initscripts ]
113 def feedback (file, msg):
114 print ("removing", file, "...", msg)
115 for filepath in remove_files:
118 feedback(filepath, "success")
120 feedback(filepath, "failed")
122 for directory in remove_dirs:
124 shutil.rmtree(directory)
125 feedback (directory, "success")
127 feedback (directory, "failed")
129 # avoid repeating what's in the specfile already
131 with open("LICENSE.txt") as l:
134 license = "Could not open file LICENSE.txt"
136 with open("index.html") as r:
137 long_description = r.read()
139 long_description = "Unable to read index.html"
144 data_files = data_files,
145 version = version_tag,
146 keywords = ['federation', 'testbeds', 'SFA', 'SfaWrap'],
147 url = "http://svn.planet-lab.org/wiki/SFATutorial",
148 author = "Thierry Parmentelat, Tony Mack, Scott Baker",
149 author_email = "thierry.parmentelat@inria.fr, tmack@princeton.cs.edu, smbaker@gmail.com",
150 download_url = "http://build.onelab.eu/sfa/{v}/sfa-{v}.tar.gz".format(v=version_tag),
151 description = "SFA Wrapper with drivers for PlanetLab and IotLab and others",
153 long_description = long_description,