]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: Add scaffolding for connecting to the build service
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Oct 2023 09:43:54 +0000 (09:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 17 Oct 2023 09:43:54 +0000 (09:43 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/libpakfire/buildservice.c [new file with mode: 0644]
src/libpakfire/include/pakfire/buildservice.h [new file with mode: 0644]
src/libpakfire/libpakfire.sym

index 78f414af713c7afb93a98692cf6cea923f68e9f2..2a37a6635757c4cb97d44d905b9aafbbb87217e3 100644 (file)
@@ -214,6 +214,7 @@ libpakfire_la_SOURCES = \
        src/libpakfire/arch.c \
        src/libpakfire/archive.c \
        src/libpakfire/build.c \
+       src/libpakfire/buildservice.c \
        src/libpakfire/cgroup.c \
        src/libpakfire/compress.c \
        src/libpakfire/config.c \
@@ -255,6 +256,7 @@ pkginclude_HEADERS += \
        src/libpakfire/include/pakfire/arch.h \
        src/libpakfire/include/pakfire/archive.h \
        src/libpakfire/include/pakfire/build.h \
+       src/libpakfire/include/pakfire/buildservice.h \
        src/libpakfire/include/pakfire/cgroup.h \
        src/libpakfire/include/pakfire/compress.h \
        src/libpakfire/include/pakfire/config.h \
diff --git a/src/libpakfire/buildservice.c b/src/libpakfire/buildservice.c
new file mode 100644 (file)
index 0000000..a26076e
--- /dev/null
@@ -0,0 +1,75 @@
+/*#############################################################################
+#                                                                             #
+# Pakfire - The IPFire package management system                              #
+# Copyright (C) 2021 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 <errno.h>
+#include <stdlib.h>
+
+#include <pakfire/buildservice.h>
+#include <pakfire/ctx.h>
+#include <pakfire/private.h>
+
+struct pakfire_buildservice {
+       struct pakfire_ctx* ctx;
+       int nrefs;
+};
+
+static void pakfire_buildservice_free(struct pakfire_buildservice* service) {
+       if (service->ctx)
+               pakfire_ctx_unref(service->ctx);
+
+       free(service);
+}
+
+PAKFIRE_EXPORT int pakfire_buildservice_create(
+               struct pakfire_buildservice** service, struct pakfire_ctx* ctx) {
+       struct pakfire_buildservice* s = NULL;
+
+       // Allocate some memory
+       s = calloc(1, sizeof(*s));
+       if (!s)
+               return -errno;
+
+       // Store a reference to the context
+       s->ctx = pakfire_ctx_ref(ctx);
+
+       // Initialize the reference counter
+       s->nrefs = 1;
+
+       // Return the pointer
+       *service = s;
+
+       return 0;
+}
+
+PAKFIRE_EXPORT struct pakfire_buildservice* pakfire_buildservice_ref(
+               struct pakfire_buildservice* service) {
+       ++service->nrefs;
+
+       return service;
+}
+
+PAKFIRE_EXPORT struct pakfire_buildservice* pakfire_buildservice_unref(
+               struct pakfire_buildservice* service) {
+       if (--service->nrefs > 0)
+               return service;
+
+       pakfire_buildservice_free(service);
+       return NULL;
+}
diff --git a/src/libpakfire/include/pakfire/buildservice.h b/src/libpakfire/include/pakfire/buildservice.h
new file mode 100644 (file)
index 0000000..3104097
--- /dev/null
@@ -0,0 +1,33 @@
+/*#############################################################################
+#                                                                             #
+# 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_BUILDSERVICE_H
+#define PAKFIRE_BUILDSERVICE_H
+
+struct pakfire_buildservice;
+
+#include <pakfire/ctx.h>
+
+int pakfire_buildservice_create(struct pakfire_buildservice** service, struct pakfire_ctx* ctx);
+
+struct pakfire_buildservice* pakfire_buildservice_ref(struct pakfire_buildservice* service);
+struct pakfire_buildservice* pakfire_buildservice_unref(struct pakfire_buildservice* service);
+
+#endif /* PAKFIRE_BUILDSERVICE_H */
index 6727e8354d19675edb21f429cd1ed3a5b08538b9..12812182b97be865684db1b40cfe991782214e45 100644 (file)
@@ -82,6 +82,11 @@ global:
        pakfire_build_unref;
        pakfire_shell;
 
+       # buildservice
+       pakfire_buildservice_create;
+       pakfire_buildservice_ref;
+       pakfire_buildservice_unref;
+
        # dependencies
        pakfire_static_version_compare;