From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/_emerge/
Date: Thu, 20 Nov 2014 04:08:27 +0000 (UTC) [thread overview]
Message-ID: <1416456154.103d27694197893badb3b5b5fb2e476e04f88033.zmedico@gentoo> (raw)
commit: 103d27694197893badb3b5b5fb2e476e04f88033
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 18 09:13:33 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Nov 20 04:02:34 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=103d2769
emerge: check for writable /var/db/pkg (490732)
If there are packages to be merged or unmerge, then bail out early
if /var/db/pkg is not writable (in order to avoid a fatal EROFS error
which would otherwise occur later on). Behavior remains unchanged for
--pretend mode. For --ask mode, it will bail out just after the last
relevant --ask prompt.
In contrast to the writeable_check module, which operates on files just
before they are merged, the new vardbapi.writable check is performed
before anything has been built (much earlier).
X-Gentoo-Bug: 490732
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
---
pym/_emerge/actions.py | 15 +++++++++++++++
pym/_emerge/unmerge.py | 8 ++++++++
pym/portage/dbapi/vartree.py | 12 ++++++++++++
3 files changed, 35 insertions(+)
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 48b0826..6f7dfe0 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -428,6 +428,21 @@ def action_build(settings, trees, mtimedb,
# least show warnings about missed updates and such.
mydepgraph.display_problems()
+ if not Scheduler._opts_no_self_update.intersection(myopts):
+
+ eroots = set()
+ for x in mydepgraph.altlist():
+ if isinstance(x, Package) and x.operation == "merge":
+ eroots.add(x.root)
+
+ for eroot in eroots:
+ if not trees[eroot]["vartree"].dbapi.writable:
+ writemsg_level("!!! %s\n" %
+ _("Read-only file system: %s") %
+ trees[eroot]["vartree"].dbapi._dbroot,
+ level=logging.ERROR, noiselevel=-1)
+ return 1
+
if ("--resume" in myopts):
favorites=mtimedb["resume"]["favorites"]
diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py
index df29000..03ce0a2 100644
--- a/pym/_emerge/unmerge.py
+++ b/pym/_emerge/unmerge.py
@@ -10,6 +10,7 @@ import textwrap
import portage
from portage import os
from portage.dbapi._expand_new_virt import expand_new_virt
+from portage.localization import _
from portage.output import bold, colorize, darkgreen, green
from portage._sets import SETPREFIX
from portage._sets.base import EditablePackageSet
@@ -546,6 +547,13 @@ def unmerge(root_config, myopts, unmerge_action,
print("Quitting.")
print()
return 128 + signal.SIGINT
+
+ if not vartree.dbapi.writable:
+ writemsg_level("!!! %s\n" %
+ _("Read-only file system: %s") % vartree.dbapi._dbroot,
+ level=logging.ERROR, noiselevel=-1)
+ return 1
+
#the real unmerging begins, after a short delay unless we're raging....
if not unmerge_action == "rage-clean" and clean_delay and not autoclean:
countdown(int(settings["CLEAN_DELAY"]), ">>> Unmerging")
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 0fd1bd9..df031cd 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -33,6 +33,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.util.env_update:env_update',
'portage.util.listdir:dircache,listdir',
'portage.util.movefile:movefile',
+ 'portage.util.path:first_existing',
'portage.util.writeable_check:get_ro_checker',
'portage.util._dyn_libs.PreservedLibsRegistry:PreservedLibsRegistry',
'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap',
@@ -189,6 +190,17 @@ class vardbapi(dbapi):
self._cached_counter = None
@property
+ def writable(self):
+ """
+ Check if var/db/pkg is writable, or permissions are sufficient
+ to create it if it does not exist yet.
+ @rtype: bool
+ @return: True if var/db/pkg is writable or can be created,
+ False otherwise
+ """
+ return os.access(first_existing(self._dbroot), os.W_OK)
+
+ @property
def root(self):
warnings.warn("The root attribute of "
"portage.dbapi.vartree.vardbapi"
next reply other threads:[~2014-11-20 4:08 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-20 4:08 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-04-03 20:03 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/_emerge/ Zac Medico
2015-08-30 23:44 Zac Medico
2014-02-24 9:23 Alexander Berntsen
2013-03-13 5:56 Zac Medico
2013-01-23 16:19 Zac Medico
2013-01-05 15:20 Zac Medico
2012-12-23 5:33 Arfrever Frehtes Taifersar Arahesis
2012-11-24 21:57 Zac Medico
2012-04-22 18:57 Zac Medico
2012-04-21 6:51 Zac Medico
2012-02-17 22:19 Zac Medico
2012-02-16 0:33 Zac Medico
2012-02-14 23:40 Zac Medico
2012-02-10 1:28 Zac Medico
2012-02-08 1:16 Zac Medico
2012-02-08 0:36 Zac Medico
2011-10-28 2:34 Zac Medico
2011-10-16 20:26 Zac Medico
2011-10-15 5:10 Zac Medico
2011-06-03 10:16 Zac Medico
2011-05-24 5:31 Zac Medico
2011-05-24 0:33 Zac Medico
2011-05-09 5:16 Zac Medico
2011-03-26 7:39 Zac Medico
2011-03-26 3:24 Zac Medico
2011-03-25 4:34 Zac Medico
2011-03-25 4:34 Zac Medico
2011-03-25 4:34 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416456154.103d27694197893badb3b5b5fb2e476e04f88033.zmedico@gentoo \
--to=zmedico@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox