Gentoo Archives: gentoo-catalyst

From: Matt Turner <mattst88@g.o>
To: gentoo-catalyst@l.g.o
Cc: Matt Turner <mattst88@g.o>
Subject: [gentoo-catalyst] [PATCH 2/3] catalyst: Factor out mount/source/target in bind()
Date: Fri, 15 May 2020 06:37:45
Message-Id: 20200515063730.2582596-2-mattst88@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH 1/3] catalyst: Rename shmfs -> shm by Matt Turner
1 This simplifies things, and lets us only append to the end of the list.
2 It also enables us to simply add multiple args (in the next commit).
3
4 Signed-off-by: Matt Turner <mattst88@g.o>
5 ---
6 catalyst/base/stagebase.py | 23 ++++++++++-------------
7 1 file changed, 10 insertions(+), 13 deletions(-)
8
9 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
10 index 52f9cd5b..55d1032d 100644
11 --- a/catalyst/base/stagebase.py
12 +++ b/catalyst/base/stagebase.py
13 @@ -852,6 +852,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
14
15 source = str(self.mount[x]['source'])
16 target = self.settings['chroot_path'] + str(self.mount[x]['target'])
17 + mount = ['mount']
18
19 log.debug('bind %s: "%s" -> "%s"', x, source, target)
20
21 @@ -859,29 +860,25 @@ class StageBase(TargetBase, ClearBase, GenBase):
22 if 'var_tmpfs_portage' not in self.settings:
23 continue
24
25 - _cmd = ['mount', '-t', 'tmpfs', '-o', 'size=' +
26 - self.settings['var_tmpfs_portage'] + 'G', source,
27 - target]
28 + mount += ['-t', 'tmpfs', '-o', 'size=' +
29 + self.settings['var_tmpfs_portage'] + 'G']
30 elif source == 'tmpfs':
31 - _cmd = ['mount', '-t', 'tmpfs', source, target]
32 + mount += ['-t', 'tmpfs']
33 elif source == 'shm':
34 - _cmd = ['mount', '-t', 'tmpfs', '-o', 'noexec,nosuid,nodev',
35 - source, target]
36 + mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev']
37 else:
38 - _cmd = ['mount', source, target]
39 -
40 - source = Path(self.mount[x]['source'])
41 - if source.suffix != '.sqfs':
42 - _cmd.insert(1, '--bind')
43 + source_path = Path(self.mount[x]['source'])
44 + if source_path.suffix != '.sqfs':
45 + mount.append('--bind')
46
47 # We may need to create the source of the bind mount. E.g., in the
48 # case of an empty package cache we must create the directory that
49 # the binary packages will be stored into.
50 - source.mkdir(mode=0o755, exist_ok=True)
51 + source_path.mkdir(mode=0o755, exist_ok=True)
52
53 Path(target).mkdir(mode=0o755, parents=True, exist_ok=True)
54
55 - cmd(_cmd, env=self.env, fail_func=self.unbind)
56 + cmd(mount + [source, target], env=self.env, fail_func=self.unbind)
57
58 def unbind(self):
59 ouch = 0
60 --
61 2.26.2