1 |
If there are packages to be merged or unmerge, then bail out early |
2 |
if /var/db/pkg is not writable (in order to avoid a fatal EROFS error |
3 |
which would otherwise occur later on). |
4 |
|
5 |
In contrast to the writeable_check module, which operates on files just |
6 |
before they are merged, the new vardbapi.writable check is performed |
7 |
before anything has been built (much earlier). |
8 |
|
9 |
X-Gentoo-Bug: 490732 |
10 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732 |
11 |
--- |
12 |
PATCH v2 only has an updated commit message which explains the |
13 |
relationship to the writeable_check module. |
14 |
|
15 |
pym/_emerge/actions.py | 21 +++++++++++++++++++++ |
16 |
pym/portage/dbapi/vartree.py | 9 +++++++++ |
17 |
2 files changed, 30 insertions(+) |
18 |
|
19 |
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py |
20 |
index 48b0826..4a96a22 100644 |
21 |
--- a/pym/_emerge/actions.py |
22 |
+++ b/pym/_emerge/actions.py |
23 |
@@ -428,6 +428,21 @@ def action_build(settings, trees, mtimedb, |
24 |
# least show warnings about missed updates and such. |
25 |
mydepgraph.display_problems() |
26 |
|
27 |
+ if not Scheduler._opts_no_self_update.intersection(myopts): |
28 |
+ |
29 |
+ eroots = set() |
30 |
+ for x in mydepgraph.altlist(): |
31 |
+ if isinstance(x, Package) and x.operation == "merge": |
32 |
+ eroots.add(x.root) |
33 |
+ |
34 |
+ for eroot in eroots: |
35 |
+ if not trees[eroot]["vartree"].dbapi.writable: |
36 |
+ writemsg_level("!!! %s\n" % |
37 |
+ _("Read-only file system: %s") % |
38 |
+ trees[eroot]["vartree"].dbapi._dbroot, |
39 |
+ level=logging.ERROR, noiselevel=-1) |
40 |
+ return 1 |
41 |
+ |
42 |
if ("--resume" in myopts): |
43 |
favorites=mtimedb["resume"]["favorites"] |
44 |
|
45 |
@@ -2842,6 +2857,12 @@ def action_uninstall(settings, trees, ldpath_mtimes, |
46 |
if action == 'deselect': |
47 |
return action_deselect(settings, trees, opts, valid_atoms) |
48 |
|
49 |
+ if not vardb.writable: |
50 |
+ writemsg_level("!!! %s\n" % |
51 |
+ _("Read-only file system: %s") % vardb._dbroot, |
52 |
+ level=logging.ERROR, noiselevel=-1) |
53 |
+ return 1 |
54 |
+ |
55 |
# Use the same logic as the Scheduler class to trigger redirection |
56 |
# of ebuild pkg_prerm/postrm phase output to logs as appropriate |
57 |
# for options such as --jobs, --quiet and --quiet-build. |
58 |
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
59 |
index 0fd1bd9..64b0ff6 100644 |
60 |
--- a/pym/portage/dbapi/vartree.py |
61 |
+++ b/pym/portage/dbapi/vartree.py |
62 |
@@ -33,6 +33,7 @@ portage.proxy.lazyimport.lazyimport(globals(), |
63 |
'portage.util.env_update:env_update', |
64 |
'portage.util.listdir:dircache,listdir', |
65 |
'portage.util.movefile:movefile', |
66 |
+ 'portage.util.path:first_existing', |
67 |
'portage.util.writeable_check:get_ro_checker', |
68 |
'portage.util._dyn_libs.PreservedLibsRegistry:PreservedLibsRegistry', |
69 |
'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap', |
70 |
@@ -189,6 +190,14 @@ class vardbapi(dbapi): |
71 |
self._cached_counter = None |
72 |
|
73 |
@property |
74 |
+ def writable(self): |
75 |
+ """ |
76 |
+ @rtype: bool |
77 |
+ @return: True if var/db/pkg is writable, False otherwise |
78 |
+ """ |
79 |
+ return os.access(first_existing(self._dbroot), os.W_OK) |
80 |
+ |
81 |
+ @property |
82 |
def root(self): |
83 |
warnings.warn("The root attribute of " |
84 |
"portage.dbapi.vartree.vardbapi" |
85 |
-- |
86 |
2.0.4 |