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 01FC6138351 for ; Thu, 30 Apr 2020 22:56:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0A13CE0A7E; Thu, 30 Apr 2020 22:56:26 +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 97D98E0A7E for ; Thu, 30 Apr 2020 22:56:25 +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 080E234F0B7 for ; Thu, 30 Apr 2020 22:56:24 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A5350204 for ; Thu, 30 Apr 2020 22:56:22 +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: <1587666035.4c4a82badb5ef8bd472dae7b530ef87a4c1f9127.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/base/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py X-VCS-Directories: catalyst/base/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 4c4a82badb5ef8bd472dae7b530ef87a4c1f9127 X-VCS-Branch: master Date: Thu, 30 Apr 2020 22:56:22 +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: 70a98951-ba17-499c-b416-370f98f3fae6 X-Archives-Hash: 66e5c23cbf7e72514d27d15682117b46 commit: 4c4a82badb5ef8bd472dae7b530ef87a4c1f9127 Author: Matt Turner gentoo org> AuthorDate: Sun Apr 19 01:10:51 2020 +0000 Commit: Matt Turner gentoo org> CommitDate: Thu Apr 23 18:20:35 2020 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4c4a82ba catalyst: Clean up bind() Signed-off-by: Matt Turner gentoo.org> catalyst/base/stagebase.py | 62 +++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 275c07eb..9aecf013 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -906,35 +906,41 @@ class StageBase(TargetBase, ClearBase, GenBase): def bind(self): for x in [x for x in self.mount if self.mount[x]['enable']]: - log.debug('bind(); x = %s', x) - target = normpath(self.settings['chroot_path'] + - self.mount[x]['target']) - ensure_dirs(target, mode=0o755) - - if not os.path.exists(self.mount[x]['source']): - if self.mount[x]['source'] not in ("maybe_tmpfs", "tmpfs", "shmfs"): - ensure_dirs(self.mount[x]['source'], mode=0o755) - - src = self.mount[x]['source'] - log.debug('bind(); src = %s', src) - if src == "maybe_tmpfs": - if "var_tmpfs_portage" in self.settings: - _cmd = ['mount', '-t', 'tmpfs', - '-o', 'size=' + - self.settings['var_tmpfs_portage'] + 'G', - src, target] - elif src == "tmpfs": - _cmd = ['mount', '-t', 'tmpfs', src, target] + if str(self.mount[x]['source']) == 'config': + raise CatalystError(f'"{x}" bind mount source is not configured') + if str(self.mount[x]['target']) == 'config': + raise CatalystError(f'"{x}" bind mount target is not configured') + + source = str(self.mount[x]['source']) + target = self.settings['chroot_path'] + str(self.mount[x]['target']) + + log.debug('bind %s: "%s" -> "%s"', x, source, target) + + if source == 'maybe_tmpfs': + if 'var_tmpfs_portage' not in self.settings: + return + + _cmd = ['mount', '-t', 'tmpfs', '-o', 'size=' + + self.settings['var_tmpfs_portage'] + 'G', source, + target] + elif source == 'tmpfs': + _cmd = ['mount', '-t', 'tmpfs', source, target] + elif source == 'shmfs': + _cmd = ['mount', '-t', 'tmpfs', '-o', 'noexec,nosuid,nodev', + 'shm', target] else: - if src == "shmfs": - _cmd = ['mount', '-t', 'tmpfs', '-o', - 'noexec,nosuid,nodev', 'shm', target] - else: - _cmd = ['mount', '--bind', src, target] - if _cmd: - log.debug('bind(); _cmd = %s', _cmd) - cmd(_cmd, env=self.env, fail_func=self.unbind) - log.debug('bind(); finished :D') + _cmd = ['mount', '--bind', source, target] + + source = Path(self.mount[x]['source']) + + # We may need to create the source of the bind mount. E.g., in the + # case of an empty package cache we must create the directory that + # the binary packages will be stored into. + source.mkdir(mode=0o755, exist_ok=True) + + Path(target).mkdir(mode=0o755, parents=True, exist_ok=True) + + cmd(_cmd, env=self.env, fail_func=self.unbind) def unbind(self): ouch = 0