From: Matt Turner <mattst88@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Cc: Matt Turner <mattst88@gentoo.org>
Subject: [gentoo-catalyst] [PATCH 10/11] catalyst: Add option to enter the chroot before building
Date: Mon, 18 Jan 2021 15:21:51 -0500 [thread overview]
Message-ID: <20210118202152.374078-10-mattst88@gentoo.org> (raw)
In-Reply-To: <20210118202152.374078-1-mattst88@gentoo.org>
With --enter-chroot, after the mounts and environment are set up,
catalyst will drop you into a shell inside the chroot. Useful for
hacking or debugging.
Signed-off-by: Matt Turner <mattst88@gentoo.org>
---
catalyst/base/stagebase.py | 17 ++++++++++++++++-
catalyst/main.py | 4 ++++
doc/catalyst.1.txt | 3 +++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 40b60af3..02e202c1 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -20,7 +20,7 @@ from catalyst import log
from catalyst.context import namespace
from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN)
from catalyst.support import (CatalystError, file_locate, normpath,
- cmd, read_makeconf, get_repo_name, ismount,
+ cmd, command, read_makeconf, get_repo_name,
file_check, sanitize_name)
from catalyst.base.targetbase import TargetBase
from catalyst.base.clearbase import ClearBase
@@ -94,6 +94,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.bind,
self.chroot_setup,
self.setup_environment,
+ self.enter_chroot,
]
self.finish_sequence = []
@@ -1326,6 +1327,20 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.debug('setup_environment(); env = %r', self.env)
+ def enter_chroot(self):
+ if 'enter-chroot' not in self.settings['options']:
+ return
+
+ chroot = command('chroot')
+ bash = command('bash')
+
+ log.notice("Entering chroot")
+ try:
+ cmd([chroot, self.settings['chroot_path'], bash, '-l'],
+ env=self.env)
+ except CatalystError:
+ pass
+
def run(self):
self.chroot_lock.write_lock()
diff --git a/catalyst/main.py b/catalyst/main.py
index 48daf004..b0d9015f 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -120,6 +120,8 @@ def get_parser():
parser.add_argument('-V', '--version',
action='version', version=get_version(),
help='display version information')
+ parser.add_argument('--enter-chroot', default=False, action='store_true',
+ help='Enter chroot before starting the build')
group = parser.add_argument_group('Program output options')
group.add_argument('-d', '--debug',
@@ -293,6 +295,8 @@ def _main(parser, opts):
options.append('purgetmponly')
if opts.clear_autoresume:
options.append('clear-autoresume')
+ if opts.enter_chroot:
+ options.append('enter-chroot')
# Make sure we have some work before moving further.
if not myspecfile and not mycmdline:
diff --git a/doc/catalyst.1.txt b/doc/catalyst.1.txt
index 90d5a24b..217fc86a 100644
--- a/doc/catalyst.1.txt
+++ b/doc/catalyst.1.txt
@@ -39,6 +39,9 @@ configuration file is installed at '/etc/catalyst/catalyst.conf'.
*-d*::
Enable debugging mode
+*--enter-chroot*::
+Enter the chroot before starting the build.
+
*--fetchonly*::
*-F*::
This tells *catalyst* to only fetch distfiles for the given packages without
--
2.26.2
next prev parent reply other threads:[~2021-01-18 20:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 20:21 [gentoo-catalyst] [PATCH 01/11] targets: Remove unused 'enter' command Matt Turner
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 02/11] targets: Remove some obvious comments Matt Turner
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 03/11] targets: Update seed stage's sys-apps/portage Matt Turner
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 04/11] targets: Update BINPKG_COMPRESS to new zstd default Matt Turner
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 05/11] targets: Update the @changed-subslot set by default Matt Turner
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 06/11] catalyst: Store references to functions Matt Turner
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 07/11] catalyst: Call config_profile_link for all targets Matt Turner
2021-02-25 13:09 ` [gentoo-catalyst] [PATCH] Fix specifying target_profiles in repo_name:path format Daniel Cordero
2021-02-27 18:52 ` [gentoo-catalyst] " Matt Turner
2021-02-27 23:31 ` Felix Bier
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 08/11] catalyst: Deduplicate prepare_sequence assignments Matt Turner
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 09/11] catalyst: Deduplicate the common build_sequence steps Matt Turner
2021-01-18 20:21 ` Matt Turner [this message]
2021-01-18 20:21 ` [gentoo-catalyst] [PATCH 11/11] catalyst: Remove update_seed spec option Matt Turner
2021-01-19 11:02 ` Daniel Cordero
2021-01-19 14:58 ` Matt Turner
2021-01-21 5:12 ` Matt Turner
2021-01-21 10:20 ` Daniel Cordero
2021-01-22 0:04 ` Matt Turner
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=20210118202152.374078-10-mattst88@gentoo.org \
--to=mattst88@gentoo.org \
--cc=gentoo-catalyst@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