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

« back to all changes in this revision

Viewing changes to bin/ivle-buildjail

  • Committer: William Grant
  • Date: 2009-04-28 08:17:26 UTC
  • Revision ID: grantw@unimelb.edu.au-20090428081726-7h8fyjclxtydjma0
No more ivle.conf in ivle.webapp.fileservice...

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
parser.add_option("-m", "--mirror",
45
45
    action="store", dest="apt_mirror",
46
46
    help="Sets the apt mirror.", default="http://archive.ubuntu.com/ubuntu")
 
47
parser.add_option("--python-site-packages",
 
48
    action="store", dest="python_site_packages",
 
49
    help="Path to Python site packages directory inside the jail.",
 
50
    default=None)
47
51
(options, args) = parser.parse_args(sys.argv)
48
52
 
49
53
if os.geteuid() != 0:
54
58
    print >> sys.stderr, "No jail exists -- please rerun with -r."
55
59
    sys.exit(1)
56
60
 
 
61
if (options.python_site_packages is not None and
 
62
    options.python_site_packages[:1] not in (os.path.sep, os.path.altsep)):
 
63
    print >> sys.stderr, "python-site-packages must be an absolute path."
 
64
    sys.exit(1)
 
65
 
57
66
if options.recreate:
58
67
    options.upgrade = True
59
68
 
110
119
 
111
120
    # Also copy the IVLE lib directory into the jail
112
121
    # This is necessary for running certain services
113
 
    ivle_site_packages = os.path.join(ivle.conf.python_site_packages, 'ivle')
114
 
    jail_site_packages = os.path.join(build_path, ivle_site_packages[1:])
 
122
 
 
123
    # ivle_site_packages is the IVLE install location outside the jail
 
124
    ivle_site_packages = os.path.dirname(ivle.__file__)
 
125
 
 
126
    if options.python_site_packages is None:
 
127
        # Get the site packages from the IVLE install location *OUTSIDE* the
 
128
        # jail. Warning! This only works if you have the same Python site
 
129
        # packages directory inside and out (ie. same Python version).
 
130
        # If not, you should use --python-site-packages.
 
131
        jail_site_packages = os.path.join(build_path, ivle_site_packages[1:])
 
132
    else:
 
133
        # User-specified site packages
 
134
        jail_site_packages = os.path.join(build_path,
 
135
                                options.python_site_packages[1:], "ivle")
115
136
    if os.path.exists(jail_site_packages):
116
137
        shutil.rmtree(jail_site_packages)
117
138
    shutil.copytree(ivle_site_packages, jail_site_packages)
118
139
 
119
 
    # IMPORTANT: ivle/conf/conf.py contains details which could compromise security
120
 
    # if left in the jail (such as the DB password). We delete it now! It would be
121
 
    # shadowed by the per-user conf.py anyway, but it's best to be safe.
122
 
    os.unlink(os.path.join(jail_site_packages, 'conf/conf.py'))
123
 
    # XXX: Shouldn't copy the compiled files at all, but compile them in the jail!
124
 
    os.unlink(os.path.join(jail_site_packages, 'conf/conf.pyc'))
125
 
 
126
140
if os.spawnvp(os.P_WAIT, 'rsync', ['rsync', '-a', '--delete',
127
141
              build_path + '/', ivle.conf.jail_system]) != 0:
128
142
    print >> sys.stderr, "Jail copying failed."