1 |
commit: 87b0588ab4f77e413c250a4a3e357624ec41c374 |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jan 18 16:52:20 2021 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jan 23 16:22:22 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=87b0588a |
7 |
|
8 |
catalyst: Add option to enter the chroot before building |
9 |
|
10 |
With --enter-chroot, after the mounts and environment are set up, |
11 |
catalyst will drop you into a shell inside the chroot. Useful for |
12 |
hacking or debugging. |
13 |
|
14 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
15 |
|
16 |
catalyst/base/stagebase.py | 16 +++++++++++++++- |
17 |
catalyst/main.py | 4 ++++ |
18 |
doc/catalyst.1.txt | 3 +++ |
19 |
3 files changed, 22 insertions(+), 1 deletion(-) |
20 |
|
21 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
22 |
index 40b60af3..676206ff 100644 |
23 |
--- a/catalyst/base/stagebase.py |
24 |
+++ b/catalyst/base/stagebase.py |
25 |
@@ -20,7 +20,7 @@ from catalyst import log |
26 |
from catalyst.context import namespace |
27 |
from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN) |
28 |
from catalyst.support import (CatalystError, file_locate, normpath, |
29 |
- cmd, read_makeconf, get_repo_name, ismount, |
30 |
+ cmd, command, read_makeconf, get_repo_name, |
31 |
file_check, sanitize_name) |
32 |
from catalyst.base.targetbase import TargetBase |
33 |
from catalyst.base.clearbase import ClearBase |
34 |
@@ -95,6 +95,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
35 |
self.chroot_setup, |
36 |
self.setup_environment, |
37 |
] |
38 |
+ if 'enter-chroot' in self.settings['options']: |
39 |
+ self.build_sequence.append(self.enter_chroot) |
40 |
+ |
41 |
self.finish_sequence = [] |
42 |
|
43 |
self.set_valid_build_kernel_vars(addlargs) |
44 |
@@ -1326,6 +1329,17 @@ class StageBase(TargetBase, ClearBase, GenBase): |
45 |
|
46 |
log.debug('setup_environment(); env = %r', self.env) |
47 |
|
48 |
+ def enter_chroot(self): |
49 |
+ chroot = command('chroot') |
50 |
+ bash = command('bash') |
51 |
+ |
52 |
+ log.notice("Entering chroot") |
53 |
+ try: |
54 |
+ cmd([chroot, self.settings['chroot_path'], bash, '-l'], |
55 |
+ env=self.env) |
56 |
+ except CatalystError: |
57 |
+ pass |
58 |
+ |
59 |
def run(self): |
60 |
self.chroot_lock.write_lock() |
61 |
|
62 |
|
63 |
diff --git a/catalyst/main.py b/catalyst/main.py |
64 |
index 48daf004..b0d9015f 100644 |
65 |
--- a/catalyst/main.py |
66 |
+++ b/catalyst/main.py |
67 |
@@ -120,6 +120,8 @@ def get_parser(): |
68 |
parser.add_argument('-V', '--version', |
69 |
action='version', version=get_version(), |
70 |
help='display version information') |
71 |
+ parser.add_argument('--enter-chroot', default=False, action='store_true', |
72 |
+ help='Enter chroot before starting the build') |
73 |
|
74 |
group = parser.add_argument_group('Program output options') |
75 |
group.add_argument('-d', '--debug', |
76 |
@@ -293,6 +295,8 @@ def _main(parser, opts): |
77 |
options.append('purgetmponly') |
78 |
if opts.clear_autoresume: |
79 |
options.append('clear-autoresume') |
80 |
+ if opts.enter_chroot: |
81 |
+ options.append('enter-chroot') |
82 |
|
83 |
# Make sure we have some work before moving further. |
84 |
if not myspecfile and not mycmdline: |
85 |
|
86 |
diff --git a/doc/catalyst.1.txt b/doc/catalyst.1.txt |
87 |
index 90d5a24b..217fc86a 100644 |
88 |
--- a/doc/catalyst.1.txt |
89 |
+++ b/doc/catalyst.1.txt |
90 |
@@ -39,6 +39,9 @@ configuration file is installed at '/etc/catalyst/catalyst.conf'. |
91 |
*-d*:: |
92 |
Enable debugging mode |
93 |
|
94 |
+*--enter-chroot*:: |
95 |
+Enter the chroot before starting the build. |
96 |
+ |
97 |
*--fetchonly*:: |
98 |
*-F*:: |
99 |
This tells *catalyst* to only fetch distfiles for the given packages without |