others_in_slot.append(dblink(self.cat, catsplit(cur_cpv)[1],
self.vartree.root, self.settings,
vartree=self.vartree))
- claimed_paths = set()
- for dblnk in others_in_slot:
- claimed_paths.update(dblnk.getcontents())
+ dest_root = normalize_path(self.vartree.root).rstrip(os.path.sep) + \
+ os.path.sep
+ dest_root_len = len(dest_root)
unmerge_orphans = "unmerge-orphans" in self.settings.features
obj = normalize_path(objkey)
file_data = pkgfiles[objkey]
file_type = file_data[0]
- if obj in claimed_paths:
- # A new instance of this package claims the file, so don't
- # unmerge it.
- writemsg_stdout("--- !owned %s %s\n" % \
- (pkgfiles[objkey][0], obj))
- continue
statobj = None
try:
statobj = os.stat(obj)
if lstatobj is None:
writemsg_stdout("--- !found %s %s\n" % (file_type, obj))
continue
+ if obj.startswith(dest_root):
+ relative_path = obj[dest_root_len:]
+ is_owned = False
+ for dblnk in others_in_slot:
+ if dblnk.isowner(relative_path, dest_root):
+ is_owned = True
+ break
+ if is_owned:
+ # A new instance of this package claims the file, so
+ # don't unmerge it.
+ writemsg_stdout("--- !owned %s %s\n" % \
+ (file_type, obj))
+ continue
# next line includes a tweak to protect modules from being unmerged,
# but we don't protect modules from being overwritten if they are
# upgraded. We effectively only want one half of the config protection
try:
# Remove permissions to ensure that any hardlinks to
# suid/sgid files are rendered harmless.
- os.chmod(obj, 0)
+ if not islink:
+ os.chmod(obj, 0)
os.unlink(obj)
except (OSError, IOError), e:
pass
"""
destfile = normalize_path(
os.path.join(destroot, filename.lstrip(os.path.sep)))
- try:
- mylstat = os.lstat(destfile)
- except (OSError, IOError):
- return True
pkgfiles = self.getcontents()
if pkgfiles and destfile in pkgfiles:
return True
if pkgfiles:
+ try:
+ mylstat = os.lstat(destfile)
+ except EnvironmentError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e
+ return True
if self._contents_inodes is None:
self._contents_inodes = set()
for x in pkgfiles:
self.vdb = vardb
self.portdb = portdb
+ portdir = portdb.porttree_root
+ profiles_base = os.path.join(portdir, "profiles") + os.path.sep
+ from portage.util import normalize_path
+ profile_path = normalize_path(
+ os.path.realpath(portdb.mysettings.profile_path))
+ if profile_path.startswith(profiles_base):
+ profile_path = profile_path[len(profiles_base):]
+ self._profile_path = profile_path
+
# Ensure that the unread path exists and is writable.
dirmode = 02070
modemask = 02
item = NewsItem(filename, itemid, timestamp)
except (TypeError, ValueError), e:
continue
- if item.isRelevant(profile=os.readlink(PROFILE_PATH), config=config, vardb=self.vdb):
+ if item.isRelevant(profile=self._profile_path,
+ config=self.config, vardb=self.vdb):
updates.append(item)
del path