1
# IVLE - Informatics Virtual Learning Environment
2
# Copyright (C) 2007-2008 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
# Author: Matt Giuca, Refactored by David Coles
27
from setup import util
30
usage = """usage: %prog build [options]
32
Compiles platform-specific code, and optionally Python too.
34
Compiles (GCC) bin/trampoline/trampoline.c to bin/trampoline/trampoline.
35
Compiles (GCC) bin/timount/timount.c to bin/timount/timount.
36
Optionally generates .pyc files for all the IVLE .py files."""
39
parser = optparse.OptionParser(usage)
40
parser.add_option("-n", "--dry",
41
action="store_true", dest="dry",
42
help="Print out the actions but don't do anything.")
43
parser.add_option("--no-compile",
44
action="store_true", dest="nocompile",
45
help="Don't byte-compile .py files.")
46
parser.add_option("-t", "--trampoline-uids",
47
action="store", dest="tuids", default="33",
48
help="Comma-separated list of UIDs allowed to use trampoline. "
50
(options, args) = parser.parse_args(args)
52
# Call the real function
53
return __build(options.dry, options.nocompile, options.tuids)
55
def __build(dry=False, no_compile=None, tuids=None):
56
install_list = util.InstallList()
59
print "Dry run (no actions will be executed)\n"
61
# Create trampoline configuration.
62
conf_hfile = os.path.join(os.getcwd(), "bin/trampoline/conf.h")
63
conf_h = open(conf_hfile, "w")
65
conf_h.write("""/* IVLE Configuration File
67
* Administrator settings required by trampoline.
68
* Note: trampoline will have to be rebuilt in order for changes to this file
72
#define IVLE_AUFS_JAILS
74
/* Which user IDs are allowed to run the trampoline.
75
* This list should be limited to the web server user.
76
* (Note that root is an implicit member of this list).
78
static const int allowed_uids[] = { %s };
82
# Compile the trampoline
84
os.chdir('bin/trampoline')
85
util.action_runprog('make', [], dry)
90
os.chdir('bin/timount')
91
util.action_runprog('make', [], dry)
94
# Compile .py files into .pyc or .pyo files
96
compileall.compile_dir('ivle', quiet=True)
97
compileall.compile_dir('services', quiet=True)