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