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:34:53
Message-Id: 1603989280.897b7a15df970bff62a4db98010c71d8e2f2714c.mattst88@gentoo
1 commit: 897b7a15df970bff62a4db98010c71d8e2f2714c
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:34:40 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=897b7a15
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 | 44 +--------------------------------------
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(+), 51 deletions(-)
29
30 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
31 index b9c220d0..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 @@ -1374,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
108 env=self.env)
109 log.info('unmerge shell script')
110 except CatalystError:
111 - self.unbind()
112 raise
113 self.resume.enable("unmerge")
114
115 @@ -1449,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
116 fileutils.touch(build_packages_resume)
117 self.resume.enable("build_packages")
118 except CatalystError:
119 - self.unbind()
120 raise CatalystError(
121 self.settings["spec_prefix"] +
122 "build aborting due to error.")
123 @@ -1473,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
124 self._build_kernel(kname=kname)
125 self.resume.enable("build_kernel")
126 except CatalystError:
127 - self.unbind()
128 raise CatalystError(
129 "build aborting due to kernel build error.",
130 print_traceback=True)
131 @@ -1517,7 +1478,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
132 key = 'boot/kernel/' + kname + '/config'
133 if key in self.settings:
134 if not os.path.exists(self.settings[key]):
135 - self.unbind()
136 raise CatalystError("Can't find kernel config: %s" %
137 self.settings[key])
138
139 @@ -1526,7 +1486,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
140 self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
141
142 except IOError:
143 - self.unbind()
144 + raise
145
146 def _copy_initramfs_overlay(self, kname):
147 key = 'boot/kernel/' + kname + '/initramfs_overlay'
148 @@ -1556,7 +1516,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
149 env=self.env)
150 self.resume.enable("bootloader")
151 except CatalystError:
152 - self.unbind()
153 raise CatalystError("Script aborting due to error.")
154
155 def livecd_update(self):
156 @@ -1572,7 +1531,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
157 self.resume.enable("livecd_update")
158
159 except CatalystError:
160 - self.unbind()
161 raise CatalystError(
162 "build aborting due to livecd_update error.")
163
164
165 diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
166 index 1314ce7c..e9138437 100644
167 --- a/catalyst/targets/embedded.py
168 +++ b/catalyst/targets/embedded.py
169 @@ -56,7 +56,6 @@ class embedded(StageBase):
170 "root_overlay",
171 "fsscript",
172 "unmerge",
173 - "unbind",
174 ])
175 self.finish_sequence.extend([
176 "remove",
177
178 diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
179 index 81367053..5c5e9f58 100644
180 --- a/catalyst/targets/livecd_stage1.py
181 +++ b/catalyst/targets/livecd_stage1.py
182 @@ -34,7 +34,6 @@ class livecd_stage1(StageBase):
183 "chroot_setup",
184 "setup_environment",
185 "build_packages",
186 - "unbind",
187 ])
188 self.finish_sequence.extend([
189 "clean",
190
191 diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
192 index f6c14919..3606047f 100644
193 --- a/catalyst/targets/livecd_stage2.py
194 +++ b/catalyst/targets/livecd_stage2.py
195 @@ -80,7 +80,6 @@ class livecd_stage2(StageBase):
196 for x in self.settings["livecd/modblacklist"]:
197 myf.write("\nblacklist "+x)
198 except:
199 - self.unbind()
200 raise CatalystError("Couldn't open " +
201 self.settings["chroot_path"] +
202 "/etc/modprobe.d/blacklist.conf.",
203 @@ -109,7 +108,6 @@ class livecd_stage2(StageBase):
204 "fsscript",
205 "rcupdate",
206 "unmerge",
207 - "unbind",
208 ])
209 self.finish_sequence.extend([
210 "remove",
211
212 diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
213 index 9a0a4156..55f4dff1 100644
214 --- a/catalyst/targets/netboot.py
215 +++ b/catalyst/targets/netboot.py
216 @@ -93,7 +93,6 @@ class netboot(StageBase):
217 cmd([self.settings['controller_file'], 'image'] +
218 myfiles, env=self.env)
219 except CatalystError:
220 - self.unbind()
221 raise CatalystError("Failed to copy files to image!",
222 print_traceback=True)
223
224 @@ -121,7 +120,6 @@ class netboot(StageBase):
225 cmd([self.settings['controller_file'], 'final'], env=self.env)
226 log.notice('Netboot Build Finished!')
227 except CatalystError:
228 - self.unbind()
229 raise CatalystError("Failed to move kernel images!",
230 print_traceback=True)
231
232 @@ -178,7 +176,6 @@ class netboot(StageBase):
233 "move_kernels",
234 "remove",
235 "empty",
236 - "unbind",
237 ])
238 self.finish_sequence.extend([
239 "clean",
240
241 diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
242 index 78a5c780..b7f74b01 100644
243 --- a/catalyst/targets/stage4.py
244 +++ b/catalyst/targets/stage4.py
245 @@ -57,7 +57,6 @@ class stage4(StageBase):
246 "preclean",
247 "rcupdate",
248 "unmerge",
249 - "unbind",
250 ])
251 self.finish_sequence.extend([
252 "remove",