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

803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
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
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
24
import sys
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
25
import compileall
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
26
27
from setup import util
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
28
29
def build(args):
30
    usage = """usage: %prog build [options]
31
(requires root)
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
32
Compiles platform-specific code, and optionally Python too.
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
33
Details:
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
34
Compiles (GCC) bin/trampoline/trampoline.c to bin/trampoline/trampoline.
35
Compiles (GCC) bin/timount/timount.c to bin/timount/timount.
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
36
Optionally generates .pyc files for all the IVLE .py files."""
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
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.")
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
43
    parser.add_option("--no-compile",
44
        action="store_true", dest="nocompile",
45
        help="Don't byte-compile .py files.")
1092.1.51 by William Grant
Move trampoline UID configuration out of config.
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)")
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
50
    (options, args) = parser.parse_args(args)
51
52
    # Call the real function
1092.1.51 by William Grant
Move trampoline UID configuration out of config.
53
    return __build(options.dry, options.nocompile, options.tuids)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
54
1092.1.51 by William Grant
Move trampoline UID configuration out of config.
55
def __build(dry=False, no_compile=None, tuids=None):
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
56
    install_list = util.InstallList()
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
57
58
    if dry:
59
        print "Dry run (no actions will be executed)\n"
1050 by wagrant
setup: Don't give possible options in the top-level usage string.
60
1092.1.51 by William Grant
Move trampoline UID configuration out of config.
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
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
82
    # Compile the trampoline
83
    curdir = os.getcwd()
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
84
    os.chdir('bin/trampoline')
85
    util.action_runprog('make', [], dry)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
86
    os.chdir(curdir)
87
813 by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens
88
    # Compile timount
89
    curdir = os.getcwd()
1079 by William Grant
Merge setup-refactor branch. This completely breaks existing installations;
90
    os.chdir('bin/timount')
91
    util.action_runprog('make', [], dry)
813 by William Grant
Merge jails-redux branch. We now use aufs rather than hardlinking tens
92
    os.chdir(curdir)
93
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
94
    # Compile .py files into .pyc or .pyo files
1092.1.1 by William Grant
[Uber-commit of holiday work because I lacked a local copy of the branch.]
95
    if not no_compile:
96
        compileall.compile_dir('ivle', quiet=True)
97
        compileall.compile_dir('services', quiet=True)
803 by dcoles
Setup: Modularised setup.py so it is now no longer over 1000 lines. This should
98
99
    return 0
100