--- /dev/null
+/*#############################################################################
+# #
+# 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 <Python.h>
+
+#include <pakfire/ctx.h>
+#include <pakfire/buildservice.h>
+
+#include "buildservice.h"
+
+extern struct pakfire_ctx* pakfire_ctx;
+
+static PyObject* BuildService_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+ BuildServiceObject* self = (BuildServiceObject *)type->tp_alloc(type, 0);
+ if (self)
+ self->service = NULL;
+
+ return (PyObject *)self;
+}
+
+static int BuildService_init(BuildServiceObject* self, PyObject* args, PyObject* kwds) {
+ int r;
+
+ r = pakfire_buildservice_create(&self->service, pakfire_ctx);
+ if (r) {
+ errno = -r;
+
+ PyErr_SetFromErrno(PyExc_OSError);
+ return -1;
+ }
+
+ return 0;
+}
+
+static void BuildService_dealloc(BuildServiceObject* self) {
+ if (self->service)
+ pakfire_buildservice_unref(self->service);
+
+ Py_TYPE(self)->tp_free((PyObject *)self);
+}
+
+static PyObject* BuildService_upload(BuildServiceObject* self, PyObject* args, PyObject* kwds) {
+ const char* kwlist[] = { "path", "filename", NULL };
+ const char* filename = NULL;
+ const char* path = NULL;
+ PyObject* result = NULL;
+ char* uuid = NULL;
+ int r;
+
+ // Parse arguments
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|z", (char**)kwlist, &path, &filename))
+ return NULL;
+
+ // Perform the upload
+ r = pakfire_buildservice_upload(self->service, path, filename, &uuid);
+ if (r > 0) {
+ // XXX throw some nice exceptions...
+ goto ERROR;
+
+ } else if (r < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto ERROR;
+ }
+
+ // Return the UUID
+ result = PyUnicode_FromString(uuid);
+
+ERROR:
+ if (uuid)
+ free(uuid);
+
+ return result;
+}
+
+static struct PyMethodDef BuildService_methods[] = {
+ {
+ "upload",
+ (PyCFunction)BuildService_upload,
+ METH_VARARGS|METH_KEYWORDS,
+ NULL,
+ },
+ { NULL },
+};
+
+PyTypeObject BuildServiceType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ tp_name: "_pakfire.BuildService",
+ tp_basicsize: sizeof(BuildServiceObject),
+ tp_flags: Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
+ tp_new: BuildService_new,
+ tp_dealloc: (destructor)BuildService_dealloc,
+ tp_init: (initproc)BuildService_init,
+ tp_doc: "BuildService Object",
+ tp_methods: BuildService_methods,
+};
--- /dev/null
+/*#############################################################################
+# #
+# 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 PYTHON_PAKFIRE_BUILDSERVICE_H
+#define PYTHON_PAKFIRE_BUILDSERVICE_H
+
+#include <Python.h>
+
+#include <pakfire/buildservice.h>
+
+typedef struct {
+ PyObject_HEAD
+ struct pakfire_buildservice* service;
+} BuildServiceObject;
+
+extern PyTypeObject BuildServiceType;
+
+#endif /* PYTHON_PAKFIRE_BUILDSERVICE_H */
--- /dev/null
+###############################################################################
+# #
+# 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/>. #
+# #
+###############################################################################
+
+import _pakfire
+
+class BuildService(_pakfire.BuildService):
+ """
+ This wraps the parts of the build service
+ that has been implemented in libpakfire.
+ """
+ pass