public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Matt Turner" <mattst88@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/
Date: Sat, 19 Dec 2020 19:56:02 +0000 (UTC)	[thread overview]
Message-ID: <1604097652.4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f.mattst88@gentoo> (raw)
Message-ID: <20201219195602.JrhwFz2wK3nZ6C6Z6_Wxm1MZiuRp-CvPYnfU_LkrgEI@z> (raw)

commit:     4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 20:37:54 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Fri Oct 30 22:40:52 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4b5ff905

catalyst: Drop unbind()

mount_namespaces(7) says

	A mount ceases to be a member of a peer group when either the
	mount is explicitly unmounted, or when the mount is implicitly
	unmounted because a mount namespace is removed (because it has
	no more member processes).

As a result, we can rely on exiting the mount namespace to unmount the
bind mounts.

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 catalyst/base/stagebase.py        | 44 +--------------------------------------
 catalyst/targets/embedded.py      |  1 -
 catalyst/targets/livecd_stage1.py |  1 -
 catalyst/targets/livecd_stage2.py |  2 --
 catalyst/targets/netboot.py       |  3 ---
 catalyst/targets/stage4.py        |  1 -
 6 files changed, 1 insertion(+), 51 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b9c220d0..a75dbdf9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -498,7 +498,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
             "setup_environment",
             "run_local",
             "preclean",
-            "unbind",
         ])
         self.finish_sequence.extend([
             "clean",
@@ -853,40 +852,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
                                        fstype=fstype, options=options)
                 cxt.mount()
             except OSError as e:
-                self.unbind()
                 raise CatalystError(f"Couldn't mount: {source}, {e.strerror}")
 
-    def unbind(self):
-        chroot_path = self.settings["chroot_path"]
-        umount_failed = False
-
-        # Unmount in reverse order
-        for target in [Path(chroot_path + self.mount[x]['target'])
-                       for x in reversed(self.mount)
-                       if self.mount[x]['enable']]:
-            if not target.exists():
-                log.debug('%s does not exist. Skipping', target)
-                continue
-
-            if not ismount(target):
-                log.debug('%s is not a mount point. Skipping', target)
-                continue
-
-            try:
-                cxt = libmount.Context(target=str(target))
-                cxt.umount()
-            except OSError as e:
-                log.warning("Couldn't umount: %s, %s", target,
-                            e.strerror)
-                umount_failed = True
-
-        if umount_failed:
-            # if any bind mounts really failed, then we need to raise
-            # this to potentially prevent an upcoming bash stage cleanup script
-            # from wiping our bind mounts.
-            raise CatalystError(
-                "Couldn't umount one or more bind-mounts; aborting for safety.")
-
     def chroot_setup(self):
         self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] +
                                                self.settings["make_conf"]))
@@ -1190,7 +1157,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                         env=self.env)
                     self.resume.enable("remove")
             except:
-                self.unbind()
                 raise
 
     def preclean(self):
@@ -1206,7 +1172,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                 self.resume.enable("preclean")
 
         except:
-            self.unbind()
             raise CatalystError("Build failed, could not execute preclean")
 
     def capture(self):
@@ -1269,7 +1234,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                          self.settings['controller_file'])
 
         except CatalystError:
-            self.unbind()
             raise CatalystError("Stage build aborting due to error.",
                                 print_traceback=False)
 
@@ -1374,7 +1338,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                     env=self.env)
                 log.info('unmerge shell script')
             except CatalystError:
-                self.unbind()
                 raise
             self.resume.enable("unmerge")
 
@@ -1449,7 +1412,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                     fileutils.touch(build_packages_resume)
                     self.resume.enable("build_packages")
                 except CatalystError:
-                    self.unbind()
                     raise CatalystError(
                         self.settings["spec_prefix"] +
                         "build aborting due to error.")
@@ -1473,7 +1435,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                     self._build_kernel(kname=kname)
                 self.resume.enable("build_kernel")
             except CatalystError:
-                self.unbind()
                 raise CatalystError(
                     "build aborting due to kernel build error.",
                     print_traceback=True)
@@ -1517,7 +1478,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
         key = 'boot/kernel/' + kname + '/config'
         if key in self.settings:
             if not os.path.exists(self.settings[key]):
-                self.unbind()
                 raise CatalystError("Can't find kernel config: %s" %
                                     self.settings[key])
 
