From: Michael Tremer Date: Fri, 20 Oct 2023 14:04:05 +0000 (+0000) Subject: buildservice: Implement deleting repositories X-Git-Tag: 0.9.30~1406 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18a14dafe09a97eed5747bc089838e4ff754e37e;p=pakfire.git buildservice: Implement deleting repositories Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/repo_delete.c b/src/cli/lib/repo_delete.c new file mode 100644 index 000000000..cf70d8822 --- /dev/null +++ b/src/cli/lib/repo_delete.c @@ -0,0 +1,93 @@ +/*############################################################################# +# # +# 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 . # +# # +#############################################################################*/ + +#include + +#include + +#include + +#include "command.h" +#include "dump.h" +#include "pakfire.h" +#include "repo_delete.h" + +static const char* args_doc = "DISTRO NAME"; + +static const char* doc = "Delete a repository"; + +struct config { + const char* distro; + const char* name; +}; + +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->distro) + config->distro = arg; + + else if (!config->name) + config->name = arg; + + else + argp_usage(state); + break; + + default: + return ARGP_ERR_UNKNOWN; + } + + return 0; +} + +int cli_repo_delete(void* data, int argc, char* argv[]) { + struct pakfire_buildservice* service = NULL; + struct json_object* repo = NULL; + struct config config = {}; + int r; + + struct cli_config* cli_config = data; + + // Parse the command line + r = cli_parse(NULL, NULL, args_doc, doc, parse, argc, argv, &config); + if (r) + goto ERROR; + + // Connect to the build service + r = pakfire_buildservice_create(&service, cli_config->ctx); + if (r) + goto ERROR; + + // Delete the repository + r = pakfire_buildservice_delete_repo(service, config.distro, config.name); + if (r) + goto ERROR; + +ERROR: + if (service) + pakfire_buildservice_unref(service); + if (repo) + json_object_put(repo); + + return r; +} diff --git a/src/cli/lib/repo_delete.h b/src/cli/lib/repo_delete.h new file mode 100644 index 000000000..4aa09620f --- /dev/null +++ b/src/cli/lib/repo_delete.h @@ -0,0 +1,26 @@ +/*############################################################################# +# # +# 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 . # +# # +#############################################################################*/ + +#ifndef PAKFIRE_CLI_REPO_DELETE_H +#define PAKFIRE_CLI_REPO_DELETE_H + +int cli_repo_delete(void* data, int argc, char* argv[]); + +#endif /* PAKFIRE_CLI_REPO_DELETE_H */