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

« back to all changes in this revision

Viewing changes to setup/install.py

  • Committer: Matt Giuca
  • Date: 2009-02-24 02:02:03 UTC
  • mto: This revision was merged to the branch mainline in revision 1119.
  • Revision ID: matt.giuca@gmail.com-20090224020203-aqdcjnsj6y7wl32o
Added a new look to the IVLE header bar. Mmmm... Web 2.0.
Added top-level directory image-source, containing SVG and script files for
    generating the images.
ivle/webapp/coremedia/images: Added 'chrome' directory containing the rendered
    images.
Modified ivle/webapp/base/ivle-headings.html and
    ivle/webapp/coremedia/ivle.css to support the new images.
    Note that the H1 and H2 at the top of the page are no longer displayed
    (and their custom styles have been removed). There is a heading image
    instead.

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/install
 
19
# Author: Matt Giuca, Refactored by David Coles
 
20
# Date:   03/07/2008
 
21
 
 
22
import optparse
 
23
import os
 
24
import sys
 
25
import functools
 
26
 
 
27
from setup import util
 
28
 
 
29
PYTHON_VERSION = sys.version[:3]
 
30
 
 
31
def install(args):
 
32
    usage = """usage: %prog install [options]
 
33
(Requires root)
 
34
Create target install directory ($target).
 
35
Create $target/bin.
 
36
Copy bin/trampoline/trampoline to $target/bin.
 
37
Copy bin/timount/timount to $target/bin.
 
38
chown and chmod the installed trampoline.
 
39
"""
 
40
 
 
41
    # Parse arguments
 
42
    parser = optparse.OptionParser(usage)
 
43
    parser.add_option("-n", "--dry",
 
44
        action="store_true", dest="dry",
 
45
        help="Print out the actions but don't do anything.")
 
46
    parser.add_option("-R", "--nosvnrevno",
 
47
        action="store_true", dest="nosvnrevno",
 
48
        help="Don't write out the Subversion revision to the share directory.")
 
49
    parser.add_option("--root",
 
50
        action="store", dest="rootdir",
 
51
        help="Install into a different root directory.",
 
52
        default='/')
 
53
    parser.add_option("--prefix",
 
54
        action="store", dest="prefix",
 
55
        help="Base prefix to install IVLE into (default: /usr/local).",
 
56
        default='/usr/local')
 
57
    parser.add_option("--python-site-packages",
 
58
        action="store", dest="python_site_packages",
 
59
        help="Path to Python site packages directory.",
 
60
        default='/usr/local/lib/python%s/site-packages' % PYTHON_VERSION)
 
61
    (options, args) = parser.parse_args(args)
 
62
 
 
63
    # Call the real function
 
64
    return __install(prefix=options.prefix,
 
65
                     python_site_packages=options.python_site_packages,
 
66
                     dry=options.dry, rootdir=options.rootdir,
 
67
                     nosvnrevno=options.nosvnrevno)
 
68
 
 
69
def __install(prefix, python_site_packages, dry=False, rootdir=None,
 
70
              nosvnrevno=False):
 
71
    install_list = util.InstallList()
 
72
 
 
73
    # We need to apply make_install_path with the rootdir to an awful lot of
 
74
    # config variables, so make it easy:
 
75
    mip = functools.partial(util.make_install_path, rootdir)
 
76
 
 
77
    # Compute the lib_path, share_path and bin_path (copied from
 
78
    # ivle/conf/conf.py).
 
79
    lib_path = mip(os.path.join(prefix, 'lib/ivle'))
 
80
    share_path = mip(os.path.join(prefix, 'share/ivle'))
 
81
    bin_path = mip(os.path.join(prefix, 'bin'))
 
82
    python_site_packages = mip(python_site_packages)
 
83
 
 
84
    # Must be run as root or a dry run  
 
85
    if dry:
 
86
        print "Dry run (no actions will be executed)\n"
 
87
    
 
88
    if not dry and os.geteuid() != 0:
 
89
        print >>sys.stderr, "Must be root to run install"
 
90
        return 1
 
91
 
 
92
    # Create the config directory.
 
93
    util.action_mkdir(mip('/etc/ivle/plugins.d'), dry)
 
94
 
 
95
    # Create lib and copy the compiled files there
 
96
    util.action_mkdir(lib_path, dry)
 
97
 
 
98
    tramppath = os.path.join(lib_path, 'trampoline')
 
99
    util.action_copyfile('bin/trampoline/trampoline', tramppath, dry)
 
100
    # chown trampoline to root and set setuid bit
 
101
    util.action_chown_setuid(tramppath, dry)
 
102
 
 
103
    timountpath = os.path.join(lib_path, 'timount')
 
104
    util.action_copyfile('bin/timount/timount', timountpath, dry)
 
105
 
 
106
    # Copy in the services (only usrmgt-server is needed on the host, but
 
107
    # the jail build requires the rest).
 
108
    util.action_copylist(install_list.list_services, share_path, dry)
 
109
    usrmgtpath = os.path.join(share_path, 'services/usrmgt-server')
 
110
    util.action_chmod_x(usrmgtpath, dry)
 
111
 
 
112
    # Copy the user-executable binaries using the list.
 
113
    util.action_copylist(install_list.list_user_binaries, bin_path, dry,
 
114
                         onlybasename=True)
 
115
 
 
116
    # Copy the lib directory (using the list)
 
117
    util.action_copylist(install_list.list_ivle_lib, python_site_packages, dry)
 
118
 
 
119
    if not nosvnrevno:
 
120
        # Create the ivle working revision record file
 
121
        ivle_revision_file = os.path.join(share_path, 'revision.txt')
 
122
        if not dry:
 
123
            try:
 
124
                conf = open(ivle_revision_file, "w")
 
125
 
 
126
                conf.write("""# SVN revision r%s
 
127
# Source tree location: %s
 
128
# Modified files:
 
129
""" % (util.get_svn_revision(), os.getcwd()))
 
130
 
 
131
                conf.close()
 
132
            except IOError, (errno, strerror):
 
133
                print "IO error(%s): %s" % (errno, strerror)
 
134
                sys.exit(1)
 
135
 
 
136
            os.system("svn status . >> %s" % ivle_revision_file)
 
137
 
 
138
        print "Wrote IVLE code revision status to %s" % ivle_revision_file
 
139
 
 
140
    return 0
 
141