self.not_installed = []
self.invalid_category = []
self.okay = []
+ from portage.sets import make_default_config
+ setconfig = make_default_config(portage.settings,
+ portage.db[portage.settings["ROOT"]])
+ self._sets = setconfig.getSetsWithAliases()
def _check_world(self, onProgress):
categories = set(portage.settings.categories)
self.found = os.access(self.world_file, os.R_OK)
vardb = portage.db[myroot]["vartree"].dbapi
- from portage.sets import make_default_config, SETPREFIX
- setconfig = make_default_config(portage.settings, portage.db[myroot])
- sets = setconfig.getSetsWithAliases()
- world_atoms = open(self.world_file).read().split()
+ from portage.sets import SETPREFIX
+ sets = self._sets
+ world_atoms = list(sets["world"])
maxval = len(world_atoms)
if onProgress:
onProgress(maxval, 0)
return errors
def fix(self, onProgress=None):
- self._check_world(onProgress)
- errors = []
+ world_set = self._sets["world"]
+ world_set.lock()
try:
- portage.write_atomic(self.world_file,
- "\n".join(sorted(self.okay)) + "\n")
- except portage.exception.PortageException:
- errors.append(self.world_file + " could not be opened for writing")
- return errors
+ world_set.load() # maybe it's changed on disk
+ before = set(world_set)
+ self._check_world(onProgress)
+ after = set(self.okay)
+ errors = []
+ if before != after:
+ try:
+ world_set.replace(self.okay)
+ except portage.exception.PortageException:
+ errors.append("%s could not be opened for writing" % \
+ self.world_file)
+ return errors
+ finally:
+ world_set.unlock()
class BinhostHandler(object):