diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-11-02 16:20:08 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-11-02 16:20:08 +0200 |
commit | 6e1f1350e73a57b2b4a6621227b66477d85a4850 (patch) | |
tree | 4d7c9af5664d825b90688e2504c6d6c353ded462 | |
parent | d286c58d728ec40e02bfb44ffd50ce7a92f777dc (diff) | |
download | debian-subplot-6e1f1350e73a57b2b4a6621227b66477d85a4850.tar.gz |
feat: install and remove a package
Sponsored-by: author
-rw-r--r-- | debian.md | 23 | ||||
-rw-r--r-- | debian.py | 14 | ||||
-rw-r--r-- | debian.yaml | 5 |
3 files changed, 37 insertions, 5 deletions
@@ -57,3 +57,26 @@ given a Debian system when I run, as debian, sudo apt update then command is successful ~~~ + +## Can install and remove a package + +_Requirement: The system administrator can install and remove a +package._ + +Justification: Without this, it may be impossible to install a bug fix +or security update. + +The scenario uses the `liwc` package, which is rarely used or +installed by anyone. If your Debian system does have it, this will +fail and you will need to edit the scenario to use a different +package. + +~~~scenario +given a Debian system +when I try to run, as debian, dpkg -l liwc +then command fails +when I run, as debian, sudo apt update +when I run, as debian, sudo apt install -y liwc +when I run, as debian, sudo apt remove -y liwc +then command is successful +~~~ @@ -15,13 +15,17 @@ def debian_system(ctx, hostname=None): def run_as_on_host(ctx, username=None, argv0=None, args=None): - runcmd_run = globals()["runcmd_run"] runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"] + try_to_run_as_on_host(ctx, username=username, argv0=argv0, args=args) + runcmd_exit_code_is_zero(ctx) + - logging.debug(f"run_as_on_host: username={username!r}") - logging.debug(f"run_as_on_host: argv0={argv0!r}") - logging.debug(f"run_as_on_host: args={args!r}") +def try_to_run_as_on_host(ctx, username=None, argv0=None, args=None): + runcmd_run = globals()["runcmd_run"] + + logging.debug(f"try_to_run_as_on_host: username={username!r}") + logging.debug(f"try_to_run_as_on_host: argv0={argv0!r}") + logging.debug(f"try_to_run_as_on_host: args={args!r}") target = f"{username}@{ctx['hostname']}" argv = ["ssh", target, "--", shlex.quote(argv0)] + shlex.split(args) runcmd_run(ctx, argv) - runcmd_exit_code_is_zero(ctx) diff --git a/debian.yaml b/debian.yaml index 45497ee..c488841 100644 --- a/debian.yaml +++ b/debian.yaml @@ -7,3 +7,8 @@ impl: python: function: run_as_on_host + +- when: I try to run, as {username}, {argv0}{args:text} + impl: + python: + function: try_to_run_as_on_host |