Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/
Date: Thu, 29 Oct 2020 16:14:32
Message-Id: 1603988027.093195d9023ab6abba795aa8314288f5c2d42b99.mattst88@gentoo
1 commit: 093195d9023ab6abba795aa8314288f5c2d42b99
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 22 20:37:54 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 29 16:13:47 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=093195d9
7
8 catalyst: Drop unbind()
9
10 mount_namespaces(7) says
11
12 A mount ceases to be a member of a peer group when either the
13 mount is explicitly unmounted, or when the mount is implicitly
14 unmounted because a mount namespace is removed (because it has
15 no more member processes).
16
17 As a result, we can rely on exiting the mount namespace to unmount the
18 bind mounts.
19
20 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
21
22 catalyst/base/stagebase.py | 45 +--------------------------------------
23 catalyst/targets/embedded.py | 1 -
24 catalyst/targets/livecd_stage1.py | 1 -
25 catalyst/targets/livecd_stage2.py | 2 --
26 catalyst/targets/netboot.py | 3 ---
27 catalyst/targets/stage4.py | 1 -
28 6 files changed, 1 insertion(+), 52 deletions(-)
29
30 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
31 index d5454b77..a75dbdf9 100644
32 --- a/catalyst/base/stagebase.py
33 +++ b/catalyst/base/stagebase.py
34 @@ -498,7 +498,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
35 "setup_environment",
36 "run_local",
37 "preclean",
38 - "unbind",
39 ])
40 self.finish_sequence.extend([
41 "clean",
42 @@ -853,40 +852,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
43 fstype=fstype, options=options)
44 cxt.mount()
45 except OSError as e:
46 - self.unbind()
47 raise CatalystError(f"Couldn't mount: {source}, {e.strerror}")
48
49 - def unbind(self):
50 - chroot_path = self.settings["chroot_path"]
51 - umount_failed = False
52 -
53 - # Unmount in reverse order
54 - for target in [Path(chroot_path + self.mount[x]['target'])
55 - for x in reversed(self.mount)
56 - if self.mount[x]['enable']]:
57 - if not target.exists():
58 - log.debug('%s does not exist. Skipping', target)
59 - continue
60 -
61 - if not ismount(target):
62 - log.debug('%s is not a mount point. Skipping', target)
63 - continue
64 -
65 - try:
66 - cxt = libmount.Context(target=str(target))
67 - cxt.umount()
68 - except OSError as e:
69 - log.warning("Couldn't umount: %s, %s", target,
70 - e.strerror)
71 - umount_failed = True
72 -
73 - if umount_failed:
74 - # if any bind mounts really failed, then we need to raise
75 - # this to potentially prevent an upcoming bash stage cleanup script
76 - # from wiping our bind mounts.
77 - raise CatalystError(
78 - "Couldn't umount one or more bind-mounts; aborting for safety.")
79 -
80 def chroot_setup(self):
81 self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] +
82 self.settings["make_conf"]))
83 @@ -1190,7 +1157,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
84 env=self.env)
85 self.resume.enable("remove")
86 except:
87 - self.unbind()
88 raise
89
90 def preclean(self):
91 @@ -1206,7 +1172,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
92 self.resume.enable("preclean")
93
94 except:
95 - self.unbind()
96 raise CatalystError("Build failed, could not execute preclean")
97
98 def capture(self):
99 @@ -1269,7 +1234,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
100 self.settings['controller_file'])
101
102 except CatalystError:
103 - self.unbind()
104 raise CatalystError("Stage build aborting due to error.",
105 print_traceback=False)
106
107 @@ -1349,7 +1313,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
108
109 with namespace(mount=True):
110 if not self.run_sequence(self.build_sequence):
111 - self.unbind()
112 return False
113
114 if not self.run_sequence(self.finish_sequence):
115 @@ -1375,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
116 env=self.env)
117 log.info('unmerge shell script')
118 except CatalystError:
119 - self.unbind()
120 raise
121 self.resume.enable("unmerge")
122
123 @@ -1450,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
124 fileutils.touch(build_packages_resume)
125 self.resume.enable("build_packages")
126 except CatalystError:
127 - self.unbind()
128 raise CatalystError(
129 self.settings["spec_prefix"] +
130 "build aborting due to error.")
131 @@ -1474,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
132 self._build_kernel(kname=kname)
133 self.resume.enable("build_kernel")
134 except CatalystError:
135 - self.unbind()
136 raise CatalystError(
137 "build aborting due to kernel build error.",
138 print_traceback=True)
139 @@ -1518,7 +1478,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
140 key = 'boot/kernel/' + kname + '/config'
141 if key in self.settings:
142 if not os.path.exists(self.settings[key]):
143 - self.unbind()
144 raise CatalystError("Can't find kernel config: %s" %
145 self.settings[key])
146
147 @@ -1527,7 +1486,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
148 self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
149
150 except IOError:
151 - self.unbind()
152 + raise
153
154 def _copy_initramfs_overlay(self, kname):
155 key = 'boot/kernel/' + kname + '/initramfs_overlay'
156 @@ -1557,7 +1516,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
157 env=self.env)
158 self.resume.enable("bootloader")
159 except CatalystError:
160 - self.unbind()
161 raise CatalystError("Script aborting due to error.")
162
163 def livecd_update(self):
164 @@ -1573,7 +1531,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
165 self.resume.enable("livecd_update")
166
167 except CatalystError:
168 - self.unbind()
169 raise CatalystError(
170 "build aborting due to livecd_update error.")
171
172
173 diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
174 index 1314ce7c..e9138437 100644
175 --- a/catalyst/targets/embedded.py
176 +++ b/catalyst/targets/embedded.py
177 @@ -56,7 +56,6 @@ class embedded(StageBase):
178 "root_overlay",
179 "fsscript",
180 "unmerge",
181 - "unbind",
182 ])
183 self.finish_sequence.extend([
184 "remove",
185
186 diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
187 index 81367053..5c5e9f58 100644
188 --- a/catalyst/targets/livecd_stage1.py
189 +++ b/catalyst/targets/livecd_stage1.py
190 @@ -34,7 +34,6 @@ class livecd_stage1(StageBase):
191 "chroot_setup",
192 "setup_environment",
193 "build_packages",
194 - "unbind",
195 ])
196 self.finish_sequence.extend([
197 "clean",
198
199 diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
200 index f6c14919..3606047f 100644
201 --- a/catalyst/targets/livecd_stage2.py
202 +++ b/catalyst/targets/livecd_stage2.py
203 @@ -80,7 +80,6 @@ class livecd_stage2(StageBase):
204 for x in self.settings["livecd/modblacklist"]:
205 myf.write("\nblacklist "+x)
206 except:
207 - self.unbind()
208 raise CatalystError("Couldn't open " +
209 self.settings["chroot_path"] +
210 "/etc/modprobe.d/blacklist.conf.",
211 @@ -109,7 +108,6 @@ class livecd_stage2(StageBase):
212 "fsscript",
213 "rcupdate",
214 "unmerge",
215 - "unbind",
216 ])
217 self.finish_sequence.extend([
218 "remove",
219
220 diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
221 index 9a0a4156..55f4dff1 100644
222 --- a/catalyst/targets/netboot.py
223 +++ b/catalyst/targets/netboot.py
224 @@ -93,7 +93,6 @@ class netboot(StageBase):
225 cmd([self.settings['controller_file'], 'image'] +
226 myfiles, env=self.env)
227 except CatalystError:
228 - self.unbind()
229 raise CatalystError("Failed to copy files to image!",
230 print_traceback=True)
231
232 @@ -121,7 +120,6 @@ class netboot(StageBase):
233 cmd([self.settings['controller_file'], 'final'], env=self.env)
234 log.notice('Netboot Build Finished!')
235 except CatalystError:
236 - self.unbind()
237 raise CatalystError("Failed to move kernel images!",
238 print_traceback=True)
239
240 @@ -178,7 +176,6 @@ class netboot(StageBase):
241 "move_kernels",
242 "remove",
243 "empty",
244 - "unbind",
245 ])
246 self.finish_sequence.extend([
247 "clean",
248
249 diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
250 index 78a5c780..b7f74b01 100644
251 --- a/catalyst/targets/stage4.py
252 +++ b/catalyst/targets/stage4.py
253 @@ -57,7 +57,6 @@ class stage4(StageBase):
254 "preclean",
255 "rcupdate",
256 "unmerge",
257 - "unbind",
258 ])
259 self.finish_sequence.extend([
260 "remove",