1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-18 18:15:09 +03:00

commands: add a shell command

This command spawns an interactive shell on your host but inside the
user and mount namespaces that pmbootstrap set up. It is mostly useful
for debugging issues with permissions, etc.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
This commit is contained in:
Casey Connolly 2025-05-03 20:33:27 +02:00
parent 5ce9b22ab6
commit 4302531d99
No known key found for this signature in database
GPG key ID: 0583312B195F64B6
3 changed files with 21 additions and 0 deletions

View file

@ -17,6 +17,7 @@ from .pkgrel_bump import PkgrelBump
from .pkgver_bump import PkgverBump
from .pull import Pull
from .kconfig import KConfigCheck, KConfigEdit, KConfigMigrate
from .shell import Shell
"""New way to model pmbootstrap subcommands that can be invoked without PmbArgs."""
@ -89,6 +90,8 @@ def run_command(args: PmbArgs) -> None:
command = PkgverBump(args.packages)
case "pull":
command = Pull()
case "shell":
command = Shell()
case "kconfig":
match args.action_kconfig:
case "check":

14
pmb/commands/shell.py Normal file
View file

@ -0,0 +1,14 @@
# Copyright 2024 Caleb Connolly
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations
from pmb import commands
import pmb.helpers.run
class Shell(commands.Command):
def __init__(self) -> None:
pass
def run(self) -> None:
pmb.helpers.run.user(["sh", "-i"], output="tui", check=False)

View file

@ -1008,6 +1008,10 @@ def get_parser() -> argparse.ArgumentParser:
log.add_argument("-n", "--lines", type=int, default=60, help="count of initial output lines")
log.add_argument("-c", "--clear", help="clear the log", action="store_true", dest="clear_log")
# Actions: shell
# Spawn a shell after unshare()
sub.add_parser("shell", help="Spawn a shell after unsharing namespaces (DEBUGGING)")
# Action: zap
zap = sub.add_parser("zap", help="safely delete chroot folders")
zap.add_argument(