From a9d234dfe2ab0358d3e61a53645e4ee1d83e53cb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 21 Nov 2005 10:33:10 +0000 Subject: * apt_inst.debExtractArchive() added --- python/apt_instmodule.cc | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'python/apt_instmodule.cc') 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}, -- cgit v1.2.3