[gentoo-portage-dev] [PATCH v6] Test for read-only filesystems, bail out during preinst if there are any which will be written to and display a useful error message. Fixes bug 378869.

2014-01-22 Thread Chris Reffett
v2: Reformat, add a function to return an appropriate read-only checker
for the operating system, so that this can be extended to other OSes.

v3: minor formatting tweaks from bernalex, including use os.path.join()
instead of string concatenation

v4: Update copyright header, change the code in rochecker to open with
io.open in order to not break on non-ascii characters as reported by
Arfrever. Change get_ro_checker to use a dict as suggested by vapier.

v5: Fix comment format as requested by vapier.

v6: Change linux_ro_checker to use set.intersection instead of the
longer check-and-append system as suggested by vapier.
---
 pym/portage/dbapi/vartree.py  | 34 +-
 pym/portage/util/rochecker.py | 80 +++
 2 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100644 pym/portage/util/rochecker.py

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index ed62323..cf6781b 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2013 Gentoo Foundation
+# Copyright 1998-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -32,6 +32,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
'portage.util.env_update:env_update',
'portage.util.listdir:dircache,listdir',
'portage.util.movefile:movefile',
+   'portage.util.rochecker:get_ro_checker',
'portage.util._dyn_libs.PreservedLibsRegistry:PreservedLibsRegistry',
'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap',
'portage.util._async.SchedulerInterface:SchedulerInterface',
@@ -3508,6 +3509,8 @@ class dblink(object):

This function does the following:

+   calls get_ro_checker to retrieve a function for checking 
whether Portage
+   will write to a read-only filesystem, then runs it against the 
directory list
calls self._preserve_libs if FEATURES=preserve-libs
calls self._collision_protect if FEATURES=collision-protect
calls doebuild(mydo=pkg_preinst)
@@ -3685,6 +3688,7 @@ class dblink(object):
eagain_error = False
 
myfilelist = []
+   mydirlist = []
mylinklist = []
paths_with_newlines = []
def onerror(e):
@@ -3717,6 +3721,9 @@ class dblink(object):

unicode_errors.append(new_parent[ed_len:])
break
 
+   relative_path = parent[srcroot_len:]
+   mydirlist.append(os.path.join(/, 
relative_path))
+
for fname in files:
try:
fname = _unicode_decode(fname,
@@ -3829,6 +3836,31 @@ class dblink(object):
for other in others_in_slot])
prepare_build_dirs(settings=self.settings, cleanup=cleanup)
 
+   # Check for read-only filesystems.
+   ro_checker = get_ro_checker()
+   rofilesystems = ro_checker(mydirlist)
+
+   if rofilesystems:
+   msg = _(One or more files installed to this package 
are 
+   set to be installed to read-only filesystems. 
+   Please mount the following filesystems as 
read-write 
+   and retry.)
+   msg = textwrap.wrap(msg, 70)
+   msg.append()
+   for f in rofilesystems:
+   msg.append(\t%s % os.path.join(destroot,
+   f.lstrip(os.path.sep)))
+   msg.append()
+   self._elog(eerror, preinst, msg)
+
+   msg = _(Package '%s' NOT merged due to read-only file 
systems.) % \
+   self.settings.mycpv
+   msg += _( If necessary, refer to your elog 
+   messages for the whole content of the above 
message.)
+   msg = textwrap.wrap(msg, 70)
+   eerror(msg)
+   return 1
+
# check for package collisions
blockers = self._blockers
if blockers is None:
diff --git a/pym/portage/util/rochecker.py b/pym/portage/util/rochecker.py
new file mode 100644
index 000..c13bdfc
--- /dev/null
+++ b/pym/portage/util/rochecker.py
@@ -0,0 +1,80 @@
+#-*- coding:utf-8 -*-
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+Methods to check whether Portage is going to write to read-only 

[gentoo-portage-dev] [PATCH] Add the has function to the ebuild(5) man page.

2014-01-22 Thread Michael Orlitzky
I WTF'ed on this for a long time before I noticed that the docs for
has were sort-of contained in hasv. Might as well give has its own.
From 423123cc2ea429c06914ef858a6fdb86c0c6d30b Mon Sep 17 00:00:00 2001
From: Michael Orlitzky m...@gentoo.org
Date: Wed, 22 Jan 2014 16:18:23 -0500
Subject: [PATCH] Add the has function to the ebuild(5) man page.

---
 man/ebuild.5 | 8 
 1 file changed, 8 insertions(+)

diff --git a/man/ebuild.5 b/man/ebuild.5
index 524006a..36836b3 100644
--- a/man/ebuild.5
+++ b/man/ebuild.5
@@ -1049,6 +1049,14 @@ of \fI\-\-without\-\fR. Beginning with \fBEAPI 4\fR, an empty \fIconfigure
 opt\fR argument is recognized. In \fBEAPI 3\fR and earlier, an empty
 \fIconfigure opt\fR argument is treated as if it weren't provided.
 .TP
+.B has\fR \fIitem\fR \fIitem list
+If \fIitem\fR is in \fIitem list\fR, then \fBhas\fR returns
+0. Otherwise, 1 is returned. There is another version, \fBhasv\fR, that
+will conditionally echo \fIitem\fR.
+.br
+The \fIitem list\fR is delimited by the \fIIFS\fR variable.  This variable
+has a default value of ' ', or a space.  It is a \fBbash\fR(1) setting.
+.TP
 .B hasv\fR \fIitem\fR \fIitem list
 If \fIitem\fR is in \fIitem list\fR, then \fIitem\fR is echoed and \fBhasv\fR
 returns 0.  Otherwise, nothing is echoed and 1 is returned. As indicated with
-- 
1.8.3.2



Re: [gentoo-portage-dev] [PATCH] Add the has function to the ebuild(5) man page.

2014-01-22 Thread Mike Frysinger
On Wednesday 22 January 2014 16:22:35 Michael Orlitzky wrote:
 I WTF'ed on this for a long time before I noticed that the docs for
 has were sort-of contained in hasv. Might as well give has its own.

please use `git send-email` when posting patches

this duplicates the hasv section which is not a good thing.  i rewrote hasv to 
refer to the has function, fixed up the commit message, and merged it.

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commitdiff;h=669ccb584f4d39b764223ae44cb2d45ac6eb3903
-mike


signature.asc
Description: This is a digitally signed message part.