From: Michael Tremer Date: Fri, 20 Oct 2023 11:26:05 +0000 (+0000) Subject: cli: Add option to configure the default distro X-Git-Tag: 0.9.30~1423 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=961d9b9e2c5cc5606545e42d2b7738e1ee12fb0d;p=pakfire.git cli: Add option to configure the default distro Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index ea33933e0..a98ec3f56 100644 --- a/Makefile.am +++ b/Makefile.am @@ -471,6 +471,8 @@ libcli_la_SOURCES = \ src/cli/lib/color.h \ src/cli/lib/command.c \ src/cli/lib/command.h \ + src/cli/lib/config.c \ + src/cli/lib/config.h \ src/cli/lib/dist.c \ src/cli/lib/dist.h \ src/cli/lib/dump.c \ diff --git a/contrib/config/pakfire.conf b/contrib/config/pakfire.conf index d44e568c6..ea765aa75 100644 --- a/contrib/config/pakfire.conf +++ b/contrib/config/pakfire.conf @@ -8,6 +8,10 @@ # Proxy (HTTPS + HTTP) #proxy = http://192.168.180.1:800 +# Build Configuration +[build] +distro = ipfire3 + # Pakfire Client Configuration [client] diff --git a/src/cli/lib/config.c b/src/cli/lib/config.c new file mode 100644 index 000000000..92cf14dfc --- /dev/null +++ b/src/cli/lib/config.c @@ -0,0 +1,45 @@ +/*############################################################################# +# # +# 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 "config.h" + +const char* cli_get_default_distro(struct pakfire_ctx* ctx) { + struct pakfire_config* config = NULL; + const char* distro = NULL; + +#if 0 + // Fetch the configuration + config = pakfire_ctx_get_config(ctx); + if (!config) + return NULL; + + // Fetch the distro + distro = pakfire_config_get(config, "build", "distro", NULL); + + // Cleanup + if (config) + pakfire_config_unref(config); +#endif + + return distro; +} diff --git a/src/cli/lib/config.h b/src/cli/lib/config.h new file mode 100644 index 000000000..f6a4da82f --- /dev/null +++ b/src/cli/lib/config.h @@ -0,0 +1,28 @@ +/*############################################################################# +# # +# 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_CONFIG_H +#define PAKFIRE_CLI_CONFIG_H + +#include + +const char* cli_get_default_distro(struct pakfire_ctx* ctx); + +#endif /* PAKFIRE_CLI_CONFIG_H */ diff --git a/src/cli/pakfire-builder.c b/src/cli/pakfire-builder.c index 75fb65a42..a43183efe 100644 --- a/src/cli/pakfire-builder.c +++ b/src/cli/pakfire-builder.c @@ -32,6 +32,7 @@ #include "lib/build.h" #include "lib/clean.h" #include "lib/command.h" +#include "lib/config.h" #include "lib/dist.h" #include "lib/image.h" #include "lib/info.h" @@ -147,8 +148,7 @@ int main(int argc, char* argv[]) { struct cli_config config = { .ctx = ctx, - // XXX hard-coded distro - .distro = "ipfire3", + .distro = cli_get_default_distro(ctx), .arch = NULL, .flags = PAKFIRE_FLAGS_BUILD, }; diff --git a/src/cli/pakfire-client.c b/src/cli/pakfire-client.c index 067882b88..06f1533d7 100644 --- a/src/cli/pakfire-client.c +++ b/src/cli/pakfire-client.c @@ -87,6 +87,7 @@ int main(int argc, char* argv[]) { struct cli_config config = { .ctx = ctx, + .distro = cli_get_default_distro(ctx), }; // Parse the command line and run any commands