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") + [
32 'config/sfa-config-tty',
34 'sfa/server/sfa-start.py',
35 'systemd/sfa-setup.sh',
36 'sfatables/sfatables',
37 'keyconvert/keyconvert.py',
51 'sfa/rspecs/elements',
52 'sfa/rspecs/elements/versions',
53 'sfa/rspecs/versions',
60 'sfatables/processors',
65 [ 'config/aggregates.xml',
66 'config/registries.xml',
67 'config/default_config.xml',
68 'config/api_versions.xml',
71 'sfa/managers/pl/pl.rng',
72 'sfa/trust/credential.xsd',
76 'sfa/trust/protogeni-rspec-common.xsd',
78 ('/etc/sfatables/matches/', glob('sfatables/matches/*.xml')),
79 ('/etc/sfatables/targets/', glob('sfatables/targets/*.xml')),
80 ('/usr/share/sfa/migrations', glob('sfa/storage/migrations/*.*') ),
81 ('/usr/share/sfa/migrations/versions', glob('sfa/storage/migrations/versions/*') ),
82 ('/usr/share/sfa/examples/', glob('sfa/examples/*' ) + [ 'cron.d/sfa.cron' ] ),
86 services = ['sfa-db', 'sfa-aggregate', 'sfa-registry']
88 ('/usr/lib/systemd/system',
89 ['systemd/{}.service'.format(service)
90 for service in services]))
93 # sfatables processors
94 processor_files = [f for f in glob('sfatables/processors/*')
96 data_files.append(('/etc/sfatables/processors/', processor_files))
97 processor_subdirs = [d for d in glob('sfatables/processors/*')
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))
105 if sys.argv[1] in ['uninstall', 'remove', 'delete', 'clean']:
106 python_path = sys.path
107 site_packages_path = [ os.path.join(p, 'sfa') for p in python_path if p.endswith('site-packages')]
108 site_packages_path += [ os.path.join(p, 'sfatables') for p in python_path if p.endswith('site-packages')]
109 remove_dirs = ['/etc/sfa/', '/etc/sfatables'] + site_packages_path
110 remove_bins = [ '/usr/bin/' + os.path.basename(bin) for bin in scripts ]
111 remove_files = (remove_bins
112 + ["/usr/lib/systemd/system/{}".format(x)
116 def feedback (file, msg):
117 print ("removing", file, "...", msg)
118 for filepath in remove_files:
121 feedback(filepath, "success")
123 feedback(filepath, "failed")
125 for directory in remove_dirs:
127 shutil.rmtree(directory)
128 feedback (directory, "success")
130 feedback (directory, "failed")
132 # avoid repeating what's in the specfile already
134 with open("LICENSE.txt") as l:
137 license = "Could not open file LICENSE.txt"
139 with open("index.html") as r:
140 long_description = r.read()
142 long_description = "Unable to read index.html"
147 data_files = data_files,
148 version = version_tag,
149 keywords = ['federation', 'testbeds', 'SFA', 'SfaWrap'],
150 url = "http://svn.planet-lab.org/wiki/SFATutorial",
151 author = "Thierry Parmentelat, Tony Mack, Scott Baker",
152 author_email = "thierry.parmentelat@inria.fr, tmack@princeton.cs.edu, smbaker@gmail.com",
153 download_url = "http://build.onelab.eu/sfa/{v}/sfa-{v}.tar.gz".format(v=version_tag),
154 description = "SFA Wrapper with drivers for PlanetLab and IotLab and others",
156 long_description = long_description,