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

« back to all changes in this revision

Viewing changes to bin/ivle-buildjail

  • Committer: Matt Giuca
  • Date: 2009-02-24 04:44:00 UTC
  • mto: This revision was merged to the branch mainline in revision 1119.
  • Revision ID: matt.giuca@gmail.com-20090224044400-m9mm2ngpt2d2jyv0
title.svg: Changed background colour to blue (for testing purposes)
    - this is the same as the actual background of the site.
    And moved the letters "IVLE" so they are evenly distributed, and appear
    behind the words they stand for.

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.", default=conf['jail']['mirror'])
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)
 
46
    help="Sets the apt mirror used when recreating the jail.")
51
47
(options, args) = parser.parse_args(sys.argv)
52
48
 
53
49
if os.geteuid() != 0:
58
54
    print >> sys.stderr, "No jail exists -- please rerun with -r."
59
55
    sys.exit(1)
60
56
 
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
 
 
66
57
if options.recreate:
67
 
    options.upgrade = True
68
 
 
69
58
    # Create the jail and its subdirectories
70
59
    # Note: Other subdirs will be made by copying files
71
60
    if options.apt_mirror is not None:
75
64
    ivle.jailbuilder.debian.debootstrap_create_jail(conf['jail']['suite'],
76
65
              build_path, mirror=options.apt_mirror)
77
66
 
78
 
    ivle.jailbuilder.debian.apt_update_cache(build_path)
79
 
    ivle.jailbuilder.debian.apt_install(build_path,
80
 
                        ['python2.5', 'python-cjson', 'python-svn'])
81
 
 
82
 
    ivle.jailbuilder.debian.apt_clean(build_path)
83
 
 
84
 
if options.upgrade:
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')])
91
 
 
92
67
    # Add any extra site apt sources.
93
68
    if conf['jail']['extra_sources']:
94
69
        ivle.jailbuilder.debian.mangle_sources_list(build_path,
100
75
                                            conf['jail']['extra_keys'])
101
76
 
102
77
    ivle.jailbuilder.debian.apt_update_cache(build_path)
103
 
    ivle.jailbuilder.debian.apt_upgrade(build_path)
 
78
    ivle.jailbuilder.debian.apt_install(build_path,
 
79
                        ['python2.5', 'python-cjson', 'python-svn'])
104
80
 
105
81
    # Install any extra site packages.
106
82
    if conf['jail']['extra_packages']:
109
85
 
110
86
    ivle.jailbuilder.debian.apt_clean(build_path)
111
87
 
 
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
 
112
94
if conf['jail']['devmode']:
113
95
    # Copy all console and operating system files into the jail
114
96
    services_path = os.path.join(ivle.conf.share_path, 'services')
119
101
 
120
102
    # Also copy the IVLE lib directory into the jail
121
103
    # This is necessary for running certain services
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")
 
104
    ivle_site_packages = os.path.join(ivle.conf.python_site_packages, 'ivle')
 
105
    jail_site_packages = os.path.join(build_path, ivle_site_packages[1:])
136
106
    if os.path.exists(jail_site_packages):
137
107
        shutil.rmtree(jail_site_packages)
138
108
    shutil.copytree(ivle_site_packages, jail_site_packages)
139
109
 
 
110
    # IMPORTANT: ivle/conf/conf.py contains details which could compromise security
 
111
    # if left in the jail (such as the DB password). We delete it now! It would be
 
112
    # shadowed by the per-user conf.py anyway, but it's best to be safe.
 
113
    os.unlink(os.path.join(jail_site_packages, 'conf/conf.py'))
 
114
    # XXX: Shouldn't copy the compiled files at all, but compile them in the jail!
 
115
    os.unlink(os.path.join(jail_site_packages, 'conf/conf.pyc'))
 
116
 
140
117
if os.spawnvp(os.P_WAIT, 'rsync', ['rsync', '-a', '--delete',
141
118
              build_path + '/', ivle.conf.jail_system]) != 0:
142
119
    print >> sys.stderr, "Jail copying failed."