Commits

Anonymous committed 8d5c8b1

Use an environment-based cache to simplify set re-evaluation.

Thanks to that, portage updates are no longer going to result in
updating all of the packages once again.

Comments (0)

Files changed (1)

SmartLiveRebuild/sets.py

 # (c) 2010 Michał Górny <gentoo@mgorny.alt.pl>
 # Released under the terms of the 3-clause BSD license or the GPL-2 license.
 
+import os
+
 try:
 	from portage.sets.base import PackageSet
 	from portage.sets import SetConfigError
 		PackageSet.__init__(self)
 
 	def load(self):
+		# We're caching the resulting package in an environment
+		# variable, using the pid as a safety measure to avoid random
+		# data catching. This allows us to avoid updating all
+		# the packages once again after emerge reloads itself.
+
+		cachevar = 'PORTAGE_SLR_PACKAGE_LIST'
+		pid = str(os.getpid())
+
+		packages = os.environ.get(cachevar, '').split()
+		if not packages or packages.pop(0) != pid:
+			packages = None
+
 		try:
-			packages = SmartLiveRebuild(self._options,
-					db = self._dbapi, saveuid = True)
+			if packages is None:
+				packages = SmartLiveRebuild(self._options,
+						db = self._dbapi, saveuid = True)
 		except SLRFailure:
 			pass
 		else:
 			self._setAtoms('>=%s' % p for p in packages)
+			os.environ[cachevar] = ' '.join([pid] + packages)
 
 			if self._options.offline:
 				s = self._settings
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.