Commits

Michał Górny committed 1f20863

Introduce PackageManager.root attribute.

This attribute provides access to the install root path, as used by
current PM configuration (domain).

Comments (0)

Files changed (5)

gentoopm/basepm/__init__.py

 		pass
 
 	@abstractproperty
+	def root(self):
+		"""
+		The root path as specified by current PM configuration.
+
+		@type: str
+		"""
+		pass
+
+	@abstractproperty
 	def installed(self):
 		"""
 		Repository with installed packages (vardb).

gentoopm/paludispm/__init__.py

 		return PaludisRepoDict(self._env)
 
 	@property
+	def root(self):
+		return '/'
+
+	@property
 	def installed(self):
-		return PaludisInstalledRepo(self._env)
+		return PaludisInstalledRepo(self._env, self.root)
 
 	@property
 	def stack(self):

gentoopm/paludispm/repo.py

 class PaludisInstalledRepo(PaludisBaseRepo):
 	_pkg_class = PaludisInstalledID
 
+	def __init__(self, env, root):
+		PaludisBaseRepo.__init__(self, env)
+		self._root = root
+
 	@property
 	def _filt(self):
-		return paludis.Filter.InstalledAtRoot('/')
+		return paludis.Filter.InstalledAtRoot(self._root)

gentoopm/pkgcorepm/__init__.py

 				self._domain)
 
 	@property
+	def root(self):
+		return self._domain.root
+
+	@property
 	def installed(self):
 		return PkgCoreInstalledRepo(self._domain.named_repos['vdb'],
 				self._domain)

gentoopm/portagepm/__init__.py

 				config_root = os.environ.get('PORTAGE_CONFIGROOT'),
 				target_root = os.environ.get('ROOT'))
 		tree = trees[max(trees)]
+		self._root = max(trees)
 		self._vardb = tree['vartree'].dbapi
 		self._portdb = tree['porttree'].dbapi
 
 		return PortageRepoDict(self._portdb)
 
 	@property
+	def root(self):
+		return self._root
+
+	@property
 	def installed(self):
 		return VDBRepository(self._vardb)