return 0
del e
+ noreplace = "--noreplace" in self.myopts
reinstall_for_flags = None
merging=1
if mytype == "installed":
""" If we aren't merging, perform the --newuse check.
If the package has new iuse flags or different use flags then if
--newuse is specified, we need to merge the package. """
- if merging == 0 and \
+ if not noreplace and merging == 0 and \
myroot == self.target_root and \
("--newuse" in self.myopts or
"--reinstall" in self.myopts) and \
except IOError, e:
if "errno" not in dir(e):
raise
- if e.errno == errno.EAGAIN:
+ if e.errno in (errno.EACCES, errno.EAGAIN):
# resource temp unavailable; eg, someone beat us to the lock.
if waiting_msg is None:
if isinstance(mypath, int):
if type(lockfilename) == types.StringType and \
- myfd != HARDLINK_FD and os.fstat(myfd).st_nlink == 0:
+ myfd != HARDLINK_FD and _fstat_nlink(myfd) == 0:
# The file was deleted on us... Keep trying to make one...
os.close(myfd)
portage_util.writemsg("lockfile recurse\n",1)
portage_util.writemsg(str((lockfilename,myfd,unlinkfile))+"\n",1)
return (lockfilename,myfd,unlinkfile,locking_method)
+def _fstat_nlink(fd):
+ """
+ @param fd: an open file descriptor
+ @type fd: Integer
+ @rtype: Integer
+ @return: the current number of hardlinks to the file
+ """
+ try:
+ return os.fstat(fd).st_nlink
+ except EnvironmentError, e:
+ if e.errno == errno.ENOENT:
+ # Some filesystems such as CIFS return
+ # ENOENT which means st_nlink == 0.
+ return 0
+ raise
+
def unlockfile(mytuple):
import fcntl
# We won the lock, so there isn't competition for it.
# We can safely delete the file.
portage_util.writemsg("Got the lockfile...\n",1)
- if os.fstat(myfd).st_nlink == 1:
+ if _fstat_nlink(myfd) == 1:
os.unlink(lockfilename)
portage_util.writemsg("Unlinked lockfile...\n",1)
locking_method(myfd,fcntl.LOCK_UN)