summaryrefslogtreecommitdiff
path: root/portato/backend
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-06-25 21:50:36 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-06-25 21:50:36 +0200
commitb11914a429a63f5d33bdb6fc0d543be3fff031d3 (patch)
treef070e879d47db5f00cce4bf55f5da5cb2e7f2ab4 /portato/backend
parent01f01abb51af0639bd0e1fccd4ad5fccd5ca074c (diff)
parent9f820103c30e89376a0484c614d2bbc068998e48 (diff)
downloadportato-b11914a429a63f5d33bdb6fc0d543be3fff031d3.tar.gz
portato-b11914a429a63f5d33bdb6fc0d543be3fff031d3.tar.bz2
portato-b11914a429a63f5d33bdb6fc0d543be3fff031d3.zip
First merge from portage-2.2 branch as it includes fixes for trunk too
Diffstat (limited to '')
-rw-r--r--portato/backend/portage/__init__.py12
-rw-r--r--portato/backend/portage/package.py7
-rw-r--r--portato/backend/portage/package_22.py22
-rw-r--r--portato/backend/portage/settings_22.py27
-rw-r--r--portato/backend/portage/system.py13
-rw-r--r--portato/backend/portage/system_22.py34
6 files changed, 105 insertions, 10 deletions
diff --git a/portato/backend/portage/__init__.py b/portato/backend/portage/__init__.py
index 6ccbf7f..be6cce6 100644
--- a/portato/backend/portage/__init__.py
+++ b/portato/backend/portage/__init__.py
@@ -12,5 +12,13 @@
from __future__ import absolute_import
-from .system import PortageSystem
-from .package import PortagePackage
+from portage import VERSION as PV
+
+VERSION = tuple(map(int, (x.split("_")[0] for x in PV.split("."))))
+
+if VERSION >= (2, 2):
+ from .system_22 import PortageSystem_22 as PortageSystem
+ from .package_22 import PortagePackage_22 as PortagePackage
+else:
+ from .system import PortageSystem
+ from .package import PortagePackage
diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py
index db9866a..78125ee 100644
--- a/portato/backend/portage/package.py
+++ b/portato/backend/portage/package.py
@@ -18,7 +18,12 @@ from .. import system
from ..exceptions import BlockedException, PackageNotFoundException, DependencyCalcError
from ...helper import debug, error, unique_array
-import portage, portage_dep
+import portage
+
+try:
+ import portage.dep as portage_dep
+except ImportError:
+ import portage_dep
import os.path
diff --git a/portato/backend/portage/package_22.py b/portato/backend/portage/package_22.py
new file mode 100644
index 0000000..4fe03d9
--- /dev/null
+++ b/portato/backend/portage/package_22.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/backend/portage/package_22.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2008 René 'Necoro' Neumann
+# This is free software. You may redistribute copies of it under the terms of
+# the GNU General Public License version 2.
+# There is NO WARRANTY, to the extent permitted by law.
+#
+# Written by René 'Necoro' Neumann <necoro@necoro.net>
+
+from __future__ import absolute_import, with_statement
+
+from .package import PortagePackage
+
+class PortagePackage_22 (PortagePackage):
+ """
+ The 2.2 specialization of the portage package.
+ Currently this is identical to the normal one.
+ """
+ pass
diff --git a/portato/backend/portage/settings_22.py b/portato/backend/portage/settings_22.py
new file mode 100644
index 0000000..a43d69e
--- /dev/null
+++ b/portato/backend/portage/settings_22.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/backend/portage/settings_22.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2008 René 'Necoro' Neumann
+# This is free software. You may redistribute copies of it under the terms of
+# the GNU General Public License version 2.
+# There is NO WARRANTY, to the extent permitted by law.
+#
+# Written by René 'Necoro' Neumann <necoro@necoro.net>
+
+from __future__ import absolute_import
+
+import portage.sets
+from .settings import PortageSettings
+
+class PortageSettings_22 (PortageSettings):
+ """Enhances the normal PortageSettings in ways, that it adds the setsconfig."""
+
+ def __init__ (self):
+ PortageSettings.__init__(self)
+
+ def load (self):
+ PortageSettings.load(self)
+
+ self.setsconfig = portage.sets.load_default_config(self.settings, self.trees[self.settings["ROOT"]])
diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py
index 0d81945..feaf4df 100644
--- a/portato/backend/portage/system.py
+++ b/portato/backend/portage/system.py
@@ -16,6 +16,7 @@ import re, os, os.path
import portage
from collections import defaultdict
+from . import VERSION
from .package import PortagePackage
from .settings import PortageSettings
from ..system_interface import SystemInterface
@@ -36,8 +37,6 @@ class PortageSystem (SystemInterface):
self.use_descs = {}
self.local_use_descs = defaultdict(dict)
- self._version = tuple([x.split("_")[0] for x in portage.VERSION.split(".")])
-
def get_version (self):
return "Portage %s" % portage.VERSION
@@ -142,7 +141,7 @@ class PortageSystem (SystemInterface):
"""
if not only_cpv:
- return [PortagePackage(x) for x in list_of_packages]
+ return [self.new_package(x) for x in list_of_packages]
else:
return list_of_packages
@@ -154,7 +153,7 @@ class PortageSystem (SystemInterface):
if only_cpv:
return portage.best(list)
else:
- return PortagePackage(portage.best(list))
+ return self.new_package(portage.best(list))
def find_best_match (self, search_key, masked = False, only_installed = False, only_cpv = False):
t = []
@@ -166,7 +165,7 @@ class PortageSystem (SystemInterface):
t = self.find_packages(search_key, pkgSet = pkgSet, masked = masked, with_version = True, only_cpv = True)
- if self._version >= (2,1,5):
+ if VERSION >= (2,1,5):
t += [pkg.get_cpv() for pkg in self.find_packages(search_key, "installed") if not (pkg.is_testing(True) or pkg.is_masked())]
else:
t = self.find_packages(search_key, "installed", only_cpv=True)
@@ -287,7 +286,7 @@ class PortageSystem (SystemInterface):
unresolved = []
for x in list:
cpv = x.strip()
- if len(cpv) and check(cpv):
+ if cpv and check(cpv):
pkg = self.find_best_match(cpv, only_cpv = only_cpv)
if pkg:
resolved.append(pkg)
@@ -304,7 +303,7 @@ class PortageSystem (SystemInterface):
return portage.catpkgsplit(cpv)
def sort_package_list(self, pkglist):
- pkglist.sort(PortagePackage.compare_version)
+ pkglist.sort(PortagePackage.compare_version) # XXX: waaah ... direct package naming... =/
return pkglist
def reload_settings (self):
diff --git a/portato/backend/portage/system_22.py b/portato/backend/portage/system_22.py
new file mode 100644
index 0000000..be27186
--- /dev/null
+++ b/portato/backend/portage/system_22.py
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/backend/portage/system_22.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2008 René 'Necoro' Neumann
+# This is free software. You may redistribute copies of it under the terms of
+# the GNU General Public License version 2.
+# There is NO WARRANTY, to the extent permitted by law.
+#
+# Written by René 'Necoro' Neumann <necoro@necoro.net>
+
+from __future__ import absolute_import, with_statement
+
+import os
+import portage
+
+from collections import defaultdict
+
+from .package_22 import PortagePackage_22
+from .settings_22 import PortageSettings_22
+from .system import PortageSystem
+
+class PortageSystem_22 (PortageSystem):
+
+ def __init__ (self):
+ self.settings = PortageSettings_22()
+ portage.WORLD_FILE = os.path.join(self.settings.settings["ROOT"],portage.WORLD_FILE)
+
+ self.use_descs = {}
+ self.local_use_descs = defaultdict(dict)
+
+ def new_package (self, cpv):
+ return PortagePackage_22(cpv)