The University of California, San Diego
UCSD

root/setup.py

Revision 151:af193afb799a, 5.0 kB (checked in by Marvin McNett <mmcnett@cs.ucsd.edu>, 2 years ago)

added sample plugins to default install

  • Property exe set to *
Line 
1 #!/usr/bin/env python
2 # Copyright (C) 2006, University of California Regents
3 # All rights reserved
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 #
8 #  * Redistributions of source code must retain the above copyright notice,
9 #    this list of conditions and the following disclaimer.
10 #  * Redistributions in binary form must reproduce the above copyright notice,
11 #    this list of conditions and the following disclaimer in the documentation
12 #    and/or other materials provided with the distribution.
13 #  * Neither the name of the University of California, San Diego nor the
14 #    names of its contributors may be used to endorse or promote products
15 #    derived from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28 #
29 # AUTHORS:  Marvin McNett <mmcnett@cs.ucsd.edu>
30 #           Diwaker Gupta <dgupta@cs.ucsd.edu>
31 #           Roman Kurakin <rik@inse.ru>
32 #
33 # PROJECT URL: http://usher.ucsd.edu/
34
35 import sys
36 import os
37 import time
38
39 from distutils.core import setup
40 from distutils.command.install_data import install_data
41 from distutils.util import change_root, convert_path
42 from types import StringType
43
44
45 pyver = '%d.%d'%sys.version_info[0:2]
46
47 class smart_install_data(install_data):
48
49     def initialize_options (self):
50         self.install_dir = None
51         self.outfiles = []
52         self.root = None
53         self.force = 0
54
55         self.data_files = self.distribution.data_files
56         self.script_args = self.distribution.script_args
57         self.warn_dir = 1
58
59     def run(self):
60         # Use revers order for safe removal
61         for i in range(len(self.data_files)-1, -1, -1):
62             f = self.data_files[i]
63             if type(f) is StringType:
64                 continue
65             if len(f) <= 2:
66                continue
67             # Ok, we have additional value, do some magick according it.
68             if f[2] != 'preserve':
69                 # Nope, we do not know it. Just ignore for now.
70                 # Should we scream about it?
71                 continue
72             # Check a tuple with path to install to and a list of files
73             dir = convert_path(f[0])
74             if not os.path.isabs(dir):
75                 dir = os.path.join(self.install_dir, dir)
76             elif self.root:
77                 dir = change_root(self.root, dir)
78
79             if f[1] == []:
80                 # If there are no files listed, the user must be
81                 # trying to create an empty directory, so just ignore
82                 # it.
83                 # Should we scream in this case?
84                 continue
85
86             # Check files one by one.
87             # Use revers order for safe removal
88             for j in range(len(f[1])-1, -1, -1):
89                 data=f[1][j]
90                 data = convert_path(data)
91                 if not os.path.isfile(data):
92                     # Again skip dirs.
93                     continue
94                 dst = os.path.join(dir, os.path.basename(data))
95                 if not os.path.exists(dst):
96                     continue
97                 # just move it to dst_<time>
98                 os.rename(dst, dst+'_'+time.strftime('%Y-%m-%d_%H:%M:%S',
99                     time.gmtime()))
100             #    del f[1][j]
101             #if len(f[1]) == 0:
102             #    del self.data_files[i]
103
104         return install_data.run(self)
105
106
107 setup(name = 'usher',
108       version = '0.3',
109       description = 'Usher Virtual Machine Management System',
110       author = 'Marvin McNett',
111       author_email = 'mmcnett@cs.ucsd.edu',
112       url = 'http://usher.ucsd.edu/',
113       download_url = 'http://usher.ucsd.edu/UsherDownloads',
114       license = 'New BSD',
115       packages = ['usher', 'usher.ctrl', 'usher.cli', 'usher.lnm',
116           'usher.utils', 'usher.plugins', 'usher.plugins.sample2'],
117       cmdclass = {'install_data':smart_install_data},
118       data_files = [
119           ('/var/usher', []),
120           ('/etc/init.d', ['initscripts/usherctrl', 'initscripts/usherlnm'],
121               'preserve'),
122           ('/etc/usher', ['configs/ctrl.config.orig',
123               'configs/lnm.config.orig', 'configs/cli.config.orig']),
124           ('/usr/lib/python%s/site-packages/usher/ctrl' % pyver,
125               ['usher/ctrl/app.tac']),
126           ('/usr/lib/python%s/site-packages/usher/lnm' % pyver,
127               ['usher/lnm/app.tac'])
128       ]
129      )
Note: See TracBrowser for help on using the browser.