osmith has uploaded this change for review.

View Change

testenv: add --install-packages

Add an option to quickly install packages in the container. This is
useful when making a new SUT run with osmo-ttcn3-hacks and figuring out
which packages need to be installed to make the build pass (without
rebuilding the whole container for each missing dependency). It can also
be used to quickly install additional debugging tools (strace, valgrind,
etc.). A cache for the deb files is already getting mounted inside the
container.

Change-Id: Ie54817e6c0334a224a612521beb378537c10d39d
---
M _testenv/testenv/__init__.py
M _testenv/testenv/podman.py
2 files changed, 13 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/15/41215/1
diff --git a/_testenv/testenv/__init__.py b/_testenv/testenv/__init__.py
index 44259c2..35338a4 100644
--- a/_testenv/testenv/__init__.py
+++ b/_testenv/testenv/__init__.py
@@ -210,6 +210,13 @@
action="store_true",
help="run an interactive shell before stopping daemons/container",
)
+ group.add_argument(
+ "-I",
+ "--install-packages",
+ action="append",
+ metavar="PACKAGE",
+ help="temporarily install debian packages in the container",
+ )

group = sub_run.add_argument_group("output options")
group.add_argument(
@@ -272,6 +279,9 @@
if args.kernel == "debian" and not args.podman:
raise NoTraceException("--kernel-debian requires --podman")

+ if args.install_packages and not args.podman:
+ raise NoTraceException("--install-packages requires --podman")
+
if args.kernel == "custom" and not os.path.exists(custom_kernel_path):
logging.critical(
"See _testenv/README.md for more information on downloading a pre-built kernel or building your own kernel."
diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py
index 678a0c1..2013699 100644
--- a/_testenv/testenv/podman.py
+++ b/_testenv/testenv/podman.py
@@ -285,6 +285,9 @@
if not os.path.exists(pkgcache):
exec_cmd(["apt-get", "-q", "update"])

+ if testenv.args.install_packages:
+ exec_cmd(["apt-get", "install", "-y", "--no-install-recommends"] + testenv.args.install_packages)
+

def check_titan_version():
version, _ = testenv.testenv_cfg.get_titan_version_first_cfg()

To view, visit change 41215. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ie54817e6c0334a224a612521beb378537c10d39d
Gerrit-Change-Number: 41215
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>