--- /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 <limits.h>
+#include <stdlib.h>
+
+#include "command.h"
+#include "dist.h"
+
+#include <pakfire/dist.h>
+#include <pakfire/pakfire.h>
+
+#define MAX_MAKEFILES 128
+
+struct config {
+ const char* resultdir;
+};
+
+static void help(void) {
+ printf(
+ "%s [OPTIONS...] dist MAKEFILES...\n\n"
+ "Options:\n"
+ " -h --help Show help\n",
+ program_invocation_short_name
+ );
+
+ exit(0);
+}
+
+static int parse_argv(int argc, char* argv[]) {
+ static const struct option options[] = {
+ { "help", no_argument, NULL, 'h' },
+ { NULL },
+ };
+ int c;
+
+ for (;;) {
+ c = getopt_long(argc, argv, "h", options, NULL);
+ if (c < 0)
+ break;
+
+ switch (c) {
+ case 'h':
+ help();
+
+ case '?':
+ return -EINVAL;
+
+ default:
+ break;
+ }
+ }
+
+ return 0;
+}
+
+int cli_dist(struct pakfire* pakfire, int argc, char* argv[]) {
+ struct config config = {
+ .resultdir = NULL,
+ };
+ char cwd[PATH_MAX];
+ int r;
+
+ // Parse commandline
+ r = parse_argv(argc, argv);
+ if (r)
+ return r;
+
+ // Set result directory to PWD
+ if (!config.resultdir)
+ config.resultdir = getcwd(cwd, sizeof(cwd));
+
+ // Run for all arguments
+ for (int i = optind; i < argc; i++) {
+ r = pakfire_dist(pakfire, argv[i], config.resultdir, NULL);
+ if (r)
+ break;
+ }
+
+ return r;
+}
--- /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_DIST_H
+#define PAKFIRE_CLI_DIST_H
+
+#include <pakfire/pakfire.h>
+
+int cli_dist(struct pakfire* pakfire, int argc, char* argv[]);
+
+#endif /* PAKFIRE_CLI_DIST_H */
#include "lib/clean.h"
#include "lib/command.h"
+#include "lib/dist.h"
#include "lib/info.h"
#include "lib/provides.h"
#include "lib/repolist.h"
static int cli_main(struct pakfire* pakfire, int argc, char* argv[]) {
static const struct command commands[] = {
{ "clean", 0, cli_clean },
+ { "dist", 0, cli_dist },
{ "info", 0, cli_info },
{ "provides", 0, cli_provides },
{ "repolist", 0, cli_repolist },