def __init__(self, arch, first_install=False, debug=False, unattended=False, disks=[]):
self.arch = arch
self.first_install = first_install
+ self.debug = debug
self.unattended = unattended
# Enable debug logging
with open("/etc/os-release") as f:
return util.config_read(f)
- def command(self, command, error_ok=False):
+ def command(self, command, error_ok=False, interactive=False):
"""
Runs a command in a shell environment
"""
log.debug("Running command: %s" % " ".join(command))
+ args = {}
+
+ if not interactive:
+ args.update({
+ "stdout" : subprocess.PIPE,
+ "stderr" : subprocess.STDOUT,
+ })
+
# Execute the command
- p = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ p = subprocess.run(command, **args)
# Check the return code (raises CalledProcessError on non-zero)
if not error_ok:
p.check_returncode()
+ # There is no output in interactive mode
+ if interactive:
+ return
+
# Decode output
output = p.stdout.decode()
# Wipe the screen
self._finish_screen()
+ def shell(self):
+ """
+ Opens a debug shell
+ """
+ if not self.screen:
+ return
+
+ # Hide the installer
+ self.screen.suspend()
+
+ # Show a message how to return to the installer
+ print(_("Type <exit> to return to the install program\n"))
+
+ self.bricklayer.command(["/bin/bash", "--login"], interactive=True, error_ok=True)
+
+ # Bring back the installer
+ self.screen.resume()
+
def refresh(self):
"""
Refreshes what is written on the screen
# Setup helpline
helpline = []
+ # Show how to get to shell in debug mode
+ if self.bricklayer.debug:
+ helpline.append(
+ _("<Ctrl-Z> Shell")
+ )
+
# Show key commands only when they are useful
if not self.bricklayer.unattended:
helpline += (
# Refresh the screen
self.refresh()
+ # Set the suspend callback
+ self.screen.suspendCallback(self.shell)
+
def _finish_screen(self):
"""
Cleanup screen