]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
shell: Allow passing extra packages to install
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 May 2022 17:52:53 +0000 (17:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 May 2022 17:52:53 +0000 (17:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/build.c
src/libpakfire/include/pakfire/build.h
src/scripts/pakfire-builder.in

index d67330ae1d5615bd74c538df822438ff008e54a4..6f31889c6b64180cf7509b83c35ca8c45ab29b9f 100644 (file)
@@ -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,
        },
        {
index 12e951814a32cbcc7500648727f7e9a034420bdb..d536346f17145c4b7b4a9aa057060bc19a4180d3 100644 (file)
@@ -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)
index 68741dcdc82b5c1aca23e78fd4f4227331252403..63018d5d14c38620eedaf0bb2407ce0df29e576e 100644 (file)
@@ -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 */
index e2f697f94fd8f0bcdefac8b814517d665ec0df16..1b9f4eb76c9b9e3db53bc2b8d10f6b842e41fab0 100644 (file)
@@ -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: