diff options
author | Vlastimil Babka <caster@gentoo.org> | 2006-09-08 06:14:50 +0000 |
---|---|---|
committer | Vlastimil Babka <caster@gentoo.org> | 2006-09-08 06:14:50 +0000 |
commit | e5cfab002b0def9613cf6a87e48e4bd5461dccb7 (patch) | |
tree | 81ab7b3e877c700a0619489de23470c4174abe7b | |
parent | Remove the dep class/library path stuff from gjl, make it use java-config fun... (diff) | |
download | java-config-e5cfab002b0def9613cf6a87e48e4bd5461dccb7.tar.gz java-config-e5cfab002b0def9613cf6a87e48e4bd5461dccb7.tar.bz2 java-config-e5cfab002b0def9613cf6a87e48e4bd5461dccb7.zip |
Give nice error message instead of traceback if trying to set system/user vm symlink over
existing non-symlink file/directory. Fixes bug #140926
svn path=/projects/java-config-2/trunk/; revision=2711
-rw-r--r-- | src/eselect/java-vm.eselect | 2 | ||||
-rwxr-xr-x | src/java-config-2 | 4 | ||||
-rw-r--r-- | src/java_config/EnvironmentManager.py | 7 |
3 files changed, 10 insertions, 3 deletions
diff --git a/src/eselect/java-vm.eselect b/src/eselect/java-vm.eselect index 642034d..e33d0fc 100644 --- a/src/eselect/java-vm.eselect +++ b/src/eselect/java-vm.eselect @@ -116,7 +116,7 @@ my_set() { set_symlink "${target}" "${symlink}" || die -q "Couldn't set a new symlink" elif [[ -e "${symlink}" ]] ; then - die -q "Sorry, ${symlink}" + die -q "Target file already exists and is not a symlink: ${symlink}" else set_symlink "${target}" "${symlink}" || die -q "Couldn't set a new symlink" diff --git a/src/java-config-2 b/src/java-config-2 index 175e3d4..c8a9ff1 100755 --- a/src/java-config-2 +++ b/src/java-config-2 @@ -150,6 +150,8 @@ def set_system_vm(option, opt, value, parser): fatalError("You do not have enough permissions to set the system VM!") except EnvironmentUndefinedError: fatalError("The selected VM is missing critical environment variables.") + except InvalidConfigError, e: + fatalError("Target file already exists and is not a symlink: %s" % e.file) else: fatalError("You do not have enough permissions to set the system VM!") @@ -166,6 +168,8 @@ def set_user_vm(option, opt, value, parser): manager.set_user_vm(vm) except PermissionError: fatalError("You do not have enough permissions to set the VM!") + except InvalidConfigError, e: + fatalError("Target file already exists and is not a symlink: %s" % e.file) # Deprecated def system_classpath_target(): diff --git a/src/java_config/EnvironmentManager.py b/src/java_config/EnvironmentManager.py index 5d8107a..dd18c14 100644 --- a/src/java_config/EnvironmentManager.py +++ b/src/java_config/EnvironmentManager.py @@ -214,8 +214,11 @@ class EnvironmentManager: if not os.path.isdir(sym_dir): os.makedirs(sym_dir) - if os.path.islink(target): - os.remove(target) + if os.path.lexists(target): + if os.path.islink(target): + os.remove(target) + else: + raise InvalidConfigError(target) os.symlink('/usr/lib/jvm/'+vm.name(),target) |