From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 96FF713835A for ; Fri, 30 Oct 2020 22:41:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 37768E0870; Fri, 30 Oct 2020 22:41:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0FB39E0870 for ; Fri, 30 Oct 2020 22:41:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 027F0340B23 for ; Fri, 30 Oct 2020 22:41:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 17FAD431 for ; Fri, 30 Oct 2020 22:41:07 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1604097652.4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/targets/embedded.py catalyst/targets/livecd_stage1.py catalyst/targets/livecd_stage2.py catalyst/targets/netboot.py catalyst/targets/stage4.py X-VCS-Directories: catalyst/base/ catalyst/targets/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f X-VCS-Branch: master Date: Fri, 30 Oct 2020 22:41:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d18a58e9-7bdd-44d5-96e3-ca11308e3d11 X-Archives-Hash: fcabdc25bc4501564b4f7e4b02343e3b commit: 4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f Author: Matt Turner gentoo org> AuthorDate: Thu Oct 22 20:37:54 2020 +0000 Commit: Matt Turner gentoo 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 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", From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 237091382C5 for ; Sat, 19 Dec 2020 19:56:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B88F42BC01D; Sat, 19 Dec 2020 19:56:06 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8A3EB2BC01D for ; Sat, 19 Dec 2020 19:56:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0EB6B341029 for ; Sat, 19 Dec 2020 19:56:05 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 332A739F for ; Sat, 19 Dec 2020 19:56:02 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1604097652.4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:wip/mattst88 commit in: catalyst/targets/, catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/targets/embedded.py catalyst/targets/livecd_stage1.py catalyst/targets/livecd_stage2.py catalyst/targets/netboot.py catalyst/targets/stage4.py X-VCS-Directories: catalyst/targets/ catalyst/base/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f X-VCS-Branch: wip/mattst88 Date: Sat, 19 Dec 2020 19:56:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: fcd67b86-4b04-4f7a-94b5-a242678c4b05 X-Archives-Hash: be0cf718832dd9e3022d650fa9a3d751 Message-ID: <20201219195602.JrhwFz2wK3nZ6C6Z6_Wxm1MZiuRp-CvPYnfU_LkrgEI@z> commit: 4b5ff905a7ad2ffe1ed8c863b91e9d0ce6981f5f Author: Matt Turner gentoo org> AuthorDate: Thu Oct 22 20:37:54 2020 +0000 Commit: Matt Turner gentoo 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 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",