25
25
# It is called with at least one argument, which specifies which operation to
28
# setup.py listmake (for developer use only)
29
# Recurses through the source tree and builds a list of all files which should
30
# be copied upon installation. This should be run by the developer before
31
# cutting a distribution, and the listfile it generates should be included in
32
# the distribution, avoiding the administrator having to run it.
28
34
# setup.py conf [args]
29
35
# Configures IVLE with machine-specific details, most notably, various paths.
30
36
# Either prompts the administrator for these details or accepts them as
42
48
# (eg. python and Python libs, ld.so, etc).
43
49
# Generates .pyc files for all the IVLE .py files.
45
# setup.py listmake (for developer use only)
46
# Recurses through the source tree and builds a list of all files which should
47
# be copied upon installation. This should be run by the developer before
48
# cutting a distribution, and the listfile it generates should be included in
49
# the distribution, avoiding the administrator having to run it.
51
51
# setup.py install [--nojail] [--dry|n]
53
53
# Create target install directory ($target).
88
# Try importing install_list, but don't fail if we can't, because listmake can
89
# function without it.
87
95
# Mime types which will automatically be placed in the list by listmake.
88
96
# Note that listmake is not intended to be run by the final user (the system
89
97
# administrator who installs this), so the developers can customize the list
168
176
if operation == 'help':
169
177
print """python setup.py help [operation]
170
178
Prints the usage message or detailed help on an operation, then exits."""
179
elif operation == 'listmake':
180
print """python setup.py listmake
181
(For developer use only)
182
Recurses through the source tree and builds a list of all files which should
183
be copied upon installation. This should be run by the developer before
184
cutting a distribution, and the listfile it generates should be included in
185
the distribution, avoiding the administrator having to run it."""
171
186
elif operation == 'conf':
172
187
print """python setup.py conf [args]
173
188
Configures IVLE with machine-specific details, most notably, various paths.
179
194
elif operation == 'build':
180
print """python -O setup.py build
195
print """python -O setup.py build [--dry|-n]
181
196
Compiles all files and sets up a jail template in the source directory.
182
197
-O is recommended to cause compilation to be optimised.
187
202
Copies console/ to a location within the jail.
188
203
Copies OS programs and files to corresponding locations within the jail
189
204
(eg. python and Python libs, ld.so, etc).
190
Generates .pyc or .pyo files for all the IVLE .py files."""
191
elif operation == 'listmake':
192
print """python setup.py listmake
193
(For developer use only)
194
Recurses through the source tree and builds a list of all files which should
195
be copied upon installation. This should be run by the developer before
196
cutting a distribution, and the listfile it generates should be included in
197
the distribution, avoiding the administrator having to run it."""
205
Generates .pyc or .pyo files for all the IVLE .py files.
207
--dry | -n Print out the actions but don't do anything."""
198
208
elif operation == 'install':
199
209
print """sudo python setup.py install [--nojail] [--dry|-n]
428
438
action_mkdir('jail/home', dry)
429
439
action_mkdir('jail/tmp', dry)
431
# TODO: Copy console into the jail
441
# Copy all console files into the jail
442
action_copylist(install_list.list_console, 'jail/opt/ivle', dry)
432
444
# TODO: Copy operating system files into the jail
433
446
# Compile .py files into .pyc or .pyo files
434
447
compileall.compile_dir('www', quiet=True)
435
448
compileall.compile_dir('console', quiet=True)
480
493
if err != errno.EEXIST:
496
def action_copytree(src, dst, dry):
497
"""Copies an entire directory tree. Symlinks are seen as normal files and
498
copies of the entire file (not the link) are made. Creates all parent
499
directories as necessary.
501
See shutil.copytree."""
502
if os.access(dst, os.F_OK):
505
shutil.rmtree(dst, True)
506
print "cp -r", src, dst
508
shutil.copytree(src, dst)
510
def action_copylist(srclist, dst, dry):
511
"""Copies all files in a list to a new location. The files in the list
512
are read relative to the current directory, and their destinations are the
513
same paths relative to dst. Creates all parent directories as necessary.
515
for srcfile in srclist:
516
dstfile = os.path.join(dst, srcfile)
517
dstdir = os.path.split(dstfile)[0]
518
if not os.path.isdir(dstdir):
519
action_mkdir(dstdir, dry)
520
print "cp -f", srcfile, dstfile
522
shutil.copyfile(srcfile, dstfile)
483
524
def query_user(default, prompt):
484
525
"""Prompts the user for a string, which is read from a line of stdin.
485
526
Exits silently if EOF is encountered. Returns the string, with spaces