From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id CD7F0138A1C for ; Thu, 20 Nov 2014 04:08:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A5DF7E08DA; Thu, 20 Nov 2014 04:08:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 441AFE08DA for ; Thu, 20 Nov 2014 04:08:30 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DA770340494 for ; Thu, 20 Nov 2014 04:08:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5C46AA801 for ; Thu, 20 Nov 2014 04:08:27 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1416456154.103d27694197893badb3b5b5fb2e476e04f88033.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/actions.py pym/_emerge/unmerge.py pym/portage/dbapi/vartree.py X-VCS-Directories: pym/_emerge/ pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 103d27694197893badb3b5b5fb2e476e04f88033 X-VCS-Branch: master Date: Thu, 20 Nov 2014 04:08:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d396e91b-c0c1-4567-ba87-0e75e8d2d101 X-Archives-Hash: fb2ab3b67bbe027c5c953b53ed1724e7 commit: 103d27694197893badb3b5b5fb2e476e04f88033 Author: Zac Medico gentoo org> AuthorDate: Tue Nov 18 09:13:33 2014 +0000 Commit: Zac Medico gentoo 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 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"