43
43
help='''Apply any package updates in the jail.''')
44
44
parser.add_option("-m", "--mirror",
45
45
action="store", dest="apt_mirror",
46
help="Sets the apt mirror used when recreating the jail.")
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.",
47
51
(options, args) = parser.parse_args(sys.argv)
49
53
if os.geteuid() != 0:
64
75
ivle.jailbuilder.debian.debootstrap_create_jail(conf['jail']['suite'],
65
76
build_path, mirror=options.apt_mirror)
78
ivle.jailbuilder.debian.apt_update_cache(build_path)
79
ivle.jailbuilder.debian.apt_install(build_path,
80
['python2.5', 'python-cjson', 'python-svn'])
82
ivle.jailbuilder.debian.apt_clean(build_path)
85
# Run apt-get update, apt-get upgrade and apt-get clean.
86
ivle.jailbuilder.debian.mangle_sources_list(build_path, clobber=True)
87
ivle.jailbuilder.debian.mangle_sources_list(build_path, lines=[
88
'deb %s %s%s %s' % (options.apt_mirror, conf['jail']['suite'],
89
pocket, ' '.join(['main', 'universe']))
90
for pocket in ('', '-updates', '-security')])
67
92
# Add any extra site apt sources.
68
93
if conf['jail']['extra_sources']:
69
94
ivle.jailbuilder.debian.mangle_sources_list(build_path,
86
110
ivle.jailbuilder.debian.apt_clean(build_path)
89
# Run apt-get update, apt-get upgrade and apt-get clean.
90
ivle.jailbuilder.debian.apt_update_cache(build_path)
91
ivle.jailbuilder.debian.apt_upgrade(build_path)
92
ivle.jailbuilder.debian.apt_clean(build_path)
94
# Copy all console and operating system files into the jail
95
services_path = os.path.join(ivle.conf.share_path, 'services')
96
jail_services_path = os.path.join(build_path, services_path[1:])
97
if os.path.exists(jail_services_path):
98
shutil.rmtree(jail_services_path)
99
shutil.copytree(services_path, jail_services_path)
101
# Also copy the IVLE lib directory into the jail
102
# This is necessary for running certain services
103
ivle_site_packages = os.path.join(ivle.conf.python_site_packages, 'ivle')
104
jail_site_packages = os.path.join(build_path, ivle_site_packages[1:])
105
if os.path.exists(jail_site_packages):
106
shutil.rmtree(jail_site_packages)
107
shutil.copytree(ivle_site_packages, jail_site_packages)
109
# IMPORTANT: ivle/conf/conf.py contains details which could compromise security
110
# if left in the jail (such as the DB password). We delete it now! It would be
111
# shadowed by the per-user conf.py anyway, but it's best to be safe.
112
os.unlink(os.path.join(jail_site_packages, 'conf/conf.py'))
113
# XXX: Shouldn't copy the compiled files at all, but compile them in the jail!
114
os.unlink(os.path.join(jail_site_packages, 'conf/conf.pyc'))
112
if conf['jail']['devmode']:
113
# Copy all console and operating system files into the jail
114
services_path = os.path.join(ivle.conf.share_path, 'services')
115
jail_services_path = os.path.join(build_path, services_path[1:])
116
if os.path.exists(jail_services_path):
117
shutil.rmtree(jail_services_path)
118
shutil.copytree(services_path, jail_services_path)
120
# Also copy the IVLE lib directory into the jail
121
# This is necessary for running certain services
123
# ivle_site_packages is the IVLE install location outside the jail
124
ivle_site_packages = os.path.dirname(ivle.__file__)
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:])
133
# User-specified site packages
134
jail_site_packages = os.path.join(build_path,
135
options.python_site_packages[1:], "ivle")
136
if os.path.exists(jail_site_packages):
137
shutil.rmtree(jail_site_packages)
138
shutil.copytree(ivle_site_packages, jail_site_packages)
116
140
if os.spawnvp(os.P_WAIT, 'rsync', ['rsync', '-a', '--delete',
117
141
build_path + '/', ivle.conf.jail_system]) != 0: