from portage.versions import best, catpkgsplit, catsplit
from portage.update import update_dbentries
-from portage import listdir, dep_expand
+from portage import dep_expand, listdir, _movefile
import portage.xpak, portage.getbinpkg
if e.errno != errno.EEXIST:
raise
del e
- os.rename(tbz2path, new_path)
+ _movefile(tbz2path, new_path, mysettings=self.settings)
self._remove_symlink(mycpv)
if new_path.split(os.path.sep)[-2] == "All":
self._create_symlink(mynewcpv)
if e.errno != errno.EEXIST:
raise
del e
- os.rename(src_path, os.path.join(self.pkgdir, "All", myfile))
+ dest_path = os.path.join(self.pkgdir, "All", myfile)
+ _movefile(src_path, dest_path, mysettings=self.settings)
self._create_symlink(cpv)
self._pkg_paths[cpv] = os.path.join("All", myfile)
if e.errno != errno.EEXIST:
raise
del e
- os.rename(os.path.join(self.pkgdir, "All", myfile), dest_path)
+ src_path = os.path.join(self.pkgdir, "All", myfile)
+ _movefile(src_path, dest_path, mysettings=self.settings)
self._pkg_paths[cpv] = mypath
def populate(self, getbinpkgs=0, getbinpkgsonly=0):
pkgindex_lock = lockfile(self._pkgindex_file,
wantnewlockfile=1)
if filename is not None:
- os.rename(filename, self.getname(cpv))
+ _movefile(filename, self.getname(cpv), mysettings=self.settings)
if self._all_directory and \
self.getname(cpv).split(os.path.sep)[-2] == "All":
self._create_symlink(cpv)
isjustname, dep_getkey, match_from_list
from portage.elog import elog_process
from portage.exception import InvalidPackageName, InvalidAtom, \
- UnsupportedAPIException, FileNotFound
+ FileNotFound, PermissionDenied, UnsupportedAPIException
from portage.locks import lockdir, unlockdir
from portage.output import bold, red, green
from portage.update import fixdbentries
from portage import listdir, dep_expand, config, flatten, key_expand, \
doebuild_environment, doebuild, env_update, \
- abssymlink, movefile, bsd_chflags
+ abssymlink, movefile, _movefile, bsd_chflags
import os, sys, stat, errno, commands, copy, time
from itertools import izip
except IOError, e:
if e.errno == errno.ENOENT:
self._data = {}
+ elif e.errno == PermissionDenied.errno:
+ raise PermissionDenied(self._filename)
else:
raise e
CACHE_PATH.lstrip(os.path.sep), "vdb_metadata.pickle")
self.libmap = LibraryPackageMap(os.path.join(self.root, CACHE_PATH.lstrip(os.sep), "library_consumers"), self)
- self.plib_registry = PreservedLibsRegistry(os.path.join(self.root, PRIVATE_PATH, "preserved_libs_registry"))
+ try:
+ self.plib_registry = PreservedLibsRegistry(
+ os.path.join(self.root, PRIVATE_PATH, "preserved_libs_registry"))
+ except PermissionDenied:
+ # apparently this user isn't allowed to access PRIVATE_PATH
+ self.plib_registry = None
def getpath(self, mykey, filename=None):
rValue = os.path.join(self.root, VDB_PATH, mykey)
if os.path.exists(newpath):
#dest already exists; keep this puppy where it is.
continue
- os.rename(origpath, newpath)
+ _movefile(origpath, newpath, mysettings=self.settings)
# We need to rename the ebuild now.
old_pf = catsplit(mycpv)[1]
#process symlinks second-to-last, directories last.
mydirs = []
modprotect = os.path.join(self.vartree.root, "lib/modules/")
+ def show_unmerge(zing, desc, file_type, file_name):
+ writemsg_stdout("%s %s %s %s\n" % \
+ (zing, desc.ljust(8), file_type, file_name))
for objkey in mykeys:
obj = normalize_path(objkey)
file_data = pkgfiles[objkey]
pass
islink = lstatobj is not None and stat.S_ISLNK(lstatobj.st_mode)
if lstatobj is None:
- writemsg_stdout("--- !found %s %s\n" % (file_type, obj))
+ show_unmerge("---", "!found", file_type, obj)
continue
if obj.startswith(dest_root):
relative_path = obj[dest_root_len:]
if is_owned:
# A new instance of this package claims the file, so
# don't unmerge it.
- writemsg_stdout("--- replaced %s %s\n" % \
- (file_type, obj))
+ show_unmerge("---", "replaced", 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
# functionality for /lib/modules. For portage-ng both capabilities
# should be able to be independently specified.
if obj.startswith(modprotect):
- writemsg_stdout("--- cfgpro %s %s\n" % (pkgfiles[objkey][0], obj))
+ show_unmerge("---", "cfgpro", file_type, obj)
continue
# Don't unlink symlinks to directories here since that can
os.unlink(obj)
except EnvironmentError, e:
pass
- writemsg_stdout("<<< %s %s\n" % (file_type, obj))
+ show_unmerge("<<<", "", file_type, obj)
continue
lmtime = str(lstatobj[stat.ST_MTIME])
if (pkgfiles[objkey][0] not in ("dir", "fif", "dev")) and (lmtime != pkgfiles[objkey][1]):
- writemsg_stdout("--- !mtime %s %s\n" % (pkgfiles[objkey][0], obj))
+ show_unmerge("---", "!mtime", file_type, obj)
continue
if pkgfiles[objkey][0] == "dir":
if statobj is None or not stat.S_ISDIR(statobj.st_mode):
- writemsg_stdout("--- !dir %s %s\n" % ("dir", obj))
+ show_unmerge("---", "!dir", file_type, obj)
continue
mydirs.append(obj)
elif pkgfiles[objkey][0] == "sym":
if not islink:
- writemsg_stdout("--- !sym %s %s\n" % ("sym", obj))
+ show_unmerge("---", "!sym", file_type, obj)
continue
# Go ahead and unlink symlinks to directories here when
# they're actually recorded as symlinks in the contents.
# to a symlink when it's merged to the live filesystem.
try:
os.unlink(obj)
- writemsg_stdout("<<< %s %s\n" % ("sym", obj))
+ show_unmerge("<<<", "", file_type, obj)
except (OSError, IOError),e:
- writemsg_stdout("!!! %s %s\n" % ("sym", obj))
+ show_unmerge("!!!", "", file_type, obj)
elif pkgfiles[objkey][0] == "obj":
if statobj is None or not stat.S_ISREG(statobj.st_mode):
- writemsg_stdout("--- !obj %s %s\n" % ("obj", obj))
+ show_unmerge("---", "!obj", file_type, obj)
continue
mymd5 = None
try:
mymd5 = perform_md5(obj, calc_prelink=1)
except FileNotFound, e:
# the file has disappeared between now and our stat call
- writemsg_stdout("--- !obj %s %s\n" % ("obj", obj))
+ show_unmerge("---", "!obj", file_type, obj)
continue
# string.lower is needed because db entries used to be in upper-case. The
# string.lower allows for backwards compatibility.
if mymd5 != pkgfiles[objkey][2].lower():
- writemsg_stdout("--- !md5 %s %s\n" % ("obj", obj))
+ show_unmerge("---", "!md5", file_type, obj)
continue
try:
# Remove permissions to ensure that any hardlinks to
os.unlink(obj)
except (OSError, IOError), e:
pass
- writemsg_stdout("<<< %s %s\n" % ("obj", obj))
+ show_unmerge("<<<", "fif", file_type, obj)
elif pkgfiles[objkey][0] == "fif":
if not stat.S_ISFIFO(lstatobj[stat.ST_MODE]):
- writemsg_stdout("--- !fif %s %s\n" % ("fif", obj))
+ show_unmerge("---", "!fif", file_type, obj)
continue
- writemsg_stdout("--- %s %s\n" % ("fif", obj))
+ show_unmerge("---", "fif", file_type, obj)
elif pkgfiles[objkey][0] == "dev":
- writemsg_stdout("--- %s %s\n" % ("dev", obj))
+ show_unmerge("---", "dev", file_type, obj)
mydirs.sort()
mydirs.reverse()
for obj in mydirs:
try:
os.rmdir(obj)
- writemsg_stdout("<<< %s %s\n" % ("dir", obj))
- except (OSError, IOError):
- writemsg_stdout("--- !empty dir %s\n" % obj)
+ show_unmerge("<<<", "dir", file_type, obj)
+ except EnvironmentError:
+ show_unmerge("---", "!empty", file_type, obj)
#remove self from vartree database so that our own virtual gets zapped if we're the last node
self.vartree.zap(self.mycpv)
self._collision_protect(srcroot, destroot, others_in_slot,
myfilelist+mylinklist, mylinklist)
- if os.stat(srcroot).st_dev == os.stat(destroot).st_dev:
+ if True:
""" The merge process may move files out of the image directory,
which causes invalidation of the .installed flag."""
try:
# We hold both directory locks.
self.dbdir = self.dbpkgdir
self.delete()
- movefile(self.dbtmpdir, self.dbpkgdir, mysettings=self.settings)
+ _movefile(self.dbtmpdir, self.dbpkgdir, mysettings=self.settings)
contents = self.getcontents()
#write out our collection of md5sums