--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2023 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#include <errno.h>
+#include <getopt.h>
+#include <stdlib.h>
+
+#include "command.h"
+#include "shell.h"
+
+#include <pakfire/build.h>
+#include <pakfire/pakfire.h>
+
+#define MAX_PACKAGES 128
+
+struct config {
+ int flags;
+ const char* packages[MAX_PACKAGES];
+ unsigned int num_packages;
+};
+
+static void help(void) {
+ printf(
+ "%s [OPTIONS...] shell [OPTIONS...]\n\n"
+ "Options:\n"
+ " --disable-snapshot Do not use the snapshot\n"
+ " --install PACKAGE Installs the given package\n"
+ " -h --help Show help\n",
+ program_invocation_short_name
+ );
+
+ exit(0);
+}
+
+static int parse_argv(struct config* config, int argc, char* argv[]) {
+ enum {
+ ARG_DISABLE_SNAPSHOT,
+ ARG_INSTALL,
+ };
+
+ static const struct option options[] = {
+ { "disable-snapshot", no_argument, NULL, ARG_DISABLE_SNAPSHOT },
+ { "help", no_argument, NULL, 'h' },
+ { "install", required_argument, NULL, ARG_INSTALL },
+ { NULL },
+ };
+ int c;
+
+ for (;;) {
+ c = getopt_long(argc, argv, "h", options, NULL);
+ if (c < 0)
+ break;
+
+ switch (c) {
+ case 'h':
+ help();
+
+ case ARG_DISABLE_SNAPSHOT:
+ config->flags |= PAKFIRE_BUILD_DISABLE_SNAPSHOT;
+ break;
+
+ case ARG_INSTALL:
+ if (config->num_packages >= MAX_PACKAGES)
+ return -ENOBUFS;
+
+ config->packages[config->num_packages++] = optarg;
+ break;
+
+ case '?':
+ return -EINVAL;
+
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}
+
+int cli_shell(struct pakfire* pakfire, int argc, char* argv[]) {
+ struct config config = {
+ .packages = { NULL },
+ .num_packages = 0,
+ };
+ int r;
+
+ // Parse commandline
+ r = parse_argv(&config, argc, argv);
+ if (r)
+ return r;
+
+ return pakfire_shell(pakfire, config.packages, config.flags);
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2023 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+#############################################################################*/
+
+#ifndef PAKFIRE_CLI_SHELL_H
+#define PAKFIRE_CLI_SHELL_H
+
+#include <pakfire/pakfire.h>
+
+int cli_shell(struct pakfire* pakfire, int argc, char* argv[]);
+
+#endif /* PAKFIRE_CLI_SHELL_H */
#include "lib/provides.h"
#include "lib/repolist.h"
#include "lib/requires.h"
+#include "lib/shell.h"
#include "lib/search.h"
#include "lib/terminal.h"
#include "lib/version.h"
{ "provides", 0, cli_provides },
{ "repolist", 0, cli_repolist },
{ "requires", 0, cli_requires },
+ { "shell", 0, cli_shell },
{ "search", 0, cli_search },
{ NULL },
};