Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 416341 | Differences between
and this patch

Collapse All | Expand All

(-)src/java-config-2 (-35 / +23 lines)
Lines 181-201 def set_system_vm(option, opt, value, pa Link Here
181
    if not vm:
181
    if not vm:
182
        fatalError("Could not find a vm matching: %s" % value)
182
        fatalError("Could not find a vm matching: %s" % value)
183
    else:
183
    else:
184
        if os.getuid() is 0:
184
        try:
185
            try:
185
            manager.set_system_vm(vm)
186
                manager.set_system_vm(vm)
186
            printer._print("Now using %s as your generation-2 system JVM" % (vm) )
187
                printer._print("Now using %s as your generation-2 system JVM" % (vm) )
187
            if vm.is_build_only():
188
                if vm.is_build_only():
188
                printer._printWarning("%s is marked as a build-only JVM. Using this vm is not recommended. " % (vm))
189
                    printer._printWarning("%s is marked as a build-only JVM. Using this vm is not recommended. " % (vm))
189
                printer._printWarning("Please see http://www.gentoo.org/doc/en/java.xml#build-only for more information.")
190
                    printer._printWarning("Please see http://www.gentoo.org/doc/en/java.xml#build-only for more information.")
190
        except PermissionError:
191
            except PermissionError:
192
                fatalError("You do not have enough permissions to set the system VM!")
193
            except EnvironmentUndefinedError:
194
                fatalError("The selected VM is missing critical environment variables.")
195
            except InvalidConfigError as e:
196
                fatalError("Target file already exists and is not a symlink: %s" % e.file)
197
        else:
198
            fatalError("You do not have enough permissions to set the system VM!")
191
            fatalError("You do not have enough permissions to set the system VM!")
192
        except EnvironmentUndefinedError:
193
            fatalError("The selected VM is missing critical environment variables.")
194
        except InvalidConfigError as e:
195
            fatalError("Target file already exists and is not a symlink: %s" % e.file)
199
196
200
def set_user_vm(option, opt, value, parser):
197
def set_user_vm(option, opt, value, parser):
201
    vm = manager.get_vm(value)
198
    vm = manager.get_vm(value)
Lines 231-246 def user_classpath_target(): Link Here
231
# Deprecated
228
# Deprecated
232
def set_system_classpath(option, opt, value, parser):
229
def set_system_classpath(option, opt, value, parser):
233
    deprecation_notice()
230
    deprecation_notice()
234
    if os.getuid() is 0:
231
    pkgs = value.split(',')
235
        pkgs = value.split(',')
232
    manager.set_classpath(system_classpath_target(), pkgs)
236
        manager.set_classpath(system_classpath_target(), pkgs)
237
        
233
        
238
        for package in pkgs:
234
    for package in pkgs:
239
            printer._printError("Package %s was not found!" % package)
235
        printer._printError("Package %s was not found!" % package)
240
            
236
            
241
        update_env()
237
    update_env()
242
    else:
243
       fatalError("You do not have enough permissions to set the system classpath!")
244
238
245
# Deprecated
239
# Deprecated
246
def set_user_classpath(option, opt, value, parser):
240
def set_user_classpath(option, opt, value, parser):
Lines 256-271 def set_user_classpath(option, opt, valu Link Here
256
# Deprecated
250
# Deprecated
257
def append_system_classpath(option, opt, value, parser):
251
def append_system_classpath(option, opt, value, parser):
258
    deprecation_notice()
252
    deprecation_notice()
259
    if os.getuid() is 0:
253
    pkgs = value.split(',')
260
        pkgs = value.split(',')
254
    manager.append_classpath(system_classpath_target(), pkgs)
261
        manager.append_classpath(system_classpath_target(), pkgs)
262
255
263
        for package in pkgs:
256
    for package in pkgs:
264
            printer._printError("Package %s was not found!" % package)
257
        printer._printError("Package %s was not found!" % package)
265
258
266
        update_env()
259
    update_env()
267
    else:
268
        fatalError("You do not have enough permissioins to append to the system classpath!")
269
260
270
# Deprecated
261
# Deprecated
271
def append_user_classpath(option, opt, value, parser):
262
def append_user_classpath(option, opt, value, parser):
Lines 281-291 def append_user_classpath(option, opt, v Link Here
281
# Deprecated
272
# Deprecated
282
def clean_system_classpath(option, opt, value, parser):
273
def clean_system_classpath(option, opt, value, parser):
283
    deprecation_notice()
274
    deprecation_notice()
284
    if os.getuid() is 0:
275
    manager.clean_classpath(system_classpath_target())
285
        manager.clean_classpath(system_classpath_target())
276
    update_env()
286
        update_env()
287
    else:
288
        fatalError("You do not have enough permissions to clean the system classpath!")
289
277
290
# Deprecated
278
# Deprecated
291
def clean_user_classpath(option, opt, value, parser):
279
def clean_user_classpath(option, opt, value, parser):
(-)src/java_config_2/EnvironmentManager.py (-17 / +33 lines)
Lines 13-19 from itertools import chain Link Here
13
13
14
from os.path import basename, dirname
14
from os.path import basename, dirname
15
from glob import glob
15
from glob import glob
16
import os, re, sys
16
import errno, os, re, sys
17
17
18
class EnvironmentManager(object):
18
class EnvironmentManager(object):
19
    """This is the central class, which manages all information from the 'environment'"""
19
    """This is the central class, which manages all information from the 'environment'"""
Lines 34-53 class EnvironmentManager(object): Link Here
34
        self.all_packages_loaded = False
34
        self.all_packages_loaded = False
35
        self.packages = {}
35
        self.packages = {}
36
        self.virtuals = {}
36
        self.virtuals = {}
37
        self.root = os.environ.get('ROOT', '/')
38
        if not self.root.endswith('/'):
39
            self.root += '/'
37
40
38
    def __call__(self):
41
    def __call__(self):
39
        return self
42
        return self
40
43
44
    def root_path(self, path):
45
        return os.path.join(self.root, path[1:])
46
41
    def load_vms(self):
47
    def load_vms(self):
42
        """Load all the vm files, and check for correctness"""
48
        """Load all the vm files, and check for correctness"""
43
        self.virtual_machines = {} 
49
        self.virtual_machines = {} 
44
50
45
        if os.path.isdir(self.vms_path):
51
        root_vms_path = self.root_path(self.vms_path)
52
        if os.path.isdir(root_vms_path):
46
            count = 1
53
            count = 1
47
            filelist = os.listdir(self.vms_path)
54
            filelist = os.listdir(root_vms_path)
48
            filelist.sort()
55
            filelist.sort()
49
            for file in filelist:
56
            for file in filelist:
50
                conf = os.path.join(self.vms_path,file)
57
                conf = os.path.join(root_vms_path, file)
51
                vm = None
58
                vm = None
52
59
53
                try:
60
                try:
Lines 237-252 class EnvironmentManager(object): Link Here
237
        self.set_vm(vm, self.system_vm_link())
244
        self.set_vm(vm, self.system_vm_link())
238
245
239
    def set_vm(self, vm, target):
246
    def set_vm(self, vm, target):
240
        sym_dir = dirname(target)
247
        root_target = self.root_path(target)
241
        if not os.path.isdir(sym_dir):
248
        sym_dir = dirname(root_target)
242
            os.makedirs(sym_dir)
249
        try:
243
250
            if not os.path.isdir(sym_dir):
244
        if os.path.islink(target):
251
                os.makedirs(sym_dir)
245
            os.remove(target)
246
        elif os.path.exists(target):
247
            raise InvalidConfigError(target)
248
252
249
        os.symlink('/usr/lib/jvm/'+vm.name(),target)
253
            if os.path.islink(root_target):
254
                os.remove(target)
255
            elif os.path.exists(root_target):
256
                raise InvalidConfigError(root_target)
257
258
            os.symlink('/usr/lib/jvm/' + vm.name(), root_target)
259
        except OSError as ex:
260
            if ex.errno == errno.EACCES:
261
                raise PermissionError
262
            else:
263
                raise ex
250
264
251
    def vm_links(self):
265
    def vm_links(self):
252
        # Don't try to use user-vm if HOME is undefined
266
        # Don't try to use user-vm if HOME is undefined
Lines 270-278 class EnvironmentManager(object): Link Here
270
284
271
    def clean_classpath(self, targets):
285
    def clean_classpath(self, targets):
272
        for target in targets:
286
        for target in targets:
273
            if os.path.isfile(target['file']):
287
            root_file = self.root_path(target['file'])
288
            if os.path.isfile(root_file):
274
                try:
289
                try:
275
                    os.remove(target['file'])
290
                    os.remove(root_file)
276
                except IOError:
291
                except IOError:
277
                    raise PermissionError
292
                    raise PermissionError
278
293
Lines 456-467 class EnvironmentManager(object): Link Here
456
471
457
    def write_classpath(self, targets, classpath):
472
    def write_classpath(self, targets, classpath):
458
        for target in targets:
473
        for target in targets:
459
            dir = dirname(target['file'])
474
            root_file = self.root_path(target['file'])
475
            dir = dirname(root_file)
460
            if not os.path.isdir(dir):
476
            if not os.path.isdir(dir):
461
                os.makedirs(dir)
477
                os.makedirs(dir)
462
478
463
            try:
479
            try:
464
                stream = open(target['file'], 'w')
480
                stream = open(root_file, 'w')
465
            except IOError:
481
            except IOError:
466
                raise PermissionError
482
                raise PermissionError
467
483

Return to bug 416341