Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/
Date: Wed, 27 Jul 2011 01:51:52
Message-Id: a4a4d87786e6c0c34370870af2071904d6184a9d.zmedico@gentoo
1 commit: a4a4d87786e6c0c34370870af2071904d6184a9d
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 27 01:51:25 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 27 01:51:25 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a4a4d877
7
8 merge: abort if symlink replacing dir
9
10 This is required for compliance with PMS section 13.4 as discussed in
11 bug #326685.
12
13 ---
14 pym/portage/dbapi/vartree.py | 38 ++++++++++++++++++++++++++++++--------
15 1 files changed, 30 insertions(+), 8 deletions(-)
16
17 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
18 index c703415..47f5eb2 100644
19 --- a/pym/portage/dbapi/vartree.py
20 +++ b/pym/portage/dbapi/vartree.py
21 @@ -62,6 +62,7 @@ from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
22 import errno
23 import gc
24 import io
25 +from itertools import chain
26 import logging
27 import os as _os
28 import re
29 @@ -2699,7 +2700,8 @@ class dblink(object):
30
31 self.vartree.dbapi._plib_registry.pruneNonExisting()
32
33 - def _collision_protect(self, srcroot, destroot, mypkglist, mycontents):
34 + def _collision_protect(self, srcroot, destroot, mypkglist,
35 + file_list, symlink_list):
36
37 os = _os_merge
38
39 @@ -2729,10 +2731,13 @@ class dblink(object):
40 showMessage = self._display_merge
41 stopmerge = False
42 collisions = []
43 + symlink_collisions = []
44 destroot = self.settings['ROOT']
45 showMessage(_(" %s checking %d files for package collisions\n") % \
46 - (colorize("GOOD", "*"), len(mycontents)))
47 - for i, f in enumerate(mycontents):
48 + (colorize("GOOD", "*"), len(file_list) + len(symlink_list)))
49 + for i, (f, f_type) in enumerate(chain(
50 + ((f, "reg") for f in file_list),
51 + ((f, "sym") for f in symlink_list))):
52 if i % 1000 == 0 and i != 0:
53 showMessage(_("%d files checked ...\n") % i)
54
55 @@ -2772,6 +2777,14 @@ class dblink(object):
56 if f[0] != "/":
57 f="/"+f
58
59 + if stat.S_ISDIR(dest_lstat.st_mode):
60 + if f_type == "sym":
61 + # This case is explicitly banned
62 + # by PMS (see bug #326685).
63 + symlink_collisions.append(f)
64 + collisions.append(f)
65 + continue
66 +
67 plibs = plib_inodes.get((dest_lstat.st_dev, dest_lstat.st_ino))
68 if plibs:
69 for path in plibs:
70 @@ -2806,7 +2819,7 @@ class dblink(object):
71 break
72 if stopmerge:
73 collisions.append(f)
74 - return collisions, plib_collisions
75 + return collisions, symlink_collisions, plib_collisions
76
77 def _lstat_inode_map(self, path_iter):
78 """
79 @@ -3233,9 +3246,9 @@ class dblink(object):
80 blockers = self._blockers
81 if blockers is None:
82 blockers = []
83 - collisions, plib_collisions = \
84 + collisions, symlink_collisions, plib_collisions = \
85 self._collision_protect(srcroot, destroot,
86 - others_in_slot + blockers, myfilelist + mylinklist)
87 + others_in_slot + blockers, myfilelist, mylinklist)
88
89 # Make sure the ebuild environment is initialized and that ${T}/elog
90 # exists for logging of collision-protect eerror messages.
91 @@ -3294,7 +3307,7 @@ class dblink(object):
92 eerror(msg)
93
94 owners = None
95 - if collision_protect or protect_owned:
96 + if collision_protect or protect_owned or symlink_collisions:
97 msg = []
98 msg.append("")
99 msg.append(_("Searching all installed"
100 @@ -3333,12 +3346,21 @@ class dblink(object):
101 # it may not be visible via a scrollback buffer, especially
102 # if the number of file collisions is large. Therefore,
103 # show a summary at the end.
104 + abort = False
105 if collision_protect:
106 + abort = True
107 msg = _("Package '%s' NOT merged due to file collisions.") % \
108 self.settings.mycpv
109 elif protect_owned and owners:
110 + abort = True
111 msg = _("Package '%s' NOT merged due to file collisions.") % \
112 self.settings.mycpv
113 + elif symlink_collisions:
114 + abort = True
115 + msg = _("Package '%s' NOT merged due to collision " + \
116 + "between a symlink and a directory which is explicitly " + \
117 + "forbidden by PMS (see bug #326685).") % \
118 + (self.settings.mycpv,)
119 else:
120 msg = _("Package '%s' merged despite file collisions.") % \
121 self.settings.mycpv
122 @@ -3346,7 +3368,7 @@ class dblink(object):
123 "messages for the whole content of the above message.")
124 eerror(wrap(msg, 70))
125
126 - if collision_protect or (protect_owned and owners):
127 + if abort:
128 return 1
129
130 # The merge process may move files out of the image directory,