]> git.ipfire.org Git - people/ms/pakfire.git/blob - src/cli/pakfire-daemon.c
cli: daemon: Add scaffolding
[people/ms/pakfire.git] / src / cli / pakfire-daemon.c
1 /*#############################################################################
2 # #
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2023 Pakfire development team #
5 # #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
18 # #
19 #############################################################################*/
20
21 #include <argp.h>
22 #include <syslog.h>
23
24 #include <pakfire/ctx.h>
25
26 #include "lib/client-build.h"
27 #include "lib/command.h"
28 #include "lib/config.h"
29 #include "lib/pakfire.h"
30 #include "lib/progressbar.h"
31 #include "lib/repo.h"
32 #include "lib/upload.h"
33
34 const char* argp_program_version = PACKAGE_VERSION;
35
36 static const char* doc = "The Pakfire Build Daemon";
37
38 enum {
39 OPT_DEBUG = 1,
40 };
41
42 static struct argp_option options[] = {
43 { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 },
44 { NULL },
45 };
46
47 static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
48 struct pakfire_ctx* ctx = data;
49
50 switch (key) {
51 case OPT_DEBUG:
52 pakfire_ctx_set_log_level(ctx, LOG_DEBUG);
53 break;
54
55 default:
56 return ARGP_ERR_UNKNOWN;
57 }
58
59 return 0;
60 }
61
62 int main(int argc, char* argv[]) {
63 struct pakfire_ctx* ctx = NULL;
64 int r;
65
66 // Setup the context
67 r = pakfire_ctx_create(&ctx, NULL);
68 if (r)
69 goto ERROR;
70
71 // Parse the command line and run any commands
72 r = cli_parse(options, NULL, NULL, doc, parse, argc, argv, ctx);
73 if (r)
74 goto ERROR;
75
76 // XXX Do the work
77
78 ERROR:
79 if (ctx)
80 pakfire_ctx_unref(ctx);
81
82 return r;
83 }