]> git.ipfire.org Git - pakfire.git/commitdiff
cli: Add option to configure the default distro
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 Oct 2023 11:26:05 +0000 (11:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 20 Oct 2023 11:26:05 +0000 (11:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
contrib/config/pakfire.conf
src/cli/lib/config.c [new file with mode: 0644]
src/cli/lib/config.h [new file with mode: 0644]
src/cli/pakfire-builder.c
src/cli/pakfire-client.c

index ea33933e01121140848ac9f8313fec18ea655308..a98ec3f56cfb582ce2eb6ec51bf1fcbf917cccf0 100644 (file)
@@ -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 \
index d44e568c697cbb503fe14abddc50f7e71913346c..ea765aa75de474171cb8d2b8b5950a61b4666155 100644 (file)
@@ -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 (file)
index 0000000..92cf14d
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <pakfire/ctx.h>
+#include <pakfire/config.h>
+
+#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 (file)
index 0000000..f6a4da8
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifndef PAKFIRE_CLI_CONFIG_H
+#define PAKFIRE_CLI_CONFIG_H
+
+#include <pakfire/ctx.h>
+
+const char* cli_get_default_distro(struct pakfire_ctx* ctx);
+
+#endif /* PAKFIRE_CLI_CONFIG_H */
index 75fb65a42b637cb63742150099d50b34778533db..a43183efead375cb91eebce8506e0d0d854b427f 100644 (file)
@@ -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,
        };
index 067882b884449e7a746fbd9af1ad51311724cd40..06f1533d757888816414cd42e93d010365e7476e 100644 (file)
@@ -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