updated copyright and added csv results output to bench.py
[scons.git] / bin / scons_dev_master.py
blobd54c1575c2ab746eb959c76e367becb9c9c59603
1 #!/usr/bin/python
4 # A script for turning a generic Ubuntu system into a master for
5 # SCons development.
6 import getopt
7 import sys
9 from Command import CommandRunner, Usage
11 INITIAL_PACKAGES = [
12 'git',
15 INSTALL_PACKAGES = [
16 'wget',
17 'xz-utils',
20 PYTHON_PACKAGES = [
21 'g++',
22 'gcc',
23 'make',
24 'zlib1g-dev',
25 'libreadline-gplv2-dev',
26 'libncursesw5-dev',
27 'libssl-dev',
28 'libsqlite3-dev',
29 'tk-dev',
30 'libgdbm-dev',
31 'libc6-dev',
32 'libbz2-dev'
35 BUILDING_PACKAGES = [
36 'python3-lxml',
37 'fop',
38 'python3-dev',
39 'rpm',
40 'tar',
41 'lynx',
43 # additional packages that Bill Deegan's web page suggests
44 #'docbook-to-man',
45 #'docbook2x',
46 #'tetex-bin',
47 #'tetex-latex',
49 'python3-sphinx',
50 'python3-sphinx-rtd-theme',
54 DOCUMENTATION_PACKAGES = [
55 'docbook-doc',
56 'sphinx-doc',
57 'gcc-doc',
58 'pkg-config',
59 'python3-doc',
60 'openjdk-8-doc',
61 'swig-doc',
62 'texlive-doc',
65 TESTING_PACKAGES = [
66 'bison',
67 'cssc',
68 'cvs',
69 'flex',
70 'g++',
71 'gcc',
72 # not on ubuntu 18.04
73 # 'gcj',
74 # 'hg',
75 'ghostscript',
76 'm4',
77 'openssh-client',
78 'openssh-server',
79 'python3-profiler',
80 'python3-line-profiler',
81 'python3-all-dev',
82 'pypy3-dev',
83 'rcs',
84 'rpm',
85 'openjdk-8-jdk',
86 'swig',
87 'texlive-base-bin',
88 'texlive-font-utils',
89 'texlive-extra-utils',
90 'texlive-latex-base',
91 'texlive-latex-extra',
92 'texlive-bibtex-extra',
93 'docbook-xsl',
94 'biber',
95 'zip',
98 BUILDBOT_PACKAGES = [
99 'buildbot-worker',
100 'cron',
103 default_args = [
104 'upgrade',
105 'checkout',
106 'building',
107 'testing',
108 'python-versions',
109 'scons-versions',
112 def main(argv=None):
113 if argv is None:
114 argv = sys.argv
116 short_options = 'hnqy'
117 long_options = ['help', 'no-exec', 'password=', 'quiet', 'username=',
118 'yes', 'assume-yes']
120 helpstr = """\
121 Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER]
122 [ACTIONS ...]
124 ACTIONS (in default order):
125 upgrade Upgrade the system
126 checkout Check out SCons
127 building Install packages for building SCons
128 testing Install packages for testing SCons
129 scons-versions Install versions of SCons
130 python-versions Install versions of Python
132 ACTIONS (optional):
133 buildbot Install packages for running BuildBot
136 scons_url = 'https://github.com/SCons/scons.git'
137 sudo = 'sudo'
138 password = '""'
139 username = 'guest'
140 yesflag = ''
142 try:
143 try:
144 opts, args = getopt.getopt(argv[1:], short_options, long_options)
145 except getopt.error as msg:
146 raise Usage(msg)
148 for o, a in opts:
149 if o in ('-h', '--help'):
150 print(helpstr)
151 sys.exit(0)
152 elif o in ('-n', '--no-exec'):
153 CommandRunner.execute = CommandRunner.do_not_execute
154 elif o == '--password':
155 password = a
156 elif o in ('-q', '--quiet'):
157 CommandRunner.display = CommandRunner.do_not_display
158 elif o == '--username':
159 username = a
160 elif o in ('-y', '--yes', '--assume-yes'):
161 yesflag = o
162 except Usage as err:
163 sys.stderr.write(str(err.msg) + '\n')
164 sys.stderr.write('use -h to get help\n')
165 return 2
167 if not args:
168 args = default_args
170 initial_packages = ' '.join(INITIAL_PACKAGES)
171 install_packages = ' '.join(INSTALL_PACKAGES)
172 building_packages = ' '.join(BUILDING_PACKAGES)
173 testing_packages = ' '.join(TESTING_PACKAGES)
174 buildbot_packages = ' '.join(BUILDBOT_PACKAGES)
175 python_packages = ' '.join(PYTHON_PACKAGES)
176 doc_packages = ' '.join(DOCUMENTATION_PACKAGES)
178 cmd = CommandRunner(locals())
180 for arg in args:
181 if arg == 'upgrade':
182 cmd.run('%(sudo)s apt-get %(yesflag)s upgrade')
183 elif arg == 'checkout':
184 cmd.run('%(sudo)s apt-get %(yesflag)s install %(initial_packages)s')
185 cmd.run('git clone" %(scons_url)s')
186 elif arg == 'building':
187 cmd.run('%(sudo)s apt-get %(yesflag)s install %(building_packages)s')
188 elif arg == 'docs':
189 cmd.run('%(sudo)s apt-get %(yesflag)s install %(doc_packages)s')
190 elif arg == 'testing':
191 cmd.run('%(sudo)s apt-get %(yesflag)s install %(testing_packages)s')
192 #TODO: maybe copy ipkg-build from openwrt git
193 #cmd.run('%(sudo)s wget https://raw.githubusercontent.com/openwrt/openwrt/master/scripts/ipkg-build SOMEWHERE')
194 elif arg == 'buildbot':
195 cmd.run('%(sudo)s apt-get %(yesflag)s install %(buildbot_packages)s')
196 elif arg == 'python-versions':
197 if install_packages:
198 cmd.run('%(sudo)s apt-get %(yesflag)s install %(install_packages)s')
199 install_packages = None
200 cmd.run('%(sudo)s apt-get %(yesflag)s install %(python_packages)s')
201 try:
202 import install_python
203 except ImportError:
204 msg = 'Could not import install_python; skipping python-versions.\n'
205 sys.stderr.write(msg)
206 else:
207 install_python.main(['install_python.py', '-a'])
208 elif arg == 'scons-versions':
209 if install_packages:
210 cmd.run('%(sudo)s apt-get %(yesflag)s install %(install_packages)s')
211 install_packages = None
212 try:
213 import install_scons
214 except ImportError:
215 msg = 'Could not import install_scons; skipping scons-versions.\n'
216 sys.stderr.write(msg)
217 else:
218 install_scons.main(['install_scons.py', '-a'])
219 else:
220 msg = '%s: unknown argument %s\n'
221 sys.stderr.write(msg % (argv[0], repr(arg)))
222 sys.exit(1)
224 if __name__ == "__main__":
225 sys.exit(main())
227 # Local Variables:
228 # tab-width:4
229 # indent-tabs-mode:nil
230 # End:
231 # vim: set expandtab tabstop=4 shiftwidth=4: