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

« back to all changes in this revision

Viewing changes to bin/ivle-buildjail

  • Committer: William Grant
  • Date: 2009-02-27 05:07:09 UTC
  • Revision ID: grantw@unimelb.edu.au-20090227050709-k16kvhyl50nzjbwm
Subject URLs now contain the short name (eg. info1) rather than the code
(eg. 600151).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
47
(options, args) = parser.parse_args(sys.argv)
48
48
 
49
49
if os.geteuid() != 0:
55
55
    sys.exit(1)
56
56
 
57
57
if options.recreate:
 
58
    options.upgrade = True
 
59
 
58
60
    # Create the jail and its subdirectories
59
61
    # Note: Other subdirs will be made by copying files
60
62
    if options.apt_mirror is not None:
64
66
    ivle.jailbuilder.debian.debootstrap_create_jail(conf['jail']['suite'],
65
67
              build_path, mirror=options.apt_mirror)
66
68
 
 
69
    ivle.jailbuilder.debian.apt_update_cache(build_path)
 
70
    ivle.jailbuilder.debian.apt_install(build_path,
 
71
                        ['python2.5', 'python-cjson', 'python-svn'])
 
72
 
 
73
    ivle.jailbuilder.debian.apt_clean(build_path)
 
74
 
 
75
if options.upgrade:
 
76
    # Run apt-get update, apt-get upgrade and apt-get clean.
 
77
    ivle.jailbuilder.debian.mangle_sources_list(build_path, clobber=True)
 
78
    ivle.jailbuilder.debian.mangle_sources_list(build_path, lines=[
 
79
            'deb %s %s%s %s' % (options.apt_mirror, conf['jail']['suite'],
 
80
                                pocket, ' '.join(['main', 'universe']))
 
81
            for pocket in ('', '-updates', '-security')])
 
82
 
67
83
    # Add any extra site apt sources.
68
84
    if conf['jail']['extra_sources']:
69
85
        ivle.jailbuilder.debian.mangle_sources_list(build_path,
75
91
                                            conf['jail']['extra_keys'])
76
92
 
77
93
    ivle.jailbuilder.debian.apt_update_cache(build_path)
78
 
    ivle.jailbuilder.debian.apt_install(build_path,
79
 
                        ['python2.5', 'python-cjson', 'python-svn'])
 
94
    ivle.jailbuilder.debian.apt_upgrade(build_path)
80
95
 
81
96
    # Install any extra site packages.
82
97
    if conf['jail']['extra_packages']:
85
100
 
86
101
    ivle.jailbuilder.debian.apt_clean(build_path)
87
102
 
88
 
if options.upgrade:
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)
93
 
 
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)
100
 
 
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)
108
 
 
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'))
 
103
if conf['jail']['devmode']:
 
104
    # Copy all console and operating system files into the jail
 
105
    services_path = os.path.join(ivle.conf.share_path, 'services')
 
106
    jail_services_path = os.path.join(build_path, services_path[1:])
 
107
    if os.path.exists(jail_services_path):
 
108
        shutil.rmtree(jail_services_path)
 
109
    shutil.copytree(services_path, jail_services_path)
 
110
 
 
111
    # Also copy the IVLE lib directory into the jail
 
112
    # 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:])
 
115
    if os.path.exists(jail_site_packages):
 
116
        shutil.rmtree(jail_site_packages)
 
117
    shutil.copytree(ivle_site_packages, jail_site_packages)
 
118
 
 
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'))
115
125
 
116
126
if os.spawnvp(os.P_WAIT, 'rsync', ['rsync', '-a', '--delete',
117
127
              build_path + '/', ivle.conf.jail_system]) != 0: