aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Sennhauser <sera@gentoo.org>2011-09-10 05:35:40 +0000
committerRalph Sennhauser <sera@gentoo.org>2011-09-10 05:35:40 +0000
commit7ffab265b219f80af77c7e8c1c8261ccbbc83bf9 (patch)
treebcd66af293b811eeabd60874abf57b9a0119e3b0
parentDon't require uid 0 for setting system vm, write permission for the link shou... (diff)
downloadjava-config-7ffab265b219f80af77c7e8c1c8261ccbbc83bf9.tar.gz
java-config-7ffab265b219f80af77c7e8c1c8261ccbbc83bf9.tar.bz2
java-config-7ffab265b219f80af77c7e8c1c8261ccbbc83bf9.zip
VersionManager takes an EnvnironmentManager at instantiation
svn path=/projects/java-config-2/branches/generation3-support/; revision=8800
-rwxr-xr-xsrc/depend-java-query6
-rwxr-xr-xsrc/gjl10
-rw-r--r--src/java_config_2/VersionManager.py82
-rw-r--r--src/java_config_2/Virtual.py4
4 files changed, 45 insertions, 57 deletions
diff --git a/src/depend-java-query b/src/depend-java-query
index 3cab713..2da35de 100755
--- a/src/depend-java-query
+++ b/src/depend-java-query
@@ -1,7 +1,7 @@
#!/usr/bin/env python -E
# -*- coding: UTF-8 -*-
-# Copyright 2004-2005 Gentoo Foundation
+# Copyright 2004-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
@@ -69,11 +69,11 @@ if __name__ == '__main__':
global printer, manager, verman
printer = OutputFormatter(True, True)
manager = EnvironmentManager(root, eprefix)
- verman = VersionManager()
+ verman = VersionManager(manager)
usage = "depend-java-query [options]\n\n"
usage += "Java Dep Query Utility Version " + str(__version__) + "\n"
- usage += "Copyright 2004-2006 Gentoo Foundation\n"
+ usage += "Copyright 2004-2011 Gentoo Foundation\n"
usage += "Distributed under the terms of the GNU General Public License v2\n"
usage += "Please contact the Gentoo Java Herd <java@gentoo.org> with problems."
diff --git a/src/gjl b/src/gjl
index 1e70e48..ea636af 100755
--- a/src/gjl
+++ b/src/gjl
@@ -1,7 +1,7 @@
#!/usr/bin/env python -E
# -*- coding: UTF-8 -*-
-# Copyright 2004-2005 Gentoo Foundation
+# Copyright 2004-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
@@ -25,7 +25,7 @@ atom_parser = re.compile(r"([<>=]+)virtual/(jre|jdk)-([0-9\.*]+)")
def get_needed_target(pkg):
highest_target = ""
needs_jdk = False
- for pkg in get_needed_packages(pkg):
+ for pkg in verman.get_needed_packages(pkg):
pkg_needs_jdk = False
x = pkg.query("TARGET")
try:
@@ -45,7 +45,7 @@ def get_needed_target(pkg):
def get_needed_target2(pkg):
highest_target = ""
needs_jdk = set()
- for pkg in get_needed_packages(pkg):
+ for pkg in verman.get_needed_packages(pkg):
target = pkg.target()
if highest_target < target:
highest_target = target
@@ -76,7 +76,7 @@ def abort(msg):
def get_needed_vms(pkg):
virtuals = set()
vms = set()
- for pkg in get_needed_packages(pkg):
+ for pkg in verman.get_needed_packages(pkg):
try:
x = pkg.query("VM")
if atom_parser.match( x ):
@@ -254,7 +254,7 @@ if __name__ == '__main__':
global printer, manager, verman
printer = OutputFormatter(True, True)
manager = EnvironmentManager(root, eprefix)
- verman = VersionManager()
+ verman = VersionManager(manager)
if not options.package:
abort("Too dumb todo anything without -p")
diff --git a/src/java_config_2/VersionManager.py b/src/java_config_2/VersionManager.py
index 3e568e0..8751482 100644
--- a/src/java_config_2/VersionManager.py
+++ b/src/java_config_2/VersionManager.py
@@ -1,6 +1,6 @@
# -*- coding: UTF-8 -*-
-# Copyright 2005 Gentoo Foundation
+# Copyright 2005-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public license v2
# $Header: $
@@ -58,13 +58,10 @@ class VersionManager:
default_pref_file = '/usr/share/java-config-2/config/jdk-defaults.conf'
_prefs = None
- def __init__(self):
- pass
+ def __init__(self, env_manager):
+ self.env_manager = env_manager
def get_prefs(self):
- from java_config_2.EnvironmentManager import EnvironmentManager
- envman = EnvironmentManager()
-
if self._prefs:
return self._prefs
else:
@@ -73,7 +70,7 @@ class VersionManager:
if os.path.exists(self.user_pref_file):
self._prefs += PrefsFileParser(self.user_pref_file).get_config()
# then try system vm
- sys_vm = envman.system_vm_name()
+ sys_vm = self.env_manager.system_vm_name()
if sys_vm is not None:
self._prefs.append(['*', [sys_vm]])
# then try the build defaults
@@ -194,8 +191,6 @@ class VersionManager:
def get_target_from_pkg_deps(self, matches):
""" Get the lowest virtual machine version from a packages dependencies."""
- from java_config_2.EnvironmentManager import EnvironmentManager
- manager = EnvironmentManager()
highest = None
pkg_name = None
@@ -206,7 +201,7 @@ class VersionManager:
if match['slot'] and match['slot'] != '0':
pkg_name += '-' + match['slot']
try:
- pkg = manager.get_package(pkg_name)
+ pkg = self.manager.get_package(pkg_name)
pkgs.append(pkg)
except:
pass
@@ -228,8 +223,6 @@ class VersionManager:
return pkg_name, highest
def get_vm(self, atoms, allow_build_only = False):
- from java_config_2.EnvironmentManager import EnvironmentManager
-
pkg_name, highest_pkg_target = self.get_target_from_pkg_deps(self.parse_depend_packages(atoms))
matched_atoms = self.parse_depend(atoms)
@@ -250,7 +243,7 @@ class VersionManager:
for gvm in self.find_vm(vmProviderString, atom, highest_pkg_target, allow_build_only):
if need_virtual: # Package we are finding a vm for needs a virtual
# New, correct way of searching for virtuals
- if EnvironmentManager().have_provider(need_virtual, gvm, self): # We have a package available that provides it, will use that
+ if self.env_manager.have_provider(need_virtual, gvm, self): # We have a package available that provides it, will use that
return gvm
else:
return gvm # use it!
@@ -260,7 +253,7 @@ class VersionManager:
for atom in matched_atoms:
for gvm in self.find_vm("", atom, highest_pkg_target, allow_build_only):
if need_virtual: # Package we are finding a vm for needs a virtual
- if EnvironmentManager().have_provider(need_virtual, gvm, self):
+ if self.env_manager.have_provider(need_virtual, gvm, self):
return gvm
else:
return gvm
@@ -281,8 +274,7 @@ class VersionManager:
def find_vm(self, vmProviderString, atom, min_package_target, allow_build_only = True):
- from java_config_2.EnvironmentManager import EnvironmentManager
- vm_list = EnvironmentManager().find_vm(vmProviderString)
+ vm_list = self.env_manager.find_vm(vmProviderString)
vm_list.sort()
vm_list.reverse()
for vm in vm_list:
@@ -333,44 +325,40 @@ class VersionManager:
return 0
-def get_needed_packages(*packages):
- from java_config_2.EnvironmentManager import EnvironmentManager
-
- manager = EnvironmentManager()
-
- unresolved = set()
- for package in packages:
- unresolved.add(package)
-
- resolved = set()
-
- while len(unresolved) > 0:
- pkg = unresolved.pop()
- resolved.add(pkg)
- # dep is in the form of (jar, pkg)
- for dep in manager.get_pkg_deps(pkg):
- dep_pkg = dep[-1]
- p = manager.get_package(dep_pkg)
- if p is None:
- if ',' in dep_pkg:
- msg = """
+ def get_needed_packages(self, *packages):
+ unresolved = set()
+ for package in packages:
+ unresolved.add(package)
+
+ resolved = set()
+
+ while len(unresolved) > 0:
+ pkg = unresolved.pop()
+ resolved.add(pkg)
+ # dep is in the form of (jar, pkg)
+ for dep in self.env_manager.get_pkg_deps(pkg):
+ dep_pkg = dep[-1]
+ p = self.env_manager.get_package(dep_pkg)
+ if p is None:
+ if ',' in dep_pkg:
+ msg = """
Package %s has a broken DEPEND entry in package.env. Please reinstall it.
If this does not fix it, please report this to http://bugs.gentoo.org
"""
- msg = msg % pkg
- else:
- msg = """
+ msg = msg % pkg
+ else:
+ msg = """
Package %s not found in the system. This package is listed as a
dependency of %s. Please run emerge -1Da %s and if it does not bring in the
needed dependency, report this to http://bugs.gentoo.org.
"""
- msg = msg % (dep_pkg,pkg,pkg)
- abort(msg)
-
- if p not in resolved:
- unresolved.add(p)
-
- return resolved
+ msg = msg % (dep_pkg,pkg,pkg)
+ abort(msg)
+
+ if p not in resolved:
+ unresolved.add(p)
+
+ return resolved
#vator=VersionManager()
#for i in [
diff --git a/src/java_config_2/Virtual.py b/src/java_config_2/Virtual.py
index 365d103..db7f3e8 100644
--- a/src/java_config_2/Virtual.py
+++ b/src/java_config_2/Virtual.py
@@ -1,6 +1,6 @@
# -*- coding: UTF-8 -*-
-# Copyright 2004-2007 Gentoo Foundation
+# Copyright 2004-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
@@ -65,7 +65,7 @@ class Virtual(Package):
if not element in self._packages:
self._packages.append(element)
- verman = VersionManager()
+ verman = VersionManager(self._manager)
vmachines = self._manager.get_virtual_machines()
for vm in vmachines:
if verman.version_satisfies(" ".join(vms), vmachines[vm]):