diff options
| -rwxr-xr-x | debian/rules | 1 | ||||
| -rw-r--r-- | python/acquire-item.cc | 38 | ||||
| -rw-r--r-- | python/acquire.cc | 8 | ||||
| -rw-r--r-- | python/apt_instmodule.cc | 141 | ||||
| -rw-r--r-- | python/apt_instmodule.h | 6 | ||||
| -rw-r--r-- | python/apt_pkgmodule.cc | 157 | ||||
| -rw-r--r-- | python/cache.cc | 61 | ||||
| -rw-r--r-- | python/cdrom.cc | 36 | ||||
| -rw-r--r-- | python/depcache.cc | 25 | ||||
| -rw-r--r-- | python/generic.cc | 69 | ||||
| -rw-r--r-- | python/generic.h | 6 | ||||
| -rw-r--r-- | python/pkgmanager.cc | 9 | ||||
| -rw-r--r-- | python/pkgrecords.cc | 9 | ||||
| -rw-r--r-- | python/pkgsrcrecords.cc | 38 | ||||
| -rw-r--r-- | python/progress.cc | 117 | ||||
| -rw-r--r-- | python/sourcelist.cc | 9 | ||||
| -rw-r--r-- | python/tag.cc | 19 | ||||
| -rw-r--r-- | python/tar.cc | 197 | ||||
| -rw-r--r-- | setup.py | 2 |
19 files changed, 1 insertions, 947 deletions
diff --git a/debian/rules b/debian/rules index c6c3e053..b2da3003 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,6 @@ #!/usr/bin/make -f # Should be include-links, but that somehow fails. export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') -# For compatibility, add -DCOMPAT_0_7 export CFLAGS=-Wno-write-strings export PATH := $(CURDIR)/utils:$(PATH) export pyversions := $(CURDIR)/utils/pyversions diff --git a/python/acquire-item.cc b/python/acquire-item.cc index 5e7423ab..53c3802b 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -320,41 +320,3 @@ PyTypeObject PyAcquireFile_Type = { acquirefile_new, // tp_new }; -#ifdef COMPAT_0_7 -char *doc_GetPkgAcqFile = - "GetPkgAcqFile(pkgAquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) -> PkgAcqFile\n"; -PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgAcqFile() is " - "deprecated. Please see apt_pkg.AcquireFile() for the " - "replacement", 1); - PyObject *pyfetcher; - char *uri, *md5, *descr, *shortDescr, *destDir, *destFile; - int size = 0; - uri = md5 = descr = shortDescr = destDir = destFile = ""; - - char * kwlist[] = {"owner","uri", "md5", "size", "descr", "shortDescr", - "destDir", "destFile", NULL - }; - - if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist, - &PyAcquire_Type, &pyfetcher, &uri, &md5, - &size, &descr, &shortDescr, &destDir, &destFile) == 0) - return 0; - - pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyfetcher); - pkgAcqFile *af = new pkgAcqFile(fetcher, // owner - uri, // uri - md5, // md5 - size, // size - descr, // descr - shortDescr, - destDir, - destFile); // short-desc - CppPyObject<pkgAcqFile*> *AcqFileObj = CppPyObject_NEW<pkgAcqFile*>(NULL, &PyAcquireFile_Type); - AcqFileObj->Object = af; - AcqFileObj->NoDelete = true; - - return AcqFileObj; -} -#endif diff --git a/python/acquire.cc b/python/acquire.cc index 45b4493c..82968a9d 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -400,12 +400,4 @@ PyTypeObject PyAcquire_Type = { PkgAcquireNew, // tp_new }; -#ifdef COMPAT_0_7 -PyObject *GetAcquire(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetAcquire() is deprecated." - " Please see apt_pkg.Acquire() for the replacement.", 1); - return PkgAcquireNew(&PyAcquire_Type,Args,0); -} -#endif diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 732f1bd0..0f0a187a 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -23,148 +23,7 @@ #include <Python.h> /*}}}*/ -#ifdef COMPAT_0_7 - -// debExtractControl - Exctract an arbitary control member /*{{{*/ -// --------------------------------------------------------------------- -/* This is a common operation so this function will stay, but others that - expose the full range of the apt-inst .deb processing will join it some - day. */ -static char *doc_debExtractControl = -"deb_extract_control(file[,member]) -> String\n" -"Returns the indicated file from the control tar. The default is 'control'\n"; -static PyObject *debExtractControl(PyObject *Self,PyObject *Args) -{ - char *Member = "control"; - PyObject *File; - if (PyArg_ParseTuple(Args,"O|s",&File,&Member) == 0) - return 0; - - // Subscope makes sure any clean up errors are properly handled. - PyObject *Res = 0; - { - // Open the file and associate the .deb - int fileno = PyObject_AsFileDescriptor(File); - if (fileno == -1) - return 0; - FileFd Fd(fileno,false); - debDebFile Deb(Fd); - if (_error->PendingError() == true) - return HandleErrors(); - - debDebFile::MemControlExtract Extract(Member); - if (Extract.Read(Deb) == false) - return HandleErrors(); - - // Build the return result - - if (Extract.Control == 0) - { - Py_INCREF(Py_None); - Res = Py_None; - } - else - Res = PyString_FromStringAndSize(Extract.Control,Extract.Length+2); - } - - return HandleErrors(Res); -} - /*}}}*/ - -// debExtractArchive - Exctract the archive /*{{{*/ -// --------------------------------------------------------------------- -static char *doc_debExtractArchive = -"deb_extract_archive(File,rootdir) -> Bool\n" -"Extracts the Archive into the given root dir"; -static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) -{ - char *Rootdir = NULL; - char cwd[512]; - PyObject *File; - if (PyArg_ParseTuple(Args,"O|s",&File,&Rootdir) == 0) - return 0; - - // Subscope makes sure any clean up errors are properly handled. - bool res = false; - { - if(Rootdir != NULL) - { - getcwd(cwd, sizeof(cwd)); - chdir(Rootdir); - } - - // Open the file and associate the .deb - int fileno = PyObject_AsFileDescriptor(File); - if (fileno == -1) - return 0; - FileFd Fd(fileno,false); - debDebFile Deb(Fd); - if (_error->PendingError() == true) { - if (Rootdir != NULL) - chdir (cwd); - return HandleErrors(); - } - - // extracts relative to the current dir - pkgDirStream Extract; - res = Deb.ExtractArchive(Extract); - - if (Rootdir != NULL) - chdir (cwd); - if (res == false) - return HandleErrors(PyBool_FromLong(res)); - } - return HandleErrors(PyBool_FromLong(res)); -} - /*}}}*/ -// arFindMember - Find member in AR archive /*{{{*/ -// --------------------------------------------------------------------- -static char *doc_arCheckMember = -"ar_check_member(file, membername) -> Bool\n"; -static PyObject *arCheckMember(PyObject *Self,PyObject *Args) -{ - char *Member = NULL; - bool res = false; - PyObject *File; - if (PyArg_ParseTuple(Args,"Os",&File,&Member) == 0) - return 0; - - // Open the file and associate the .deb - int fileno = PyObject_AsFileDescriptor(File); - if (fileno == -1) - return 0; - FileFd Fd(fileno,false); - ARArchive AR(Fd); - if (_error->PendingError() == true) - return HandleErrors(); - - if(AR.FindMember(Member) != 0) - res = true; - - return HandleErrors(PyBool_FromLong(res)); -} - /*}}}*/ - -// initapt_inst - Core Module Initialization /*{{{*/ -// --------------------------------------------------------------------- -/* */ -static PyMethodDef methods[] = -{ - // access to ar files - {"arCheckMember", arCheckMember, METH_VARARGS, doc_arCheckMember}, - - // access to deb files - {"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl}, - {"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive}, - - // access to tar streams - {"tarExtract",tarExtract,METH_VARARGS,doc_tarExtract}, - {"debExtract",debExtract,METH_VARARGS,doc_debExtract}, - {} -}; -#else static PyMethodDef *methods = 0; -#endif // defined(COMPAT_0_7) static const char *apt_inst_doc = diff --git a/python/apt_instmodule.h b/python/apt_instmodule.h index f6b337f4..ad4e9f72 100644 --- a/python/apt_instmodule.h +++ b/python/apt_instmodule.h @@ -14,12 +14,6 @@ #include "generic.h" #include <apt-pkg/extracttar.h> -#ifdef COMPAT_0_7 -PyObject *debExtract(PyObject *Self,PyObject *Args); -extern char *doc_debExtract; -PyObject *tarExtract(PyObject *Self,PyObject *Args); -extern char *doc_tarExtract; -#endif extern PyTypeObject PyArMember_Type; extern PyTypeObject PyArArchive_Type; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 7704aa01..5e48be04 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -53,15 +53,6 @@ static PyObject *py_gettext(PyObject *self, PyObject *Args) { // newConfiguration - Build a new configuration class /*{{{*/ // --------------------------------------------------------------------- -#ifdef COMPAT_0_7 -static char *doc_newConfiguration = "Construct a configuration instance"; -static PyObject *newConfiguration(PyObject *self,PyObject *args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is " - "deprecated. Use apt_pkg.Configuration() instead.", 1); - return CppPyObject_NEW<Configuration*>(NULL, &PyConfiguration_Type, new Configuration()); -} -#endif /*}}}*/ // Version Wrappers /*{{{*/ @@ -124,32 +115,6 @@ static PyObject *CheckDep(PyObject *Self,PyObject *Args) return PyBool_FromLong(_system->VS->CheckDep(A,Op,B)); } -#ifdef COMPAT_0_7 -static char *doc_CheckDepOld = "CheckDep(PkgVer,DepOp,DepVer) -> bool"; -static PyObject *CheckDepOld(PyObject *Self,PyObject *Args) -{ - char *A; - char *B; - char *OpStr; - unsigned int Op = 0; - - if (PyArg_ParseTuple(Args,"sss",&A,&OpStr,&B) == 0) - return 0; - if (*debListParser::ConvertRelation(OpStr,Op) != 0) - { - PyErr_SetString(PyExc_ValueError,"Bad comparision operation"); - return 0; - } - - if (_system == 0) - { - PyErr_SetString(PyExc_ValueError,"_system not initialized"); - return 0; - } - - return PyBool_FromLong(_system->VS->CheckDep(A,Op,B)); -} -#endif static char *doc_UpstreamVersion = "upstream_version(ver: str) -> str\n\n" @@ -249,16 +214,6 @@ static PyObject *ParseSrcDepends(PyObject *Self,PyObject *Args) { return RealParseDepends(Self, Args, true, "parse_src_depends"); } -#ifdef COMPAT_0_7 -static PyObject *ParseDepends_old(PyObject *Self,PyObject *Args) -{ - return RealParseDepends(Self, Args, false, "ParseDepends", true); -} -static PyObject *ParseSrcDepends_old(PyObject *Self,PyObject *Args) -{ - return RealParseDepends(Self, Args, true, "ParseSrcDepends", true); -} -#endif /*}}}*/ // md5sum - Compute the md5sum of a file or string /*{{{*/ // --------------------------------------------------------------------- @@ -615,55 +570,6 @@ static PyMethodDef methods[] = "Convert the given RFC 1123 formatted string to a Unix timestamp."}, // DEPRECATED - #ifdef COMPAT_0_7 - {"CheckDep",CheckDepOld,METH_VARARGS,doc_CheckDepOld}, - {"newConfiguration",newConfiguration,METH_VARARGS,doc_newConfiguration}, - {"InitConfig",InitConfig,METH_VARARGS,doc_InitConfig}, - {"InitSystem",InitSystem,METH_VARARGS,doc_InitSystem}, - - {"ParseSection",ParseSection,METH_VARARGS,doc_ParseSection}, - {"ParseTagFile",ParseTagFile,METH_VARARGS,doc_ParseTagFile}, - {"RewriteSection",RewriteSection,METH_VARARGS,doc_RewriteSection}, - - {"GetLock",GetLock,METH_VARARGS,doc_GetLock}, - {"PkgSystemLock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock}, - {"PkgSystemUnLock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock}, - - {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig}, - {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, - {"ReadConfigFileISC",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, - {"ParseCommandLine",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, - - {"VersionCompare",VersionCompare,METH_VARARGS,doc_VersionCompare}, - {"UpstreamVersion",UpstreamVersion,METH_VARARGS,doc_UpstreamVersion}, - - {"ParseDepends",ParseDepends_old,METH_VARARGS,doc_ParseDepends}, - {"ParseSrcDepends",ParseSrcDepends_old,METH_VARARGS,doc_ParseDepends}, - - {"CheckDomainList",StrCheckDomainList,METH_VARARGS, - "CheckDomainList(String,String) -> Bool"}, - {"QuoteString",StrQuoteString,METH_VARARGS,"QuoteString(String,String) -> String"}, - {"DeQuoteString",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"}, - {"SizeToStr",StrSizeToStr,METH_VARARGS,"SizeToStr(int) -> String"}, - {"TimeToStr",StrTimeToStr,METH_VARARGS,"TimeToStr(int) -> String"}, - {"URItoFileName",StrURItoFileName,METH_VARARGS,"URItoFileName(String) -> String"}, - {"Base64Encode",StrBase64Encode,METH_VARARGS,"Base64Encode(String) -> String"}, - {"StringToBool",StrStringToBool,METH_VARARGS,"StringToBool(String) -> int"}, - {"TimeRFC1123",StrTimeRFC1123,METH_VARARGS,"TimeRFC1123(int) -> String"}, - {"StrToTime",StrStrToTime,METH_VARARGS,"StrToTime(String) -> Int"}, - - {"GetCache",TmpGetCache,METH_VARARGS,"GetCache() -> PkgCache"}, - {"GetDepCache",GetDepCache,METH_VARARGS,"GetDepCache(Cache) -> DepCache"}, - {"GetPkgRecords",GetPkgRecords,METH_VARARGS,"GetPkgRecords(Cache) -> PkgRecords"}, - {"GetPkgSrcRecords",GetPkgSrcRecords,METH_VARARGS,"GetPkgSrcRecords() -> PkgSrcRecords"}, - {"GetPkgSourceList",GetPkgSourceList,METH_VARARGS,"GetPkgSourceList() -> PkgSourceList"}, - {"GetPkgProblemResolver",GetPkgProblemResolver,METH_VARARGS,"GetDepProblemResolver(DepCache) -> PkgProblemResolver"}, - {"GetPkgActionGroup",GetPkgActionGroup,METH_VARARGS,"GetPkgActionGroup(DepCache) -> PkgActionGroup"}, - {"GetCdrom",GetCdrom,METH_VARARGS,"GetCdrom() -> Cdrom"}, - {"GetAcquire",GetAcquire,METH_VARARGS,"GetAcquire() -> Acquire"}, - {"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS, doc_GetPkgAcqFile}, - {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager(DepCache) -> PackageManager"}, - #endif {} }; @@ -821,10 +727,6 @@ extern "C" void initapt_pkg() // Global configuration, should never be deleted. Config->NoDelete = true; PyModule_AddObject(Module,"config",Config); - #ifdef COMPAT_0_7 - Py_INCREF(Config); - PyModule_AddObject(Module,"Config",Config); - #endif @@ -904,14 +806,6 @@ extern "C" void initapt_pkg() MkPyNumber(pkgAcquire::Continue)); PyDict_SetItemString(PyAcquire_Type.tp_dict, "RESULT_FAILED", MkPyNumber(pkgAcquire::Failed)); -#ifdef COMPAT_0_7 - PyDict_SetItemString(PyAcquire_Type.tp_dict, "ResultCancelled", - MkPyNumber(pkgAcquire::Cancelled)); - PyDict_SetItemString(PyAcquire_Type.tp_dict, "ResultContinue", - MkPyNumber(pkgAcquire::Continue)); - PyDict_SetItemString(PyAcquire_Type.tp_dict, "ResultFailed", - MkPyNumber(pkgAcquire::Failed)); -#endif // Dependency constants PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_DEPENDS", MkPyNumber(pkgCache::Dep::Depends)); @@ -941,14 +835,6 @@ extern "C" void initapt_pkg() PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_INCOMPLETE", MkPyNumber(pkgPackageManager::Incomplete)); -#ifdef COMPAT_0_7 - PyDict_SetItemString(PyPackageManager_Type.tp_dict, "ResultCompleted", - MkPyNumber(pkgPackageManager::Completed)); - PyDict_SetItemString(PyPackageManager_Type.tp_dict, "ResultFailed", - MkPyNumber(pkgPackageManager::Failed)); - PyDict_SetItemString(PyPackageManager_Type.tp_dict, "ResultIncomplete", - MkPyNumber(pkgPackageManager::Incomplete)); -#endif PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_NONE", MkPyNumber(pkgCache::Version::None)); @@ -978,18 +864,6 @@ extern "C" void initapt_pkg() PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_AUTH_ERROR", MkPyNumber(pkgAcquire::Item::StatAuthError)); -#ifdef COMPAT_0_7 - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatIdle", - MkPyNumber(pkgAcquire::Item::StatIdle)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatFetching", - MkPyNumber(pkgAcquire::Item::StatFetching)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatDone", - MkPyNumber(pkgAcquire::Item::StatDone)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatError", - MkPyNumber(pkgAcquire::Item::StatError)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatAuthError", - MkPyNumber(pkgAcquire::Item::StatAuthError)); -#endif #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 PyObject *PyCapsule = PyCapsule_New(&API, "apt_pkg._C_API", NULL); @@ -1030,38 +904,7 @@ extern "C" void initapt_pkg() // DEPRECATED API - #ifdef COMPAT_0_7 - PyModule_AddObject(Module,"RewritePackageOrder", - CharCharToList(TFRewritePackageOrder)); - PyModule_AddObject(Module,"RewriteSourceOrder", - CharCharToList(TFRewriteSourceOrder)); - PyModule_AddStringConstant(Module,"LibVersion",(char *)pkgLibVersion); - PyModule_AddStringConstant(Module,"Date",__DATE__); - PyModule_AddStringConstant(Module,"Time",__TIME__); - PyModule_AddIntConstant(Module,"PriImportant",pkgCache::State::Important); - PyModule_AddIntConstant(Module,"PriRequired",pkgCache::State::Required); - PyModule_AddIntConstant(Module,"PriStandard",pkgCache::State::Standard); - PyModule_AddIntConstant(Module,"PriOptional",pkgCache::State::Optional); - PyModule_AddIntConstant(Module,"PriExtra",pkgCache::State::Extra); - PyModule_AddIntConstant(Module,"CurStateNotInstalled",pkgCache::State::NotInstalled); - PyModule_AddIntConstant(Module,"CurStateUnPacked",pkgCache::State::UnPacked); - PyModule_AddIntConstant(Module,"CurStateHalfConfigured",pkgCache::State::HalfConfigured); - PyModule_AddIntConstant(Module,"CurStateHalfInstalled",pkgCache::State::HalfInstalled); - PyModule_AddIntConstant(Module,"CurStateConfigFiles",pkgCache::State::ConfigFiles); - PyModule_AddIntConstant(Module,"CurStateInstalled",pkgCache::State::Installed); - PyModule_AddIntConstant(Module,"SelStateUnknown",pkgCache::State::Unknown); - PyModule_AddIntConstant(Module,"SelStateInstall",pkgCache::State::Install); - PyModule_AddIntConstant(Module,"SelStateHold",pkgCache::State::Hold); - PyModule_AddIntConstant(Module,"SelStateDeInstall",pkgCache::State::DeInstall); - PyModule_AddIntConstant(Module,"SelStatePurge",pkgCache::State::Purge); - PyModule_AddIntConstant(Module,"InstStateOk",pkgCache::State::Ok); - PyModule_AddIntConstant(Module,"InstStateReInstReq",pkgCache::State::ReInstReq); - PyModule_AddIntConstant(Module,"InstStateHold",pkgCache::State::Hold); - PyModule_AddIntConstant(Module,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); - PyModule_AddIntConstant(Module,"_COMPAT_0_7",1); - #else PyModule_AddIntConstant(Module,"_COMPAT_0_7",0); - #endif #if PY_MAJOR_VERSION >= 3 return Module; #endif diff --git a/python/cache.cc b/python/cache.cc index 01330adb..65b99210 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -161,63 +161,10 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) return HandleErrors(PyRes); } -#ifdef COMPAT_0_7 -static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Close() is deprecated, " - "because it causes segfaults. Delete the Cache instead.", 1); - PyObject *CacheFilePy = GetOwner<pkgCache*>(Self); - pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy); - Cache->Close(); - - Py_INCREF(Py_None); - return HandleErrors(Py_None); -} - -static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Open() is deprecated, " - "because it causes memory leaks. Create a new Cache instead.", - 1); - PyObject *CacheFilePy = GetOwner<pkgCache*>(Self); - pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy); - - PyObject *pyCallbackInst = 0; - if (PyArg_ParseTuple(Args, "|O", &pyCallbackInst) == 0) - return 0; - - if(pyCallbackInst != 0) { - PyOpProgress progress; - progress.setCallbackInst(pyCallbackInst); - if (Cache->Open(progress,false) == false) - return HandleErrors(); - } else { - OpTextProgress Prog; - if (Cache->Open(Prog,false) == false) - return HandleErrors(); - } - - //std::cout << "new cache is " << (pkgCache*)(*Cache) << std::endl; - - // ensure that the states are correct (LP: #659438) - pkgApplyStatus(*Cache); - - // update the cache pointer after the cache was rebuild - ((CppPyObject<pkgCache*> *)Self)->Object = (pkgCache*)(*Cache); - - Py_INCREF(Py_None); - return HandleErrors(Py_None); -} -#endif static PyMethodDef PkgCacheMethods[] = { {"update",PkgCacheUpdate,METH_VARARGS,cache_update_doc}, -#ifdef COMPAT_0_7 - {"Open", PkgCacheOpen, METH_VARARGS, - "Open the cache; deprecated and unsafe"}, - {"Close", PkgCacheClose, METH_VARARGS,"Close the cache"}, -#endif {} }; @@ -1654,11 +1601,3 @@ PyTypeObject PyDependencyList_Type = /*}}}*/ -#ifdef COMPAT_0_7 -PyObject *TmpGetCache(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCache() is deprecated. " - "Please see apt_pkg.Cache() for the replacement.", 1); - return PkgCacheNew(&PyCache_Type,Args,0); -} -#endif diff --git a/python/cdrom.cc b/python/cdrom.cc index 46bb769c..392dd834 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -78,38 +78,10 @@ static PyObject *cdrom_ident(PyObject *Self,PyObject *Args) } } -#ifdef COMPAT_0_7 -static PyObject *cdrom_ident_old(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "Method 'Ident' of the " - "'apt_pkg.Cdrom' object is deprecated, use 'ident' instead.", - 1); - pkgCdrom &Cdrom = GetCpp<pkgCdrom>(Self); - - PyObject *pyCdromProgressInst = 0; - if (PyArg_ParseTuple(Args, "O", &pyCdromProgressInst) == 0) { - return 0; - } - - PyCdromProgress progress; - progress.setCallbackInst(pyCdromProgressInst); - - std::string ident; - bool res = Cdrom.Ident(ident, &progress); - - PyObject *boolres = PyBool_FromLong(res); - PyObject *result = Py_BuildValue("(Os)", boolres, ident.c_str()); - - return HandleErrors(result); -} -#endif static PyMethodDef cdrom_methods[] = { {"add",cdrom_add,METH_VARARGS,cdrom_add_doc}, {"ident",cdrom_ident,METH_VARARGS,cdrom_ident_doc}, -#ifdef COMPAT_0_7 - {"Ident",cdrom_ident_old,METH_VARARGS,"DEPRECATED. DO NOT USE"}, -#endif {} }; @@ -165,11 +137,3 @@ PyTypeObject PyCdrom_Type = { cdrom_new, // tp_new }; -#ifdef COMPAT_0_7 -PyObject *GetCdrom(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCdrom() is deprecated. " - "Please see apt_pkg.Cdrom() for the replacement.", 1); - return cdrom_new(&PyCdrom_Type,Args,0); -} -#endif diff --git a/python/depcache.cc b/python/depcache.cc index 73993c82..acd41a85 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -794,14 +794,6 @@ PyTypeObject PyDepCache_Type = PkgDepCacheNew, // tp_new }; -#ifdef COMPAT_0_7 -PyObject *GetDepCache(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetDepCache() is deprecated" - ". Please see apt_pkg.DepCache() for the replacement.",1); - return PkgDepCacheNew(&PyDepCache_Type,Args,0); -} -#endif @@ -829,14 +821,6 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec return PkgProblemResolverPyObj; } -#ifdef COMPAT_0_7 -PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) { - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgProblemResolver() is" - " deprecated. Please see apt_pkg.ProblemResolver() for the " - "replacement.", 1); - return PkgProblemResolverNew(&PyProblemResolver_Type,Args,0); -} -#endif static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args) { @@ -1121,15 +1105,6 @@ PyTypeObject PyActionGroup_Type = PkgActionGroupNew, // tp_new }; -#ifdef COMPAT_0_7 -PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgActionGroup() is " - "deprecated. Please see apt_pkg.ActionGroup() for the " - "replacement.", 1); - return PkgActionGroupNew(&PyActionGroup_Type,Args,0); -} -#endif /*}}}*/ diff --git a/python/generic.cc b/python/generic.cc index e04743ff..8e65c4f3 100644 --- a/python/generic.cc +++ b/python/generic.cc @@ -49,75 +49,6 @@ PyObject *HandleErrors(PyObject *Res) return 0; } -# ifdef COMPAT_0_7 -// Helpers for deprecation. - -// Given the name of the old attribute, return the name of the new attribute -// in a PyObject. -static PyObject *_PyApt_NewNameForAttribute(const char *attr) { - // Some exceptions from the standard algorithm. - if (strcasecmp(attr, "FileName") == 0) return PyString_FromString("filename"); - if (strcasecmp(attr, "DestFile") == 0) return PyString_FromString("destfile"); - if (strcasecmp(attr, "FileSize") == 0) return PyString_FromString("filesize"); - if (strcasecmp(attr, "SubTree") == 0) return PyString_FromString("subtree"); - if (strcasecmp(attr, "ReadPinFile") == 0) return PyString_FromString("read_pinfile"); - if (strcasecmp(attr, "SetReInstall") == 0) return PyString_FromString("set_reinstall"); - if (strcasecmp(attr, "URI") == 0) return PyString_FromString("uri"); - if (strcasecmp(attr, "ArchiveURI") == 0) return PyString_FromString("archive_uri"); - if (strcasecmp(attr, "MD5Hash") == 0) return PyString_FromString("md5_hash"); - if (strcasecmp(attr, "SHA1Hash") == 0) return PyString_FromString("sha1_hash"); - if (strcasecmp(attr, "SHA256Hash") == 0) return PyString_FromString("sha256_hash"); - if (strcasecmp(attr, "UntranslatedDepType") == 0) return PyString_FromString("dep_type_untranslated"); - size_t attrlen = strlen(attr); - // Reserve the old name + 5, this should reduce resize to a minimum. - string new_name; - new_name.reserve(attrlen + 5); - for(unsigned int i=0; i < attrlen; i++) { - // Replace all uppercase ASCII characters with their lower-case ones. - if (attr[i] > 64 && attr[i] < 91) { - if (i > 0) - new_name += "_"; - new_name += attr[i] + 32; - } else { - new_name += attr[i]; - } - } - return CppPyString(new_name); -} - -// Handle deprecated attributes by setting a warning and returning the new -// attribute. -PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr) { - PyObject *value = PyObject_GenericGetAttr(self, attr); - if (value == NULL) { - PyObject *ptype, *pvalue, *ptraceback; - PyErr_Fetch(&ptype, &pvalue, &ptraceback); - const char *attrname = PyObject_AsString(attr); - PyObject *newattr = _PyApt_NewNameForAttribute(attrname); - value = PyObject_GenericGetAttr(self, newattr); - if (value != NULL) { - const char *newattrname = PyString_AsString(newattr); - const char *cls = self->ob_type->tp_name; - char *warning_string = new char[strlen(newattrname) + strlen(cls) + - strlen(attrname) + 66]; - sprintf(warning_string, "Attribute '%s' of the '%s' object is " - "deprecated, use '%s' instead.", attrname, cls, newattrname); - PyErr_WarnEx(PyExc_DeprecationWarning, warning_string, 1); - delete[] warning_string; - } else { - Py_XINCREF(ptype); - Py_XINCREF(pvalue); - Py_XINCREF(ptraceback); - PyErr_Restore(ptype, pvalue, ptraceback); - } - Py_DECREF(newattr); - Py_XDECREF(ptype); - Py_XDECREF(pvalue); - Py_XDECREF(ptraceback); - } - return value; -} -# endif //COMPAT_0_7 /*}}}*/ // ListToCharChar - Convert a list to an array of char char /*{{{*/ // --------------------------------------------------------------------- diff --git a/python/generic.h b/python/generic.h index 914456e2..e4679c6c 100644 --- a/python/generic.h +++ b/python/generic.h @@ -58,8 +58,6 @@ typedef int Py_ssize_t; #define PyInt_Check PyLong_Check #define PyInt_AsLong PyLong_AsLong #define PyInt_FromLong PyLong_FromLong -// Force 0.7 compatibility to be off in Python 3 builds -#undef COMPAT_0_7 #else // Compatibility for Python 2.5 and previous. #if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 5) @@ -251,10 +249,6 @@ inline PyObject *MkPyNumber(char o) { return PyInt_FromLong(o); } inline PyObject *MkPyNumber(double o) { return PyFloat_FromDouble(o); } -# ifdef COMPAT_0_7 -PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr); -# else # define _PyAptObject_getattro 0 -# endif #endif diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 9a5d0e5b..5fff1e57 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -225,15 +225,6 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return PkgManagerObj; } -#ifdef COMPAT_0_7 -PyObject *GetPkgManager(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPackageManager() is " - "deprecated. Please see apt_pkg.PackageManager() for the " - "replacement.", 1); - return PkgManagerNew(&PyPackageManager2_Type,Args,0); -} -#endif static PyObject *PkgManagerInstall(PyObject *Self,PyObject *Args) { diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 8d2cb502..8e6084a9 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -218,12 +218,3 @@ PyTypeObject PyPackageRecords_Type = /*}}}*/ -#ifdef COMPAT_0_7 -PyObject *GetPkgRecords(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgRecords() is " - "deprecated. Please see apt_pkg.Records() for the " - "replacement.", 1); - return PkgRecordsNew(&PyPackageRecords_Type,Args,0); -} -#endif diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 4c889129..6a60a9af 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -205,29 +205,6 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) { return Dict; } -#ifdef COMPAT_0_7 -static PyObject *PkgSrcRecordsGetBuildDepends_old(PyObject *Self,void*) { - PkgSrcRecordsStruct &Struct = GetStruct(Self,"BuildDepends"); - if (Struct.Last == 0) - return 0; - PyObject *List = PyList_New(0); - - vector<pkgSrcRecords::Parser::BuildDepRec> bd; - if(!Struct.Last->BuildDepends(bd, false /* arch-only*/)) - return NULL; // error - - PyObject *v; - for(unsigned int i=0;i<bd.size();i++) { - v = Py_BuildValue("(ssNN)", bd[i].Package.c_str(), - bd[i].Version.c_str(), - MkPyNumber(bd[i].Op), - MkPyNumber(bd[i].Type)); - PyList_Append(List, v); - Py_DECREF(v); - } - return List; -} -#endif static PyGetSetDef PkgSrcRecordsGetSet[] = { {"binaries",PkgSrcRecordsGetBinaries,0, @@ -251,9 +228,6 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { "The section of the source package."}, {"version",PkgSrcRecordsGetVersion,0, "The version of the source package."}, -#ifdef COMPAT_0_7 - {"BuildDepends",PkgSrcRecordsGetBuildDepends_old,0,"Deprecated function and deprecated output format."}, -#endif {} }; @@ -316,15 +290,3 @@ PyTypeObject PySourceRecords_Type = /*}}}*/ -#ifdef COMPAT_0_7 -PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSrcRecords() is " - "deprecated. Please see apt_pkg.SourceRecords() for the " - "replacement.", 1); - if (PyArg_ParseTuple(Args,"") == 0) - return 0; - - return HandleErrors(CppPyObject_NEW<PkgSrcRecordsStruct>(NULL, &PySourceRecords_Type)); -} -#endif diff --git a/python/progress.cc b/python/progress.cc index 9e870875..aedd7581 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -95,15 +95,7 @@ void PyOpProgress::Update() setattr(callbackInst, "subop", "s", SubOp.c_str()); setattr(callbackInst, "major_change", "b", MajorChange); setattr(callbackInst, "percent", "N", MkPyNumber(Percent)); -#ifdef COMPAT_0_7 - setattr(callbackInst, "Op", "s", Op.c_str()); - setattr(callbackInst, "subOp", "s", SubOp.c_str()); - setattr(callbackInst, "majorChange", "b", MajorChange); - PyObject *arglist = Py_BuildValue("(N)", MkPyNumber(Percent)); - RunSimpleCallback("update", arglist); -#else RunSimpleCallback("update"); -#endif } void PyOpProgress::Done() @@ -241,13 +233,6 @@ void PyFetchProgress::Start() //std::cout << "Start" << std::endl; pkgAcquireStatus::Start(); -#ifdef COMPAT_0_7 - setattr(callbackInst, "currentCPS", "N", MkPyNumber(0)); - setattr(callbackInst, "currentBytes", "N", MkPyNumber(0)); - setattr(callbackInst, "currentItems", "N", MkPyNumber(0)); - setattr(callbackInst, "totalItems", "N", MkPyNumber(0)); - setattr(callbackInst, "totalBytes", "N", MkPyNumber(0)); -#endif RunSimpleCallback("start"); /* After calling the start method we can safely allow @@ -314,106 +299,7 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) PyCbObj_BEGIN_ALLOW_THREADS return true; } -#ifdef COMPAT_0_7 - setattr(callbackInst, "currentCPS", "N", MkPyNumber(CurrentCPS)); - setattr(callbackInst, "currentBytes", "N", MkPyNumber(CurrentBytes)); - setattr(callbackInst, "totalBytes", "N", MkPyNumber(TotalBytes)); - setattr(callbackInst, "fetchedBytes", "N", MkPyNumber(FetchedBytes)); - setattr(callbackInst, "currentItems", "N", MkPyNumber(CurrentItems)); - setattr(callbackInst, "totalItems", "N", MkPyNumber(TotalItems)); - // Go through the list of items and add active items to the - // activeItems vector. - map<pkgAcquire::Worker *, pkgAcquire::ItemDesc *> activeItemMap; - - for(pkgAcquire::Worker *Worker = Owner->WorkersBegin(); - Worker != 0; Worker = Owner->WorkerStep(Worker)) { - - if (Worker->CurrentItem == 0) { - // Ignore workers with no item running - continue; - } - activeItemMap.insert(std::make_pair(Worker, Worker->CurrentItem)); - } - - // Create the tuple that is passed as argument to pulse(). - // This tuple contains activeItemMap.size() item tuples. - PyObject *arglist; - - if (((int)activeItemMap.size()) > 0) { - PyObject *itemsTuple = PyTuple_New((Py_ssize_t) activeItemMap.size()); - - // Go through activeItems, create an item tuple in the form - // (URI, Description, ShortDesc, FileSize, PartialSize) and - // add that tuple to itemsTuple. - map<pkgAcquire::Worker *, pkgAcquire::ItemDesc *>::iterator iter; - int tuplePos; - - for(tuplePos = 0, iter = activeItemMap.begin(); - iter != activeItemMap.end(); ++iter, tuplePos++) { - pkgAcquire::Worker *worker = iter->first; - pkgAcquire::ItemDesc *itm = iter->second; - - PyObject *itmTuple = Py_BuildValue("(sssNN)", itm->URI.c_str(), - itm->Description.c_str(), - itm->ShortDesc.c_str(), - MkPyNumber(worker->TotalSize), - MkPyNumber(worker->CurrentSize)); - PyTuple_SetItem(itemsTuple, tuplePos, itmTuple); - } - - // Now our itemsTuple is ready for being passed to pulse(). - // pulse() is going to receive a single argument, being the - // tuple of items, which again contains one tuple with item - // information per item. - // - // Python Example: - // - // class MyFetchProgress(FetchProgress): - // def pulse(self, items): - // for itm in items: - // uri, desc, shortdesc, filesize, partialsize = itm - // - arglist = PyTuple_Pack(1, itemsTuple); - } - else { - arglist = Py_BuildValue("(())"); - } - - PyObject *result; - bool res = true; - - if (RunSimpleCallback("pulse_items", arglist, &result)) { - if (result != NULL && PyArg_Parse(result, "b", &res) && res == false) { - // the user returned a explicit false here, stop - PyCbObj_BEGIN_ALLOW_THREADS - return false; - } - } - - - arglist = Py_BuildValue("()"); - if (!RunSimpleCallback("pulse", arglist, &result)) { - PyCbObj_BEGIN_ALLOW_THREADS - return true; - } - - if((result == NULL) || (!PyArg_Parse(result, "b", &res))) - { - // most of the time the user who subclasses the pulse() - // method forgot to add a return {True,False} so we just - // assume he wants a True. There may be a Python exception on the stack - // that must be cleared. - PyErr_Clear(); - PyCbObj_BEGIN_ALLOW_THREADS - return true; - } - - PyCbObj_BEGIN_ALLOW_THREADS - // fetching can be canceld by returning false - return res; -#else return false; -#endif } @@ -548,9 +434,6 @@ void PyCdromProgress::Update(std::string text, int current) { PyObject *arglist = Py_BuildValue("(si)", text.c_str(), current); setattr(callbackInst, "total_steps", "i", totalSteps); - #ifdef COMPAT_0_7 - setattr(callbackInst, "totalSteps", "i", totalSteps); - #endif RunSimpleCallback("update", arglist); } diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 784b161e..a38cb1bb 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -168,12 +168,3 @@ PyTypeObject PySourceList_Type = PkgSourceListNew, // tp_new }; -#ifdef COMPAT_0_7 -PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSourceList() is " - "deprecated. Please see apt_pkg.SourceList() for the " - "replacement.", 1); - return PkgSourceListNew(&PySourceList_Type,Args,0); -} -#endif diff --git a/python/tag.cc b/python/tag.cc index 6ae439f5..a0f526ad 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -418,16 +418,6 @@ static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { return New; } -#ifdef COMPAT_0_7 -char *doc_ParseSection = "ParseSection(Text) -> TagSection()\n\nDeprecated."; -PyObject *ParseSection(PyObject *self,PyObject *Args) -{ - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseSection() is " - "deprecated. Please see apt_pkg.TagSection() for the " - "replacement.", 1); - return TagSecNew(&PyTagSection_Type,Args,0); -} -#endif /*}}}*/ // ParseTagFile - Parse a tagd file /*{{{*/ // --------------------------------------------------------------------- @@ -507,15 +497,6 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return HandleErrors(New); } -#ifdef COMPAT_0_7 -char *doc_ParseTagFile = "ParseTagFile(file) -> TagFile()\n\nDeprecated."; -PyObject *ParseTagFile(PyObject *self,PyObject *Args) { - PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseTagFile() is " - "deprecated. Please see apt_pkg.TagFile() for the " - "replacement.", 1); - return TagFileNew(&PyTagFile_Type,Args,0); -} -#endif /*}}}*/ // RewriteSection - Rewrite a section.. /*{{{*/ // --------------------------------------------------------------------- diff --git a/python/tar.cc b/python/tar.cc deleted file mode 100644 index e42a9c50..00000000 --- a/python/tar.cc +++ /dev/null @@ -1,197 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: tar.cc,v 1.4 2004/12/12 17:55:54 mdz Exp $ -/* ###################################################################### - - Tar Inteface - * THIS FILE IS COMPLETELY DEPRECATED, AND NOT USED ANYMORE IF BUILT * - * WITHOUT COMPATIBILITY. * - - ##################################################################### */ - /*}}}*/ -// Include Files /*{{{*/ -#ifdef COMPAT_0_7 -#include "generic.h" - -#include <apt-pkg/extracttar.h> -#include <apt-pkg/error.h> -#include <apt-pkg/debfile.h> -#include "apt_instmodule.h" - -#include <Python.h> - /*}}}*/ - -class ProcessTar : public pkgDirStream -{ - public: - - PyObject *Function; - - virtual bool DoItem(Item &Itm,int &Fd); - - ProcessTar(PyObject *Function) : Function(Function) - { - Py_INCREF(Function); - } - virtual ~ProcessTar() - { - Py_DECREF(Function); - } -}; - -// ProcessTar::DoItem - Feed an item to a python function /*{{{*/ -// --------------------------------------------------------------------- -/* The function is called with a tuple that has: - (FileName,Link,Mode,UID,GID,Size,MTime,Major,Minor) */ -bool ProcessTar::DoItem(Item &Itm,int &Fd) -{ - const char *Type; - switch (Itm.Type) - { - case Item::File: - Type = "FILE"; - break; - - case Item::HardLink: - Type = "HARDLINK"; - break; - - case Item::SymbolicLink: - Type = "SYMLINK"; - break; - - case Item::CharDevice: - Type = "CHARDEV"; - break; - - case Item::BlockDevice: - Type = "BLKDEV"; - break; - - case Item::Directory: - Type = "DIR"; - break; - - case Item::FIFO: - Type = "FIFO"; - break; - - default: - return false; - } - - - if (PyObject_CallFunction(Function,"sssiiiiiii",Type,Itm.Name, - Itm.LinkTarget,Itm.Mode,Itm.UID,Itm.GID,Itm.Size, - Itm.MTime,Itm.Major,Itm.Minor) == 0) - return false; - - Fd = -1; - return true; -} - /*}}}*/ - -// tarExtract - Examine files from a tar /*{{{*/ -// --------------------------------------------------------------------- -/* */ -char *doc_tarExtract = -"tarExtract(File,Func,Comp) -> None\n" -"The tar file referenced by the file object File, Func called for each\n" -"Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n"; -PyObject *tarExtract(PyObject *Self,PyObject *Args) -{ - PyObject *File; - PyObject *Function; - char *Comp; - - if (PyArg_ParseTuple(Args,"OOs",&File, &Function,&Comp) == 0) - return 0; - - if (PyCallable_Check(Function) == 0) - { - PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable."); - return 0; - } - - { - // Open the file and associate the tar - int fileno = PyObject_AsFileDescriptor(File); - if (fileno == -1) - return 0; - - FileFd Fd(fileno,false); - ExtractTar Tar(Fd,0xFFFFFFFF,Comp); - if (_error->PendingError() == true) - return HandleErrors(); - - ProcessTar Proc(Function); - if (Tar.Go(Proc) == false) - return HandleErrors(); - } - - Py_INCREF(Py_None); - return HandleErrors(Py_None); -} - /*}}}*/ - -// debExtract - Examine files from a deb /*{{{*/ -// --------------------------------------------------------------------- -/* */ -char *doc_debExtract = -"debExtract(File,Func,Chunk) -> None\n" -"The deb referenced by the file object File is examined. The AR member\n" -"given by Chunk is treated as a tar.gz and fed through Func like\n" -"tarExtract\n"; -PyObject *debExtract(PyObject *Self,PyObject *Args) -{ - PyObject *File; - PyObject *Function; - char *Chunk; - const char *Comp = "gzip"; - - if (PyArg_ParseTuple(Args,"OOs",&File,&Function,&Chunk) == 0) - return 0; - - if (PyCallable_Check(Function) == 0) - { - PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable."); - return 0; - } - - int fileno = PyObject_AsFileDescriptor(File); - if (fileno == -1) - return 0; - { - // Open the file and associate the tar - // Open the file and associate the .deb - FileFd Fd(fileno,false); - debDebFile Deb(Fd); - if (_error->PendingError() == true) - return HandleErrors(); - - // Get the archive member and positition the file - const ARArchive::Member *Member = Deb.GotoMember(Chunk); - if (Member == 0) - { - _error->Error("Cannot find chunk %s",Chunk); - return HandleErrors(); - } - - // Extract it. - if (strcmp(".bz2", &Chunk[strlen(Chunk)-4]) == 0) - Comp = "bzip2"; - else if(strcmp(".lzma", &Chunk[strlen(Chunk)-5]) == 0) - Comp = "lzma"; - else if(strcmp(".xz", &Chunk[strlen(Chunk)-3]) == 0) - Comp = "xz"; - ExtractTar Tar(Deb.GetFile(),Member->Size,Comp); - ProcessTar Proc(Function); - if (Tar.Go(Proc) == false) - return HandleErrors(); - } - - Py_INCREF(Py_None); - return HandleErrors(Py_None); -} - /*}}}*/ -#endif // defined(COMPAT_0_7) @@ -43,7 +43,7 @@ files = sorted(['python/' + fname for fname in files], key=lambda s: s[:-3]) apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module -files = ["python/apt_instmodule.cc", "python/generic.cc", "python/tar.cc", +files = ["python/apt_instmodule.cc", "python/generic.cc", "python/arfile.cc", "python/tarfile.cc"] apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) |