@@ -1526,7 +1486,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
                             self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
 
             except IOError:
-                self.unbind()
+                raise
 
     def _copy_initramfs_overlay(self, kname):
         key = 'boot/kernel/' + kname + '/initramfs_overlay'
@@ -1556,7 +1516,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                 env=self.env)
             self.resume.enable("bootloader")
         except CatalystError:
-            self.unbind()
             raise CatalystError("Script aborting due to error.")
 
     def livecd_update(self):
@@ -1572,7 +1531,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
             self.resume.enable("livecd_update")
 
         except CatalystError:
-            self.unbind()
             raise CatalystError(
                 "build aborting due to livecd_update error.")
 

diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 1314ce7c..e9138437 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -56,7 +56,6 @@ class embedded(StageBase):
             "root_overlay",
             "fsscript",
             "unmerge",
-            "unbind",
         ])
         self.finish_sequence.extend([
             "remove",

diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index 81367053..5c5e9f58 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -34,7 +34,6 @@ class livecd_stage1(StageBase):
             "chroot_setup",
             "setup_environment",
             "build_packages",
-            "unbind",
         ])
         self.finish_sequence.extend([
             "clean",

diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index f6c14919..3606047f 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -80,7 +80,6 @@ class livecd_stage2(StageBase):
                     for x in self.settings["livecd/modblacklist"]:
                         myf.write("\nblacklist "+x)
             except:
-                self.unbind()
                 raise CatalystError("Couldn't open " +
                                     self.settings["chroot_path"] +
                                     "/etc/modprobe.d/blacklist.conf.",
@@ -109,7 +108,6 @@ class livecd_stage2(StageBase):
                 "fsscript",
                 "rcupdate",
                 "unmerge",
-                "unbind",
             ])
             self.finish_sequence.extend([
                 "remove",

diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 9a0a4156..55f4dff1 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -93,7 +93,6 @@ class netboot(StageBase):
                 cmd([self.settings['controller_file'], 'image'] +
                     myfiles, env=self.env)
             except CatalystError:
-                self.unbind()
                 raise CatalystError("Failed to copy files to image!",
                                     print_traceback=True)
 
@@ -121,7 +120,6 @@ class netboot(StageBase):
             cmd([self.settings['controller_file'], 'final'], env=self.env)
             log.notice('Netboot Build Finished!')
         except CatalystError:
-            self.unbind()
             raise CatalystError("Failed to move kernel images!",
                                 print_traceback=True)
 
@@ -178,7 +176,6 @@ class netboot(StageBase):
             "move_kernels",
             "remove",
             "empty",
-            "unbind",
         ])
         self.finish_sequence.extend([
             "clean",

diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 78a5c780..b7f74b01 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -57,7 +57,6 @@ class stage4(StageBase):
             "preclean",
             "rcupdate",
             "unmerge",
-            "unbind",
         ])
         self.finish_sequence.extend([
             "remove",


             reply	other threads:[~2020-12-19 19:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 22:41 Matt Turner [this message]
2020-12-19 19:56 ` [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/ Matt Turner
  -- strict thread matches above, loose matches on Subject: below --
2021-01-28  1:54 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/targets/ Matt Turner
2021-01-23 16:22 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/base/ Matt Turner
2020-10-30 22:41 Matt Turner
2020-04-22  5:52 Matt Turner
2020-04-13 20:36 Matt Turner
2015-12-15 17:13 Brian Dolbec
2015-10-06 13:46 Mike Frysinger
2015-02-26 20:44 [gentoo-commits] proj/catalyst:pending " Brian Dolbec
2015-02-26 22:18 ` [gentoo-commits] proj/catalyst:master " Brian Dolbec
2015-02-26 20:44 [gentoo-commits] proj/catalyst:pending commit in: catalyst/base/, catalyst/targets/ Brian Dolbec
2015-02-26 22:18 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/base/ Brian Dolbec
2015-02-26 19:25 [gentoo-commits] proj/catalyst:pending commit in: catalyst/base/, catalyst/targets/ Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/base/ Brian Dolbec
2015-02-26 19:25 [gentoo-commits] proj/catalyst:pending commit in: catalyst/base/, catalyst/targets/ Brian Dolbec
2015-02-26 20:12 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/base/ Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1604097652.4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f.mattst88@gentoo \
    --to=mattst88@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox