summaryrefslogtreecommitdiff
path: root/python/apt_instmodule.cc
diff options
context:
space:
mode:
Diffstat (limited to 'python/apt_instmodule.cc')
-rw-r--r--python/apt_instmodule.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc
index 96bd029b..d672a40a 100644
--- a/python/apt_instmodule.cc
+++ b/python/apt_instmodule.cc
@@ -66,6 +66,43 @@ static PyObject *debExtractControl(PyObject *Self,PyObject *Args)
}
/*}}}*/
+// debExtractArchive - Exctract the archive /*{{{*/
+// ---------------------------------------------------------------------
+static char *doc_debExtractArchive =
+"debExtractArchve(File,rootdir) -> Bool\n"
+"Extracts the Archive into the given root dir";
+static PyObject *debExtractArchive(PyObject *Self,PyObject *Args)
+{
+ char *Rootdir = NULL;
+ PyObject *File;
+ if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0)
+ return 0;
+
+ // Subscope makes sure any clean up errors are properly handled.
+ bool res = false;
+ {
+ if(Rootdir != NULL)
+ {
+ chdir(Rootdir);
+ }
+
+ // Open the file and associate the .deb
+ FileFd Fd(fileno(PyFile_AsFile(File)),false);
+ debDebFile Deb(Fd);
+ if (_error->PendingError() == true)
+ return HandleErrors();
+
+ // extracts relative to the current dir
+ pkgDirStream Extract;
+ res = Deb.ExtractArchive(Extract);
+
+ if (res == false)
+ return HandleErrors();
+ }
+ return HandleErrors(Py_BuildValue("b",res));
+}
+ /*}}}*/
+
// initapt_inst - Core Module Initialization /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -73,6 +110,7 @@ static PyMethodDef methods[] =
{
// Stuff
{"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl},
+ {"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive},
{"tarExtract",tarExtract,METH_VARARGS,doc_tarExtract},
{"debExtract",debExtract,METH_VARARGS,doc_debExtract},