]> git.ipfire.org Git - pakfire.git/commitdiff
cli: daemon: Add scaffolding
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2023 09:53:49 +0000 (09:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2023 11:11:51 +0000 (11:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
src/cli/pakfire-daemon.c [new file with mode: 0644]

index 52d8643e3bb8579a499c88592c4c91422ec87afa..9bb476be16f38530e20b1c51d03f2658da33e149 100644 (file)
@@ -8,6 +8,7 @@
 /contrib/pakfire.nm
 /pakfire
 /pakfire-builder
+/pakfire-daemon
 /src/pakfire/__version__.py
 /src/scripts/pakfire-daemon
 /src/systemd/*.service
index 039c18d6b2e2553454616e8452442edaa6a6cbf6..d80f50d7ed9fc5291af99718e135149efdaa5033 100644 (file)
@@ -452,6 +452,28 @@ pakfire_client_LDADD = \
 
 # ------------------------------------------------------------------------------
 
+bin_PROGRAMS += \
+       pakfire-daemon
+
+pakfire_daemon_SOURCES = \
+       src/cli/pakfire-daemon.c
+
+pakfire_daemon_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -I$(top_srcdir)/src/libpakfire/include
+
+pakfire_daemon_CFLAGS = \
+       $(AM_CFLAGS)
+
+pakfire_daemon_LDFLAGS = \
+       $(AM_LDFLAGS)
+
+pakfire_daemon_LDADD = \
+       libpakfire.la \
+       libcli.la
+
+# ------------------------------------------------------------------------------
+
 noinst_LTLIBRARIES += \
        libcli.la
 
diff --git a/src/cli/pakfire-daemon.c b/src/cli/pakfire-daemon.c
new file mode 100644 (file)
index 0000000..e903bf6
--- /dev/null
@@ -0,0 +1,83 @@
+/*#############################################################################
+#                                                                             #
+# 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 <argp.h>
+#include <syslog.h>
+
+#include <pakfire/ctx.h>
+
+#include "lib/client-build.h"
+#include "lib/command.h"
+#include "lib/config.h"
+#include "lib/pakfire.h"
+#include "lib/progressbar.h"
+#include "lib/repo.h"
+#include "lib/upload.h"
+
+const char* argp_program_version = PACKAGE_VERSION;
+
+static const char* doc = "The Pakfire Build Daemon";
+
+enum {
+       OPT_DEBUG  = 1,
+};
+
+static struct argp_option options[] = {
+       { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 },
+       { NULL },
+};
+
+static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
+       struct pakfire_ctx* ctx = data;
+
+       switch (key) {
+               case OPT_DEBUG:
+                       pakfire_ctx_set_log_level(ctx, LOG_DEBUG);
+                       break;
+
+               default:
+                       return ARGP_ERR_UNKNOWN;
+       }
+
+       return 0;
+}
+
+int main(int argc, char* argv[]) {
+       struct pakfire_ctx* ctx = NULL;
+       int r;
+
+       // Setup the context
+       r = pakfire_ctx_create(&ctx, NULL);
+       if (r)
+               goto ERROR;
+
+       // Parse the command line and run any commands
+       r = cli_parse(options, NULL, NULL, doc, parse, argc, argv, ctx);
+       if (r)
+               goto ERROR;
+
+       // XXX Do the work
+
+ERROR:
+       if (ctx)
+               pakfire_ctx_unref(ctx);
+
+       return r;
+}