1 |
The ro_checker code added in commit |
2 |
47ef9a0969474f963dc8e52bfbbb8bc075e8d73c incorrectly asserts that all |
3 |
parent directories be writable. Fix it to only assert that the nearest |
4 |
parent directory be writable. |
5 |
|
6 |
Fixes 47ef9a096947: ("Test for read-only filesystems, fixes bug 378869") |
7 |
X-Gentoo-Bug: 547390 |
8 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=547390 |
9 |
--- |
10 |
pym/portage/dbapi/vartree.py | 44 +++++++++++++++++++++++++------------------- |
11 |
1 file changed, 25 insertions(+), 19 deletions(-) |
12 |
|
13 |
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
14 |
index 1c0deab..c59d778 100644 |
15 |
--- a/pym/portage/dbapi/vartree.py |
16 |
+++ b/pym/portage/dbapi/vartree.py |
17 |
@@ -33,7 +33,7 @@ portage.proxy.lazyimport.lazyimport(globals(), |
18 |
'portage.util.env_update:env_update', |
19 |
'portage.util.listdir:dircache,listdir', |
20 |
'portage.util.movefile:movefile', |
21 |
- 'portage.util.path:first_existing', |
22 |
+ 'portage.util.path:first_existing,iter_parents', |
23 |
'portage.util.writeable_check:get_ro_checker', |
24 |
'portage.util._dyn_libs.PreservedLibsRegistry:PreservedLibsRegistry', |
25 |
'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap', |
26 |
@@ -3325,6 +3325,8 @@ class dblink(object): |
27 |
showMessage = self._display_merge |
28 |
stopmerge = False |
29 |
collisions = [] |
30 |
+ dirs = set() |
31 |
+ dirs_ro = set() |
32 |
symlink_collisions = [] |
33 |
destroot = self.settings['ROOT'] |
34 |
showMessage(_(" %s checking %d files for package collisions\n") % \ |
35 |
@@ -3337,6 +3339,18 @@ class dblink(object): |
36 |
|
37 |
dest_path = normalize_path( |
38 |
os.path.join(destroot, f.lstrip(os.path.sep))) |
39 |
+ |
40 |
+ parent = os.path.dirname(dest_path) |
41 |
+ if parent not in dirs: |
42 |
+ for x in iter_parents(parent): |
43 |
+ if x in dirs: |
44 |
+ break |
45 |
+ dirs.add(x) |
46 |
+ if os.path.isdir(x): |
47 |
+ if not os.access(x, os.W_OK): |
48 |
+ dirs_ro.add(x) |
49 |
+ break |
50 |
+ |
51 |
try: |
52 |
dest_lstat = os.lstat(dest_path) |
53 |
except EnvironmentError as e: |
54 |
@@ -3410,7 +3424,7 @@ class dblink(object): |
55 |
break |
56 |
if stopmerge: |
57 |
collisions.append(f) |
58 |
- return collisions, symlink_collisions, plib_collisions |
59 |
+ return collisions, dirs_ro, symlink_collisions, plib_collisions |
60 |
|
61 |
def _lstat_inode_map(self, path_iter): |
62 |
""" |
63 |
@@ -3759,7 +3773,6 @@ class dblink(object): |
64 |
eagain_error = False |
65 |
|
66 |
filelist = [] |
67 |
- dirlist = [] |
68 |
linklist = [] |
69 |
paths_with_newlines = [] |
70 |
def onerror(e): |
71 |
@@ -3792,13 +3805,6 @@ class dblink(object): |
72 |
unicode_errors.append(new_parent[ed_len:]) |
73 |
break |
74 |
|
75 |
- relative_path = parent[srcroot_len:] |
76 |
- if len(relative_path) >= eprefix_len: |
77 |
- # Files are never installed outside of the prefix, |
78 |
- # therefore we skip the readonly filesystem check for |
79 |
- # parent directories of the prefix (see bug 544624). |
80 |
- dirlist.append(os.path.join(destroot, relative_path)) |
81 |
- |
82 |
for fname in files: |
83 |
try: |
84 |
fname = _unicode_decode(fname, |
85 |
@@ -3911,9 +3917,17 @@ class dblink(object): |
86 |
for other in others_in_slot]) |
87 |
prepare_build_dirs(settings=self.settings, cleanup=cleanup) |
88 |
|
89 |
+ # check for package collisions |
90 |
+ blockers = self._blockers |
91 |
+ if blockers is None: |
92 |
+ blockers = [] |
93 |
+ collisions, dirs_ro, symlink_collisions, plib_collisions = \ |
94 |
+ self._collision_protect(srcroot, destroot, |
95 |
+ others_in_slot + blockers, filelist, linklist) |
96 |
+ |
97 |
# Check for read-only filesystems. |
98 |
ro_checker = get_ro_checker() |
99 |
- rofilesystems = ro_checker(dirlist) |
100 |
+ rofilesystems = ro_checker(dirs_ro) |
101 |
|
102 |
if rofilesystems: |
103 |
msg = _("One or more files installed to this package are " |
104 |
@@ -3935,14 +3949,6 @@ class dblink(object): |
105 |
eerror(msg) |
106 |
return 1 |
107 |
|
108 |
- # check for package collisions |
109 |
- blockers = self._blockers |
110 |
- if blockers is None: |
111 |
- blockers = [] |
112 |
- collisions, symlink_collisions, plib_collisions = \ |
113 |
- self._collision_protect(srcroot, destroot, |
114 |
- others_in_slot + blockers, filelist, linklist) |
115 |
- |
116 |
if symlink_collisions: |
117 |
# Symlink collisions need to be distinguished from other types |
118 |
# of collisions, in order to avoid confusion (see bug #409359). |
119 |
-- |
120 |
2.3.5 |