Gentoo Archives: gentoo-portage-dev

From: Sam James <sam@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Sam James <sam@g.o>
Subject: [gentoo-portage-dev] [PATCH] lib/_emerge/actions.py: warn on missing /run
Date: Thu, 07 Oct 2021 03:20:09
Message-Id: 20211007031948.662947-1-sam@gentoo.org
1 Newer versions of build-docbook-catalog use
2 /run/lock. This exposed that we weren't
3 asking users to mount /run in the handbook.
4
5 Check if it exists and warn if it doesn't.
6
7 This should primarily (exclusively?) be a
8 problem in chroots given an init system
9 should be creating this.
10
11 Bug: https://bugs.gentoo.org/816303
12 Signed-off-by: Sam James <sam@g.o>
13 ---
14 lib/_emerge/actions.py | 34 ++++++++++++++++++++++------------
15 1 file changed, 22 insertions(+), 12 deletions(-)
16
17 diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py
18 index 05a115250..1b40bebd3 100644
19 --- a/lib/_emerge/actions.py
20 +++ b/lib/_emerge/actions.py
21 @@ -2986,17 +2986,26 @@ def validate_ebuild_environment(trees):
22 check_locale()
23
24
25 -def check_procfs():
26 - procfs_path = "/proc"
27 - if platform.system() not in ("Linux",) or os.path.ismount(procfs_path):
28 - return os.EX_OK
29 - msg = "It seems that %s is not mounted. You have been warned." % procfs_path
30 - writemsg_level(
31 - "".join("!!! %s\n" % l for l in textwrap.wrap(msg, 70)),
32 - level=logging.ERROR,
33 - noiselevel=-1,
34 - )
35 - return 1
36 +def check_mounted_fs():
37 + paths = {"/proc": False, "/run": False}
38 +
39 + for path in paths.keys():
40 + if platform.system() not in ("Linux",) or os.path.ismount(path):
41 + paths[path] = True
42 + continue
43 +
44 + msg = "It seems that %s is not mounted. You have been warned." % path
45 + writemsg_level(
46 + "".join("!!! %s\n" % l for l in textwrap.wrap(msg, 70)),
47 + level=logging.ERROR,
48 + noiselevel=-1,
49 + )
50 +
51 + # Were any of the mounts we were looking for missing?
52 + if False in paths.values():
53 + return 1
54 +
55 + return os.EX_OK
56
57
58 def config_protect_check(trees):
59 @@ -3474,7 +3483,8 @@ def run_action(emerge_config):
60 repo_name_check(emerge_config.trees)
61 repo_name_duplicate_check(emerge_config.trees)
62 config_protect_check(emerge_config.trees)
63 - check_procfs()
64 +
65 + check_mounted_fs()
66
67 for mytrees in emerge_config.trees.values():
68 mydb = mytrees["porttree"].dbapi
69 --
70 2.33.0

Replies