~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup/build.py

  • Committer: drtomc
  • Date: 2007-12-04 01:57:41 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:3
A README file describing sundry bits of the platform infrastructure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# IVLE - Informatics Virtual Learning Environment
2
 
# Copyright (C) 2007-2008 The University of Melbourne
3
 
#
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.
8
 
#
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.
13
 
#
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
17
 
 
18
 
# Module: setup/build
19
 
# Author: Matt Giuca, Refactored by David Coles
20
 
# Date:   02/07/2008
21
 
 
22
 
import optparse
23
 
import os
24
 
import sys
25
 
import compileall
26
 
 
27
 
from setup import util
28
 
 
29
 
def build(args):
30
 
    usage = """usage: %prog build [options]
31
 
(requires root)
32
 
Compiles platform-specific code, and optionally Python too.
33
 
Details:
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."""
37
 
 
38
 
    # Parse arguments
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. "
49
 
             "(default: 33)")
50
 
    (options, args) = parser.parse_args(args)
51
 
 
52
 
    # Call the real function
53
 
    return __build(options.dry, options.nocompile, options.tuids)
54
 
 
55
 
def __build(dry=False, no_compile=None, tuids=None):
56
 
    install_list = util.InstallList()
57
 
 
58
 
    if dry:
59
 
        print "Dry run (no actions will be executed)\n"
60
 
 
61
 
    # Create trampoline configuration.
62
 
    conf_hfile = os.path.join(os.getcwd(), "bin/trampoline/conf.h")
63
 
    conf_h = open(conf_hfile, "w")
64
 
 
65
 
    conf_h.write("""/* IVLE Configuration File
66
 
 * conf.h
67
 
 * Administrator settings required by trampoline.
68
 
 * Note: trampoline will have to be rebuilt in order for changes to this file
69
 
 * to take effect.
70
 
 */
71
 
 
72
 
#define IVLE_AUFS_JAILS
73
 
 
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).
77
 
 */
78
 
static const int allowed_uids[] = { %s };
79
 
""" % tuids)
80
 
    conf_h.close()
81
 
 
82
 
    # Compile the trampoline
83
 
    curdir = os.getcwd()
84
 
    os.chdir('bin/trampoline')
85
 
    util.action_runprog('make', [], dry)
86
 
    os.chdir(curdir)
87
 
 
88
 
    # Compile timount
89
 
    curdir = os.getcwd()
90
 
    os.chdir('bin/timount')
91
 
    util.action_runprog('make', [], dry)
92
 
    os.chdir(curdir)
93
 
 
94
 
    # Compile .py files into .pyc or .pyo files
95
 
    if not no_compile:
96
 
        compileall.compile_dir('ivle', quiet=True)
97
 
        compileall.compile_dir('services', quiet=True)
98
 
 
99
 
    return 0
100