Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 378869
Collapse All | Expand All

(-)a/pym/portage/dbapi/vartree.py (+31 lines)
Lines 28-33 portage.proxy.lazyimport.lazyimport(globals(), Link Here
28
	'portage.util:apply_secpass_permissions,ConfigProtect,ensure_dirs,' + \
28
	'portage.util:apply_secpass_permissions,ConfigProtect,ensure_dirs,' + \
29
		'writemsg,writemsg_level,write_atomic,atomic_ofstream,writedict,' + \
29
		'writemsg,writemsg_level,write_atomic,atomic_ofstream,writedict,' + \
30
		'grabdict,normalize_path,new_protect_filename',
30
		'grabdict,normalize_path,new_protect_filename',
31
	'portage.util.checkwriteable:check_dirs_writeable',
31
	'portage.util.digraph:digraph',
32
	'portage.util.digraph:digraph',
32
	'portage.util.env_update:env_update',
33
	'portage.util.env_update:env_update',
33
	'portage.util.listdir:dircache,listdir',
34
	'portage.util.listdir:dircache,listdir',
Lines 3508-3513 class dblink(object): Link Here
3508
		
3509
		
3509
		This function does the following:
3510
		This function does the following:
3510
		
3511
		
3512
		calls check_dirs_writeable to verify that no files will be
3513
		written to read-only filesystems
3511
		calls self._preserve_libs if FEATURES=preserve-libs
3514
		calls self._preserve_libs if FEATURES=preserve-libs
3512
		calls self._collision_protect if FEATURES=collision-protect
3515
		calls self._collision_protect if FEATURES=collision-protect
3513
		calls doebuild(mydo=pkg_preinst)
3516
		calls doebuild(mydo=pkg_preinst)
Lines 3685-3690 class dblink(object): Link Here
3685
			eagain_error = False
3688
			eagain_error = False
3686
3689
3687
			myfilelist = []
3690
			myfilelist = []
3691
			mydirlist = []
3688
			mylinklist = []
3692
			mylinklist = []
3689
			paths_with_newlines = []
3693
			paths_with_newlines = []
3690
			def onerror(e):
3694
			def onerror(e):
Lines 3717-3722 class dblink(object): Link Here
3717
					unicode_errors.append(new_parent[ed_len:])
3721
					unicode_errors.append(new_parent[ed_len:])
3718
					break
3722
					break
3719
3723
3724
				relative_path = parent[srcroot_len:]
3725
				mydirlist.append("/" + relative_path)
3726
3720
				for fname in files:
3727
				for fname in files:
3721
					try:
3728
					try:
3722
						fname = _unicode_decode(fname,
3729
						fname = _unicode_decode(fname,
Lines 3829-3834 class dblink(object): Link Here
3829
			for other in others_in_slot])
3836
			for other in others_in_slot])
3830
		prepare_build_dirs(settings=self.settings, cleanup=cleanup)
3837
		prepare_build_dirs(settings=self.settings, cleanup=cleanup)
3831
3838
3839
		# Check for read-only filesystems
3840
		rofilesystems = check_dirs_writeable(mydirlist)
3841
3842
		if rofilesystems:
3843
			msg = _("One or more files installed to this package are "
3844
				"set to be installed to read-only filesystems. "
3845
				"Please mount the filesystems below read-write "
3846
				"and retry.")
3847
			msg = textwrap.wrap(msg, 70)
3848
			msg.append("")
3849
			for f in rofilesystems:
3850
				msg.append("\t%s" % os.path.join(destroot,
3851
					f.lstrip(os.path.sep)))
3852
			msg.append("")
3853
			self._elog("eerror", "preinst", msg)
3854
3855
			msg = _("Package '%s' NOT merged due to read-only file systems.") % \
3856
				self.settings.mycpv
3857
			msg += _(" If necessary, refer to your elog "
3858
				"messages for the whole content of the above message.")
3859
			msg = textwrap.wrap(msg, 70)
3860
			eerror(msg)
3861
			return 1
3862
3832
		# check for package collisions
3863
		# check for package collisions
3833
		blockers = self._blockers
3864
		blockers = self._blockers
3834
		if blockers is None:
3865
		if blockers is None:
(-)a/pym/portage/util/checkwriteable.py (-1 / +49 lines)
Line 0 Link Here
0
- 
1
#-*- coding:utf-8 -*-
2
# Copyright 2014 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
5
from __future__ import unicode_literals
6
7
import re
8
9
from portage.util import writemsg
10
from portage.localization import _
11
12
13
def check_dirs_writeable(dir_list):
14
	"""
15
	Use /proc/mounts to check that no directories installed by the ebuild are set to
16
	be installed to	a read-only filesystem
17
18
	@param dir_list: Directories installed by the ebuild
19
	@type dir_list: List
20
	@return:
21
	1. A list of filesystems which are both set to be written to and are mounted
22
	read-only, may be empty.
23
	"""
24
	ro_filesystems = set()
25
	ro_filesystems_written = set()
26
27
	try:
28
		with open("/proc/mounts") as procmounts:
29
			roregex = re.compile(r'(\A|,)ro(\Z|,)')
30
			for line in procmounts:
31
				if roregex.search(line.split(" ")[3].strip()) is not None:
32
					romount = line.split(" ")[1].strip()
33
					ro_filesystems.add(romount)
34
35
	# If /proc/mounts can't be read, assume that there are no RO
36
	# filesystems and return
37
	except EnvironmentError:
38
		writemsg(_("!!! /proc/mounts cannot be read"))
39
		return []
40
41
	if not ro_filesystems:
42
		return ro_filesystems
43
44
	for directory in dir_list:
45
		for filesystem in ro_filesystems:
46
			if re.match(filesystem, directory):
47
				ro_filesystems_written.add(filesystem)
48
49
	return ro_filesystems_written

Return to bug 378869