From: Michael Tremer Date: Fri, 20 May 2022 17:52:53 +0000 (+0000) Subject: shell: Allow passing extra packages to install X-Git-Tag: 0.9.28~772 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f068a0855ad997a098fdfa4c9a2cf2e75d699e2;p=pakfire.git shell: Allow passing extra packages to install Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index d67330ae1..6f31889c6 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -1085,8 +1085,18 @@ static PyObject* Pakfire_build(PakfireObject* self, PyObject* args, PyObject* kw return execute_return_value(r); } -static PyObject* Pakfire_shell(PakfireObject* self) { - int r = pakfire_shell(self->pakfire); +static PyObject* Pakfire_shell(PakfireObject* self, PyObject* args, PyObject* kwargs) { + char* kwlist[] = { + "install", + NULL, + }; + char** packages = NULL; + + // Parse everything + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O&", kwlist, convert_packages, &packages)) + return NULL; + + int r = pakfire_shell(self->pakfire, (const char**)packages); return execute_return_value(r); } @@ -1357,7 +1367,7 @@ static struct PyMethodDef Pakfire_methods[] = { { "shell", (PyCFunction)Pakfire_shell, - METH_NOARGS, + METH_VARARGS|METH_KEYWORDS, NULL, }, { diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 12e951814..d536346f1 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -885,7 +885,7 @@ ERROR: return r; } -PAKFIRE_EXPORT int pakfire_shell(struct pakfire* pakfire) { +PAKFIRE_EXPORT int pakfire_shell(struct pakfire* pakfire, const char** packages) { int r; // Setup build environment @@ -893,6 +893,13 @@ PAKFIRE_EXPORT int pakfire_shell(struct pakfire* pakfire) { if (r) return r; + // Install any additional packages + if (packages) { + r = pakfire_install(pakfire, 0, packages, NULL, 0, NULL, NULL, NULL); + if (r) + return r; + } + // Export local repository if running in interactive mode r = pakfire_build_enable_repos(pakfire); if (r) diff --git a/src/libpakfire/include/pakfire/build.h b/src/libpakfire/include/pakfire/build.h index 68741dcdc..63018d5d1 100644 --- a/src/libpakfire/include/pakfire/build.h +++ b/src/libpakfire/include/pakfire/build.h @@ -26,7 +26,7 @@ int pakfire_build(struct pakfire* pakfire, const char* path, const char* target, const char* id, int flags, pakfire_execute_logging_callback logging_callback, void* data); -int pakfire_shell(struct pakfire* pakfire); +int pakfire_shell(struct pakfire* pakfire, const char** packages); int pakfire_build_clean(struct pakfire* pakfire, int flags); #endif /* PAKFIRE_BUILD_H */ diff --git a/src/scripts/pakfire-builder.in b/src/scripts/pakfire-builder.in index e2f697f94..1b9f4eb76 100644 --- a/src/scripts/pakfire-builder.in +++ b/src/scripts/pakfire-builder.in @@ -150,6 +150,9 @@ class Cli(object): # shell shell = subparsers.add_parser("shell", help=_("Go into a build shell")) + shell.add_argument("--install", nargs="*", + help=_("Install additional packages"), + ) shell.set_defaults(func=self._shell) args = parser.parse_args() @@ -292,7 +295,7 @@ class Cli(object): p = self.pakfire(ns) try: - p.shell() + p.shell(install=ns.install) # Exit program with the shell's exit code except pakfire.errors.CommandExecutionError as e: