Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Cc: Brian Dolbec <dolsen@g.o>
Subject: [gentoo-catalyst] [PATCH 2/2] catalyst/targets/generic_stage_target.py: mount /dev/shm on linux
Date: Fri, 03 Jan 2014 06:01:02
Message-Id: 1388728844-2142-3-git-send-email-dolsen@gentoo.org
In Reply to: [gentoo-catalyst] Fix the recent python sem_open failure by Brian Dolbec
1 Add shm targets defaults. Anthony G. Basile <blueness@g.o>
2 Some build systems require /dev/shm to be mounted, like python's
3 build system. We make sure that on Linux systems, /dev/shm is
4 mounted in the stage chroots. See bug #496328.
5
6 Douglas Freed <dwfreed@×××.edu> :
7 Mount /dev/shm in the chroot with the right options
8 Bind mounting /dev/shm into the chroot isn't a good idea, as there may
9 be collisions and result in weird side effects. Instead, we can just
10 mount a new tmpfs there, with the right options to ensure security.
11
12 (Forward ported to pending branch from 2.X Brian Dolbec)
13 Conflicts:
14 catalyst/targets/generic_stage_target.py
15 ---
16 modules/generic_stage_target.py | 8 +++++++-
17 1 file changed, 7 insertions(+), 1 deletion(-)
18
19 diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
20 index 790e4da..3d66231 100644
21 --- a/modules/generic_stage_target.py
22 +++ b/modules/generic_stage_target.py
23 @@ -20,6 +20,7 @@ TARGET_MOUNTS_DEFAULTS = {
24 "port_tmpdir": "/var/tmp/portage",
25 "port_logdir": "/var/log/portage",
26 "proc": "/proc",
27 + "shm": "/dev/shm",
28 }
29
30 SOURCE_MOUNTS_DEFAULTS = {
31 @@ -29,6 +30,7 @@ SOURCE_MOUNTS_DEFAULTS = {
32 "portdir": "/usr/portage",
33 "port_tmpdir": "tmpfs",
34 "proc": "/proc",
35 + "shm": "shmfs",
36 }
37
38
39 @@ -218,6 +220,7 @@ class generic_stage_target(generic_target):
40 #self.mountmap["portdir"] = None
41 if os.uname()[0] == "Linux":
42 self.mounts.append("devpts")
43 + self.mounts.append("shm")
44
45 self.set_mounts()
46
47 @@ -938,7 +941,7 @@ class generic_stage_target(generic_target):
48 os.makedirs(target, 0755)
49
50 if not os.path.exists(self.mountmap[x]):
51 - if not self.mountmap[x] == "tmpfs":
52 + if self.mountmap[x] not in ["tmpfs", "shmfs"]:
53 os.makedirs(self.mountmap[x], 0755)
54
55 src=self.mountmap[x]
56 @@ -959,6 +962,9 @@ class generic_stage_target(generic_target):
57 self.settings["var_tmpfs_portage"] + "G " + \
58 src + " " + target
59 retval=os.system(cmd)
60 + elif src == "shmfs":
61 + cmd = "mount -t tmpfs -o noexec,nosuid,nodev shm " + target
62 + retval=os.system(cmd)
63 else:
64 cmd = "mount --bind " + src + " " + target
65 #print "bind(); cmd =", cmd
66 --
67 1.8.3.2

Replies