src/cli/lib/info.h \
src/cli/lib/install.h \
src/cli/lib/install.c \
+ src/cli/lib/lint.c \
+ src/cli/lib/lint.h \
src/cli/lib/pakfire.c \
src/cli/lib/pakfire.h \
src/cli/lib/progressbar.c \
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2024 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 <argp.h>
+
+#include <pakfire/archive.h>
+#include <pakfire/pakfire.h>
+
+#include "command.h"
+#include "lint.h"
+#include "pakfire.h"
+
+static const char* args_doc = "lint [OPTIONS...] ARCHIVES...";
+
+static const char* doc = "Lint archives";
+
+#define MAX_ARCHIVES 128
+
+struct config {
+ // Archives
+ char* archives[MAX_ARCHIVES];
+ unsigned int num_archives;
+};
+
+static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
+ struct config* config = data;
+
+ switch (key) {
+ case ARGP_KEY_ARG:
+ if (config->num_archives >= MAX_ARCHIVES)
+ return -ENOBUFS;
+
+ config->archives[config->num_archives++] = arg;
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+
+ return 0;
+}
+
+static int do_lint(struct pakfire* pakfire, const char* path) {
+ struct pakfire_archive* archive = NULL;
+ int r;
+
+ // Open the archive
+ r = pakfire_archive_open(&archive, pakfire, path);
+ if (r < 0) {
+ fprintf(stderr, "Could not open %s: %s\n", path, strerror(-r));
+ goto ERROR;
+ }
+
+ // Perform the linting...
+ r = pakfire_archive_lint(archive);
+ if (r < 0) {
+ fprintf(stderr, "Could not lint %s: %s\n", path, strerror(-r));
+ goto ERROR;
+ }
+
+ERROR:
+ if (archive)
+ pakfire_archive_unref(archive);
+
+ return r;
+}
+
+int cli_lint(void* data, int argc, char* argv[]) {
+ struct pakfire* pakfire = NULL;
+ int r;
+
+ struct cli_config* cli_config = data;
+
+ struct config config = {};
+
+ // Parse the command line
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ if (r)
+ goto ERROR;
+
+ // Setup Pakfire
+ r = cli_setup_pakfire(&pakfire, cli_config);
+ if (r)
+ goto ERROR;
+
+ // Lint all archives
+ for (unsigned int i = 0; i < config.num_archives; i++) {
+ r = do_lint(pakfire, config.archives[i]);
+ if (r < 0)
+ goto ERROR;
+ }
+
+ERROR:
+ if (pakfire)
+ pakfire_unref(pakfire);
+
+ return r;
+}
+
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2024 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_LINT_H
+#define PAKFIRE_CLI_LINT_H
+
+int cli_lint(void* data, int argc, char* argv[]);
+
+#endif /* PAKFIRE_CLI_LINT_H */
#include "lib/dist.h"
#include "lib/image.h"
#include "lib/info.h"
+#include "lib/lint.h"
#include "lib/pakfire.h"
#include "lib/progressbar.h"
#include "lib/provides.h"
{ "dist", cli_dist, 1, -1, 0 },
{ "image", cli_image, -1, -1, 0 },
{ "info", cli_info, 1, -1, 0 },
+ { "lint", cli_lint, 1, -1, 0 },
{ "provides", cli_provides, 1, -1, 0 },
{ "repo", cli_repo, -1, -1, 0 },
{ "repolist", cli_repolist, 0, 0, 0 },
"clean\n"
"dist MAKEFILES...\n"
"image ...\n"
+ "lint [ARCHIVE...]\n"
"provides PATTERN\n"
"repo compose PATH PACKAGES...\n"
"repolist\n"
#include <pakfire/filelist.h>
#include <pakfire/i18n.h>
#include <pakfire/jail.h>
+#include <pakfire/linter.h>
#include <pakfire/logging.h>
#include <pakfire/package.h>
#include <pakfire/pakfire.h>
return 0;
}
+
+PAKFIRE_EXPORT int pakfire_archive_lint(struct pakfire_archive* archive) {
+ struct pakfire_linter* linter = NULL;
+ int r;
+
+ // Create a new linter
+ r = pakfire_linter_create(&linter, archive->ctx, archive);
+ if (r < 0)
+ goto ERROR;
+
+ // Lint, lint, lint...
+ r = pakfire_linter_lint(linter);
+ if (r < 0)
+ goto ERROR;
+
+ERROR:
+ if (linter)
+ pakfire_linter_unref(linter);
+
+ return r;
+}
int pakfire_archive_make_package(struct pakfire_archive* archive,
struct pakfire_repo* repo, struct pakfire_package** package);
+int pakfire_archive_lint(struct pakfire_archive* archive);
+
#ifdef PAKFIRE_PRIVATE
#include <pakfire/pakfire.h>
pakfire_archive_get_format;
pakfire_archive_get_path;
pakfire_archive_get_size;
+ pakfire_archive_lint;
pakfire_archive_make_package;
pakfire_archive_open;
pakfire_archive_read;