]> git.ipfire.org Git - pakfire.git/commitdiff
build: Support reading from archives
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 Jun 2019 23:12:01 +0000 (00:12 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 Jun 2019 23:12:01 +0000 (00:12 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/archive.c
src/libpakfire/libpakfire.sym
src/pakfire/builder.py

index 7e3b72002fcf449dd7f32cb1076d1cf763d0b096..e50f5c899d0b44f42ce5f738cc57589e2f4d4c9c 100644 (file)
@@ -175,6 +175,23 @@ static PyObject* Archive_get_package(ArchiveObject* self) {
        return ret;
 }
 
+static PyObject* Archive_get(ArchiveObject* self, PyObject* args) {
+       const char* key = NULL;
+
+       if (!PyArg_ParseTuple(args, "|s", &key))
+               return NULL;
+
+       char* value = pakfire_archive_get(self->archive, key);
+
+       if (!value)
+               Py_RETURN_NONE;
+
+       PyObject* ret = PyUnicode_FromString(value);
+       pakfire_free(value);
+
+       return ret;
+}
+
 static struct PyMethodDef Archive_methods[] = {
        {
                "extract",
@@ -182,6 +199,12 @@ static struct PyMethodDef Archive_methods[] = {
                METH_VARARGS,
                NULL
        },
+       {
+               "get",
+               (PyCFunction)Archive_get,
+               METH_VARARGS,
+               NULL
+       },
        {
                "get_package",
                (PyCFunction)Archive_get_package,
index 2e1bd7de5fecea3d89b7888cc6b2d1d7569399d1..ec4708f11c7921ea841dc42f396ce06323f628fa 100644 (file)
@@ -47,6 +47,7 @@ global:
        pakfire_archive_create;
        pakfire_archive_extract;
        pakfire_archive_extraction_path;
+       pakfire_archive_get;
        pakfire_archive_get_filelist;
        pakfire_archive_get_format;
        pakfire_archive_get_pakfire;
index 140519f67a69d896488cf2ca2e46380b57fb8b00..563539c5654ecc5c826ab95a13fd41e605194db2 100644 (file)
@@ -536,19 +536,12 @@ class BuilderContext(object):
                        transaction.run()
 
        def build(self, package, private_network=True, shell=True):
-               package = self._prepare_package(package)
-               assert package
+               archive = _pakfire.Archive(self.pakfire, package)
 
-               # Setup the environment including any build dependencies
-               self.setup(install=package.requires)
-
-       def _prepare_package(self, package):
-               # Check if the file exists
-               if not os.path.exists(package):
-                       raise FileNotFoundError(package)
+               requires = archive.get("dependencies.requires")
 
-               # Try opening the package
-               return packages.open(self.pakfire, None, package)
+               # Setup the environment including any build dependencies
+               self.setup(install=requires.splitlines())
 
        def shell(self, install=[]):
                if not util.cli_is_interactive():