From 6c3e74bdf3a8bd6aced0a2ddb38c1cc7b22ec655 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Apr 2009 18:19:41 +0200 Subject: * doc/source/conf.py: Do not require python-debian anymore Try to get the release from the information in the environment variable DEBVER, which is exported in debian/rules. If it is not set, use python-debian to read the release from the changelog. --- debian/control | 1 - 1 file changed, 1 deletion(-) (limited to 'debian') diff --git a/debian/control b/debian/control index 4c7b542f..72476c58 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,6 @@ Build-Depends: apt-utils, python-all-dbg, python-all-dev, python-central (>= 0.5), - python-debian, python-distutils-extra (>= 1.9.0), python-gtk2, python-sphinx (>= 0.5), -- cgit v1.2.3 From 506cb021d62e643fba38ddb4b84572a86cb3a3ba Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Apr 2009 18:27:43 +0200 Subject: * python/tag.cc: Support 'key in mapping' for TagSections Support the replacement of mapping.has_key() for sections, and update the usage in apt/package.py and apt/debfile accordingly. This is implemented by extending the TagSecType with sequence methods, but only settings the contains method there. The TagSecGetAttr() function has been removed and replaced by the use of the tp_methods slot. --- apt/debfile.py | 10 +++++----- apt/package.py | 4 ++-- debian/changelog | 7 +++++++ doc/source/apt_pkg/cache.rst | 4 ++++ python/apt_pkgmodule.cc | 4 ++++ python/tag.cc | 47 +++++++++++++++++++++++++++++--------------- 6 files changed, 53 insertions(+), 23 deletions(-) (limited to 'debian') diff --git a/apt/debfile.py b/apt/debfile.py index 0406a250..8d4f534c 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -463,18 +463,18 @@ class DscSrcPackage(DebPackage): try: while tagfile.Step() == 1: for tag in depends_tags: - if not sec.has_key(tag): + if not tag in sec: continue self._depends.extend(apt_pkg.ParseSrcDepends(sec[tag])) for tag in conflicts_tags: - if not sec.has_key(tag): + if not tag in sec: continue self._conflicts.extend(apt_pkg.ParseSrcDepends(sec[tag])) - if sec.has_key('Source'): + if 'Source' in sec: self.pkgname = sec['Source'] - if sec.has_key('Binary'): + if 'Binary' in sec: self.binaries = sec['Binary'].split(', ') - if sec.has_key('Version'): + if 'Version' in sec: self._sections['Version'] = sec['Version'] finally: del sec diff --git a/apt/package.py b/apt/package.py index ec88a456..e308da4b 100644 --- a/apt/package.py +++ b/apt/package.py @@ -157,7 +157,7 @@ class Record(object): return self._rec[key] def __contains__(self, key): - return self._rec.has_key(key) + return key in self._rec def __iter__(self): return iter(self._rec.keys()) @@ -176,7 +176,7 @@ class Record(object): def has_key(self, key): """deprecated form of 'key in x'.""" - return self._rec.has_key(key) + return key in self._rec class Version(object): diff --git a/debian/changelog b/debian/changelog index 83b00150..f623254e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.11) UNRELEASED; urgency=low + + * python/tag.cc: + - Support 'key in mapping' for TagSections + + -- Julian Andres Klode Mon, 13 Apr 2009 18:08:10 +0200 + python-apt (0.7.10.3) unstable; urgency=low * apt/package.py: Handle cases where no candidate is available, by returning diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst index af67d82f..146c2c2a 100644 --- a/doc/source/apt_pkg/cache.rst +++ b/doc/source/apt_pkg/cache.rst @@ -1199,6 +1199,10 @@ broken dependencies: Return the value of the field at *key*. If *key* is not available, raise :exc:`KeyError`. + .. describe:: key in section + + Return ``True`` if *section* has a key *key*, else ``False``. + .. method:: Bytes The number of bytes in the section. diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 86732781..34669fd5 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -472,6 +472,10 @@ static void AddInt(PyObject *Dict,const char *Itm,unsigned long I) extern "C" void initapt_pkg() { + // Finalize our types to add slots, etc. + if (PyType_Ready(&TagSecType) == -1) return; + + // Initialize the module PyObject *Module = Py_InitModule("apt_pkg",methods); PyObject *Dict = PyModule_GetDict(Module); diff --git a/python/tag.cc b/python/tag.cc index 217be290..cab32370 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -174,6 +174,16 @@ static PyObject *TagSecExists(PyObject *Self,PyObject *Args) return Py_BuildValue("i",1); } +static int TagSecContains(PyObject *Self,PyObject *Arg) +{ + char *Name = PyString_AsString(Arg); + const char *Start; + const char *Stop; + if (GetCpp(Self).Find(Name,Start,Stop) == false) + return 0; + return 1; +} + static char *doc_Bytes = "Bytes() -> integer"; static PyObject *TagSecBytes(PyObject *Self,PyObject *Args) { @@ -365,36 +375,41 @@ static PyMethodDef TagSecMethods[] = {} }; -// TagSecGetAttr - Get an attribute - variable/method /*{{{*/ -// --------------------------------------------------------------------- -/* */ -static PyObject *TagSecGetAttr(PyObject *Self,char *Name) -{ - return Py_FindMethod(TagSecMethods,Self,Name); -} - /*}}}*/ -// Type for a Tag Section + +PySequenceMethods TagSecSeqMeth = {0,0,0,0,0,0,0,TagSecContains,0,0}; PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0}; PyTypeObject TagSecType = { PyObject_HEAD_INIT(&PyType_Type) - 0, // ob_size - "TagSection", // tp_name + 0, // ob_size + "TagSection", // tp_name sizeof(TagSecData), // tp_basicsize 0, // tp_itemsize // Methods TagSecFree, // tp_dealloc - 0, // tp_print - TagSecGetAttr, // tp_getattr + 0, // tp_print + 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number - 0, // tp_as_sequence + &TagSecSeqMeth, // tp_as_sequence &TagSecMapMeth, // tp_as_mapping 0, // tp_hash - 0, // tp_call - TagSecStr, // tp_str + 0, // tp_call + TagSecStr, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags + "TagSection Object", // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + TagSecMethods // tp_methods }; // Method table for the Tag File object -- cgit v1.2.3 From 62d7f4b80d56ef1e27039441cd6584cfb71d6502 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Apr 2009 19:13:25 +0200 Subject: * python/*.cc: Use PyObject_AsFileDescriptor instead of fileno(PyFile_AsFile) Replace support for file objects with a more generic support for any object providing a fileno() method and for file descriptors (integers). This also helps us to port to Python 3, where the previously used PyFile_ functions are not available anymore. --- debian/changelog | 2 ++ python/apt_instmodule.cc | 21 +++++++++++++++------ python/apt_pkgmodule.cc | 12 ++++++------ python/tag.cc | 7 +++++-- python/tar.cc | 17 +++++++++++------ 5 files changed, 39 insertions(+), 20 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index f623254e..dc8d1545 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.11) UNRELEASED; urgency=low * python/tag.cc: - Support 'key in mapping' for TagSections + * Replace support for file objects with a more generic support for any object + providing a fileno() method and for file descriptors (integers). -- Julian Andres Klode Mon, 13 Apr 2009 18:08:10 +0200 diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 48868d86..a9d81be4 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -35,14 +35,17 @@ static PyObject *debExtractControl(PyObject *Self,PyObject *Args) { char *Member = "control"; PyObject *File; - if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Member) == 0) + 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 - FileFd Fd(fileno(PyFile_AsFile(File)),false); + int fileno = PyObject_AsFileDescriptor(File); + if (fileno == -1) + return 0; + FileFd Fd(fileno,false); debDebFile Deb(Fd); if (_error->PendingError() == true) return HandleErrors(); @@ -76,7 +79,7 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) char *Rootdir = NULL; char cwd[512]; PyObject *File; - if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0) + if (PyArg_ParseTuple(Args,"O|s",&File,&Rootdir) == 0) return 0; // Subscope makes sure any clean up errors are properly handled. @@ -89,7 +92,10 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) } // Open the file and associate the .deb - FileFd Fd(fileno(PyFile_AsFile(File)),false); + int fileno = PyObject_AsFileDescriptor(File); + if (fileno == -1) + return 0; + FileFd Fd(fileno,false); debDebFile Deb(Fd); if (_error->PendingError() == true) { if (Rootdir != NULL) @@ -118,11 +124,14 @@ static PyObject *arCheckMember(PyObject *Self,PyObject *Args) char *Member = NULL; bool res = false; PyObject *File; - if (PyArg_ParseTuple(Args,"O!s",&PyFile_Type,&File,&Member) == 0) + if (PyArg_ParseTuple(Args,"Os",&File,&Member) == 0) return 0; // Open the file and associate the .deb - FileFd Fd(fileno(PyFile_AsFile(File)),false); + int fileno = PyObject_AsFileDescriptor(File); + if (fileno == -1) + return 0; + FileFd Fd(fileno,false); ARArchive AR(Fd); if (_error->PendingError() == true) return HandleErrors(Py_BuildValue("b",res)); diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 1417e5d0..10d98911 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -184,10 +184,10 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args) } // Digest of a file - if (PyFile_Check(Obj) != 0) + int Fd = PyObject_AsFileDescriptor(Obj); + if (Fd != -1) { MD5Summation Sum; - int Fd = fileno(PyFile_AsFile(Obj)); struct stat St; if (fstat(Fd,&St) != 0 || Sum.AddFD(Fd,St.st_size) == false) @@ -224,10 +224,10 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) } // Digest of a file - if (PyFile_Check(Obj) != 0) + int Fd = PyObject_AsFileDescriptor(Obj); + if (Fd != -1) { SHA1Summation Sum; - int Fd = fileno(PyFile_AsFile(Obj)); struct stat St; if (fstat(Fd,&St) != 0 || Sum.AddFD(Fd,St.st_size) == false) @@ -264,10 +264,10 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) } // Digest of a file - if (PyFile_Check(Obj) != 0) + int Fd = PyObject_AsFileDescriptor(Obj); + if (Fd != -1) { SHA256Summation Sum; - int Fd = fileno(PyFile_AsFile(Obj)); struct stat St; if (fstat(Fd,&St) != 0 || Sum.AddFD(Fd,St.st_size) == false) diff --git a/python/tag.cc b/python/tag.cc index f3fb2e6c..baf97b59 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -272,11 +272,14 @@ char *doc_ParseTagFile = "ParseTagFile(File) -> TagFile"; PyObject *ParseTagFile(PyObject *self,PyObject *Args) { PyObject *File; - if (PyArg_ParseTuple(Args,"O!",&PyFile_Type,&File) == 0) + if (PyArg_ParseTuple(Args,"O",&File) == 0) + return 0; + int fileno = PyObject_AsFileDescriptor(File); + if (fileno == -1) return 0; TagFileData *New = PyObject_NEW(TagFileData,&TagFileType); - new (&New->Fd) FileFd(fileno(PyFile_AsFile(File)),false); + new (&New->Fd) FileFd(fileno,false); New->File = File; Py_INCREF(New->File); new (&New->Object) pkgTagFile(&New->Fd); diff --git a/python/tar.cc b/python/tar.cc index e5aaee6f..f0d57823 100644 --- a/python/tar.cc +++ b/python/tar.cc @@ -97,8 +97,7 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args) PyObject *Function; char *Comp; - if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File, - &Function,&Comp) == 0) + if (PyArg_ParseTuple(Args,"OOs",&File, &Function,&Comp) == 0) return 0; if (PyCallable_Check(Function) == 0) @@ -109,7 +108,11 @@ PyObject *tarExtract(PyObject *Self,PyObject *Args) { // Open the file and associate the tar - FileFd Fd(fileno(PyFile_AsFile(File)),false); + 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(); @@ -139,8 +142,7 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) char *Chunk; const char *Comp = "gzip"; - if (PyArg_ParseTuple(Args,"O!Os",&PyFile_Type,&File, - &Function,&Chunk) == 0) + if (PyArg_ParseTuple(Args,"OOs",&File,&Function,&Chunk) == 0) return 0; if (PyCallable_Check(Function) == 0) @@ -149,10 +151,13 @@ PyObject *debExtract(PyObject *Self,PyObject *Args) 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(PyFile_AsFile(File)),false); + FileFd Fd(fileno,false); debDebFile Deb(Fd); if (_error->PendingError() == true) return HandleErrors(); -- cgit v1.2.3 From ebedf54fd4c72bfbf5c5e60d3d908cd66acace95 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Apr 2009 19:28:33 +0200 Subject: * python/cache.cc: Add support for the Breaks fields This also fixes problems on packages with Breaks field, where the lookup of the field name leads to some unprintable characters (because the index exceeds the number of items). --- debian/changelog | 1 + python/cache.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index dc8d1545..29927989 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ python-apt (0.7.11) UNRELEASED; urgency=low - Support 'key in mapping' for TagSections * Replace support for file objects with a more generic support for any object providing a fileno() method and for file descriptors (integers). + * Add support for the Breaks fields -- Julian Andres Klode Mon, 13 Apr 2009 18:08:10 +0200 diff --git a/python/cache.cc b/python/cache.cc index 0c59f561..4db097c7 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -502,7 +502,7 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, { "", "Depends","PreDepends","Suggests", "Recommends","Conflicts","Replaces", - "Obsoletes" + "Obsoletes", "Breaks" }; PyObject *Dep = PyString_FromString(Types[Start->Type]); LastDepType = Start->Type; -- cgit v1.2.3 From ccd98916ba50c7583f354e0d3487ffb0830103f0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 13 Apr 2009 20:00:09 +0200 Subject: * python/configuration.cc: Support the 'in' operator for Configuration Support the replacement of mapping.has_key() for Configuration,ConfigurationPtr and ConfigurationSub objects. This is implemented by extending the various types with the tp_as_sequence slot, which refers to a PySequenceMethods containing only this method. The CnfGetAttr() function has been removed and replaced by the use of the tp_method slot. This helps the py3k port because the previously used Py_FindMethod() is not avilable anymore. This completes the support of the 'in' operator in all python-apt objects, which makes it even easier to convert python-apt-using applications to py3k once python-apt supports it, as 2to3 converts 'm.has_key(k)' to 'k in m'. Also finalize the types in apt_pkgmodule.cc and add the new 'key in conf' description to the documentation. --- debian/changelog | 4 +-- doc/source/apt_pkg/cache.rst | 4 +++ python/apt_pkgmodule.cc | 3 ++ python/configuration.cc | 70 ++++++++++++++++++++++++++++++++++---------- 4 files changed, 64 insertions(+), 17 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 29927989..261ff7bd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ python-apt (0.7.11) UNRELEASED; urgency=low - * python/tag.cc: - - Support 'key in mapping' for TagSections + * Support the 'in' operator (e.g. "k in d") in Configuration{,Ptr,Sub} + objects (e.g. apt_pkg.Config) and in TagSections (apt_pkg.ParseSection()) * Replace support for file objects with a more generic support for any object providing a fileno() method and for file descriptors (integers). * Add support for the Breaks fields diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst index 146c2c2a..3ecbf069 100644 --- a/doc/source/apt_pkg/cache.rst +++ b/doc/source/apt_pkg/cache.rst @@ -117,6 +117,10 @@ Classes in apt_pkg The Configuration objects store the configuration of apt. + .. describe:: key in conf + + Return ``True`` if *conf* has a key *key*, else ``False``. + .. describe:: conf[key] Return the value of the option given key *key*. If it does not diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 10d98911..3d043179 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -475,6 +475,9 @@ extern "C" void initapt_pkg() // Finalize our types to add slots, etc. if (PyType_Ready(&TagSecType) == -1) return; if (PyType_Ready(&TagFileType) == -1) return; + if (PyType_Ready(&ConfigurationType) == -1) return; + if (PyType_Ready(&ConfigurationPtrType) == -1) return; + if (PyType_Ready(&ConfigurationSubType) == -1) return; // Initialize the module PyObject *Module = Py_InitModule("apt_pkg",methods); diff --git a/python/configuration.cc b/python/configuration.cc index 21f70bc1..a95ac029 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -128,6 +128,11 @@ static PyObject *CnfExists(PyObject *Self,PyObject *Args) return Py_BuildValue("i",(int)GetSelf(Self).Exists(Name)); } +static int CnfContains(PyObject *Self,PyObject *Arg) +{ + return (int)GetSelf(Self).Exists(PyString_AsString(Arg)); +} + static char *doc_Clear = "Clear(Name) -> None"; static PyObject *CnfClear(PyObject *Self,PyObject *Args) { @@ -470,34 +475,41 @@ static PyMethodDef CnfMethods[] = {} }; -// CnfGetAttr - Get an attribute - variable/method /*{{{*/ -// --------------------------------------------------------------------- -/* */ -static PyObject *CnfGetAttr(PyObject *Self,char *Name) -{ - return Py_FindMethod(CnfMethods,Self,Name); -} - // Type for a Normal Configuration object +static PySequenceMethods ConfigurationSeq = {0,0,0,0,0,0,0,CnfContains,0,0}; static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; PyTypeObject ConfigurationType = { PyObject_HEAD_INIT(&PyType_Type) - 0, // ob_size + 0, // ob_size "Configuration", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods CppDealloc, // tp_dealloc 0, // tp_print - CnfGetAttr, // tp_getattr + 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number - 0, // tp_as_sequence + &ConfigurationSeq, // tp_as_sequence &ConfigurationMap, // tp_as_mapping 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags + "Configuration Object", // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + CnfMethods, // tp_methods }; PyTypeObject ConfigurationPtrType = @@ -510,14 +522,28 @@ PyTypeObject ConfigurationPtrType = // Methods (destructor)PyObject_Free, // tp_dealloc 0, // tp_print - CnfGetAttr, // tp_getattr + 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number - 0, // tp_as_sequence + &ConfigurationSeq, // tp_as_sequence &ConfigurationMap, // tp_as_mapping 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags + "ConfigurationPtr Object", // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + CnfMethods, // tp_methods }; PyTypeObject ConfigurationSubType = @@ -530,13 +556,27 @@ PyTypeObject ConfigurationSubType = // Methods CnfSubFree, // tp_dealloc 0, // tp_print - CnfGetAttr, // tp_getattr + 0, // tp_getattr 0, // tp_setattr 0, // tp_compare 0, // tp_repr 0, // tp_as_number - 0, // tp_as_sequence + &ConfigurationSeq, // tp_as_sequence &ConfigurationMap, // tp_as_mapping 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags + "ConfigurationSub Object", // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + CnfMethods, // tp_methods }; -- cgit v1.2.3 From 2b867aebe32d59b7450f3a7fb22390e0dd9f8cc7 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Apr 2009 14:16:28 +0200 Subject: * apt/cache.py: Use set() and WeakValueDictionary() for holding packages. Only create Package objects when they are requested, do not keep them in a dict. Saves 10MB for 25,000 packages on my machine. The set holds the names of all packages which have at least one version, and the WeakValueDictionary() holds weak references to created Package objects. This way accessing the same package two times should return the same object, kept by the WeakValueDictionary(). --- apt/cache.py | 38 +++++++++++++++++++++++--------------- debian/changelog | 4 +++- 2 files changed, 26 insertions(+), 16 deletions(-) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index cc425ccb..d13010af 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -20,6 +20,7 @@ # USA import os +import weakref import apt_pkg from apt import Package @@ -80,7 +81,8 @@ class Cache(object): self._records = apt_pkg.GetPkgRecords(self._cache) self._list = apt_pkg.GetPkgSourceList() self._list.ReadMainList() - self._dict = {} + self._set = set() + self._weakref = weakref.WeakValueDictionary() progress.Op = "Building data structures" i=last=0 @@ -91,7 +93,7 @@ class Cache(object): last=i # drop stuff with no versions (cruft) if len(pkg.VersionList) > 0: - self._dict[pkg.Name] = Package(self, pkg) + self._set.add(pkg.Name) i += 1 @@ -100,30 +102,36 @@ class Cache(object): def __getitem__(self, key): """ look like a dictionary (get key) """ - return self._dict[key] + try: + return self._weakref[key] + except KeyError: + if key in self._set: + pkg = self._weakref[key] = Package(self, self._cache[key]) + return pkg + else: + raise KeyError('The cache has no package named %r' % key) def __iter__(self): - for pkgname in self._dict.keys(): - yield self._dict[pkgname] + for pkgname in self._set: + yield self[pkgname] raise StopIteration def has_key(self, key): - return (key in self._dict) + return (key in self._set) def __contains__(self, key): - return (key in self._dict) + return (key in self._set) def __len__(self): - return len(self._dict) + return len(self._set) def keys(self): - return self._dict.keys() + return list(self._set) def getChanges(self): """ Get the marked changes """ changes = [] - for name in self._dict.keys(): - p = self._dict[name] + for p in self: if p.markedUpgrade or p.markedInstall or p.markedDelete or \ p.markedDowngrade or p.markedReinstall: changes.append(p) @@ -348,7 +356,7 @@ class FilteredCache(object): return len(self._filtered) def __getitem__(self, key): - return self.cache._dict[key] + return self.cache[key] def __iter__(self): for pkgname in self._filtered: @@ -366,10 +374,10 @@ class FilteredCache(object): def _reapplyFilter(self): " internal helper to refilter " self._filtered = {} - for pkg in self.cache._dict.keys(): + for pkg in self.cache: for f in self._filters: - if f.apply(self.cache._dict[pkg]): - self._filtered[pkg] = 1 + if f.apply(pkg): + self._filtered[pkg.name] = 1 break def setFilter(self, filter): diff --git a/debian/changelog b/debian/changelog index 261ff7bd..6cbdaac7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,8 +5,10 @@ python-apt (0.7.11) UNRELEASED; urgency=low * Replace support for file objects with a more generic support for any object providing a fileno() method and for file descriptors (integers). * Add support for the Breaks fields + * Only create Package objects when they are requested, do not keep them in + a dict. Saves 10MB for 25,000 packages on my machine. - -- Julian Andres Klode Mon, 13 Apr 2009 18:08:10 +0200 + -- Julian Andres Klode Wed, 15 Apr 2009 13:47:42 +0200 python-apt (0.7.10.3) unstable; urgency=low -- cgit v1.2.3 From c876c5095673a2f1c0f2c0eef6eadef2ce200e19 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Apr 2009 16:19:12 +0200 Subject: * Introduce support for Python 3 (Closes: #523645) This is the first initial port to Python 3. The API is almost completely identical to the one found in Python 2, except that functions working with binary data require bytes (md5sum,sha1sum,sha256sum,Base64Encode). Using setup3.py to install the modules will not work, because the apt package still has to be converted to Python 3. For the package, we call 2to3-3.1 in debian/rules to do this automatically. --- apt/package.py | 6 +++- debian/changelog | 2 ++ debian/control | 2 ++ debian/rules | 26 +++++++++++++-- po/python-apt.pot | 10 +++--- python/acquire.cc | 6 ++++ python/apt_instmodule.cc | 35 ++++++++++++++++++- python/apt_pkgmodule.cc | 87 +++++++++++++++++++++++++++++++++++------------- python/cache.cc | 18 ++++++++++ python/cdrom.cc | 2 ++ python/configuration.cc | 6 ++++ python/depcache.cc | 6 ++++ python/generic.h | 25 ++++++++++++++ python/indexfile.cc | 2 ++ python/metaindex.cc | 2 ++ python/pkgmanager.cc | 2 ++ python/pkgrecords.cc | 2 ++ python/pkgsrcrecords.cc | 2 ++ python/sourcelist.cc | 2 ++ python/string.cc | 16 ++++++++- python/tag.cc | 4 +++ setup3.py | 77 ++++++++++++++++++++++++++++++++++++++++++ 22 files changed, 307 insertions(+), 33 deletions(-) create mode 100644 setup3.py (limited to 'debian') diff --git a/apt/package.py b/apt/package.py index 3ea1105d..f12f5559 100644 --- a/apt/package.py +++ b/apt/package.py @@ -272,8 +272,12 @@ class Version(object): """ self.summary # This does the lookup for us. desc = '' + + dsc = self.package._pcache._records.LongDesc try: - dsc = unicode(self.package._pcache._records.LongDesc, "utf-8") + if not isinstance(dsc, unicode): + # Only convert where needed (i.e. Python 2.X) + dsc = unicode(dsc, "utf-8") except UnicodeDecodeError, err: return _("Invalid unicode in description for '%s' (%s). " "Please report.") % (self.package.name, err) diff --git a/debian/changelog b/debian/changelog index 6cbdaac7..a9518d7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,7 @@ python-apt (0.7.11) UNRELEASED; urgency=low + * Introduce support for Python 3 (Closes: #523645) + * Support the 'in' operator (e.g. "k in d") in Configuration{,Ptr,Sub} objects (e.g. apt_pkg.Config) and in TagSections (apt_pkg.ParseSection()) * Replace support for file objects with a more generic support for any object diff --git a/debian/control b/debian/control index 72476c58..08ee329f 100644 --- a/debian/control +++ b/debian/control @@ -11,6 +11,8 @@ Build-Depends: apt-utils, libapt-pkg-dev (>= 0.7.10), python-all-dbg, python-all-dev, + python3.1-dev, + python3.1-dbg, python-central (>= 0.5), python-distutils-extra (>= 1.9.0), python-gtk2, diff --git a/debian/rules b/debian/rules index 6d709ecd..7de945f2 100755 --- a/debian/rules +++ b/debian/rules @@ -11,22 +11,44 @@ DEB_PYTHON_PACKAGES_EXCLUDE=python-apt-dbg include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk +PY3K = y PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) export DEBVER + +ifeq ($(PY3K),y) +build/python-apt:: + python3.1 setup3.py build + +install/python-apt:: + python3.1 ./setup3.py install --root $(CURDIR)/debian/python-apt \ + --install-layout=deb --no-compile + + find $(CURDIR)/debian/python-apt/usr/lib/python3.1/dist-packages/ -name '*.py' \ + | xargs 2to3-3.1 | patch -p0 +endif + build/python-apt-dbg:: set -e; \ for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py build; \ done + ifeq($(PY3K),y) + python3.1-dbg ./setup3.py build + endif install/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ - python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg; \ + python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg \ + --no-compile; \ done + ifeq($(PY3K),y) + python3.1-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ + --install-layout=deb --no-compile + endif find debian/python-apt-dbg \ ! -type d ! -name '*_d.so' | xargs rm -f find debian/python-apt-dbg -depth -empty -exec rmdir {} \; @@ -39,4 +61,4 @@ binary-predeb/python-apt-dbg:: ln -s python-apt debian/python-apt-dbg/usr/share/doc/python-apt-dbg clean:: - rm -rf build/lib* build/temp* + rm -rf build/lib* build/temp* build diff --git a/po/python-apt.pot b/po/python-apt.pot index 9c23c579..d12ae967 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-04-12 19:07+0200\n" +"POT-Creation-Date: 2009-04-15 16:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -354,16 +354,16 @@ msgstr "" msgid "Complete" msgstr "" -#: ../apt/package.py:278 +#: ../apt/package.py:282 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:745 ../apt/package.py:849 +#: ../apt/package.py:830 ../apt/package.py:934 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:853 +#: ../apt/package.py:938 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -372,7 +372,7 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:859 +#: ../apt/package.py:944 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." diff --git a/python/acquire.cc b/python/acquire.cc index d39ee495..053753cd 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -72,7 +72,9 @@ static PyObject *AcquireItemRepr(PyObject *Self) PyTypeObject AcquireItemType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgAcquire::ItemIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -175,7 +177,9 @@ static PyGetSetDef PkgAcquireGetSet[] = { PyTypeObject PkgAcquireType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Acquire", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -234,7 +238,9 @@ PyObject *GetAcquire(PyObject *Self,PyObject *Args) PyTypeObject PkgAcquireFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgAcquireFile", // tp_name sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index a9d81be4..09e3937e 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -162,8 +162,41 @@ static PyMethodDef methods[] = {} }; +#if PY_MAJOR_VERSION >= 3 +struct module_state { + PyObject *error; +}; +#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) + +static int apt_inst_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; +} + +static int apt_inst_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; +} + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "apt_inst", + NULL, + sizeof(struct module_state), + methods, + NULL, + apt_inst_traverse, + apt_inst_clear, + NULL +}; + +extern "C" PyObject * PyInit_apt_inst() +{ + return PyModule_Create(&moduledef); +} +#else extern "C" void initapt_inst() { Py_InitModule("apt_inst",methods); } - /*}}}*/ +#endif /*}}}*/ diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index fe6a739e..e71d8ee6 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -173,12 +173,12 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; MD5Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -213,12 +213,12 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; SHA1Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -253,12 +253,12 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) return 0; // Digest of a string. - if (PyString_Check(Obj) != 0) + if (PyBytes_Check(Obj) != 0) { char *s; Py_ssize_t len; SHA256Summation Sum; - PyString_AsStringAndSize(Obj, &s, &len); + PyBytes_AsStringAndSize(Obj, &s, &len); Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -470,30 +470,68 @@ static void AddInt(PyObject *Dict,const char *Itm,unsigned long I) Py_DECREF(Obj); } +#if PY_MAJOR_VERSION >= 3 +struct module_state { + PyObject *error; +}; + +#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) + +static int apt_inst_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; +} + +static int apt_inst_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; +} + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "apt_inst", + NULL, + sizeof(struct module_state), + methods, + NULL, + apt_inst_traverse, + apt_inst_clear, + NULL +}; + +#define INIT_ERROR return 0 +extern "C" PyObject * PyInit_apt_pkg() +#else +#define INIT_ERROR return extern "C" void initapt_pkg() +#endif { // Finalize our types to add slots, etc. - if (PyType_Ready(&TagSecType) == -1) return; - if (PyType_Ready(&TagFileType) == -1) return; - if (PyType_Ready(&ConfigurationType) == -1) return; - if (PyType_Ready(&ConfigurationPtrType) == -1) return; - if (PyType_Ready(&ConfigurationSubType) == -1) return; - if (PyType_Ready(&PkgCdromType) == -1) return; - if (PyType_Ready(&PkgProblemResolverType) == -1) return; - if (PyType_Ready(&PkgActionGroupType) == -1) return; - if (PyType_Ready(&PkgSourceListType) == -1) return; - if (PyType_Ready(&PkgCacheType) == -1) return; - if (PyType_Ready(&DependencyType) == -1) return; - if (PyType_Ready(&PkgDepCacheType) == -1) return; - if (PyType_Ready(&PkgAcquireType) == -1) return; - if (PyType_Ready(&PackageIndexFileType) == -1) return; - if (PyType_Ready(&PkgManagerType) == -1) return; - if (PyType_Ready(&PkgSrcRecordsType) == -1) return; - if (PyType_Ready(&PkgRecordsType) == -1) return; + if (PyType_Ready(&TagSecType) == -1) INIT_ERROR; + if (PyType_Ready(&TagFileType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationPtrType) == -1) INIT_ERROR; + if (PyType_Ready(&ConfigurationSubType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgCdromType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgProblemResolverType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgActionGroupType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgSourceListType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgCacheType) == -1) INIT_ERROR; + if (PyType_Ready(&DependencyType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgDepCacheType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgAcquireType) == -1) INIT_ERROR; + if (PyType_Ready(&PackageIndexFileType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgManagerType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgSrcRecordsType) == -1) INIT_ERROR; + if (PyType_Ready(&PkgRecordsType) == -1) INIT_ERROR; // Initialize the module + #if PY_MAJOR_VERSION >= 3 + PyObject *Module = PyModule_Create(&moduledef); + #else PyObject *Module = Py_InitModule("apt_pkg",methods); + #endif PyObject *Dict = PyModule_GetDict(Module); // Global variable linked to the global configuration class @@ -549,6 +587,9 @@ extern "C" void initapt_pkg() AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); AddInt(Dict,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); + #if PY_MAJOR_VERSION >= 3 + return Module; + #endif } /*}}}*/ diff --git a/python/cache.cc b/python/cache.cc index 2d8b8db7..957681ba 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -239,7 +239,9 @@ static PyMappingMethods CacheMap = {0,CacheMapOp,0}; PyTypeObject PkgCacheType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -277,7 +279,9 @@ PyTypeObject PkgCacheType = PyTypeObject PkgCacheFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCacheFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -345,7 +349,9 @@ static PySequenceMethods PkgListSeq = PyTypeObject PkgListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::PkgIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -435,7 +441,9 @@ static PyObject *PackageRepr(PyObject *Self) PyTypeObject PackageType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::Package", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -498,7 +506,9 @@ static PyObject *DescriptionRepr(PyObject *Self) PyTypeObject DescriptionType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DescIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -684,7 +694,9 @@ static PyObject *VersionRepr(PyObject *Self) PyTypeObject VersionType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::VerIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -759,7 +771,9 @@ static PyObject *PackageFileRepr(PyObject *Self) PyTypeObject PackageFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::PkgFileIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -905,7 +919,9 @@ static PyGetSetDef DependencyGetSet[] = { PyTypeObject DependencyType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DepIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -991,7 +1007,9 @@ static PySequenceMethods RDepListSeq = PyTypeObject RDepListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgCache::DepIterator", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/cdrom.cc b/python/cdrom.cc index 0816d93e..b3a38438 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -67,7 +67,9 @@ static PyMethodDef PkgCdromMethods[] = PyTypeObject PkgCdromType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Cdrom", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/configuration.cc b/python/configuration.cc index b4adf357..eaac48ec 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -481,7 +481,9 @@ static PyMappingMethods ConfigurationMap = {0,CnfMap,CnfMapSet}; PyTypeObject ConfigurationType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "Configuration", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -515,7 +517,9 @@ PyTypeObject ConfigurationType = PyTypeObject ConfigurationPtrType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "ConfigurationPtr", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize @@ -549,7 +553,9 @@ PyTypeObject ConfigurationPtrType = PyTypeObject ConfigurationSubType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "ConfigurationSub", // tp_name sizeof(SubConfiguration), // tp_basicsize 0, // tp_itemsize diff --git a/python/depcache.cc b/python/depcache.cc index ade3d4f5..1c9eeff7 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -594,7 +594,9 @@ static PyGetSetDef PkgDepCacheGetSet[] = { PyTypeObject PkgDepCacheType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgDepCache", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -773,7 +775,9 @@ static PyMethodDef PkgProblemResolverMethods[] = PyTypeObject PkgProblemResolverType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgProblemResolver", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize @@ -829,7 +833,9 @@ static PyMethodDef PkgActionGroupMethods[] = PyTypeObject PkgActionGroupType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgActionGroup", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/generic.h b/python/generic.h index ce79a54c..6e66d24c 100644 --- a/python/generic.h +++ b/python/generic.h @@ -35,6 +35,31 @@ typedef int Py_ssize_t; #endif +/* Define compatibility for Python 3. + * + * We will use the names PyString_* to refer to the default string type + * of the current Python version (PyString on 2.X, PyUnicode on 3.X). + * + * When we really need unicode strings, we will use PyUnicode_* directly, as + * long as it exists in Python 2 and Python 3. + * + * When we want bytes in Python 3, we use PyBytes*_ instead of PyString_* and + * define aliases from PyBytes_* to PyString_* for Python 2. + */ + +#if PY_MAJOR_VERSION >= 3 +#define PyString_Check PyUnicode_Check +#define PyString_FromString PyUnicode_FromString +#define PyString_FromStringAndSize PyUnicode_FromStringAndSize +#define PyString_AsString(op) PyBytes_AsString(PyUnicode_AsUTF8String(op)) +#define PyInt_Check PyLong_Check +#define PyInt_AsLong PyLong_AsLong +#else +#define PyBytes_Check PyString_Check +#define PyBytes_AsString PyString_AsString +#define PyBytes_AsStringAndSize PyString_AsStringAndSize +#endif + template struct CppPyObject : public PyObject { // We are only using CppPyObject and friends as dumb structs only, ie the diff --git a/python/indexfile.cc b/python/indexfile.cc index dc55634f..bb40cdd0 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -81,7 +81,9 @@ static PyGetSetDef PackageIndexFileGetSet[] = { PyTypeObject PackageIndexFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgIndexFile", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/metaindex.cc b/python/metaindex.cc index efbc38af..cbaeafbd 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -59,7 +59,9 @@ static PyObject *MetaIndexRepr(PyObject *Self) PyTypeObject MetaIndexType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "metaIndex", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 52f86228..8f56cddc 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -95,7 +95,9 @@ static PyGetSetDef PkgManagerGetSet[] = { PyTypeObject PkgManagerType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "PackageManager", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 577aaf1c..978de6b7 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -135,7 +135,9 @@ static PyGetSetDef PkgRecordsGetSet[] = { PyTypeObject PkgRecordsType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgRecords", // tp_name sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index c830f8d2..97667d7a 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -183,7 +183,9 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { PyTypeObject PkgSrcRecordsType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgSrcRecords", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 9f8f8878..48b3b7c8 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -100,7 +100,9 @@ static PyGetSetDef PkgSourceListGetSet[] = { PyTypeObject PkgSourceListType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "pkgSourceList", // tp_name sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize diff --git a/python/string.cc b/python/string.cc index 8168ea5b..b95ee3eb 100644 --- a/python/string.cc +++ b/python/string.cc @@ -38,7 +38,21 @@ PyObject *Python(PyObject *Self,PyObject *Args) \ } MkStr(StrDeQuote,DeQuoteString); -MkStr(StrBase64Encode,Base64Encode); + +/* + * Input bytes(Py3k)/str(Py2), output str. + */ +PyObject *StrBase64Encode(PyObject *Self,PyObject *Args) { + char *Str = 0; + #if PY_MAJOR_VERSION >= 3 + if (PyArg_ParseTuple(Args,"y",&Str) == 0) + #else + if (PyArg_ParseTuple(Args,"s",&Str) == 0) + #endif + return 0; + return CppPyString(Base64Encode(Str)); +} + MkStr(StrURItoFileName,URItoFileName); //MkFloat(StrSizeToStr,SizeToStr); diff --git a/python/tag.cc b/python/tag.cc index cdea3e03..18d08580 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -384,7 +384,9 @@ PyMappingMethods TagSecMapMeth = {TagSecLength,TagSecMap,0}; PyTypeObject TagSecType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "TagSection", // tp_name sizeof(TagSecData), // tp_basicsize 0, // tp_itemsize @@ -442,7 +444,9 @@ static PyGetSetDef TagFileGetSet[] = { PyTypeObject TagFileType = { PyObject_HEAD_INIT(&PyType_Type) + #if PY_MAJOR_VERSION < 3 0, // ob_size + #endif "TagFile", // tp_name sizeof(TagFileData), // tp_basicsize 0, // tp_itemsize diff --git a/setup3.py b/setup3.py new file mode 100644 index 00000000..a3cbdc8e --- /dev/null +++ b/setup3.py @@ -0,0 +1,77 @@ +#! /usr/bin/env python3 +# $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ +import glob +import os +import shutil +import sys + +from distutils.core import setup, Extension +from distutils.sysconfig import parse_makefile +#from DistUtilsExtra.command import build_extra, build_i18n + + +# The apt_pkg module +files = ["python/"+source for source in parse_makefile("python/makefile")["APT_PKG_SRC"].split()] +apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) + +# The apt_inst module +files = ["python/"+source for source in parse_makefile("python/makefile")["APT_INST_SRC"].split()] +apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) + +# Replace the leading _ that is used in the templates for translation +templates = [] + +# build doc +if len(sys.argv) > 1 and sys.argv[1] == "build": + if not os.path.exists("build/data/templates/"): + os.makedirs("build/data/templates") + for template in glob.glob('data/templates/*.info.in'): + source = open(template, "r") + build = open(os.path.join("build", template[:-3]), "w") + lines = source.readlines() + for line in lines: + build.write(line.lstrip("_")) + source.close() + build.close() + + +if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: + for dirname in "build/doc", "doc/build", "build/data", "build/mo": + if os.path.exists(dirname): + print("Removing", dirname) + shutil.rmtree(dirname) + else: + print("Not removing", dirname, "because it does not exist") + +setup(name="python-apt", + description="Python bindings for APT", + version=os.environ.get('DEBVER'), + author="APT Development Team", + author_email="deity@lists.debian.org", + ext_modules=[apt_pkg, apt_inst], + packages=['apt', 'apt.progress', 'aptsources'], + data_files = [('share/python-apt/templates', + glob.glob('build/data/templates/*.info')), + ('share/python-apt/templates', + glob.glob('data/templates/*.mirrors'))], +# cmdclass = {"build": build_extra.build_extra, +# "build_i18n": build_i18n.build_i18n}, + license = 'GNU GPL', + platforms = 'posix') + +if len(sys.argv) > 1 and sys.argv[1] == "build": + try: + import sphinx + except ImportError: + print(('W: Sphinx not available - Not building' + 'documentation'), file=sys.stderr) + try: + import pygtk + except ImportError: + print(('W: Not building documentation because python-' + 'gtk2 is not available at the moment.'), file=sys.stderr) + sys.exit(0) + sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/html"]) + sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", + os.path.abspath("doc/source"), "build/doc/text"]) -- cgit v1.2.3 From b71b5243d22f75ba5df926e8086345498157032e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Apr 2009 20:22:04 +0200 Subject: * debian/rules: Fix building. --- debian/rules | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'debian') diff --git a/debian/rules b/debian/rules index 7de945f2..9d0219e2 100755 --- a/debian/rules +++ b/debian/rules @@ -36,19 +36,19 @@ build/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py build; \ done - ifeq($(PY3K),y) +ifeq ($(PY3K),y) python3.1-dbg ./setup3.py build - endif +endif install/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg \ --no-compile; \ done - ifeq($(PY3K),y) +ifeq ($(PY3K),y) python3.1-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ --install-layout=deb --no-compile - endif +endif find debian/python-apt-dbg \ ! -type d ! -name '*_d.so' | xargs rm -f find debian/python-apt-dbg -depth -empty -exec rmdir {} \; -- cgit v1.2.3 From abc7c861e85265b0725aa82a51fe41f9183bc506 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Apr 2009 20:23:04 +0200 Subject: * Upload as 0.7.90 to experimental This is the first pre-release of python-apt 0.8. It is completely backward compatible (even on Python 3), API changes will appear in 0.7.91. --- debian/changelog | 2 +- doc/source/apt_inst.rst | 10 +++++----- doc/source/apt_pkg/cache.rst | 8 ++++---- doc/source/apt_pkg/index.rst | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index d356c3cf..b2f2b965 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.11) UNRELEASED; urgency=low +python-apt (0.7.90) experimental; urgency=low * Introduce support for Python 3 (Closes: #523645) diff --git a/doc/source/apt_inst.rst b/doc/source/apt_inst.rst index 999d074e..cd371e36 100644 --- a/doc/source/apt_inst.rst +++ b/doc/source/apt_inst.rst @@ -15,7 +15,7 @@ Checking packages :class:`file()` object, a file descriptor, or anything implementing a :meth:`fileno` method. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for file descriptors and objects implementing a :meth:`fileno` method. @@ -34,7 +34,7 @@ Listing contents See :ref:`emulating-dpkg-contents` for a more detailed example. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for file descriptors and objects implementing a :meth:`fileno` method. .. function:: tarExtract(file,func,comp) @@ -47,7 +47,7 @@ Listing contents The parameter *file* may be a :class:`file()` object, a file descriptor, or anything implementing a :meth:`fileno` method. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for file descriptors and objects implementing a :meth:`fileno` method. @@ -81,7 +81,7 @@ Extracting contents If the directory given by *rootdir* does not exist, the package is extracted into the current directory. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for file descriptors and objects implementing a :meth:`fileno` method. .. function:: debExtractControl(file[, member='control']) @@ -97,7 +97,7 @@ Extracting contents print debExtractControl(open("package.deb")) - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for file descriptors and objects implementing a :meth:`fileno` method. diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst index 86515569..a58f1356 100644 --- a/doc/source/apt_pkg/cache.rst +++ b/doc/source/apt_pkg/cache.rst @@ -121,7 +121,7 @@ Classes in apt_pkg Return ``True`` if *conf* has a key *key*, else ``False``. - .. versionadded:: 0.7.11 + .. versionadded:: 0.8.0 .. describe:: conf[key] @@ -207,7 +207,7 @@ Classes in apt_pkg Return whether the configuration contains the key *key*. - .. deprecated:: 0.7.11 + .. deprecated:: 0.8.0 .. method:: get(key[, default='']) @@ -1211,7 +1211,7 @@ broken dependencies: Return ``True`` if *section* has a key *key*, else ``False``. - .. versionadded:: 0.7.11 + .. versionadded:: 0.8.0 .. method:: Bytes @@ -1236,7 +1236,7 @@ broken dependencies: Check whether the field with named by *key* exists. - .. deprecated:: 0.7.11 + .. deprecated:: 0.8.0 .. method:: keys() diff --git a/doc/source/apt_pkg/index.rst b/doc/source/apt_pkg/index.rst index 60c3ba9b..47923c23 100644 --- a/doc/source/apt_pkg/index.rst +++ b/doc/source/apt_pkg/index.rst @@ -166,7 +166,7 @@ of the ones provides in Python's :mod:`hashlib` module. object (or a file descriptor), in which case the md5sum of its contents is returned. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for using file descriptors. .. function:: sha1sum(object) @@ -176,7 +176,7 @@ of the ones provides in Python's :mod:`hashlib` module. object (or a file descriptor), in which case the sha1sum of its contents is returned. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for using file descriptors. .. function:: sha256sum(object) @@ -186,7 +186,7 @@ of the ones provides in Python's :mod:`hashlib` module. object (or a file descriptor), in which case the sha256sum of its contents is returned. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for using file descriptors. Debian control files @@ -202,7 +202,7 @@ Debian control files be a :class:`file()` object, a file descriptor, or anything providing a :meth:`fileno()` method. - .. versionchanged:: 0.7.11 + .. versionchanged:: 0.8.0 Added support for using file descriptors. .. autofunction:: RewriteSection(section, order, rewrite_list) -- cgit v1.2.3 From 337c885e7dd531858c35b256d974989bac6463df Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 16 Apr 2009 20:06:14 +0200 Subject: * apt/*.py: Initial rename work for Bug#481061 A new module, apt.deprecation, is introduced containing functions and classes which assist in the deprecation. The apt_pkg extension gets a new attribute, _COMPAT_0_7 which can be set by defining COMPAT_0_7 at compile time (-DCOMPAT_0_7). The names are changed, and compatibility functions are enabled if bool(apt_pkg._COMPAT_0_7) == True, i.e. if the package has been built with backward compatibility fixes. This commit changes the apt and aptsources packages, the apt_pkg and apt_inst extensions will be the next renames. --- apt/__init__.py | 15 ++++-- apt/cache.py | 108 +++++++++++++++++++++++++-------------- apt/cdrom.py | 6 ++- apt/debfile.py | 32 ++++++------ apt/deprecation.py | 76 ++++++++++++++++++++++++++++ apt/package.py | 126 +++++++++++++++++++++++++++++++--------------- apt/progress/gtk2.py | 6 +-- aptsources/sourceslist.py | 6 ++- debian/changelog | 6 +++ debian/control | 2 +- debian/rules | 3 ++ po/python-apt.pot | 10 ++-- python/apt_pkgmodule.cc | 6 +++ 13 files changed, 290 insertions(+), 112 deletions(-) create mode 100644 apt/deprecation.py (limited to 'debian') diff --git a/apt/__init__.py b/apt/__init__.py index ae2abbf2..734b3240 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -17,17 +17,21 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # import the core of apt_pkg +"""High-Level Interface for working with apt.""" import apt_pkg -import sys -import os # import some fancy classes from apt.package import Package from apt.cache import Cache -from apt.progress import ( - OpProgress, FetchProgress, InstallProgress, CdromProgress) from apt.cdrom import Cdrom -from apt_pkg import SizeToStr, TimeToStr, VersionCompare + +if apt_pkg._COMPAT_0_7: + from apt.progress import (OpProgress, FetchProgress, InstallProgress, + CdromProgress) + + +if apt_pkg._COMPAT_0_7: + from apt_pkg import SizeToStr, TimeToStr, VersionCompare # init the package system apt_pkg.init() @@ -36,3 +40,4 @@ apt_pkg.init() #import warnings #warnings.warn("apt API not stable yet", FutureWarning) #del warnings +__all__ = ['Cache', 'Cdrom', 'Package'] diff --git a/apt/cache.py b/apt/cache.py index d13010af..928322d2 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -24,6 +24,7 @@ import weakref import apt_pkg from apt import Package +from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by import apt.progress @@ -63,7 +64,7 @@ class Cache(object): rootdir + "/var/lib/dpkg/status") self.open(progress) - def _runCallbacks(self, name): + def _run_callbacks(self, name): """ internal helper to run a callback """ if name in self._callbacks: for callback in self._callbacks[name]: @@ -75,7 +76,7 @@ class Cache(object): """ if progress is None: progress = apt.progress.OpProgress() - self._runCallbacks("cache_pre_open") + self._run_callbacks("cache_pre_open") self._cache = apt_pkg.GetCache(progress) self._depcache = apt_pkg.GetDepCache(self._cache) self._records = apt_pkg.GetPkgRecords(self._cache) @@ -98,7 +99,7 @@ class Cache(object): i += 1 progress.done() - self._runCallbacks("cache_post_open") + self._run_callbacks("cache_post_open") def __getitem__(self, key): """ look like a dictionary (get key) """ @@ -128,12 +129,12 @@ class Cache(object): def keys(self): return list(self._set) - def getChanges(self): + def get_changes(self): """ Get the marked changes """ changes = [] for p in self: - if p.markedUpgrade or p.markedInstall or p.markedDelete or \ - p.markedDowngrade or p.markedReinstall: + if p.marked_upgrade or p.marked_install or p.marked_delete or \ + p.marked_downgrade or p.marked_reinstall: changes.append(p) return changes @@ -141,12 +142,12 @@ class Cache(object): """ Upgrade the all package, DistUpgrade will also install new dependencies """ - self.cachePreChange() + self.cache_pre_change() self._depcache.Upgrade(distUpgrade) - self.cachePostChange() + self.cache_post_change() @property - def requiredDownload(self): + def required_download(self): """Get the size of the packages that are required to download.""" pm = apt_pkg.GetPackageManager(self._depcache) fetcher = apt_pkg.GetAcquire() @@ -154,12 +155,12 @@ class Cache(object): return fetcher.FetchNeeded @property - def additionalRequiredSpace(self): + def required_space(self): """Get the size of the additional required space on the fs.""" return self._depcache.UsrSize @property - def reqReinstallPkgs(self): + def req_reinstall_pkgs(self): """Return the packages not downloadable packages in reqreinst state.""" reqreinst = set() for pkg in self: @@ -169,7 +170,7 @@ class Cache(object): reqreinst.add(pkg.name) return reqreinst - def _runFetcher(self, fetcher): + def _run_fetcher(self, fetcher): # do the actual fetching res = fetcher.Run() @@ -194,7 +195,7 @@ class Cache(object): raise FetchFailedException(errMsg) return res - def _fetchArchives(self, fetcher, pm): + def _fetch_archives(self, fetcher, pm): """ fetch the needed archives """ # get lock @@ -209,16 +210,16 @@ class Cache(object): return False # now run the fetcher, throw exception if something fails to be # fetched - return self._runFetcher(fetcher) + return self._run_fetcher(fetcher) finally: os.close(lock) - def isVirtualPackage(self, pkgname): + def is_virtual_package(self, pkgname): """Return whether the package is a virtual package.""" pkg = self._cache[pkgname] return bool(pkg.ProvidesList and not pkg.VersionList) - def getProvidingPackages(self, virtual): + def get_providing_packages(self, virtual): """ Return a list of packages which provide the virtual package of the specified name @@ -254,10 +255,16 @@ class Cache(object): finally: os.close(lock) - def installArchives(self, pm, installProgress): - installProgress.startUpdate() + def install_archives(self, pm, installProgress): + try: + installProgress.start_update() + except AttributeError: + installProgress.startUpdate() res = installProgress.run(pm) - installProgress.finishUpdate() + try: + installProgress.finish_update() + except AttributeError: + installProgress.finishUpdate() return res def commit(self, fetchProgress=None, installProgress=None): @@ -278,10 +285,10 @@ class Cache(object): fetcher = apt_pkg.GetAcquire(fetchProgress) while True: # fetch archives first - res = self._fetchArchives(fetcher, pm) + res = self._fetch_archives(fetcher, pm) # then install - res = self.installArchives(pm, installProgress) + res = self.install_archives(pm, installProgress) if res == pm.ResultCompleted: break if res == pm.ResultFailed: @@ -296,14 +303,14 @@ class Cache(object): # cache changes - def cachePostChange(self): + def cache_post_change(self): " called internally if the cache has changed, emit a signal then " - self._runCallbacks("cache_post_change") + self._run_callbacks("cache_post_change") - def cachePreChange(self): + def cache_pre_change(self): """ called internally if the cache is about to change, emit a signal then """ - self._runCallbacks("cache_pre_change") + self._run_callbacks("cache_pre_change") def connect(self, name, callback): """ connect to a signal, currently only used for @@ -312,6 +319,20 @@ class Cache(object): self._callbacks[name] = [] self._callbacks[name].append(callback) + if apt_pkg._COMPAT_0_7: + _runCallbacks = function_deprecated_by(_run_callbacks) + getChanges = function_deprecated_by(get_changes) + requiredDownload = AttributeDeprecatedBy('required_download') + additionalRequiredSpace = AttributeDeprecatedBy('required_space') + reqReinstallPkgs = AttributeDeprecatedBy('req_reinstall_pkgs') + _runFetcher = function_deprecated_by(_run_fetcher) + _fetchArchives = function_deprecated_by(_fetch_archives) + isVirtualPackage = function_deprecated_by(is_virtual_package) + getProvidingPackages = function_deprecated_by(get_providing_packages) + installArchives = function_deprecated_by(install_archives) + cachePostChange = function_deprecated_by(cache_post_change) + cachePreChange = function_deprecated_by(cache_pre_change) + # ----------------------------- experimental interface @@ -330,7 +351,7 @@ class MarkedChangesFilter(Filter): """ Filter that returns all marked changes """ def apply(self, pkg): - if pkg.markedInstall or pkg.markedDelete or pkg.markedUpgrade: + if pkg.marked_install or pkg.marked_delete or pkg.marked_upgrade: return True else: return False @@ -347,8 +368,8 @@ class FilteredCache(object): self.cache = Cache(progress) else: self.cache = cache - self.cache.connect("cache_post_change", self.filterCachePostChange) - self.cache.connect("cache_post_open", self.filterCachePostChange) + self.cache.connect("cache_post_change", self.filter_cache_post_change) + self.cache.connect("cache_post_open", self.filter_cache_post_change) self._filtered = {} self._filters = [] @@ -371,7 +392,7 @@ class FilteredCache(object): def __contains__(self, key): return (key in self._filtered) - def _reapplyFilter(self): + def _reapply_filter(self): " internal helper to refilter " self._filtered = {} for pkg in self.cache: @@ -380,18 +401,19 @@ class FilteredCache(object): self._filtered[pkg.name] = 1 break - def setFilter(self, filter): + def set_filter(self, filter): """Set the current active filter.""" self._filters = [] self._filters.append(filter) #self._reapplyFilter() # force a cache-change event that will result in a refiltering - self.cache.cachePostChange() + self.cache.cache_post_change() - def filterCachePostChange(self): + def filter_cache_post_change(self): """Called internally if the cache changes, emit a signal then.""" #print "filterCachePostChange()" - self._reapplyFilter() + self._reapply_filter() + # def connect(self, name, callback): # self.cache.connect(name, callback) @@ -401,6 +423,12 @@ class FilteredCache(object): #print "getattr: %s " % key return getattr(self.cache, key) + if apt_pkg._COMPAT_0_7: + _reapplyFilter = function_deprecated_by(_reapply_filter) + setFilter = function_deprecated_by(set_filter) + filterCachePostChange = function_deprecated_by(\ + filter_cache_post_change) + def cache_pre_changed(): print "cache pre changed" @@ -410,8 +438,8 @@ def cache_post_changed(): print "cache post changed" -# internal test code -if __name__ == "__main__": +def _test(): + """Internal test code.""" print "Cache self test" apt_pkg.init() c = Cache(apt.progress.OpTextProgress()) @@ -426,7 +454,7 @@ if __name__ == "__main__": x= c[pkg].name c.upgrade() - changes = c.getChanges() + changes = c.get_changes() print len(changes) for p in changes: #print p.name @@ -440,7 +468,7 @@ if __name__ == "__main__": apt_pkg.Config.Set("Dir::Cache::Archives", "/tmp/pytest") pm = apt_pkg.GetPackageManager(c._depcache) fetcher = apt_pkg.GetAcquire(apt.progress.TextFetchProgress()) - c._fetchArchives(fetcher, pm) + c._fetch_archives(fetcher, pm) #sys.exit(1) print "Testing filtered cache (argument is old cache)" @@ -448,7 +476,7 @@ if __name__ == "__main__": f.cache.connect("cache_pre_change", cache_pre_changed) f.cache.connect("cache_post_change", cache_post_changed) f.cache.upgrade() - f.setFilter(MarkedChangesFilter()) + f.set_filter(MarkedChangesFilter()) print len(f) for pkg in f.keys(): #print c[pkg].name @@ -461,10 +489,12 @@ if __name__ == "__main__": f.cache.connect("cache_pre_change", cache_pre_changed) f.cache.connect("cache_post_change", cache_post_changed) f.cache.upgrade() - f.setFilter(MarkedChangesFilter()) + f.set_filter(MarkedChangesFilter()) print len(f) for pkg in f.keys(): #print c[pkg].name x = f[pkg].name print len(f) +if __name__ == '__main__': + _test() diff --git a/apt/cdrom.py b/apt/cdrom.py index b52762ad..907ac622 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -24,6 +24,7 @@ import glob import apt_pkg from apt.progress import CdromProgress +from apt.deprecation import AttributeDeprecatedBy class Cdrom(object): @@ -69,7 +70,7 @@ class Cdrom(object): return ident @property - def inSourcesList(self): + def in_sources_list(self): """Check if the cdrom is already in the current sources.list.""" cd_id = self.ident() if cd_id is None: @@ -84,3 +85,6 @@ class Cdrom(object): if not line.lstrip().startswith("#") and cd_id in line: return True return False + + if apt_pkg._COMPAT_0_7: + inSourcesList = AttributeDeprecatedBy('in_sources_list') diff --git a/apt/debfile.py b/apt/debfile.py index 8d4f534c..c60fc92d 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -97,11 +97,11 @@ class DebPackage(object): # check for virtual pkgs if not depname in self._cache: - if self._cache.isVirtualPackage(depname): + if self._cache.is_virtual_package(depname): self._dbg(3, "_isOrGroupSatisfied(): %s is virtual dep" % depname) - for pkg in self._cache.getProvidingPackages(depname): - if pkg.isInstalled: + for pkg in self._cache.get_providing_packages(depname): + if pkg.is_installed: return True continue @@ -117,9 +117,9 @@ class DebPackage(object): # if we don't have it in the cache, it may be virtual if not depname in self._cache: - if not self._cache.isVirtualPackage(depname): + if not self._cache.is_virtual_package(depname): continue - providers = self._cache.getProvidingPackages(depname) + providers = self._cache.get_providing_packages(depname) # if a package just has a single virtual provider, we # just pick that (just like apt) if len(providers) != 1: @@ -158,9 +158,9 @@ class DebPackage(object): (pkgname, ver, oper)) pkg = self._cache[pkgname] - if pkg.isInstalled: + if pkg.is_installed: pkgver = pkg.installed.version - elif pkg.markedInstall: + elif pkg.marked_install: pkgver = pkg.candidate.version else: return False @@ -191,8 +191,8 @@ class DebPackage(object): if not depname in self._cache: # FIXME: we have to check for virtual replaces here as # well (to pass tests/gdebi-test8.deb) - if self._cache.isVirtualPackage(depname): - for pkg in self._cache.getProvidingPackages(depname): + if self._cache.is_virtual_package(depname): + for pkg in self._cache.get_providing_packages(depname): self._dbg(3, "conflicts virtual check: %s" % pkg.name) # P/C/R on virtal pkg, e.g. ftpd if self.pkgname == pkg.name: @@ -253,9 +253,9 @@ class DebPackage(object): """ self._dbg(3, "replacesPkg() %s %s %s" % (pkgname, oper, ver)) pkg = self._cache[pkgname] - if pkg.isInstalled: + if pkg.is_installed: pkgver = pkg.installed.version - elif pkg.markedInstall: + elif pkg.marked_install: pkgver = pkg.candidate.version else: pkgver = None @@ -371,7 +371,7 @@ class DebPackage(object): # now try it out in the cache for pkg in self._need_pkgs: try: - self._cache[pkg].markInstall(fromUser=False) + self._cache[pkg].mark_install(fromUser=False) except SystemError, e: self._failure_string = _("Cannot install '%s'" % pkg) self._cache.clear() @@ -396,7 +396,7 @@ class DebPackage(object): remove = [] unauthenticated = [] for pkg in self._cache: - if pkg.markedInstall or pkg.markedUpgrade: + if pkg.marked_install or pkg.marked_upgrade: install.append(pkg.name) # check authentication, one authenticated origin is enough # libapt will skip non-authenticated origins then @@ -405,7 +405,7 @@ class DebPackage(object): authenticated |= origin.trusted if not authenticated: unauthenticated.append(pkg.name) - if pkg.markedDelete: + if pkg.marked_delete: remove.append(pkg.name) return (install, remove, unauthenticated) @@ -492,7 +492,7 @@ class DscSrcPackage(DebPackage): for pkgname in self._installed_conflicts: if self._cache[pkgname]._pkg.Essential: raise Exception(_("An essential package would be removed")) - self._cache[pkgname].markDelete() + self._cache[pkgname].mark_delete() # FIXME: a additional run of the checkConflicts() # after _satisfyDepends() should probably be done return self._satisfy_depends(self.depends) @@ -507,7 +507,7 @@ def _test(): vp = "www-browser" #print "%s virtual: %s" % (vp, cache.isVirtualPackage(vp)) - providers = cache.getProvidingPackages(vp) + providers = cache.get_providing_packages(vp) print "Providers for %s :" % vp for pkg in providers: print " %s" % pkg.name diff --git a/apt/deprecation.py b/apt/deprecation.py new file mode 100644 index 00000000..a14d49e6 --- /dev/null +++ b/apt/deprecation.py @@ -0,0 +1,76 @@ +# deprecation.py - Module providing classes and functions for deprecation. +# +# Copyright (c) 2009 Julian Andres Klode +# Copyright (c) 2009 Ben Finney +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +"""Classes and functions for deprecating features. + +This is used for internal purposes only and not part of the official API. Do +not use it for anything outside the apt package. +""" +import re +import operator +import warnings + +__all__ = [] + + +class AttributeDeprecatedBy(object): + """Property acting as a proxy for a new attribute. + + When accessed, the property issues a DeprecationWarning and (on get) calls + attrgetter() for the attribute 'attribute' on the current object or (on + set) uses setattr to set the value of the wrapped attribute. + """ + + def __init__(self, attribute): + """Initialize the property.""" + self.attribute = attribute + self.__doc__ = 'Deprecated, please use \'%s\' instead' % attribute + self.getter = operator.attrgetter(attribute) + + def __get__(self, obj, type=None): + """Issue a DeprecationWarning and return the requested value.""" + if obj is None: + return getattr(type, self.attribute, self) + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + return self.getter(obj or type) + + def __set__(self, obj, value): + """Issue a DeprecationWarning and set the requested value.""" + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + setattr(obj, self.attribute, value) + + +def function_deprecated_by(func, convert_names=True): + """Return a function that warns it is deprecated by another function. + + Returns a new function that warns it is deprecated by function 'func', + then acts as a pass-through wrapper for 'func'. + + This function also converts all keyword argument names from mixedCase to + lowercase_with_underscores, but only if 'convert_names' is True (default). + """ + warning = 'Deprecated, please use \'%s\' instead' % func.func_name + + def deprecated_function(*args, **kwds): + warnings.warn(warning, DeprecationWarning, stacklevel=2) + if convert_names: + for key in kwds.keys(): + kwds[re.sub('([A-Z])', '_\\1', key).lower()] = kwds.pop(key) + return func(*args, **kwds) + return deprecated_function diff --git a/apt/package.py b/apt/package.py index db5696ae..70997383 100644 --- a/apt/package.py +++ b/apt/package.py @@ -31,6 +31,7 @@ import warnings import apt_pkg import apt.progress +from apt.deprecation import function_deprecated_by, AttributeDeprecatedBy __all__ = ('BaseDependency', 'Dependency', 'Origin', 'Package', 'Record', 'Version') @@ -56,21 +57,24 @@ class BaseDependency(object): """A single dependency. Attributes defined here: - name - The name of the dependency - relation - The relation (>>,>=,==,<<,<=,) - version - The version depended on - preDepend - Boolean value whether this is a pre-dependency. + name - The name of the dependency + relation - The relation (>>,>=,==,<<,<=,) + version - The version depended on + pre_depend - Boolean value whether this is a pre-dependency. """ def __init__(self, name, rel, ver, pre): self.name = name self.relation = rel self.version = ver - self.preDepend = pre + self.pre_depend = pre def __repr__(self): return ('' - % (self.name, self.relation, self.version, self.preDepend)) + % (self.name, self.relation, self.version, self.pre_depend)) + + if apt_pkg._COMPAT_0_7: + preDepend = AttributeDeprecatedBy('pre_depend') class Dependency(object): @@ -103,7 +107,7 @@ class DeprecatedProperty(property): warnings.warn("Accessed deprecated property %s.%s, please see the " "Version class for alternatives." % ((obj.__class__.__name__ or type.__name__), - self.fget.func_name), DeprecationWarning, 2) + self.fget.__name__), DeprecationWarning, 2) return property.__get__(self, obj, type) @@ -528,9 +532,9 @@ class Package(object): def __set_candidate(self, version): """Set the candidate version of the package.""" - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.SetCandidateVer(self._pkg, version._cand) - self._pcache.cachePostChange() + self._pcache.cache_post_change() candidate = property(candidate, __set_candidate) @@ -703,55 +707,56 @@ class Package(object): # depcache states @property - def markedInstall(self): + def marked_install(self): """Return ``True`` if the package is marked for install.""" return self._pcache._depcache.MarkedInstall(self._pkg) @property - def markedUpgrade(self): + def marked_upgrade(self): """Return ``True`` if the package is marked for upgrade.""" return self._pcache._depcache.MarkedUpgrade(self._pkg) @property - def markedDelete(self): + def marked_delete(self): """Return ``True`` if the package is marked for delete.""" return self._pcache._depcache.MarkedDelete(self._pkg) @property - def markedKeep(self): + def marked_keep(self): """Return ``True`` if the package is marked for keep.""" return self._pcache._depcache.MarkedKeep(self._pkg) @property - def markedDowngrade(self): + def marked_downgrade(self): """ Package is marked for downgrade """ return self._pcache._depcache.MarkedDowngrade(self._pkg) @property - def markedReinstall(self): + def marked_reinstall(self): """Return ``True`` if the package is marked for reinstall.""" return self._pcache._depcache.MarkedReinstall(self._pkg) @property - def isInstalled(self): + def is_installed(self): """Return ``True`` if the package is installed.""" return (self._pkg.CurrentVer is not None) @property - def isUpgradable(self): + def is_upgradable(self): """Return ``True`` if the package is upgradable.""" - return (self.isInstalled and + return (self.is_installed and self._pcache._depcache.IsUpgradable(self._pkg)) @property - def isAutoRemovable(self): + def is_auto_removable(self): """Return ``True`` if the package is no longer required. If the package has been installed automatically as a dependency of another package, and if no packages depend on it anymore, the package is no longer required. """ - return self.isInstalled and self._pcache._depcache.IsGarbage(self._pkg) + return self.is_installed and \ + self._pcache._depcache.IsGarbage(self._pkg) # sizes @@ -789,7 +794,7 @@ class Package(object): return getattr(self.installed, 'installed_size', 0) @property - def installedFiles(self): + def installed_files(self): """Return a list of files installed by the package. Return a list of unicode names of the files which have @@ -805,7 +810,7 @@ class Package(object): except EnvironmentError: return [] - def getChangelog(self, uri=None, cancel_lock=None): + def get_changelog(self, uri=None, cancel_lock=None): """ Download the changelog of the package and return it as unicode string. @@ -928,7 +933,7 @@ class Package(object): if match: # strip epoch from installed version # and from changelog too - installed = self.installedVersion + installed = getattr(self.installed, 'version', None) if installed and ":" in installed: installed = installed.split(":", 1)[1] changelog_ver = match.group(1) @@ -976,13 +981,13 @@ class Package(object): # depcache actions - def markKeep(self): + def mark_keep(self): """Mark a package for keep.""" - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.MarkKeep(self._pkg) - self._pcache.cachePostChange() + self._pcache.cache_post_change() - def markDelete(self, autoFix=True, purge=False): + def mark_delete(self, autoFix=True, purge=False): """Mark a package for install. If *autoFix* is ``True``, the resolver will be run, trying to fix @@ -991,7 +996,7 @@ class Package(object): If *purge* is ``True``, remove the configuration files of the package as well. The default is to keep the configuration. """ - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.MarkDelete(self._pkg, purge) # try to fix broken stuffsta if autoFix and self._pcache._depcache.BrokenCount > 0: @@ -1001,9 +1006,9 @@ class Package(object): Fix.Remove(self._pkg) Fix.InstallProtect() Fix.Resolve() - self._pcache.cachePostChange() + self._pcache.cache_post_change() - def markInstall(self, autoFix=True, autoInst=True, fromUser=True): + def mark_install(self, autoFix=True, autoInst=True, fromUser=True): """Mark a package for install. If *autoFix* is ``True``, the resolver will be run, trying to fix @@ -1017,7 +1022,7 @@ class Package(object): want to be able to automatically remove the package at a later stage when no other package depends on it. """ - self._pcache.cachePreChange() + self._pcache.cache_pre_change() self._pcache._depcache.MarkInstall(self._pkg, autoInst, fromUser) # try to fix broken stuff if autoFix and self._pcache._depcache.BrokenCount > 0: @@ -1025,12 +1030,12 @@ class Package(object): fixer.Clear(self._pkg) fixer.Protect(self._pkg) fixer.Resolve(True) - self._pcache.cachePostChange() + self._pcache.cache_post_change() - def markUpgrade(self): + def mark_upgrade(self): """Mark a package for upgrade.""" - if self.isUpgradable: - self.markInstall() + if self.is_upgradable: + self.mark_install() else: # FIXME: we may want to throw a exception here sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: " @@ -1048,11 +1053,50 @@ class Package(object): self._pcache._depcache.Commit(fprogress, iprogress) + if not apt_pkg._COMPAT_0_7: + del installedVersion + del candidateVersion + del candidateDependencies + del installedDependencies + del architecture + del candidateDownloadable + del installedDownloadable + del sourcePackageName + del homepage + del priority + del installedPriority + del summary + del description + del rawDescription + del candidateRecord + del installedRecord + del packageSize + del installedPackageSize + del candidateInstalledSize + del installedSize + del candidateOrigin + else: + markedInstalled = AttributeDeprecatedBy('marked_installed') + markedUpgrade = AttributeDeprecatedBy('marked_upgrade') + markedDelete = AttributeDeprecatedBy('marked_delete') + markedKeep = AttributeDeprecatedBy('marked_keep') + markedDowngrade = AttributeDeprecatedBy('marked_downgrade') + markedReinstall = AttributeDeprecatedBy('marked_reinstall') + isInstalled = AttributeDeprecatedBy('is_installed') + isUpgradable = AttributeDeprecatedBy('is_upgradable') + isAutoRemovable = AttributeDeprecatedBy('is_auto_removable') + installedFiles = AttributeDeprecatedBy('installed_files') + getChangelog = function_deprecated_by(get_changelog) + markDelete = function_deprecated_by(mark_delete) + markInstall = function_deprecated_by(mark_install) + markKeep = function_deprecated_by(mark_keep) + markUpgrade = function_deprecated_by(mark_upgrade) + + def _test(): """Self-test.""" print "Self-test for the Package modul" import random - import apt apt_pkg.init() progress = apt.progress.OpTextProgress() cache = apt.Cache(progress) @@ -1075,19 +1119,19 @@ def _test(): print "Dependencies: %s" % pkg.installed.dependencies for dep in pkg.candidate.dependencies: print ",".join("%s (%s) (%s) (%s)" % (o.name, o.version, o.relation, - o.preDepend) for o in dep.or_dependencies) + o.pre_depend) for o in dep.or_dependencies) print "arch: %s" % pkg.candidate.architecture print "homepage: %s" % pkg.candidate.homepage print "rec: ", pkg.candidate.record - print cache["2vcard"].getChangelog() + print cache["2vcard"].get_changelog() for i in True, False: print "Running install on random upgradable pkgs with AutoFix: %s " % i for pkg in cache: - if pkg.isUpgradable: + if pkg.is_upgradable: if random.randint(0, 1) == 1: - pkg.markInstall(i) + pkg.mark_install(i) print "Broken: %s " % cache._depcache.BrokenCount print "InstCount: %s " % cache._depcache.InstCount @@ -1099,7 +1143,7 @@ def _test(): for name in cache.keys(): if random.randint(0, 1) == 1: try: - cache[name].markDelete(i) + cache[name].mark_delete(i) except SystemError: print "Error trying to remove: %s " % name print "Broken: %s " % cache._depcache.BrokenCount diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index f872e34f..36d459bc 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -422,10 +422,10 @@ def _test(): win.show() cache = apt.cache.Cache(apt_progress.open) pkg = cache["xterm"] - if pkg.isInstalled: - pkg.markDelete() + if pkg.is_installed: + pkg.mark_delete() else: - pkg.markInstall() + pkg.mark_install() apt_progress.show_terminal(True) try: cache.commit(apt_progress.fetch, apt_progress.install) diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 1dfd870f..fdc0f029 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -33,6 +33,7 @@ import time import apt_pkg from aptsources.distinfo import DistInfo +from apt.deprecation import function_deprecated_by # some global helpers @@ -309,7 +310,7 @@ class SourcesList(object): """ remove the specified entry from the sources.list """ self.list.remove(source_entry) - def restoreBackup(self, backup_ext): + def restore_backup(self, backup_ext): " restore sources.list files based on the backup extension " file = apt_pkg.Config.FindFile("Dir::Etc::sourcelist") if os.path.exists(file+backup_ext) and \ @@ -321,6 +322,9 @@ class SourcesList(object): if os.path.exists(file+backup_ext): shutil.copy(file+backup_ext, file) + if apt_pkg._COMPAT_0_7: + restoreBackup = function_deprecated_by(restore_backup) + def backup(self, backup_ext=None): """ make a backup of the current source files, if no backup extension is given, the current date/time is used (and returned) """ diff --git a/debian/changelog b/debian/changelog index b2f2b965..e344c145 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-apt (0.7.91) UNRELEASED; urgency=low + + * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) + + -- Julian Andres Klode Thu, 16 Apr 2009 18:54:29 +0200 + python-apt (0.7.90) experimental; urgency=low * Introduce support for Python 3 (Closes: #523645) diff --git a/debian/control b/debian/control index 08ee329f..374a177c 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.1 -XS-Python-Version: all +XS-Python-Version: >= 2.5 Build-Depends: apt-utils, cdbs, debhelper (>= 5.0.37.1), diff --git a/debian/rules b/debian/rules index 9d0219e2..5fc6e13b 100755 --- a/debian/rules +++ b/debian/rules @@ -16,6 +16,9 @@ PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) + +# Define COMPAT_0_7 to get all the deprecated interfaces. +export CFLAGS+=-DCOMPAT_0_7 export DEBVER diff --git a/po/python-apt.pot b/po/python-apt.pot index d12ae967..3fcd395a 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-04-15 16:10+0200\n" +"POT-Creation-Date: 2009-04-16 19:54+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -354,16 +354,16 @@ msgstr "" msgid "Complete" msgstr "" -#: ../apt/package.py:282 +#: ../apt/package.py:286 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:830 ../apt/package.py:934 +#: ../apt/package.py:846 ../apt/package.py:950 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:938 +#: ../apt/package.py:954 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -372,7 +372,7 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:944 +#: ../apt/package.py:960 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 3beec747..a056b0bc 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -589,6 +589,12 @@ extern "C" void initapt_pkg() AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); AddInt(Dict,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq); + + #ifdef COMPAT_0_7 + AddInt(Dict,"_COMPAT_0_7",1); + #else + AddInt(Dict,"_COMPAT_0_7",0); + #endif #if PY_MAJOR_VERSION >= 3 return Module; #endif -- cgit v1.2.3 From 6bc61a050bd278b28e883b91cfa5999a7cf76d9d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Apr 2009 18:01:30 +0200 Subject: * apt/package.py: Where possible, derive apt.package.Record from collections.Mapping. This works on Python 2.6 and newer and enhances the Record class with some new methods on these platforms, e.g. keys(). --- apt/package.py | 13 ++++++++++++- debian/changelog | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/apt/package.py b/apt/package.py index 1a2626fa..411f9635 100644 --- a/apt/package.py +++ b/apt/package.py @@ -28,6 +28,11 @@ import socket import subprocess import urllib2 import warnings +try: + from collections import Mapping +except ImportError: + # (for Python < 2.6) pylint: disable-msg=C0103 + Mapping = object import apt_pkg import apt.progress @@ -145,7 +150,7 @@ class Origin(object): self.site, self.trusted) -class Record(object): +class Record(Mapping): """Represent a pkgRecord. It can be accessed like a dictionary and can also give the original package @@ -155,6 +160,9 @@ class Record(object): def __init__(self, record_str): self._rec = apt_pkg.ParseSection(record_str) + def __hash__(self): + return hash(self._rec) + def __str__(self): return str(self._rec) @@ -183,6 +191,9 @@ class Record(object): """deprecated form of ``key in x``.""" return key in self._rec + def __len__(self): + return len(self._rec) + class Version(object): """Representation of a package version. diff --git a/debian/changelog b/debian/changelog index e344c145..e8e14306 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,9 @@ python-apt (0.7.91) UNRELEASED; urgency=low * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) + * Where possible, derive apt.package.Record from collections.Mapping. - -- Julian Andres Klode Thu, 16 Apr 2009 18:54:29 +0200 + -- Julian Andres Klode Fri, 17 Apr 2009 17:48:27 +0200 python-apt (0.7.90) experimental; urgency=low -- cgit v1.2.3 From a7026989dd1ea3b70cbfc80cf92077efb2f52ba3 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 19 Apr 2009 15:57:07 +0200 Subject: ActionGroups can be used as a context manager for the 'with' statement. --- debian/changelog | 1 + python/depcache.cc | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index e8e14306..30d54a29 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ python-apt (0.7.91) UNRELEASED; urgency=low * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) * Where possible, derive apt.package.Record from collections.Mapping. + * ActionGroups can be used as a context manager for the 'with' statement. -- Julian Andres Klode Fri, 17 Apr 2009 17:48:27 +0200 diff --git a/python/depcache.cc b/python/depcache.cc index 0cadee64..70d5af4e 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -852,9 +852,24 @@ static PyObject *PkgActionGroupRelease(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } +static PyObject *PkgActionGroupEnter(PyObject *Self,PyObject *Args) { + if (PyArg_ParseTuple(Args,"") == 0) + return 0; + return Self; +} +static PyObject *PkgActionGroupExit(PyObject *Self,PyObject *Args) { + pkgDepCache::ActionGroup *ag = GetCpp(Self); + ag->release(); + Py_RETURN_FALSE; +} + static PyMethodDef PkgActionGroupMethods[] = { {"release", PkgActionGroupRelease, METH_VARARGS, "release()"}, + {"__exit__", PkgActionGroupExit, METH_VARARGS, "__exit__(...) -> " + "Release the action group, for 'with' statement."}, + {"__enter__", PkgActionGroupEnter, METH_VARARGS, "__enter__() -> " + "Enter, for the 'with' statement. Does nothing."}, {} }; @@ -879,11 +894,18 @@ static PyObject *PkgActionGroupNew(PyTypeObject *type,PyObject *Args,PyObject *k } static const char *doc_PkgActionGroup = "ActionGroup(depcache)\n\n" - "Create a new ActionGroup() object. ActionGroups disable certain cleanup\n" - "actions, so modifying many packages is much faster.\n\n" - "Creating an ActionGroup() makes it active, use release() to disable it\n" - "again.\n\n" - "The parameter *depcache* refers to an apt_pkg.DepCache() object."; + "Create a new ActionGroup() object. The parameter *depcache* refers to an\n" + "apt_pkg.DepCache() object.\n\n" + "ActionGroups disable certain cleanup actions, so modifying many packages\n" + "is much faster.\n\n" + "ActionGroup() can also be used with the 'with' statement, but be aware\n" + "that the ActionGroup() is active as soon as it is created, and not just\n" + "when entering the context. This means you can write::\n\n" + " with apt_pkg.ActionGroup(depcache):\n" + " depcache.markInstall(pkg)\n\n" + "Once the block of the with statement is left, the action group is \n" + "automatically released from the cache."; + PyTypeObject PkgActionGroupType = { -- cgit v1.2.3 From bd47802c98f30f67b323b0796ff5d79a5e308c08 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 20 Apr 2009 19:26:05 +0200 Subject: * utils/migrate-0.8.py: Helper to check Python code for deprecated functions, attributes, etc. Has to be run from the python-apt source tree, but can be used for all Python code using python-apt. The output may not be completely correct, but false positives are better than not checking the code. --- debian/changelog | 3 + utils/migrate-0.8.py | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100755 utils/migrate-0.8.py (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 30d54a29..f2d57afa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,9 @@ python-apt (0.7.91) UNRELEASED; urgency=low * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) * Where possible, derive apt.package.Record from collections.Mapping. * ActionGroups can be used as a context manager for the 'with' statement. + * utils/migrate-0.8.py: Helper to check Python code for deprecated functions, + attributes,etc. Has to be run from the python-apt source tree, but can be + used for all Python code using python-apt. -- Julian Andres Klode Fri, 17 Apr 2009 17:48:27 +0200 diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py new file mode 100755 index 00000000..b3f143b0 --- /dev/null +++ b/utils/migrate-0.8.py @@ -0,0 +1,194 @@ +#!/usr/bin/python2.6 +# +# migrate-0.8.py - Find use of deprecated methods/attributes in the code. +# +# Copyright (C) 2009 Julian Andres Klode +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +"""migrate-0.8.py - Find all occurences of funcs./attrs. deprecated in 0.8. + +Usage: python2.6 migrate-0.8.py [options] ... + +This reads the list of all functions and attributes available only in +COMPAT_0_7 builds and checks for occurences in the given Python modules. Has +to be run from the python-apt source code directory. + +Requires python2.6 to be installed. + +Parameters: + -h Display this help + -c Colorize the matching parts in the output. +""" +import _ast +import ast +import glob +import linecache +import os +import re +import sys +import types +from collections import defaultdict +from textwrap import fill + +color=False +if sys.argv[1] in ('-c', '--color', '--colour'): + color=True + del sys.argv[1] + +if '-h' in sys.argv or '--help' in sys.argv or not sys.argv[1:]: + print __doc__.strip() + sys.exit(0) + +if os.path.dirname(__file__).endswith('utils'): + sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) + + +def do_color(string, words): + """Colorize (red) the given words in the given string.""" + if not color: + return string + for word in words: + string = re.sub('([^_]*)(%s)([^_]*)' % word, "\\1\033[31m\033[1m" + + r"\2" + "\033[0m\\3", string) + return string + + +def find_deprecated_cpp(): + """Find all the deprecated functions and attributes.""" + is_open=False + all_old = set() + for fname in glob.glob('python/*.cc'): + lines = list(open(fname, 'r')) + while lines: + line = lines.pop(0) + while lines and not ('static PyMethodDef' in line or + 'static PyGetSetDef' in line): + line = lines.pop(0) + if not lines: + break + + while lines and not ';' in line: + while lines and not 'COMPAT_0_7' in line: + line = lines.pop(0) + if lines: + line = lines.pop(0) + while lines and not '#endif' in line: + all_old.add(line.split(",")[0].strip().strip('{"')) + line = lines.pop(0) + return all_old + + +def find_deprecated_py(): + """Same as find_deprecated_cpp(), but for apt and aptsources. + + We import apt_pkg, set _COMPAT_0_7 to 0, import apt and aptsources and + create a list of all attributes. + + No we remove the imported modules, reimport them (with _COMPAT_0_7=1), + and see which functions have been removed. + """ + + modules = ('apt', 'apt.package', 'apt.cdrom', 'apt.cache', 'apt.debfile', + 'apt.progress', 'aptsources.distinfo', 'aptsources.distro', + 'aptsources.sourceslist') + + import apt_pkg + apt_pkg._COMPAT_0_7 = 0 + + empty = set(sys.modules) + new, deprecated = set(), set() + + for mname in sorted(modules): + module = __import__(mname) + + for clsname in dir(module): + cls = getattr(module, clsname) + if not isinstance(cls, types.TypeType): + new.add(clsname) + continue + new.update(dir(cls)) + + for mname in sys.modules.keys(): + if not mname in empty: + del sys.modules[mname] + + apt_pkg._COMPAT_0_7 = 1 + + for mname in sorted(modules): + module = __import__(mname) + for clsname in dir(module): + cls = getattr(module, clsname) + if not isinstance(cls, types.TypeType): + deprecated.add(clsname) + continue + deprecated.update(dir(cls)) + + + for mname in sys.modules.keys(): + if not mname in empty: + del sys.modules[mname] + + return deprecated.difference(new) + + +def find_occurences(all_old, files): + """Find all ocurrences in the given Python files.""" + for fname in files: + if fname.endswith('setup3.py') or not fname.endswith('.py'): + continue + + words = defaultdict(lambda: set()) + for i in ast.walk(ast.parse(open(fname).read())): + + if isinstance(i, _ast.ImportFrom): + for alias in i.names: + if alias.name in all_old: + words[i.lineno].add(alias.name) + if isinstance(i, _ast.Name) and i.id in all_old: + words[i.lineno].add(i.id) + + if isinstance(i, _ast.Attribute) and i.attr in all_old: + words[i.lineno].add(i.attr) + + for lineno in sorted(words): + line = do_color(linecache.getline(fname, lineno).rstrip('\n'), + words[lineno]) + print '%s:%s:%s' % (fname, lineno, line) + +# Now, let's find them in the code. + +print __doc__.split("\n")[0] +print +if color: + print fill('Information: The color is not always correct, because we ' + 'simply highlight the matched words (like grep).', 79) + print + +all_old = find_deprecated_cpp() | find_deprecated_py() + + +files = set() +for path in sys.argv[1:]: + if not os.path.exists(path): + raise ValueError('Path does not exist: %s' % path) + if os.path.isfile(path): + files.add(path) + else: + for root, dirs, files_ in os.walk(path): + for fname in files_: + files.add(os.path.normpath(os.path.join(root, fname))) + +find_occurences(all_old, sorted(files)) -- cgit v1.2.3 From aa5b58b56b7e332d15e6ac9f3dfeffa60c2749a6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 24 Apr 2009 18:43:52 +0200 Subject: * debian/control: Do not require python >= 2.5, mistake in previous commit. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/control b/debian/control index 374a177c..08ee329f 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.1 -XS-Python-Version: >= 2.5 +XS-Python-Version: all Build-Depends: apt-utils, cdbs, debhelper (>= 5.0.37.1), -- cgit v1.2.3 From 7ba5f4686ddea5076f086d54e68dd407bff32147 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 24 Apr 2009 19:02:11 +0200 Subject: * debian/rules: Support multiple PY3K versions. Introduce PY3K_VERSIONS, a list of all py3k versions the package should be built for. The default is to build for the currently installed versions. Introduce 2TO3_VERSION to select a 2to3 version which will convert the python code to python 3. Points to the latest version by default. --- debian/rules | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'debian') diff --git a/debian/rules b/debian/rules index 5fc6e13b..7a6ff690 100755 --- a/debian/rules +++ b/debian/rules @@ -11,7 +11,9 @@ DEB_PYTHON_PACKAGES_EXCLUDE=python-apt-dbg include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk -PY3K = y +PY3K_VERSIONS := $(shell find /usr/bin/python3.? | sed s/.*python//) +2TO3_VERSION := $(lastword $(PY3K_VERSIONS)) + PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv @@ -21,17 +23,20 @@ DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us export CFLAGS+=-DCOMPAT_0_7 export DEBVER - -ifeq ($(PY3K),y) build/python-apt:: - python3.1 setup3.py build + set -e; for i in $(PY3K_VERSIONS); do \ + python$$i setup3.py build; \ + done install/python-apt:: - python3.1 ./setup3.py install --root $(CURDIR)/debian/python-apt \ - --install-layout=deb --no-compile + set -e; for i in $(PY3K_VERSIONS); do \ + python$$i ./setup3.py install --root $(CURDIR)/debian/python-apt \ + --install-layout=deb --no-compile; \ + done - find $(CURDIR)/debian/python-apt/usr/lib/python3.1/dist-packages/ -name '*.py' \ - | xargs 2to3-3.1 | patch -p0 +ifneq ($(PY3K_VERSIONS),) + find $(CURDIR)/debian/python-apt/usr/lib/python3*/dist-packages/ -name '*.py' \ + | xargs 2to3-$(2TO3_VERSION)| patch -p0 endif build/python-apt-dbg:: @@ -39,25 +44,29 @@ build/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py build; \ done -ifeq ($(PY3K),y) - python3.1-dbg ./setup3.py build -endif + set -e; for i in $(PY3K_VERSIONS); do \ + python$$i-dbg setup3.py build; \ + done + install/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg \ --no-compile; \ done -ifeq ($(PY3K),y) - python3.1-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ - --install-layout=deb --no-compile -endif + + set -e; for i in $(PY3K_VERSIONS); do \ + python$$i-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ + --install-layout=deb --no-compile; \ + done + find debian/python-apt-dbg \ ! -type d ! -name '*_d.so' | xargs rm -f find debian/python-apt-dbg -depth -empty -exec rmdir {} \; binary-predeb/python-apt:: - ln -sf ../../../../javascript/jquery/jquery.js debian/python-apt/usr/share/doc/python-apt/html/_static/jquery.js + ln -sf ../../../../javascript/jquery/jquery.js \ + debian/python-apt/usr/share/doc/python-apt/html/_static/jquery.js binary-predeb/python-apt-dbg:: rm -rf debian/python-apt-dbg/usr/share/doc/python-apt-dbg -- cgit v1.2.3 From 7d6f85c475d5f50e0c54814cd8b644e38147b282 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Mon, 18 May 2009 17:54:18 +0200 Subject: * debian/python-apt.doc-base: register the documentation with the doc-base system (Closes: #525134) --- debian/changelog | 5 +++++ debian/python-apt.doc-base | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 debian/python-apt.doc-base (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index f2d57afa..f2e03811 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ python-apt (0.7.91) UNRELEASED; urgency=low + [ Julian Andres Klode ] * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) * Where possible, derive apt.package.Record from collections.Mapping. * ActionGroups can be used as a context manager for the 'with' statement. @@ -7,6 +8,10 @@ python-apt (0.7.91) UNRELEASED; urgency=low attributes,etc. Has to be run from the python-apt source tree, but can be used for all Python code using python-apt. + [ Stefano Zacchiroli ] + * debian/python-apt.doc-base: register the documentation with the + doc-base system (Closes: #525134) + -- Julian Andres Klode Fri, 17 Apr 2009 17:48:27 +0200 python-apt (0.7.90) experimental; urgency=low diff --git a/debian/python-apt.doc-base b/debian/python-apt.doc-base new file mode 100644 index 00000000..d25926b7 --- /dev/null +++ b/debian/python-apt.doc-base @@ -0,0 +1,11 @@ +Document: python-apt-api-reference +Title: Python APT: API reference manual +Abstract: API reference manual for Python bindings to libapt-pkg +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/python-apt/html/index.html +Files: /usr/share/doc/python-apt/html/* + +Format: Text +Files: /usr/share/doc/python-apt/text/* -- cgit v1.2.3 From 4ced65ec744e29019e7890eb6f505387940e74d5 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Jun 2009 19:36:59 +0200 Subject: debian/control: Only recommend libjs-jquery (Closes: #527543). --- debian/changelog | 3 ++- debian/control | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index f2e03811..6150632c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,12 +7,13 @@ python-apt (0.7.91) UNRELEASED; urgency=low * utils/migrate-0.8.py: Helper to check Python code for deprecated functions, attributes,etc. Has to be run from the python-apt source tree, but can be used for all Python code using python-apt. + * debian/control: Only recommend libjs-jquery (Closes: #527543). [ Stefano Zacchiroli ] * debian/python-apt.doc-base: register the documentation with the doc-base system (Closes: #525134) - -- Julian Andres Klode Fri, 17 Apr 2009 17:48:27 +0200 + -- Julian Andres Klode Fri, 05 Jun 2009 19:36:45 +0200 python-apt (0.7.90) experimental; urgency=low diff --git a/debian/control b/debian/control index 08ee329f..25c58f15 100644 --- a/debian/control +++ b/debian/control @@ -23,9 +23,8 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release, - libjs-jquery -Recommends: iso-codes +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release +Recommends: iso-codes, libjs-jquery Breaks: debdelta (<< 0.28~) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte -- cgit v1.2.3 From 6c4e35354bba110758d9009e1555b2e13cd5ce4f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Jun 2009 19:48:35 +0200 Subject: Set distribution to experimental. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 61ec1527..55e68a52 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ -python-apt (0.7.91) UNRELEASED; urgency=low +python-apt (0.7.91) experimental; urgency=low [ Julian Andres Klode ] - * Rename all methods,functions,attributes to conform to PEP 8 (Closes: #481061) + * Rename where needed according to PEP 8 conventions (Closes: #481061) * Where possible, derive apt.package.Record from collections.Mapping. * ActionGroups can be used as a context manager for the 'with' statement. * utils/migrate-0.8.py: Helper to check Python code for deprecated functions, -- cgit v1.2.3 From 33293ab8c53a9b1427012c297f288972e11ea3bb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Jun 2009 17:47:46 +0200 Subject: Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) --- debian/changelog | 6 +++ python/apt_pkgmodule.cc | 2 + python/apt_pkgmodule.h | 7 +++ python/hashstring.cc | 140 ++++++++++++++++++++++++++++++++++++++++++++++++ python/indexrecords.cc | 121 +++++++++++++++++++++++++++++++++++++++++ python/makefile | 2 +- 6 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 python/hashstring.cc create mode 100644 python/indexrecords.cc (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index ca215554..1a80d081 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-apt (0.7.92) experimental; urgency=low + + * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) + + -- Julian Andres Klode Mon, 08 Jun 2009 17:23:37 +0200 + python-apt (0.7.91) experimental; urgency=low [ Julian Andres Klode ] diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 4ad4e56c..085d12f4 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -603,6 +603,8 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"SourceRecords",&PkgSrcRecordsType); /* ========================= sourcelist.cc ========================= */ ADDTYPE(Module,"SourceList",&PkgSourceListType); + ADDTYPE(Module,"IndexRecords",&PyIndexRecords_Type); + ADDTYPE(Module,"HashString",&PyHashString_Type); // Tag file constants PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", CharCharToList(TFRewritePackageOrder)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index f7ef63c2..043e29cc 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -11,6 +11,7 @@ #define APT_PKGMODULE_H #include +#include // Configuration Stuff #define Configuration_Check(op) ((op)->ob_type == &ConfigurationType || \ @@ -106,5 +107,11 @@ extern PyTypeObject PackageIndexFileType; // metaIndex extern PyTypeObject MetaIndexType; +// HashString +PyObject *PyHashString_FromCpp(HashString *obj); +extern PyTypeObject PyHashString_Type; + +// IndexRecord +extern PyTypeObject PyIndexRecords_Type; #endif diff --git a/python/hashstring.cc b/python/hashstring.cc new file mode 100644 index 00000000..02a80210 --- /dev/null +++ b/python/hashstring.cc @@ -0,0 +1,140 @@ +/* hashstring.cc - Wrapper around HashString + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include +#include "generic.h" +#include "apt_pkgmodule.h" +#include + +static PyObject *HashString_NEW(PyTypeObject *type,PyObject *Args, + PyObject *kwds) +{ + const char *Hash; + const char *Type; + char *kwlist[] = {"type", "hash", NULL}; + if (PyArg_ParseTupleAndKeywords(Args, kwds, "s|s", kwlist, &Type, + &Hash) == 0) + return 0; + CppPyObject *PyObj = CppPyObject_NEW(type); + if (Hash) + PyObj->Object = new HashString(Type,Hash); + else // Type is the combined form now (i.e. type:hash) + PyObj->Object = new HashString(Type); + return PyObj; +} + +PyObject *PyHashString_FromCpp(HashString *obj) +{ + return CppPyObject_NEW(&PyHashString_Type, obj); +} + +static PyObject *HashString_Repr(PyObject *self) +{ + HashString *hash = GetCpp(self); + char repr[100]; + sprintf(repr, "<%s: \"%s\">", self->ob_type->tp_name, hash->toStr().c_str()); + return PyString_FromString(repr); +} + +static PyObject *HashString_ToStr(PyObject *self) +{ + HashString *hash = GetCpp(self); + return CppPyString(hash->toStr()); +} + +static PyObject *HashString_HashType(PyObject *self) +{ + HashString *hash = GetCpp(self); + return CppPyString(hash->HashType()); +} + +static const char *HashString_VerifyFile_doc = + "verify_file(filename: str) --> bool\n\n" + "Verify that the file indicated by filename matches the hash."; + +static PyObject *HashString_VerifyFile(PyObject *self,PyObject *args) +{ + HashString *hash = GetCpp(self); + char *filename; + if (PyArg_ParseTuple(args, "s", &filename) == 0) + return 0; + return PyBool_FromLong(hash->VerifyFile(filename)); +} + +static PyMethodDef HashString_Methods[] = { + {"to_str",(PyCFunction)HashString_ToStr,METH_NOARGS, + "to_str() --> str\n\nReturn a string, consisting of type:hash"}, + {"verify_file",HashString_VerifyFile,METH_VARARGS, + HashString_VerifyFile_doc}, + {"hash_type",(PyCFunction)HashString_HashType,METH_NOARGS, + "hash_type() --> str\n\nReturn the type of hash (MD5Sum,SHA1,SHA256)"}, + {} +}; + +static const char *HashString_doc = + "HashString(type, hash) OR HashString('type:hash')\n\n" + "Create a new HashString object. The first form allows you to specify\n" + "a type and a hash, and the second form a single string where type and\n" + "hash are seperated by a colon, e.g.::\n\n" + " HashString('MD5Sum', '6cc1b6e6655e3555ac47e5b5fe26d04e')\n\n" + "Valid options for 'type' are: MD5Sum, SHA1, SHA256."; +PyTypeObject PyHashString_Type = { + PyObject_HEAD_INIT(&PyType_Type) +#if PY_MAJOR_VERSION < 3 + 0, // ob_size +#endif + "apt_pkg.HashString", // tp_name + sizeof(CppPyObject), // tp_basicsize + 0, // tp_itemsize + // Methods + CppDealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + HashString_Repr, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + HashString_ToStr, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags + HashString_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + HashString_Methods, // tp_methods + 0, // tp_members + 0, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + HashString_NEW, // tp_new +}; diff --git a/python/indexrecords.cc b/python/indexrecords.cc new file mode 100644 index 00000000..e6099a69 --- /dev/null +++ b/python/indexrecords.cc @@ -0,0 +1,121 @@ +/* + * indexrecords.cc - Wrapper around indexRecords + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include +#include "apt_pkgmodule.h" +#include "generic.h" +#include + +static PyObject *IndexRecords_NEW(PyTypeObject *type,PyObject *Args, + PyObject *kwds) +{ + char * kwlist[] = {NULL}; + if (PyArg_ParseTupleAndKeywords(Args, kwds, "", kwlist) == 0) + return 0; + indexRecords *records = new indexRecords(); + CppPyObject *New = CppPyObject_NEW(type, + records); + return New; +} + +static PyObject *IndexRecords_Load(PyObject *self,PyObject *args) +{ + const char *filename; + if (PyArg_ParseTuple(args, "s", &filename) == 0) + return 0; + indexRecords *records = GetCpp(self); + return HandleErrors(Py_BuildValue("i", records->Load(filename))); +} + +static const char *IndexRecords_Lookup_doc = "lookup(metakey)\n\n" + "Lookup the filename given by metakey, return a tuple (size,hash).\n" + "The hash part is a HashString() object."; +static PyObject *IndexRecords_Lookup(PyObject *self,PyObject *args) +{ + const char *keyname; + if (PyArg_ParseTuple(args, "s", &keyname) == 0) + return 0; + indexRecords *records = GetCpp(self); + const indexRecords::checkSum *result = records->Lookup(keyname); + return Py_BuildValue("(iO)",result->Size, + PyHashString_FromCpp((HashString*)&result->Hash)); +} + +static PyObject *IndexRecords_GetDist(PyObject *self) +{ + indexRecords *records = GetCpp(self); + return HandleErrors(PyString_FromString(records->GetDist().c_str())); +} + +static PyMethodDef IndexRecords_Methods[] = { + {"load",IndexRecords_Load,METH_VARARGS, + "load(filename: str)\n\nLoad the file given by filename."}, + {"get_dist",(PyCFunction)IndexRecords_GetDist,METH_NOARGS, + "get_dist() -> str\n\nReturn a distribution set in the release file."}, + {"lookup",IndexRecords_Lookup,METH_VARARGS,IndexRecords_Lookup_doc}, + {} +}; + +static char *IndexRecords_doc = "IndexRecords()\n\n" + "Representation of a release file."; +PyTypeObject PyIndexRecords_Type = { + PyObject_HEAD_INIT(&PyType_Type) +#if PY_MAJOR_VERSION < 3 + 0, // ob_size +#endif + "apt_pkg.IndexRecords", // tp_name + sizeof(CppPyObject), // tp_basicsize + 0, // tp_itemsize + // Methods + CppDealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT, // tp_flags + IndexRecords_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + IndexRecords_Methods, // tp_methods + 0, // tp_members + 0, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + IndexRecords_NEW, // tp_new +}; diff --git a/python/makefile b/python/makefile index 3e6458f4..f4d559ce 100644 --- a/python/makefile +++ b/python/makefile @@ -12,7 +12,7 @@ LIB_MAKES = apt-pkg/makefile APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \ cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \ depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \ - indexfile.cc metaindex.cc + indexfile.cc metaindex.cc hashstring.cc indexrecords.cc SOURCE := $(APT_PKG_SRC) include $(PYTHON_H) progress.h -- cgit v1.2.3 From f652213b76f72382bab21e730bf0ccc4419a1267 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Jun 2009 18:10:19 +0200 Subject: Allow types providing __new__() to be subclassed. --- debian/changelog | 3 ++- python/acquire.cc | 6 ++++-- python/cache.cc | 3 ++- python/cdrom.cc | 3 ++- python/configuration.cc | 3 ++- python/depcache.cc | 9 ++++++--- python/hashstring.cc | 3 ++- python/indexrecords.cc | 3 ++- python/pkgmanager.cc | 3 ++- python/pkgrecords.cc | 3 ++- python/pkgsrcrecords.cc | 3 ++- python/sourcelist.cc | 3 ++- python/tag.cc | 6 ++++-- 13 files changed, 34 insertions(+), 17 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 1a80d081..818bf630 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,9 @@ python-apt (0.7.92) experimental; urgency=low * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) + * Allow types providing __new__() to be subclassed. - -- Julian Andres Klode Mon, 08 Jun 2009 17:23:37 +0200 + -- Julian Andres Klode Tue, 09 Jun 2009 18:09:53 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/acquire.cc b/python/acquire.cc index 05bffc65..702d48ce 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -276,7 +276,8 @@ PyTypeObject PkgAcquireType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgAcquire, // tp_doc 0, // tp_traverse 0, // tp_clear @@ -366,7 +367,8 @@ PyTypeObject PkgAcquireFileType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgAcquireFile, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/cache.cc b/python/cache.cc index c988145f..14484104 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -331,7 +331,8 @@ PyTypeObject PkgCacheType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT , // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgCache, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/cdrom.cc b/python/cdrom.cc index 3e63a89c..e98947d1 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -108,7 +108,8 @@ PyTypeObject PkgCdromType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "Cdrom Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/configuration.cc b/python/configuration.cc index 3c6ea88c..365a35fd 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -526,7 +526,8 @@ PyTypeObject ConfigurationType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "Configuration Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/depcache.cc b/python/depcache.cc index a69e0723..f1c34fef 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -675,7 +675,8 @@ PyTypeObject PkgDepCacheType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgDepCache, // tp_doc 0, // tp_traverse 0, // tp_clear @@ -858,7 +859,8 @@ PyTypeObject PkgProblemResolverType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "ProblemResolver Object", // tp_doc 0, // tp_traverse 0, // tp_clear @@ -975,7 +977,8 @@ PyTypeObject PkgActionGroupType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_PkgActionGroup, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/hashstring.cc b/python/hashstring.cc index 71ae5bf4..58bcca9e 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -118,7 +118,8 @@ PyTypeObject PyHashString_Type = { 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), HashString_doc, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/indexrecords.cc b/python/indexrecords.cc index 35e41c59..61ff07fc 100644 --- a/python/indexrecords.cc +++ b/python/indexrecords.cc @@ -104,7 +104,8 @@ PyTypeObject PyIndexRecords_Type = { 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), IndexRecords_doc, // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 7752ce5b..f47e77ad 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -153,7 +153,8 @@ PyTypeObject PkgManagerType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "PackageManager Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 6022097a..8beefffd 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -186,7 +186,8 @@ PyTypeObject PkgRecordsType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "Records Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 50445432..e6b78a83 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -228,7 +228,8 @@ PyTypeObject PkgSrcRecordsType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "SourceRecords Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 1c05d83e..5e5838d8 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -138,7 +138,8 @@ PyTypeObject PkgSourceListType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), "pkgSourceList Object", // tp_doc 0, // tp_traverse 0, // tp_clear diff --git a/python/tag.cc b/python/tag.cc index 31491c90..7e7eb21c 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -434,7 +434,8 @@ PyTypeObject TagSecType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_TagSec, // tp_doc 0, // tp_traverse 0, // tp_clear @@ -521,7 +522,8 @@ PyTypeObject TagFileType = 0, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), doc_TagFile, // tp_doc 0, // tp_traverse 0, // tp_clear -- cgit v1.2.3 From a307f6c405d55895690e16d55de36549f5b05d8b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 9 Jun 2009 20:44:58 +0200 Subject: Add apt_pkg.Policy class (Closes: #382725) --- debian/changelog | 3 +- python/apt_pkgmodule.cc | 1 + python/apt_pkgmodule.h | 3 + python/makefile | 2 +- python/policy.cc | 189 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 python/policy.cc (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 818bf630..3e85c5be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,10 @@ python-apt (0.7.92) experimental; urgency=low * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) + * Add apt_pkg.Policy class (Closes: #382725) * Allow types providing __new__() to be subclassed. - -- Julian Andres Klode Tue, 09 Jun 2009 18:09:53 +0200 + -- Julian Andres Klode Tue, 09 Jun 2009 20:39:39 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 95b72de4..3d76894d 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -606,6 +606,7 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"SourceList",&PkgSourceListType); ADDTYPE(Module,"IndexRecords",&PyIndexRecords_Type); ADDTYPE(Module,"HashString",&PyHashString_Type); + ADDTYPE(Module,"Policy",&PyPolicy_Type); // Tag file constants PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", CharCharToList(TFRewritePackageOrder)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 043e29cc..21355072 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -114,4 +114,7 @@ extern PyTypeObject PyHashString_Type; // IndexRecord extern PyTypeObject PyIndexRecords_Type; +// Policy +extern PyTypeObject PyPolicy_Type; + #endif diff --git a/python/makefile b/python/makefile index f4d559ce..6799d749 100644 --- a/python/makefile +++ b/python/makefile @@ -12,7 +12,7 @@ LIB_MAKES = apt-pkg/makefile APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \ cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \ depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \ - indexfile.cc metaindex.cc hashstring.cc indexrecords.cc + indexfile.cc metaindex.cc hashstring.cc indexrecords.cc policy.cc SOURCE := $(APT_PKG_SRC) include $(PYTHON_H) progress.h diff --git a/python/policy.cc b/python/policy.cc new file mode 100644 index 00000000..89604e9a --- /dev/null +++ b/python/policy.cc @@ -0,0 +1,189 @@ +/* + * policy.cc - Wrapper around pkgPolicy + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include +#include "apt_pkgmodule.h" +#include "generic.h" +#include + +static PyObject *Policy_NEW(PyTypeObject *type,PyObject *Args, + PyObject *kwds) { + PyObject *cache; + char *kwlist[] = {"cache", NULL}; + if (PyArg_ParseTupleAndKeywords(Args, kwds, "O", kwlist, &cache) == 0) + return 0; + if (!PyObject_TypeCheck(cache, &PkgCacheType)) { + PyErr_SetString(PyExc_TypeError,"`cache` must be a apt_pkg.Cache()."); + return 0; + } + pkgPolicy *policy = new pkgPolicy(GetCpp(cache)); + return CppOwnedPyObject_NEW(cache,&PyPolicy_Type,policy); +} + +static char *Policy_GetPriority_doc = "get_priority(package: apt_pkg.Package)" + " -> int\n\n" + "Return the priority of the package."; + +PyObject *Policy_GetPriority(PyObject *self, PyObject *arg) { + pkgPolicy *policy = GetCpp(self); + if (PyObject_TypeCheck(arg, &PackageType)) { + pkgCache::PkgIterator pkg = GetCpp(arg); + return Py_BuildValue("i", policy->GetPriority(pkg)); + } else { + PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); + return 0; + } +} + +static char *Policy_GetCandidateVer_doc = "get_match(package: apt_pkg.Package)" + " -> apt_pkg.Version\n\n" + "Get the best package for the job."; + +PyObject *Policy_GetCandidateVer(PyObject *self, PyObject *arg) { + if (PyObject_TypeCheck(arg, &PackageType)) { + pkgPolicy *policy = GetCpp(self); + pkgCache::PkgIterator pkg = GetCpp(arg); + pkgCache::VerIterator ver = policy->GetCandidateVer(pkg); + return CppOwnedPyObject_NEW(arg,&VersionType, + ver); + } else { + PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); + return 0; + } +} + +static char *Policy_GetMatch_doc = "get_match(package: apt_pkg.Package) -> " + "apt_pkg.Version\n\n" + "Return a matching version for the given package."; + +static PyObject *Policy_GetMatch(PyObject *self, PyObject *arg) { + if (PyObject_TypeCheck(arg, &PackageType) == 0) { + PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); + return 0; + } + pkgPolicy *policy = GetCpp(self); + pkgCache::PkgIterator pkg = GetCpp(arg); + pkgCache::VerIterator ver = policy->GetMatch(pkg); + return CppOwnedPyObject_NEW(arg,&VersionType,ver); +} + +static char *Policy_ReadPinFile_doc = "read_pinfile(filename: str) -> bool\n\n" + "Read the pin file given by filename (e.g. '/etc/apt/preferences') and\n" + "add it to the policy."; + +static PyObject *Policy_ReadPinFile(PyObject *self, PyObject *arg) { + if (!PyString_Check(arg)) + return 0; + pkgPolicy *policy = GetCpp(self); + + return PyBool_FromLong(ReadPinFile(*policy, PyString_AsString(arg))); +} + +static char *Policy_CreatePin_doc = "create_pin(type: str, pkg: str, " + "data: str, priority: int)\n\n" + "Create a pin for the policy. The parameter 'type' refers to one of the\n" + "following strings: 'Version', 'Release', 'Origin'. The argument 'pkg'\n" + "is the name of the package, the parameter 'data' refers to the value\n" + "e.g. unstable for type='Release' and the other possible options. \n" + "The parameter 'priority' gives the priority of the pin."; + +static PyObject *Policy_CreatePin(PyObject *self, PyObject *args) { + pkgVersionMatch::MatchType match_type; + const char *type, *pkg, *data; + signed short priority; + if (PyArg_ParseTuple(args, "sssh", &type, &pkg, &data, &priority) == 0) + return 0; + pkgPolicy *policy = GetCpp(self); + if (type == "Version" || type == "version") + match_type = pkgVersionMatch::Version; + if (type == "Release" || type == "release") + match_type = pkgVersionMatch::Release; + if (type == "Origin" || type == "origin") + match_type = pkgVersionMatch::Origin; + else + match_type = pkgVersionMatch::None; + policy->CreatePin(match_type,pkg,data,priority); + HandleErrors(); + Py_RETURN_NONE; +} + +static PyMethodDef Policy_Methods[] = { + {"get_priority",(PyCFunction)Policy_GetPriority,METH_O, + Policy_GetPriority_doc}, + {"get_candidate_ver",(PyCFunction)Policy_GetCandidateVer,METH_O, + Policy_GetCandidateVer_doc}, + {"read_pinfile",(PyCFunction)Policy_ReadPinFile,METH_O, + Policy_ReadPinFile_doc}, + {"create_pin",Policy_CreatePin,METH_VARARGS,Policy_CreatePin_doc}, + {"get_match",(PyCFunction)Policy_GetMatch,METH_O, Policy_GetMatch_doc}, + {} +}; + +static char *Policy_doc = "Policy(cache)\n\n" + "Representation of the policy of the Cache object given by cache. This\n" + "provides a superset of policy-related functionality compared to the\n" + "DepCache class. The DepCache can be used for most purposes, but there\n" + "may be some cases where a special policy class is needed."; + +PyTypeObject PyPolicy_Type = { + PyObject_HEAD_INIT(&PyType_Type) +#if PY_MAJOR_VERSION < 3 + 0, // ob_size +#endif + "apt_pkg.Policy", // tp_name + sizeof(CppOwnedPyObject),// tp_basicsize + 0, // tp_itemsize + // Methods + CppOwnedDealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + (Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE), + Policy_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + Policy_Methods, // tp_methods + 0, // tp_members + 0, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + Policy_NEW, // tp_new +}; -- cgit v1.2.3 From 395b33f9f8e93223f933c625bacbf1e2d23c6673 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Jun 2009 18:56:23 +0200 Subject: Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) We previously called the destructor of the pointer. This resulted in no object using pointers being deallocated. This patch introduces CppDeallocPtr() and CppOwnedDeallocPtr() which do the same as the other CppDealloc() and CppOwnedDealloc(), but use 'delete' on the pointer instead of the deconstructor. Furthermore, this patch also changes AcquireFile to be a CppOwnedPyObject, owned by the Acquire object. Without this change, deleting the Acquire object would cause a crash when AcquireFile is deallocated. --- debian/changelog | 5 +++-- python/acquire.cc | 8 ++++---- python/cache.cc | 4 ++-- python/depcache.cc | 6 +++--- python/generic.h | 19 +++++++++++++++++++ python/hashstring.cc | 2 +- python/indexfile.cc | 2 +- python/indexrecords.cc | 2 +- python/metaindex.cc | 2 +- python/pkgmanager.cc | 2 +- python/policy.cc | 2 +- python/sourcelist.cc | 2 +- 12 files changed, 38 insertions(+), 18 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 3e85c5be..9f9838c3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,11 @@ -python-apt (0.7.92) experimental; urgency=low +python-apt (0.7.92) UNRELEASED; urgency=low * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) * Add apt_pkg.Policy class (Closes: #382725) * Allow types providing __new__() to be subclassed. + * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) - -- Julian Andres Klode Tue, 09 Jun 2009 20:39:39 +0200 + -- Julian Andres Klode Fri, 12 Jun 2009 18:42:02 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/acquire.cc b/python/acquire.cc index 702d48ce..6b091479 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -261,7 +261,7 @@ PyTypeObject PkgAcquireType = sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -329,7 +329,7 @@ static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject shortDescr, destDir, destFile); // short-desc - CppPyObject *AcqFileObj = CppPyObject_NEW(type); + CppOwnedPyObject *AcqFileObj = CppOwnedPyObject_NEW(pyfetcher, type); AcqFileObj->Object = af; return AcqFileObj; @@ -349,10 +349,10 @@ PyTypeObject PkgAcquireFileType = 0, // ob_size #endif "apt_pkg.AcquireFile", // tp_name - sizeof(CppPyObject),// tp_basicsize + sizeof(CppOwnedPyObject),// tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/cache.cc b/python/cache.cc index 14484104..22ed9ecc 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -247,7 +247,7 @@ void PkgCacheFileDealloc(PyObject *Self) PyObject *CacheFilePy = GetOwner(Self); pkgCacheFile *CacheF = GetCpp(CacheFilePy); CacheF->Close(); - CppOwnedDealloc(Self); + CppOwnedDeallocPtr(Self); } static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) @@ -365,7 +365,7 @@ PyTypeObject PkgCacheFileType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/depcache.cc b/python/depcache.cc index f1c34fef..9bbda527 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -660,7 +660,7 @@ PyTypeObject PkgDepCacheType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -844,7 +844,7 @@ PyTypeObject PkgProblemResolverType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr,// tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -962,7 +962,7 @@ PyTypeObject PkgActionGroupType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/generic.h b/python/generic.h index df4d8755..b7b958f5 100644 --- a/python/generic.h +++ b/python/generic.h @@ -153,6 +153,25 @@ void CppOwnedDealloc(PyObject *iObj) iObj->ob_type->tp_free(iObj); } +// Pointer deallocation +// Generic Dealloc type functions +template +void CppDeallocPtr(PyObject *Obj) +{ + delete GetCpp(Obj); + Obj->ob_type->tp_free(Obj); +} + +template +void CppOwnedDeallocPtr(PyObject *iObj) +{ + CppOwnedPyObject *Obj = (CppOwnedPyObject *)iObj; + delete Obj->Object; + if (Obj->Owner != 0) + Py_DECREF(Obj->Owner); + iObj->ob_type->tp_free(iObj); +} + inline PyObject *CppPyString(std::string Str) { return PyString_FromStringAndSize(Str.c_str(),Str.length()); diff --git a/python/hashstring.cc b/python/hashstring.cc index 58bcca9e..23212a4b 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -103,7 +103,7 @@ PyTypeObject PyHashString_Type = { sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/indexfile.cc b/python/indexfile.cc index 795931fb..78a4f513 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -99,7 +99,7 @@ PyTypeObject PackageIndexFileType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/indexrecords.cc b/python/indexrecords.cc index 61ff07fc..fcb2b85d 100644 --- a/python/indexrecords.cc +++ b/python/indexrecords.cc @@ -89,7 +89,7 @@ PyTypeObject PyIndexRecords_Type = { sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/metaindex.cc b/python/metaindex.cc index b451f0b5..b5d194b4 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -80,7 +80,7 @@ PyTypeObject MetaIndexType = sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index f47e77ad..0fd2cd92 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -138,7 +138,7 @@ PyTypeObject PkgManagerType = sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/policy.cc b/python/policy.cc index 89604e9a..992a1192 100644 --- a/python/policy.cc +++ b/python/policy.cc @@ -151,7 +151,7 @@ PyTypeObject PyPolicy_Type = { sizeof(CppOwnedPyObject),// tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 5e5838d8..e53fccd3 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -123,7 +123,7 @@ PyTypeObject PkgSourceListType = sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr -- cgit v1.2.3 From 986993847b3d833f9ac0926c64f00fa03b895832 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 14 Jun 2009 16:47:05 +0200 Subject: apt/package.py: Return VersionList objects in Package.versions. VersionList objects provide the same features as sequences (they are even derived from collections.Sequence in Python 2.6 and newer), but also provide a mapping like interface. They are also more efficient than lists because Version objects are only created when they are accessed. --- apt/package.py | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++------ debian/changelog | 4 ++- 2 files changed, 87 insertions(+), 10 deletions(-) (limited to 'debian') diff --git a/apt/package.py b/apt/package.py index a0727429..0a80215e 100644 --- a/apt/package.py +++ b/apt/package.py @@ -29,10 +29,10 @@ import subprocess import urllib2 import warnings try: - from collections import Mapping + from collections import Mapping, Sequence except ImportError: # (for Python < 2.6) pylint: disable-msg=C0103 - Mapping = object + Sequence = Mapping = object import apt_pkg import apt.progress @@ -206,7 +206,10 @@ class Version(object): self._cand = cand def __eq__(self, other): - return self._cand.id == other._cand.id + try: + return self._cand.id == other._cand.id + except: + return apt_pkg.version_compare(self.version, other) == 0 def __gt__(self, other): return apt_pkg.version_compare(self.version, other.version) > 0 @@ -515,6 +518,81 @@ class Version(object): return os.path.abspath(dsc) +class VersionList(Sequence): + """Provide a mapping & sequence interface to all versions of a package. + + This class can be used like a dictionary, where version strings are the + keys. It can also be used as a sequence, where integers are the keys. + + You can also convert this to a dictionary or a list, using the usual way + of dict(version_list) or list(version_list). This is useful if you need + to access the version objects multiple times, because they do not have to + be recreated this way. + + Examples ('package.versions' being a version list): + '0.7.92' in package.versions # Check whether 0.7.92 is a valid version. + package.versions[0] # Return first version or raise IndexError + package.versions[0:2] # Return a new VersionList for objects 0-2 + package.versions['0.7.92'] # Return version 0.7.92 or raise KeyError + package.versions.keys() # All keys, as strings. + max(package.versions) + """ + + def __init__(self, package, slice=None): + self._package = package # apt.package.Package() + self._versions = package._pkg.version_list # [apt_pkg.Version(), ...] + if slice: + self._versions = self._versions[slice] + + def __getitem__(self, item): + if isinstance(item, slice): + return self.__class__(self._package, item) + try: + # Sequence interface, item is an integer + return Version(self._package, self._versions[item]) + except TypeError: + # Dictionary interface item is a string. + for ver in self._versions: + if ver.ver_str == item: + return Version(self._package, ver) + raise KeyError("Version: %r not found." % (item)) + + def __repr__(self): + return '' % self.keys() + + def __iter__(self): + """Return an iterator over all value objects.""" + return (Version(self._package, ver) for ver in self._versions) + + def __contains__(self, item): + if isinstance(item, Version): # Sequence interface + item = item.version + # Dictionary interface. + for ver in self._versions: + if ver.ver_str == item: + return True + return False + + def __eq__(self, other): + return list(self) == list(other) + + def __len__(self): + return len(self._versions) + + # Mapping interface + + def keys(self): + """Return a list of all versions, as strings.""" + return [ver.ver_str for ver in self._versions] + + def get(self, key, default=None): + """Return the key or the default.""" + try: + return self[key] + except LookupError: + return default + + class Package(object): """Representation of a package in a cache. @@ -988,18 +1066,15 @@ class Package(object): @property def versions(self): - """Return a list of versions. + """Return a VersionList() object for all available versions. .. versionadded:: 0.7.9 """ - return [Version(self, ver) for ver in self._pkg.version_list] + return VersionList(self) def get_version(self, version): """Get the Version instance matching the given version string.""" - for ver in self.versions: - if ver.version == version: - return ver - return None + return self.versions[version] # depcache actions diff --git a/debian/changelog b/debian/changelog index 7e79e89c..648b008d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,12 +5,14 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Add apt_pkg.Policy class (Closes: #382725) * Allow types providing __new__() to be subclassed. * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) + * apt/package.py: Return VersionList objects in Package.versions, which + are sequences and also provide features of mappings. (small API BREAK) [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message (Closes: #532660) - -- Julian Andres Klode Fri, 12 Jun 2009 18:42:02 +0200 + -- Julian Andres Klode Sun, 14 Jun 2009 16:23:39 +0200 python-apt (0.7.91) experimental; urgency=low -- cgit v1.2.3 From dc759b837ad5d7790fd54f081c1b95ffe76b926c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 15 Jun 2009 14:47:15 +0200 Subject: apt/progress/__init__.py: Check for EINTR in select (Closes: #499296) --- apt/progress/__init__.py | 8 +++++++- debian/changelog | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index a6287dc4..3c5d4588 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -116,6 +116,7 @@ class FetchProgress(object): This happens eg. when the downloads fails or is completed. """ + def update_status_full(self, uri, descr, short_descr, status, file_size, partial_size): """Called when the status of an item changes. @@ -314,7 +315,12 @@ class InstallProgress(DumbInstallProgress): def wait_child(self): """Wait for child progress to exit.""" while True: - select.select([self.statusfd], [], [], self.select_timeout) + try: + select.select([self.statusfd], [], [], self.select_timeout) + except select.error, e: + if e[0] != errno.EINTR: + raise + self.update_interface() (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) if pid == self.child_pid: diff --git a/debian/changelog b/debian/changelog index 6ad40154..55d3a834 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) * apt/package.py: Return VersionList objects in Package.versions, which are sequences and also provide features of mappings. (small API BREAK) + * apt/progress/__init__.py: Check for EINTR in select (Closes: #499296) [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -22,7 +23,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Sun, 14 Jun 2009 16:23:39 +0200 + -- Julian Andres Klode Mon, 15 Jun 2009 14:45:06 +0200 python-apt (0.7.91) experimental; urgency=low -- cgit v1.2.3 From 7618780d7e0550897f87eecc4ab52d75b9c0ec39 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 15 Jun 2009 14:58:41 +0200 Subject: Add support for Enhances as a dependency type (Closes: #416247) --- debian/changelog | 1 + python/cache.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 55d3a834..9809d423 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * apt/package.py: Return VersionList objects in Package.versions, which are sequences and also provide features of mappings. (small API BREAK) * apt/progress/__init__.py: Check for EINTR in select (Closes: #499296) + * Add support for Enhances as a dependency type (Closes: #416247) [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/python/cache.cc b/python/cache.cc index 80a7a8a5..7e75ccab 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -711,7 +711,7 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, { "", "Depends","PreDepends","Suggests", "Recommends","Conflicts","Replaces", - "Obsoletes", "Breaks" + "Obsoletes", "Breaks", "Enhances" }; PyObject *Dep = PyString_FromString(Types[Start->Type]); LastDepType = Start->Type; -- cgit v1.2.3 From 56ce90ed8cc9ce939dd7904c9b07478b0c3b2071 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 15 Jun 2009 15:14:30 +0200 Subject: apt/cache.py: Provide broken_count, delete_count, install_count, keep_count properties (Closes: #532338) --- apt/cache.py | 20 ++++++++++++++++++++ debian/changelog | 2 ++ 2 files changed, 22 insertions(+) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index 16dfc011..949de6cc 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -368,6 +368,26 @@ class Cache(object): """ return apt_pkg.ActionGroup(self._depcache) + @property + def broken_count(self): + """Return the number of packages with broken dependencies.""" + return self._depcache.broken_count + + @property + def delete_count(self): + """Return the number of packages marked for deletion.""" + return self._depcache.del_count + + @property + def install_count(self): + """Return the number of packages marked for installation.""" + return self._depcache.inst_count + + @property + def keep_count(self): + """Return the number of packages marked as keep.""" + return self._depcache.keep_count + if apt_pkg._COMPAT_0_7: _runCallbacks = function_deprecated_by(_run_callbacks) getChanges = function_deprecated_by(get_changes) diff --git a/debian/changelog b/debian/changelog index 9809d423..97b49021 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low are sequences and also provide features of mappings. (small API BREAK) * apt/progress/__init__.py: Check for EINTR in select (Closes: #499296) * Add support for Enhances as a dependency type (Closes: #416247) + * apt/cache.py: Provide broken_count, delete_count, install_count, keep_count + properties (Closes: #532338) [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message -- cgit v1.2.3 From 6842933fb0b51aaa6fdc66e17b4645312876d0c9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 21 Jun 2009 20:46:24 +0200 Subject: apt/cache.py: Correctly handle rootdir on second and later invocations of open() (LP: #320665). --- apt/cache.py | 4 ++++ debian/changelog | 2 ++ 2 files changed, 6 insertions(+) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index 737061ad..414bd982 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -80,6 +80,10 @@ class Cache(object): if progress is None: progress = apt.progress.OpProgress() self._run_callbacks("cache_pre_open") + + # Make changes to Dir::State::Status work again, by reinitialising + # the system. + apt_pkg.init_system() self._cache = apt_pkg.Cache(progress) self._depcache = apt_pkg.DepCache(self._cache) self._records = apt_pkg.PackageRecords(self._cache) diff --git a/debian/changelog b/debian/changelog index 97b49021..4fb6b0de 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Add support for Enhances as a dependency type (Closes: #416247) * apt/cache.py: Provide broken_count, delete_count, install_count, keep_count properties (Closes: #532338) + * apt/cache.py: Correctly handle rootdir on second and later invocations of + open() (LP: #320665). [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message -- cgit v1.2.3 From b426f959e7e515d5f267558b6ae51ed9ae03fb9d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Jun 2009 14:54:31 +0200 Subject: Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to mark a package as automatically installed. --- apt/package.py | 13 +++++++++++++ debian/changelog | 4 +++- python/depcache.cc | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/apt/package.py b/apt/package.py index cb99fe6a..39a73c07 100644 --- a/apt/package.py +++ b/apt/package.py @@ -846,6 +846,10 @@ class Package(object): return self.is_installed and \ self._pcache._depcache.is_garbage(self._pkg) + @property + def is_auto_installed(self): + """Return whether the package is marked as automatically installed.""" + return self._pcache._depcache.is_auto_installed(self._pkg) # sizes @DeprecatedProperty @@ -1135,6 +1139,15 @@ class Package(object): sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: " "'%s'\n") % self._pkg.name) + def mark_auto(self, auto=True): + """Mark a package as automatically installed. + + Call this function to mark a package as automatically installed. If the + optional parameter *auto* is set to ``False``, the package will not be + marked as automatically installed anymore. The default is ``True``. + """ + self._pcache._depcache.mark_auto(self._pkg, auto) + def commit(self, fprogress, iprogress): """Commit the changes. diff --git a/debian/changelog b/debian/changelog index 4fb6b0de..f0b3efbe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low properties (Closes: #532338) * apt/cache.py: Correctly handle rootdir on second and later invocations of open() (LP: #320665). + * Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to + mark a package as automatically installed. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -28,7 +30,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Mon, 15 Jun 2009 14:45:06 +0200 + -- Julian Andres Klode Mon, 22 Jun 2009 14:38:19 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/depcache.cc b/python/depcache.cc index d0b233b8..e1514300 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -367,6 +367,23 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args) return HandleErrors(Py_None); } +static PyObject *PkgDepCacheMarkAuto(PyObject *Self,PyObject *Args) +{ + pkgDepCache *depcache = GetCpp(Self); + + PyObject *PackageObj; + char value = 0; + if (PyArg_ParseTuple(Args,"O!b",&PackageType,&PackageObj, &value) == 0) + return 0; + + pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); + depcache->MarkAuto(Pkg,value); + + Py_INCREF(Py_None); + return HandleErrors(Py_None); +} + + static PyObject *PkgDepCacheIsUpgradable(PyObject *Self,PyObject *Args) { pkgDepCache *depcache = GetCpp(Self); @@ -541,6 +558,7 @@ static PyMethodDef PkgDepCacheMethods[] = {"mark_keep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"}, {"mark_delete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"}, {"mark_install",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"}, + {"mark_auto",PkgDepCacheMarkAuto,METH_VARARGS,"mark_auto(pkg: apt_pkg.Package, auto: bool)\n\nMark package as automatically installed."}, {"set_reinstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, // state information {"is_upgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, -- cgit v1.2.3 From 7c248775da6c86e70a8444630722c92a2dcd676f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Jun 2009 15:53:45 +0200 Subject: python/cache.cc: Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(). Drop these functions, because they cause segfaults and memory leaks. To replace this functionality, simply create/delete a Cache object. This way, reference counting can work. --- debian/changelog | 4 +++- python/cache.cc | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index f0b3efbe..0ef7e38b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low open() (LP: #320665). * Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to mark a package as automatically installed. + * Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(), they cause segfaults + and memory leaks. Simply create a new cache instead. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -30,7 +32,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Mon, 22 Jun 2009 14:38:19 +0200 + -- Julian Andres Klode Mon, 22 Jun 2009 15:49:03 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/cache.cc b/python/cache.cc index 4624dc34..4ce3178c 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -95,6 +95,8 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) 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(Self); pkgCacheFile *Cache = GetCpp(CacheFilePy); Cache->Close(); @@ -105,6 +107,9 @@ static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) 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(Self); pkgCacheFile *Cache = GetCpp(CacheFilePy); @@ -137,8 +142,6 @@ static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) static PyMethodDef PkgCacheMethods[] = { {"update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, - {"open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, - {"close", PkgCacheClose, METH_VARARGS,"Close the cache"}, #ifdef COMPAT_0_7 {"Update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, {"Open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, -- cgit v1.2.3 From 4b80a5fbfcab291f2386119d40473ec6e782928d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Jun 2009 16:07:31 +0200 Subject: debian/changelog: Add entry about the merge of 0.7.10.4 --- debian/changelog | 1 + 1 file changed, 1 insertion(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 0ef7e38b..60ace1f8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low mark a package as automatically installed. * Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(), they cause segfaults and memory leaks. Simply create a new cache instead. + * Merge 0.7.10.4 from unstable [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message -- cgit v1.2.3 From f01f323bf739c8deee17722f5fc6aaf480d7bc13 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Jun 2009 16:17:23 +0200 Subject: debian/control: Update Standards-Version to 3.8.2 --- debian/changelog | 1 + debian/control | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 60ace1f8..843c6b3b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(), they cause segfaults and memory leaks. Simply create a new cache instead. * Merge 0.7.10.4 from unstable + * debian/control: Update Standards-Version to 3.8.2 [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/debian/control b/debian/control index 25c58f15..fc48f192 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: python Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode -Standards-Version: 3.8.1 +Standards-Version: 3.8.2 XS-Python-Version: all Build-Depends: apt-utils, cdbs, -- cgit v1.2.3 From 6e9b361307e4c024fd882ab4a59d39dfb2b25b60 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 23 Jun 2009 11:29:21 +0200 Subject: python/acquire.cc: Make AcquireFile a subclass of AcquireItem Generalized the code a bit, so we can now access the various attributes of AcquireItem in the AcquireFile (pkgAcqFile is a subclass of pkgAcquire::Item). This will allow us to implement a raw object with a single pointer to an Item later, which we will need for the new progress interface. --- debian/changelog | 1 + python/acquire.cc | 50 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 18 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 843c6b3b..c4486505 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low and memory leaks. Simply create a new cache instead. * Merge 0.7.10.4 from unstable * debian/control: Update Standards-Version to 3.8.2 + * Make AcquireFile a subclass of AcquireItem [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/python/acquire.cc b/python/acquire.cc index b0dd2cab..e13e47d6 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -14,20 +14,27 @@ #define MkGet(PyFunc,Ret) static PyObject *PyFunc(PyObject *Self,void*) \ { \ - pkgAcquire::ItemIterator &I = GetCpp(Self); \ + pkgAcquire::Item *Itm; \ + if (PyObject_TypeCheck(Self, &PkgAcquireFileType)) { \ + Itm = GetCpp(Self); \ + } else { \ + pkgAcquire::ItemIterator &I = GetCpp(Self); \ + Itm = *I; \ + } \ return Ret; \ } // Define our getters -MkGet(AcquireItemGetComplete,Py_BuildValue("i",(*I)->Complete)); -MkGet(AcquireItemGetDescURI,Safe_FromString((*I)->DescURI().c_str())); -MkGet(AcquireItemGetDestFile,Safe_FromString((*I)->DestFile.c_str())); -MkGet(AcquireItemGetErrorText,Safe_FromString((*I)->ErrorText.c_str())); -MkGet(AcquireItemGetFileSize,Py_BuildValue("i",(*I)->FileSize)); -MkGet(AcquireItemGetID,Py_BuildValue("i",(*I)->ID)); -MkGet(AcquireItemGetIsTrusted,Py_BuildValue("i",(*I)->IsTrusted())); -MkGet(AcquireItemGetLocal,Py_BuildValue("i",(*I)->Local)); -MkGet(AcquireItemGetStatus,Py_BuildValue("i",(*I)->Status)); +MkGet(AcquireItemGetComplete,Py_BuildValue("i",Itm->Complete)); +MkGet(AcquireItemGetDescURI,Safe_FromString(Itm->DescURI().c_str())); +MkGet(AcquireItemGetDestFile,Safe_FromString(Itm->DestFile.c_str())); +MkGet(AcquireItemGetErrorText,Safe_FromString(Itm->ErrorText.c_str())); +MkGet(AcquireItemGetFileSize,Py_BuildValue("i",Itm->FileSize)); +MkGet(AcquireItemGetID,Py_BuildValue("i",Itm->ID)); +MkGet(AcquireItemGetIsTrusted,Py_BuildValue("i",Itm->IsTrusted())); +MkGet(AcquireItemGetLocal,Py_BuildValue("i",Itm->Local)); +MkGet(AcquireItemGetStatus,Py_BuildValue("i",Itm->Status)); + // Constants MkGet(AcquireItemGetStatIdle,Py_BuildValue("i", pkgAcquire::Item::StatIdle)); @@ -43,7 +50,7 @@ static PyGetSetDef AcquireItemGetSet[] = { {"destfile",AcquireItemGetDestFile}, {"error_text",AcquireItemGetErrorText}, {"filesize",AcquireItemGetFileSize}, - {"is",AcquireItemGetID}, + {"id",AcquireItemGetID}, {"is_trusted",AcquireItemGetIsTrusted}, {"local",AcquireItemGetLocal}, {"status",AcquireItemGetStatus}, @@ -75,16 +82,23 @@ static PyGetSetDef AcquireItemGetSet[] = { static PyObject *AcquireItemRepr(PyObject *Self) { - pkgAcquire::ItemIterator &I = GetCpp(Self); + pkgAcquire::Item *Itm; + if (PyObject_TypeCheck(Self, &PkgAcquireFileType)) { + Itm = GetCpp(Self); + } else { + pkgAcquire::ItemIterator &I = GetCpp(Self); + Itm = *I; + } char S[300]; - snprintf(S,sizeof(S),"", - (*I)->Status, (*I)->Complete, (*I)->Local, (*I)->IsTrusted(), - (*I)->FileSize, (*I)->DestFile.c_str(), (*I)->DescURI().c_str(), - (*I)->ID,(*I)->ErrorText.c_str()); + Self->ob_type->tp_name, + Itm->Status, Itm->Complete, Itm->Local, Itm->IsTrusted(), + Itm->FileSize, Itm->DestFile.c_str(), Itm->DescURI().c_str(), + Itm->ID,Itm->ErrorText.c_str()); return PyString_FromString(S); } @@ -383,8 +397,8 @@ PyTypeObject PkgAcquireFileType = 0, // tp_iternext 0, // tp_methods 0, // tp_members - 0, // tp_getset - 0, // tp_base + 0, // tp_getset + &AcquireItemType, // tp_base 0, // tp_dict 0, // tp_descr_get 0, // tp_descr_set -- cgit v1.2.3 From c41d1e0c66ab4effdf737ca4c9a9c86c08237451 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 23 Jun 2009 11:39:09 +0200 Subject: python/configuration.cc: Make ConfigurationPtr,ConfigurationSub subclasses of Configuration. This makes isinstance(apt_pkg.config, apt_pkg.Configuration) return True instead of False. --- debian/changelog | 1 + python/configuration.cc | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index c4486505..3209f7ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Merge 0.7.10.4 from unstable * debian/control: Update Standards-Version to 3.8.2 * Make AcquireFile a subclass of AcquireItem + * Make ConfigurationPtr,ConfigurationSub subclasses of Configuration. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/python/configuration.cc b/python/configuration.cc index 365a35fd..9ef5967b 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -582,6 +582,9 @@ PyTypeObject ConfigurationPtrType = 0, // tp_iter 0, // tp_iternext CnfMethods, // tp_methods + 0, // tp_members + 0, // tp_getset + &ConfigurationType, // tp_base }; PyTypeObject ConfigurationSubType = @@ -618,5 +621,8 @@ PyTypeObject ConfigurationSubType = 0, // tp_iter 0, // tp_iternext CnfMethods, // tp_methods + 0, // tp_members + 0, // tp_getset + &ConfigurationType, // tp_base }; -- cgit v1.2.3 From ca5913fc53580b29034d56dd7942c5cdf5207afe Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 7 Jul 2009 16:57:05 +0200 Subject: debian/control: Build-Depend on libapt-pkg-dev (>= 0.7.22~). --- debian/changelog | 3 ++- debian/control | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 3209f7ee..2b3f0ac1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * debian/control: Update Standards-Version to 3.8.2 * Make AcquireFile a subclass of AcquireItem * Make ConfigurationPtr,ConfigurationSub subclasses of Configuration. + * debian/control: Build-Depend on libapt-pkg-dev (>= 0.7.22~). [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -36,7 +37,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Mon, 22 Jun 2009 15:49:03 +0200 + -- Julian Andres Klode Tue, 07 Jul 2009 16:56:44 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/debian/control b/debian/control index fc48f192..10b9bc31 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ XS-Python-Version: all Build-Depends: apt-utils, cdbs, debhelper (>= 5.0.37.1), - libapt-pkg-dev (>= 0.7.10), + libapt-pkg-dev (>= 0.7.22~), python-all-dbg, python-all-dev, python3.1-dev, -- cgit v1.2.3 From 3770906714c5e73b844514c431ce07fd9ac416fb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 8 Jul 2009 17:43:01 +0200 Subject: python/apt_pkgmodule.cc: Unify dep handling -- part 1: parse_depends() apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb (i.e. < instead of <<) to match the interface of Version.depends_list_str. --- debian/changelog | 4 ++++ python/apt_pkgmodule.cc | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 2b3f0ac1..581e1be1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,10 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Make AcquireFile a subclass of AcquireItem * Make ConfigurationPtr,ConfigurationSub subclasses of Configuration. * debian/control: Build-Depend on libapt-pkg-dev (>= 0.7.22~). + * Unification of dependency handling: + - apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb + (i.e. < instead of <<) to match the interface of Version.depends_list_str + [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 9f750996..3f4aae37 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -104,9 +104,10 @@ static char *doc_ParseDepends = "The resulting tuples are (Pkg,Ver,Operation). Each anded dependency is a\n" "list of or'd dependencies\n" "Source depends are evaluated against the curernt arch and only those that\n" -"Match are returned."; +"Match are returned.\n\n" +"apt_pkg.Parse{,Src}Depends() are old forms which return >>,<< instead of >,<"; static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, - bool ParseArchFlags) + bool ParseArchFlags, bool debStyle=false) { string Package; string Version; @@ -143,7 +144,7 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args, PyObject *Obj; PyList_Append(LastRow,Obj = Py_BuildValue("sss",Package.c_str(), Version.c_str(), - pkgCache::CompTypeDeb(Op))); + debStyle ? pkgCache::CompTypeDeb(Op) : pkgCache::CompType(Op))); Py_DECREF(Obj); } @@ -165,6 +166,14 @@ static PyObject *ParseDepends(PyObject *Self,PyObject *Args) static PyObject *ParseSrcDepends(PyObject *Self,PyObject *Args) { return RealParseDepends(Self,Args,true); +} +static PyObject *ParseDepends_old(PyObject *Self,PyObject *Args) +{ + return RealParseDepends(Self,Args,false, true); +} +static PyObject *ParseSrcDepends_old(PyObject *Self,PyObject *Args) +{ + return RealParseDepends(Self,Args,true, true); } /*}}}*/ // md5sum - Compute the md5sum of a file or string /*{{{*/ @@ -444,8 +453,8 @@ static PyMethodDef methods[] = {"parse_depends",ParseDepends,METH_VARARGS,doc_ParseDepends}, {"parse_src_depends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, #ifdef COMPAT_0_7 - {"ParseDepends",ParseDepends,METH_VARARGS,doc_ParseDepends}, - {"ParseSrcDepends",ParseSrcDepends,METH_VARARGS,doc_ParseDepends}, + {"ParseDepends",ParseDepends_old,METH_VARARGS,doc_ParseDepends}, + {"ParseSrcDepends",ParseSrcDepends_old,METH_VARARGS,doc_ParseDepends}, #endif // Stuff -- cgit v1.2.3 From d2423e2c28df63cb0a235f822a9588f8a221600a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 8 Jul 2009 20:18:36 +0200 Subject: python/pkgsrcrecords.cc: Unify dep handling -- part 2: SourceRecords.build_depends Change apt_pkg.SourceRecords.build_depends to match exactly the interface of Version.depends_list_str just with different keys (e.g. Build-Depends). + Closes: #468123 - there is no need anymore for binding CompType or CompTypeDeb, because we don't return integer values for CompType anymore. --- debian/changelog | 6 +++++- python/pkgsrcrecords.cc | 51 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 581e1be1..8bc3e320 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,7 +25,11 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Unification of dependency handling: - apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb (i.e. < instead of <<) to match the interface of Version.depends_list_str - + - apt_pkg.SourceRecords.build_depends matches exactly the interface of + Version.depends_list_str just with different keys (e.g. Build-Depends). + + Closes: #468123 - there is no need anymore for binding CompType or + CompTypeDeb, because we don't return integer values for CompType + anymore. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 187050b7..06fd4e3b 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -151,6 +151,54 @@ static PyObject *PkgSrcRecordsGetFiles(PyObject *Self,void*) { } static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) { + PkgSrcRecordsStruct &Struct = GetStruct(Self,"BuildDepends"); + if (Struct.Last == 0) + return 0; + + PyObject *Dict = PyDict_New(); + PyObject *Dep = 0; + PyObject *LastDep = 0; + PyObject *OrGroup = 0; + + vector bd; + if(!Struct.Last->BuildDepends(bd, false /* arch-only*/)) + return NULL; // error + + PyObject *v; + for(unsigned int i=0;i Date: Sun, 12 Jul 2009 19:07:55 +0200 Subject: python/hashes.cc: Introduce the Hashes class. The Hashes class is a function which calculates all supported hashes for one input. DebImg will use this for calculating the hashes of files. --- debian/changelog | 3 +- doc/source/apt_pkg.rst | 26 +++++++-- python/apt_pkgmodule.cc | 1 + python/apt_pkgmodule.h | 1 + python/hashes.cc | 136 ++++++++++++++++++++++++++++++++++++++++++++++++ python/makefile | 5 +- 6 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 python/hashes.cc (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 8bc3e320..1f43cc8c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low + Closes: #468123 - there is no need anymore for binding CompType or CompTypeDeb, because we don't return integer values for CompType anymore. + * Introduce apt_pkg.Hashes class. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -45,7 +46,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Tue, 07 Jul 2009 16:56:44 +0200 + -- Julian Andres Klode Sun, 12 Jul 2009 18:51:57 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/doc/source/apt_pkg.rst b/doc/source/apt_pkg.rst index 2af934a0..9a14266e 100644 --- a/doc/source/apt_pkg.rst +++ b/doc/source/apt_pkg.rst @@ -1139,15 +1139,31 @@ installation. the file using the parameter *destfile*. You can not combine both. +Hashes +------ +The apt_pkg module also provides several hash functions. If you develop +applications with python-apt it is often easier to use these functions instead +of the ones provides in Python's :mod:`hashlib` module. +.. class:: Hashes(object) + Calculate all supported hashes of the object. *object* may either be a + string, in which cases the hashes of the string are calculated, or a + :class:`file()` object or file descriptor, in which case the hashes of + its contents is calculated. The calculated hashes are then available via + attributes: + .. attribute:: md5 -Hash functions --------------- -The apt_pkg module also provides several hash functions. If you develop -applications with python-apt it is often easier to use these functions instead -of the ones provides in Python's :mod:`hashlib` module. + The MD5 hash of the data, as string. + + .. attribute:: sha1 + + The SHA1 hash of the data, as string. + + .. attribute:: sha256 + + The SHA256 hash of the data, as string. .. function:: md5sum(object) diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 3f4aae37..4c0fd5ed 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -618,6 +618,7 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"IndexRecords",&PyIndexRecords_Type); ADDTYPE(Module,"HashString",&PyHashString_Type); ADDTYPE(Module,"Policy",&PyPolicy_Type); + ADDTYPE(Module,"Hashes",&PyHashes_Type); // Tag file constants PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", CharCharToList(TFRewritePackageOrder)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 21355072..1a2f1a1a 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -116,5 +116,6 @@ extern PyTypeObject PyIndexRecords_Type; // Policy extern PyTypeObject PyPolicy_Type; +extern PyTypeObject PyHashes_Type; #endif diff --git a/python/hashes.cc b/python/hashes.cc new file mode 100644 index 00000000..a1ace6fc --- /dev/null +++ b/python/hashes.cc @@ -0,0 +1,136 @@ +/* hashes.cc - Wrapper around apt-pkg's Hashes. + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include +#include "generic.h" +#include "apt_pkgmodule.h" +#include + +static PyObject *hashes_new(PyTypeObject *type,PyObject *args, + PyObject *kwds) +{ + return CppPyObject_NEW(type); +} + +static int hashes_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *object = 0; + int Fd; + char *kwlist[] = {"object", NULL}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "|O:__init__", kwlist, + &object) == 0) + return -1; + if (object == 0) + return 0; + Hashes &hashes = GetCpp(self); + + if (PyBytes_Check(object) != 0) { + char *s; + Py_ssize_t len; + PyBytes_AsStringAndSize(object, &s, &len); + hashes.Add((const unsigned char*)s, len); + } + else if ((Fd = PyObject_AsFileDescriptor(object)) != -1) { + struct stat St; + if (fstat(Fd, &St) != 0 || hashes.AddFD(Fd, St.st_size) == false) { + PyErr_SetFromErrno(PyExc_SystemError); + return -1; + } + } + else { + PyErr_SetString(PyExc_TypeError, "__init__() only understand strings" + " and files"); + return -1; + } + return 0; +} + +static PyObject *hashes_get_md5(PyObject *self, void*) +{ + return CppPyString(GetCpp(self).MD5.Result().Value()); +} + +static PyObject *hashes_get_sha1(PyObject *self, void*) +{ + return CppPyString(GetCpp(self).SHA1.Result().Value()); +} + +static PyObject *hashes_get_sha256(PyObject *self, void*) +{ + return CppPyString(GetCpp(self).SHA256.Result().Value()); +} + +static PyGetSetDef hashes_getset[] = { + {"md5",hashes_get_md5,0,"The MD5Sum of the file as a string."}, + {"sha1",hashes_get_sha1,0,"The SHA1Sum of the file as a string."}, + {"sha256",hashes_get_sha256,0,"The SHA256Sum of the file as a string."}, + {} +}; + +static char *hashes_doc = + "Hashes([object: (bytes, file)])\n\n" + "Calculate hashes for the given object. It can be used to create all\n" + "supported hashes for a file.\n\n" + "The parameter *object* can be a bytes (3.X) / str (2.X) object, or an\n" + "object providing the fileno() method or an integer describing a file\n" + "descriptor."; + +PyTypeObject PyHashes_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "apt_pkg.Hashes", // tp_name + sizeof(CppPyObject), // tp_basicsize + 0, // tp_itemsize + // Methods + CppDealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE, + hashes_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + 0, // tp_methods + 0, // tp_members + hashes_getset, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + hashes_init, // tp_init + 0, // tp_alloc + hashes_new, // tp_new +}; diff --git a/python/makefile b/python/makefile index 6799d749..fff3a2e8 100644 --- a/python/makefile +++ b/python/makefile @@ -11,8 +11,9 @@ SLIBS = -lapt-pkg LIB_MAKES = apt-pkg/makefile APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \ cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \ - depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \ - indexfile.cc metaindex.cc hashstring.cc indexrecords.cc policy.cc + depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \ + indexfile.cc metaindex.cc hashstring.cc indexrecords.cc \ + policy.cc hashes.cc SOURCE := $(APT_PKG_SRC) include $(PYTHON_H) progress.h -- cgit v1.2.3 From b0abeea43f6e51c452af68d8ec9bf3d0f701d772 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 12 Jul 2009 21:22:58 +0200 Subject: python/acquire.cc: Fix segmentation faults, introduce PyAcquireObject. Make AcquireItem objects raise ValueError instead of segfaulting when the Acquire() object is shut down or the main object (e.g. AcquireFile) is deallocated. This is implemented by using a vector of the AcquireItem objects, and setting AcquireItem->Object = NULL, when the memory 'Object' previously pointed to is going to be deleted. --- debian/changelog | 4 ++- python/acquire.cc | 96 ++++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 27 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 1f43cc8c..304237c1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low CompTypeDeb, because we don't return integer values for CompType anymore. * Introduce apt_pkg.Hashes class. + * Make AcquireItem objects raise ValueError instead of segfaulting when the Acquire() + object is shut down or the main object (e.g. AcquireFile) is deallocated. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -46,7 +48,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Sun, 12 Jul 2009 18:51:57 +0200 + -- Julian Andres Klode Sun, 12 Jul 2009 21:19:40 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/acquire.cc b/python/acquire.cc index 6c6c2ea4..054956ea 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -12,15 +12,27 @@ #include +typedef CppPyObject PyAcquireItemObject; + +// Keep a vector to PyAcquireItemObject pointers, so we can set the Object +// pointers to NULL when deallocating the main object (mostly AcquireFile). +struct PyAcquireObject : public CppPyObject { + vector items; +}; + +inline pkgAcquire::Item *PyAcquireItem_ToCpp(PyObject *self) { + pkgAcquire::Item *itm = GetCpp(self); + if (itm == 0) + PyErr_SetString(PyExc_ValueError, "Acquire() has been shut down or " + "the AcquireFile() object has been deallocated."); + return itm; +} + #define MkGet(PyFunc,Ret) static PyObject *PyFunc(PyObject *Self,void*) \ { \ - pkgAcquire::Item *Itm; \ - if (PyObject_TypeCheck(Self, &PkgAcquireFileType)) { \ - Itm = GetCpp(Self); \ - } else { \ - pkgAcquire::ItemIterator &I = GetCpp(Self); \ - Itm = *I; \ - } \ + pkgAcquire::Item *Itm = PyAcquireItem_ToCpp(Self); \ + if (Itm == 0) \ + return 0; \ return Ret; \ } @@ -30,7 +42,7 @@ MkGet(AcquireItemGetDescURI,Safe_FromString(Itm->DescURI().c_str())); MkGet(AcquireItemGetDestFile,Safe_FromString(Itm->DestFile.c_str())); MkGet(AcquireItemGetErrorText,Safe_FromString(Itm->ErrorText.c_str())); MkGet(AcquireItemGetFileSize,Py_BuildValue("i",Itm->FileSize)); -MkGet(AcquireItemGetID,Py_BuildValue("i",Itm->ID)); +MkGet(AcquireItemGetID,Py_BuildValue("i",Itm)); MkGet(AcquireItemGetIsTrusted,Py_BuildValue("i",Itm->IsTrusted())); MkGet(AcquireItemGetLocal,Py_BuildValue("i",Itm->Local)); MkGet(AcquireItemGetStatus,Py_BuildValue("i",Itm->Status)); @@ -82,14 +94,9 @@ static PyGetSetDef AcquireItemGetSet[] = { static PyObject *AcquireItemRepr(PyObject *Self) { - pkgAcquire::Item *Itm; - if (PyObject_TypeCheck(Self, &PkgAcquireFileType)) { - Itm = GetCpp(Self); - } else { - pkgAcquire::ItemIterator &I = GetCpp(Self); - Itm = *I; - } - + pkgAcquire::Item *Itm = PyAcquireItem_ToCpp(Self); + if (Itm == 0) + return 0; char S[300]; snprintf(S,sizeof(S),"<%s object: " "Status: %i Complete: %i Local: %i IsTrusted: %i " @@ -102,15 +109,45 @@ static PyObject *AcquireItemRepr(PyObject *Self) return PyString_FromString(S); } +static void AcquireItemDealloc(PyObject *self) { + pkgAcquire::Item *file = GetCpp(self); + PyAcquireObject *owner = (PyAcquireObject *)GetOwner(self); + vector &items = owner->items; + bool DeletePtr = !((CppPyObject *)self)->NoDelete; + + // Cleanup the other objects as well... + for (vector::iterator I = items.begin(); + I != items.end(); I++) { + // If it is the current object, remove it from the vector. + if ((*I) == self) { + items.erase(I); + I--; // erase() moved it one forward, move back + } + // If we delete the object below, set all other pointers to it to NULL, + // and remove them from the vector. + else if (DeletePtr && (*I)->Object == file) { + if ((*I) != self) + (*I)->Object = NULL; + items.erase(I); + I--; // erase() moved it one forward, move back + } + } +#ifdef ALLOC_DEBUG + std::cerr << "ITEMS: " << items.size() << "\n"; +#endif + CppOwnedDeallocPtr(self); +} + + PyTypeObject AcquireItemType = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireItem", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + AcquireItemDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -139,6 +176,7 @@ PyTypeObject AcquireItemType = }; + static PyObject *PkgAcquireRun(PyObject *Self,PyObject *Args) { pkgAcquire *fetcher = GetCpp(Self); @@ -161,6 +199,11 @@ static PyObject *PkgAcquireShutdown(PyObject *Self,PyObject *Args) fetcher->Shutdown(); + vector items = ((PyAcquireObject *)Self)->items; + for (vector::iterator I = items.begin(); + I != items.end(); I++) + (*I)->Object = NULL; + Py_INCREF(Py_None); return HandleErrors(Py_None); } @@ -194,12 +237,12 @@ static PyObject *PkgAcquireGetItems(PyObject *Self,void*) for (pkgAcquire::ItemIterator I = fetcher->ItemsBegin(); I != fetcher->ItemsEnd(); I++) { - PyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self, - &AcquireItemType,I); + PyAcquireItemObject *Obj; + Obj = CppOwnedPyObject_NEW(Self,&AcquireItemType,*I); + Obj->NoDelete = true; PyList_Append(List,Obj); + ((PyAcquireObject *)Self)->items.push_back(Obj); Py_DECREF(Obj); - } return List; } @@ -266,7 +309,7 @@ PyTypeObject PkgAcquireType = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Acquire", // tp_name - sizeof(CppPyObject), // tp_basicsize + sizeof(PyAcquireObject), // tp_basicsize 0, // tp_itemsize // Methods CppDeallocPtr, // tp_dealloc @@ -341,6 +384,8 @@ static PyObject *PkgAcquireFileNew(PyTypeObject *type, PyObject *Args, PyObject destFile); // short-desc CppOwnedPyObject *AcqFileObj = CppOwnedPyObject_NEW(pyfetcher, type); AcqFileObj->Object = af; + ((PyAcquireObject *)pyfetcher)->items.push_back((PyAcquireItemObject *)AcqFileObj); + return AcqFileObj; } @@ -359,9 +404,7 @@ PyTypeObject PkgAcquireFileType = sizeof(CppOwnedPyObject),// tp_basicsize 0, // tp_itemsize // Methods - // Not ..Ptr, because this would cause the item to be removed from the - // fetcher, which would be incompatible to previous behaviour. - CppOwnedDealloc, // tp_dealloc + AcquireItemDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -431,6 +474,7 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) destFile); // short-desc CppPyObject *AcqFileObj = CppPyObject_NEW(&PkgAcquireFileType); AcqFileObj->Object = af; + AcqFileObj->NoDelete = true; return AcqFileObj; } -- cgit v1.2.3 From 8430dbf041ce70dcba81101678beee0492252fd2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 14 Jul 2009 20:43:56 +0200 Subject: python/configuration.cc: Unify all Configuration,ConfigurationPtr,ConfigurationSub into one type. This makes the whole API easier. The disadvantage is that we require 8 bytes (??) more per object for the owner object pointer, which is NULL for most cases (the only exception being objects created by Configuration.sub_tree). --- debian/changelog | 3 +- python/apt_pkgmodule.cc | 9 ++-- python/apt_pkgmodule.h | 6 +-- python/configuration.cc | 116 ++++-------------------------------------------- 4 files changed, 15 insertions(+), 119 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 304237c1..4ae6e574 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,6 +33,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Introduce apt_pkg.Hashes class. * Make AcquireItem objects raise ValueError instead of segfaulting when the Acquire() object is shut down or the main object (e.g. AcquireFile) is deallocated. + * Unify all Configuration,ConfigurationPtr,ConfigurationSub into one type. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -48,7 +49,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Sun, 12 Jul 2009 21:19:40 +0200 + -- Julian Andres Klode Tue, 14 Jul 2009 20:42:03 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 3f18f785..e4fd0dfc 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -527,8 +527,7 @@ extern "C" void initapt_pkg() #endif { // Finalize our types to add slots, etc. - if (PyType_Ready(&PyConfigurationPtr_Type) == -1) INIT_ERROR; - if (PyType_Ready(&PyConfigurationSub_Type) == -1) INIT_ERROR; + if (PyType_Ready(&PyConfiguration_Type) == -1) INIT_ERROR; if (PyType_Ready(&PyCacheFile_Type) == -1) INIT_ERROR; // Initialize the module @@ -539,8 +538,10 @@ extern "C" void initapt_pkg() #endif // Global variable linked to the global configuration class - CppPyObject *Config = CppPyObject_NEW(&PyConfigurationPtr_Type); + CppOwnedPyObject *Config = CppOwnedPyObject_NEW(NULL, &PyConfiguration_Type); Config->Object = _config; + // Global configuration, should never be deleted. + Config->NoDelete = true; PyModule_AddObject(Module,"config",Config); #ifdef COMPAT_0_7 Py_INCREF(Config); @@ -568,8 +569,6 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"Cdrom",&PyCdrom_Type); /* ========================= configuration.cc ========================= */ ADDTYPE(Module,"Configuration",&PyConfiguration_Type); - //ADDTYPE(Module,"ConfigurationSub",&PyConfigurationSub_Type); // NO __new__() - //ADDTYPE(Module,"ConfigurationPtr",&PyConfigurationPtr_Type); // NO __new__() /* ========================= depcache.cc ========================= */ ADDTYPE(Module,"ActionGroup",&PyActionGroup_Type); ADDTYPE(Module,"DepCache",&PyDepCache_Type); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 7b835ca8..f77c5e73 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -14,12 +14,8 @@ #include // Configuration Stuff -#define Configuration_Check(op) ((op)->ob_type == &PyConfiguration_Type || \ - (op)->ob_type == &PyConfigurationPtr_Type || \ - (op)->ob_type == &PyConfigurationSub_Type) +#define Configuration_Check(op) ((op)->ob_type == &PyConfiguration_Type) extern PyTypeObject PyConfiguration_Type; -extern PyTypeObject PyConfigurationPtr_Type; -extern PyTypeObject PyConfigurationSub_Type; extern PyTypeObject PyVersion_Type; extern char *doc_LoadConfig; diff --git a/python/configuration.cc b/python/configuration.cc index ba075133..e7e31cc8 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -5,11 +5,8 @@ Configuration - Binding for the configuration object. - There are three seperate classes.. - Configuration - A stand alone configuration instance - ConfigurationPtr - A pointer to a configuration instance, used only - for the global instance (_config) - ConfigurationSub - A subtree - has a reference to its owner. + The Configuration object can have an owner (a parent Configuration object), + and it always uses a pointer. The wrapping is mostly 1:1 with the C++ code, but there are additions to wrap the linked tree walking into nice flat sequence walking. @@ -25,33 +22,13 @@ #include /*}}}*/ -/* If we create a sub tree then it is of this type, the Owner is used - to manage reference counting. */ -struct SubConfiguration : public CppPyObject -{ - PyObject *Owner; -}; - - /*}}}*/ -// CnfSubFree - Free a sub configuration /*{{{*/ -// --------------------------------------------------------------------- -/* */ -void CnfSubFree(PyObject *Obj) -{ - SubConfiguration *Self = (SubConfiguration *)Obj; - Py_DECREF(Self->Owner); - CppDealloc(Obj); -} - /*}}}*/ // GetSelf - Convert PyObject to Configuration /*{{{*/ // --------------------------------------------------------------------- /* */ static inline Configuration &GetSelf(PyObject *Obj) { - if (Obj->ob_type == &PyConfigurationPtr_Type) - return *GetCpp(Obj); - return GetCpp(Obj); + return *GetCpp(Obj); } /*}}}*/ @@ -160,13 +137,8 @@ static PyObject *CnfSubTree(PyObject *Self,PyObject *Args) return 0; } - // Create a new sub configuration. - SubConfiguration *New = (SubConfiguration*)(&PyConfigurationSub_Type) - ->tp_alloc(&PyConfigurationSub_Type,0); - new (&New->Object) Configuration(Itm); - New->Owner = Self; - Py_INCREF(Self); - return New; + return CppOwnedPyObject_NEW(Self,&PyConfiguration_Type, + new Configuration(Itm)); } // Return a list of items at a specific level @@ -495,7 +467,7 @@ static PyObject *CnfNew(PyTypeObject *type, PyObject *args, PyObject *kwds) { char *kwlist[] = {NULL}; if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) return 0; - return CppPyObject_NEW(type); + return CppOwnedPyObject_NEW(NULL, type, new Configuration()); } // Type for a Normal Configuration object @@ -505,10 +477,10 @@ PyTypeObject PyConfiguration_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Configuration", // tp_name - sizeof(CppPyObject), // tp_basicsize + sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppDealloc, // tp_dealloc + CppOwnedDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -545,75 +517,3 @@ PyTypeObject PyConfiguration_Type = CnfNew, // tp_new }; -PyTypeObject PyConfigurationPtr_Type = -{ - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "apt_pkg.ConfigurationPtr", // tp_name - sizeof(CppPyObject), // tp_basicsize - 0, // tp_itemsize - // Methods - (destructor)PyObject_Free, // tp_dealloc - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare - 0, // tp_repr - 0, // tp_as_number - &ConfigurationSeq, // tp_as_sequence - &ConfigurationMap, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str - 0, // tp_getattro - 0, // tp_setattro - 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags - "ConfigurationPtr Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare - 0, // tp_weaklistoffset - 0, // tp_iter - 0, // tp_iternext - CnfMethods, // tp_methods - 0, // tp_members - 0, // tp_getset - &PyConfiguration_Type, // tp_base -}; - -PyTypeObject PyConfigurationSub_Type = -{ - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "apt_pkg.ConfigurationSub", // tp_name - sizeof(SubConfiguration), // tp_basicsize - 0, // tp_itemsize - // Methods - CnfSubFree, // tp_dealloc - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare - 0, // tp_repr - 0, // tp_as_number - &ConfigurationSeq, // tp_as_sequence - &ConfigurationMap, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str - 0, // tp_getattro - 0, // tp_setattro - 0, // tp_as_buffer - Py_TPFLAGS_DEFAULT, // tp_flags - "ConfigurationSub Object", // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare - 0, // tp_weaklistoffset - 0, // tp_iter - 0, // tp_iternext - CnfMethods, // tp_methods - 0, // tp_members - 0, // tp_getset - &PyConfiguration_Type, // tp_base -}; - -- cgit v1.2.3 From 360477dcc304b8a18c467e59435d8c766bbb76bb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 14:14:44 +0200 Subject: python/python-apt.h: Introduce the C++ API The C++ API provides support for creating Python objects from C++ objects given by pointer or reference (depending on the implementation of the Python object) and for retrieving the underlying C++ object from the Python object and for checking the type of the Python object. --- debian/changelog | 1 + debian/control | 11 ++ debian/python-apt-dev.examples | 1 + debian/python-apt-dev.install | 2 + doc/client-example.cc | 46 ++++++++ python/apt_pkgmodule.cc | 38 ++++++ python/apt_pkgmodule.h | 4 +- python/hashstring.cc | 5 - python/python-apt.h | 259 +++++++++++++++++++++++++++++++++++++++++ 9 files changed, 360 insertions(+), 7 deletions(-) create mode 100644 debian/python-apt-dev.examples create mode 100644 debian/python-apt-dev.install create mode 100644 doc/client-example.cc create mode 100644 python/python-apt.h (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 4ae6e574..415ebdd2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low [ Julian Andres Klode ] * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) * Add apt_pkg.Policy class (Closes: #382725) + * Provide a C++ API in the package python-apt-dev (Closes: #334923) * Allow types providing __new__() to be subclassed. * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) * apt/package.py: Return VersionList objects in Package.versions, which diff --git a/debian/control b/debian/control index 10b9bc31..a16ae10e 100644 --- a/debian/control +++ b/debian/control @@ -54,3 +54,14 @@ Description: Python interface to libapt-pkg (debug extension) variety of functions. . This package contains the extension built for the Python debug interpreter. + +Package: python-apt-dev +Architecture: all +Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10) +Description: Python interface to libapt-pkg (development files) + The apt_pkg Python interface will provide full access to the internal + libapt-pkg structures allowing Python programs to easily perform a + variety of functions. + . + This package contains the header files needed to use python-apt objects from + C++ applications. diff --git a/debian/python-apt-dev.examples b/debian/python-apt-dev.examples new file mode 100644 index 00000000..39f7bf97 --- /dev/null +++ b/debian/python-apt-dev.examples @@ -0,0 +1 @@ +doc/client-example.cc diff --git a/debian/python-apt-dev.install b/debian/python-apt-dev.install new file mode 100644 index 00000000..2a1405fd --- /dev/null +++ b/debian/python-apt-dev.install @@ -0,0 +1,2 @@ +python/python-apt.h usr/include/python-apt/ +python/generic.h usr/include/python-apt/ diff --git a/doc/client-example.cc b/doc/client-example.cc new file mode 100644 index 00000000..7fa6672f --- /dev/null +++ b/doc/client-example.cc @@ -0,0 +1,46 @@ +/* + * client-example.cc - A simple example for using the python-apt C++ API. + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ +#include + +int main(int argc, char *argv[]) { + Py_Initialize(); + if (import_apt_pkg() < 0) + return 1; + + // Initialize a module. + PyObject *Module = Py_InitModule("client", NULL); + + // Create a HashString, which will be added to the module. + HashString *hash = new HashString("0966a120bb936bdc6fdeac445707aa6b"); + // Create a Python object for the hashstring and add it to the module + PyModule_AddObject(Module, "hash", PyHashString_FromCpp(hash)); + + // Another example: Add the HashString type to the module. + Py_INCREF(&PyHashString_Type); + PyModule_AddObject(Module, "HashString", (PyObject*)(&PyHashString_Type)); + + // Run IPython, adding the client module to the namespace. + PySys_SetArgv(argc, argv); + PyRun_SimpleString("from IPython.Shell import start\n"); + PyRun_SimpleString("import client\n"); + PyRun_SimpleString("start(user_ns=dict(client=client)).mainloop()\n"); + Py_Finalize(); +} diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e4fd0dfc..bc2f4258 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -498,6 +498,38 @@ static PyMethodDef methods[] = {} }; +static struct _PyAptPkgAPIStruct API = { + &PyAcquire_Type, // acquire_type + &PyAcquireFile_Type, // acquirefile_type + &PyAcquireItem_Type, // acquireitem_type + &PyActionGroup_Type, // actiongroup_type + &PyCache_Type, // cache_type + &PyCacheFile_Type, // cachefile_type + &PyCdrom_Type, // cdrom_type + &PyConfiguration_Type, // configuration_type + &PyDepCache_Type, // depcache_type + &PyDependency_Type, // dependency_type + &PyDependencyList_Type, // dependencylist_type + &PyDescription_Type, // description_type + &PyHashes_Type, // hashes_type + &PyHashString_Type, // hashstring_type + &PyIndexRecords_Type, // indexrecords_type + &PyMetaIndex_Type, // metaindex_type + &PyPackage_Type, // package_type + &PyPackageFile_Type, // packagefile_type + &PyPackageIndexFile_Type, // packageindexfile_type + &PyPackageList_Type, // packagelist_type + &PyPackageManager_Type, // packagemanager_type + &PyPackageRecords_Type, // packagerecords_type + &PyPolicy_Type, // policy_type + &PyProblemResolver_Type, // problemresolver_type + &PySourceList_Type, // sourcelist_type + &PySourceRecords_Type, // sourcerecords_type + &PyTagFile_Type, // tagfile_type + &PyTagSection_Type, // tagsection_type + &PyVersion_Type, // version_type +}; + #define ADDTYPE(mod,name,type) { \ if (PyType_Ready(type) == -1) INIT_ERROR; \ @@ -596,6 +628,12 @@ extern "C" void initapt_pkg() PyModule_AddObject(Module,"REWRITE_SOURCE_ORDER", CharCharToList(TFRewriteSourceOrder)); +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 + PyObject *PyCapsule = PyCapsule_New(&API, "apt_pkg._C_API", NULL); +#else + PyObject *PyCapsule = PyCObject_FromVoidPtr(&API, NULL); +#endif + PyModule_AddObject(Module, "_C_API", PyCapsule); // Version.. PyModule_AddStringConstant(Module,"VERSION",(char *)pkgVersion); PyModule_AddStringConstant(Module,"LIB_VERSION",(char *)pkgLibVersion); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index f77c5e73..97be5d5c 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -104,7 +104,6 @@ extern PyTypeObject PyPackageIndexFile_Type; extern PyTypeObject PyMetaIndex_Type; // HashString -PyObject *PyHashString_FromCpp(HashString *obj); extern PyTypeObject PyHashString_Type; // IndexRecord @@ -113,5 +112,6 @@ extern PyTypeObject PyIndexRecords_Type; // Policy extern PyTypeObject PyPolicy_Type; extern PyTypeObject PyHashes_Type; - +#include "python-apt.h" #endif + diff --git a/python/hashstring.cc b/python/hashstring.cc index d303049a..b76dc127 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -39,11 +39,6 @@ static PyObject *HashString_NEW(PyTypeObject *type,PyObject *Args, return PyObj; } -PyObject *PyHashString_FromCpp(HashString *obj) -{ - return CppPyObject_NEW(&PyHashString_Type, obj); -} - static PyObject *HashString_Repr(PyObject *self) { HashString *hash = GetCpp(self); diff --git a/python/python-apt.h b/python/python-apt.h new file mode 100644 index 00000000..557f5a3b --- /dev/null +++ b/python/python-apt.h @@ -0,0 +1,259 @@ +/* + * python-apt.h - Header file for the public interface. + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef PYTHON_APT_H +#define PYTHON_APT_H +#include +#include +#include "generic.h" + +struct _PyAptPkgAPIStruct { + PyTypeObject *acquire_type; + PyTypeObject *acquirefile_type; + PyTypeObject *acquireitem_type; + PyTypeObject *actiongroup_type; + PyTypeObject *cache_type; + PyTypeObject *cachefile_type; + PyTypeObject *cdrom_type; + PyTypeObject *configuration_type; + PyTypeObject *depcache_type; + PyTypeObject *dependency_type; + PyTypeObject *dependencylist_type; + PyTypeObject *description_type; + PyTypeObject *hashes_type; + PyTypeObject *hashstring_type; + PyTypeObject *indexrecords_type; + PyTypeObject *metaindex_type; + PyTypeObject *package_type; + PyTypeObject *packagefile_type; + PyTypeObject *packageindexfile_type; + PyTypeObject *packagelist_type; + PyTypeObject *packagemanager_type; + PyTypeObject *packagerecords_type; + PyTypeObject *policy_type; + PyTypeObject *problemresolver_type; + PyTypeObject *sourcelist_type; + PyTypeObject *sourcerecords_type; + PyTypeObject *tagfile_type; + PyTypeObject *tagsection_type; + PyTypeObject *version_type; +}; + +# ifndef APT_PKGMODULE_H +# define PyAcquire_Type *(_PyAptPkg_API->acquire_type) +# define PyAcquireFile_Type *(_PyAptPkg_API->acquirefile_type) +# define PyAcquireItem_Type *(_PyAptPkg_API->acquireitem_type) +# define PyActionGroup_Type *(_PyAptPkg_API->actiongroup_type) +# define PyCache_Type *(_PyAptPkg_API->cache_type) +# define PyCacheFile_Type *(_PyAptPkg_API->cachefile_type) +# define PyCdrom_Type *(_PyAptPkg_API->cdrom_type) +# define PyConfiguration_Type *(_PyAptPkg_API->configuration_type) +# define PyDepCache_Type *(_PyAptPkg_API->depcache_type) +# define PyDependency_Type *(_PyAptPkg_API->dependency_type) +# define PyDependencyList_Type *(_PyAptPkg_API->dependencylist_type) +# define PyDescription_Type *(_PyAptPkg_API->description_type) +# define PyHashes_Type *(_PyAptPkg_API->hashes_type) +# define PyHashString_Type *(_PyAptPkg_API->hashstring_type) +# define PyIndexRecords_Type *(_PyAptPkg_API->indexrecords_type) +# define PyMetaIndex_Type *(_PyAptPkg_API->metaindex_type) +# define PyPackage_Type *(_PyAptPkg_API->package_type) +# define PyPackageFile_Type *(_PyAptPkg_API->packagefile_type) +# define PyPackageIndexFile_Type *(_PyAptPkg_API->packageindexfile_type) +# define PyPackageList_Type *(_PyAptPkg_API->packagelist_type) +# define PyPackageManager_Type *(_PyAptPkg_API->packagemanager_type) +# define PyPackageRecords_Type *(_PyAptPkg_API->packagerecords_type) +# define PyPolicy_Type *(_PyAptPkg_API->policy_type) +# define PyProblemResolver_Type *(_PyAptPkg_API->problemresolver_type) +# define PySourceList_Type *(_PyAptPkg_API->sourcelist_type) +# define PySourceRecords_Type *(_PyAptPkg_API->sourcerecords_type) +# define PyTagFile_Type *(_PyAptPkg_API->tagfile_type) +# define PyTagSection_Type *(_PyAptPkg_API->tagsection_type) +# define PyVersion_Type *(_PyAptPkg_API->version_type) + +// Creating + +static struct _PyAptPkgAPIStruct *_PyAptPkg_API; + +static int import_apt_pkg(void) { +# if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 + _PyAptPkg_API = (_PyAptPkgAPIStruct *)PyCapsule_Import("apt_pkg._C_API", 0); + return (_PyAptPkg_API != NULL) ? 0 : -1; +# else + + PyObject *module = PyImport_ImportModule("apt_pkg"); + + if (module == NULL) { + return -1; + } + if (module != NULL) { + PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API"); + if (c_api_object == NULL) + return -1; + if (PyCObject_Check(c_api_object)) + _PyAptPkg_API = (struct _PyAptPkgAPIStruct *)PyCObject_AsVoidPtr(c_api_object); + Py_DECREF(c_api_object); + } + return 0; +# endif // PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 +} +# endif // APT_PKGMODULE_H + +// Checking macros. +# define PyAcquire_Check(op) PyObject_TypeCheck(op, &PyAcquire_Type) +# define PyAcquireFile_Check(op) PyObject_TypeCheck(op, &PyAcquireFile_Type) +# define PyAcquireItem_Check(op) PyObject_TypeCheck(op, &PyAcquireItem_Type) +# define PyActionGroup_Check(op) PyObject_TypeCheck(op, &PyActionGroup_Type) +# define PyCache_Check(op) PyObject_TypeCheck(op, &PyCache_Type) +# define PyCacheFile_Check(op) PyObject_TypeCheck(op, &PyCacheFile_Type) +# define PyCdrom_Check(op) PyObject_TypeCheck(op, &PyCdrom_Type) +# define PyConfiguration_Check(op) PyObject_TypeCheck(op, &PyConfiguration_Type) +# define PyDepCache_Check(op) PyObject_TypeCheck(op, &PyDepCache_Type) +# define PyDependency_Check(op) PyObject_TypeCheck(op, &PyDependency_Type) +# define PyDependencyList_Check(op) PyObject_TypeCheck(op, &PyDependencyList_Type) +# define PyDescription_Check(op) PyObject_TypeCheck(op, &PyDescription_Type) +# define PyHashes_Check(op) PyObject_TypeCheck(op, &PyHashes_Type) +# define PyHashString_Check(op) PyObject_TypeCheck(op, &PyHashString_Type) +# define PyIndexRecords_Check(op) PyObject_TypeCheck(op, &PyIndexRecords_Type) +# define PyMetaIndex_Check(op) PyObject_TypeCheck(op, &PyMetaIndex_Type) +# define PyPackage_Check(op) PyObject_TypeCheck(op, &PyPackage_Type) +# define PyPackageFile_Check(op) PyObject_TypeCheck(op, &PyPackageFile_Type) +# define PyPackageIndexFile_Check(op) PyObject_TypeCheck(op, &PyPackageIndexFile_Type) +# define PyPackageList_Check(op) PyObject_TypeCheck(op, &PyPackageList_Type) +# define PyPackageManager_Check(op) PyObject_TypeCheck(op, &PyPackageManager_Type) +# define PyPackageRecords_Check(op) PyObject_TypeCheck(op, &PyPackageRecords_Type) +# define PyPolicy_Check(op) PyObject_TypeCheck(op, &PyPolicy_Type) +# define PyProblemResolver_Check(op) PyObject_TypeCheck(op, &PyProblemResolver_Type) +# define PySourceList_Check(op) PyObject_TypeCheck(op, &PySourceList_Type) +# define PySourceRecords_Check(op) PyObject_TypeCheck(op, &PySourceRecords_Type) +# define PyTagFile_Check(op) PyObject_TypeCheck(op, &PyTagFile_Type) +# define PyTagSection_Check(op) PyObject_TypeCheck(op, &PyTagSection_Type) +# define PyVersion_Check(op) PyObject_TypeCheck(op, &PyVersion_Type) +// Exact check macros. +# define PyAcquire_CheckExact(op) (Py_TYPE(op) == &PyAcquire_Type) +# define PyAcquireFile_CheckExact(op) (Py_TYPE(op) == &PyAcquireFile_Type) +# define PyAcquireItem_CheckExact(op) (Py_TYPE(op) == &PyAcquireItem_Type) +# define PyActionGroup_CheckExact(op) (Py_TYPE(op) == &PyActionGroup_Type) +# define PyCache_CheckExact(op) (Py_TYPE(op) == &PyCache_Type) +# define PyCacheFile_CheckExact(op) (Py_TYPE(op) == &PyCacheFile_Type) +# define PyCdrom_CheckExact(op) (Py_TYPE(op) == &PyCdrom_Type) +# define PyConfiguration_CheckExact(op) (Py_TYPE(op) == &PyConfiguration_Type) +# define PyDepCache_CheckExact(op) (Py_TYPE(op) == &PyDepCache_Type) +# define PyDependency_CheckExact(op) (Py_TYPE(op) == &PyDependency_Type) +# define PyDependencyList_CheckExact(op) (Py_TYPE(op) == &PyDependencyList_Type) +# define PyDescription_CheckExact(op) (Py_TYPE(op) == &PyDescription_Type) +# define PyHashes_CheckExact(op) (Py_TYPE(op) == &PyHashes_Type) +# define PyHashString_CheckExact(op) (Py_TYPE(op) == &PyHashString_Type) +# define PyIndexRecords_CheckExact(op) (Py_TYPE(op) == &PyIndexRecords_Type) +# define PyMetaIndex_CheckExact(op) (Py_TYPE(op) == &PyMetaIndex_Type) +# define PyPackage_CheckExact(op) (Py_TYPE(op) == &PyPackage_Type) +# define PyPackageFile_CheckExact(op) (Py_TYPE(op) == &PyPackageFile_Type) +# define PyPackageIndexFile_CheckExact(op) (Py_TYPE(op) == &PyPackageIndexFile_Type) +# define PyPackageList_CheckExact(op) (Py_TYPE(op) == &PyPackageList_Type) +# define PyPackageManager_CheckExact(op) (Py_TYPE(op) == &PyPackageManager_Type) +# define PyPackageRecords_CheckExact(op) (Py_TYPE(op) == &PyPackageRecords_Type) +# define PyPolicy_CheckExact(op) (Py_TYPE(op) == &PyPolicy_Type) +# define PyProblemResolver_CheckExact(op) (Py_TYPE(op) == &PyProblemResolver_Type) +# define PySourceList_CheckExact(op) (Py_TYPE(op) == &PySourceList_Type) +# define PySourceRecords_CheckExact(op) (Py_TYPE(op) == &PySourceRecords_Type) +# define PyTagFile_CheckExact(op) (Py_TYPE(op) == &PyTagFile_Type) +# define PyTagSection_CheckExact(op) (Py_TYPE(op) == &PyTagSection_Type) +# define PyVersion_CheckExact(op) (Py_TYPE(op) == &PyVersion_Type) + +// Get the underlying C++ reference or pointer from the Python object. +# define PyAcquire_ToCpp GetCpp +# define PyAcquireFile_ToCpp GetCpp +# define PyAcquireItem_ToCpp GetCpp +# define PyActionGroup_ToCpp GetCpp +# define PyCache_ToCpp GetCpp +# define PyCacheFile_ToCpp GetCpp +# define PyCdrom_ToCpp GetCpp +# define PyConfiguration_ToCpp GetCpp +# define PyDepCache_ToCpp GetCpp +# define PyDependency_ToCpp GetCpp +//# define PyDependencyList_ToCpp GetCpp // NOT EXPORTED +# define PyDescription_ToCpp GetCpp +# define PyHashes_ToCpp GetCpp +# define PyHashString_ToCpp GetCpp +# define PyIndexRecords_ToCpp GetCpp +# define PyMetaIndex_ToCpp GetCpp +# define PyPackage_ToCpp GetCpp +# define PyPackageFile_ToCpp GetCpp +# define PyPackageIndexFile_ToCpp GetCpp +//# define PyPackageList_ToCpp GetCpp // NOT EXPORTED. +# define PyPackageManager_ToCpp GetCpp +//# define PyPackageRecords_ToCpp GetCpp // NOT EXPORTED +# define PyPolicy_ToCpp GetCpp +# define PyProblemResolver_ToCpp GetCpp +# define PySourceList_ToCpp GetCpp +//# define PySourceRecords_ToCpp GetCpp // NOT EXPORTED +# define PyTagFile_ToCpp GetCpp +# define PyTagSection_ToCpp GetCpp +# define PyVersion_ToCpp GetCpp + +// Python object creation, using two inline template functions and one variadic +// macro per type. +template +inline PyObject *FromCpp(PyTypeObject *pytype, Cpp obj, bool Delete=false) +{ + CppPyObject *Obj = CppPyObject_NEW(pytype, obj); + Obj->NoDelete = (!Delete); + return Obj; +} + +template +inline PyObject *FromCppOwned(PyTypeObject *pytype, Cpp const &obj, + bool Delete=false, PyObject *Owner=NULL) +{ + CppOwnedPyObject *Obj = CppOwnedPyObject_NEW(Owner, pytype, obj); + Obj->NoDelete = (!Delete); + return Obj; +} + +# define PyAcquire_FromCpp(...) FromCpp(&PyAcquire_Type, ##__VA_ARGS__) +# define PyAcquireFile_FromCpp(...) FromCppOwned(&PyAcquireFile_Type, ##__VA_ARGS__) +# define PyAcquireItem_FromCpp(...) FromCppOwned(&PyAcquireItemType,##__VA_ARGS__) +# define PyActionGroup_FromCpp(...) FromCppOwned(&PyActionGroup_Type,##__VA_ARGS__) +# define PyCache_FromCpp(...) FromCppOwned(&PyCache_Type,##__VA_ARGS__) +# define PyCacheFile_FromCpp(...) FromCpp(&PyCacheFile_Type,##__VA_ARGS__) +# define PyCdrom_FromCpp(...) FromCpp(&PyCdromType,##__VA_ARGS__) +# define PyConfiguration_FromCpp(...) FromCppOwned(&PyConfiguration_Type, ##__VA_ARGS__) +# define PyDepCache_FromCpp(...) FromCppOwned(&PyDepCache_Type,##__VA_ARGS__) +# define PyDependency_FromCpp(...) FromCppOwned(&PyDependency_Type,##__VA_ARGS__) +//# define PyDependencyList_FromCpp(...) FromCppOwned(&PyDependencyList_Type,##__VA_ARGS__) +# define PyDescription_FromCpp(...) FromCppOwned(&PyDescription_Type,##__VA_ARGS__) +# define PyHashes_FromCpp(...) FromCpp(&PyHashes_Type,##__VA_ARGS__) +# define PyHashString_FromCpp(...) FromCpp(&PyHashString_Type,##__VA_ARGS__) +# define PyIndexRecords_FromCpp(...) FromCpp(&PyIndexRecords_Type,##__VA_ARGS__) +# define PyMetaIndex_FromCpp(...) FromCppOwned(&PyMetaIndex_Type,##__VA_ARGS__) +# define PyPackage_FromCpp(...) FromCppOwned(&PyPackage_Type,##__VA_ARGS__) +# define PyPackageIndexFile_FromCpp(...) FromCppOwned(&PyPackageIndexFile_Type,##__VA_ARGS__) +# define PyPackageFile_FromCpp(...) FromCppOwned(&PyPackageFile_Type,##__VA_ARGS__) +//# define PyPackageList_FromCpp(...) FromCppOwned(&PyPackageList_Type,##__VA_ARGS__) +# define PyPackageManager_FromCpp(...) FromCpp(&PyPackageManagerType,##__VA_ARGS__) +//# define PyPackageRecords_FromCpp(...) FromCppOwned(&PyPackageRecords_Type,##__VA_ARGS__) +# define PyPolicy_FromCpp(...) FromCppOwned(&PyPolicy_Type,##__VA_ARGS__) +# define PyProblemResolver_FromCpp(...) FromCppOwned(&PyProblemResolver_Type,##__VA_ARGS__) +# define PySourceList_FromCpp(...) FromCpp(&PySourceList_Type,##__VA_ARGS__) +//# define PySourceRecords_FromCpp(...) FromCpp(&PySourceRecords_Type,##__VA_ARGS__) +//# define PyTagFile_FromCpp(...) FromCppOwned(&PyTagFile_Type,##__VA_ARGS__) +# define PyTagSection_FromCpp(...) FromCppOwned(&PyTagSection_Type,##__VA_ARGS__) +# define PyVersion_FromCpp(...) FromCppOwned(&PyVersion_Type,##__VA_ARGS__) +#endif -- cgit v1.2.3 From acf567325e793ab37292c21e6b4c0713d92ee9a1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 14:32:40 +0200 Subject: Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to work around a bug in debhelper. --- debian/changelog | 2 ++ debian/compat | 2 +- debian/control | 2 +- debian/python-apt.install | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 415ebdd2..8c1b0e67 100644 --- a/debian/changelog +++ b/debian/changelog @@ -35,6 +35,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Make AcquireItem objects raise ValueError instead of segfaulting when the Acquire() object is shut down or the main object (e.g. AcquireFile) is deallocated. * Unify all Configuration,ConfigurationPtr,ConfigurationSub into one type. + * Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to + work around a bug in debhelper. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/debian/compat b/debian/compat index 7ed6ff82..7f8f011e 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -5 +7 diff --git a/debian/control b/debian/control index a16ae10e..78c55126 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.8.2 XS-Python-Version: all Build-Depends: apt-utils, cdbs, - debhelper (>= 5.0.37.1), + debhelper (>= 7), libapt-pkg-dev (>= 0.7.22~), python-all-dbg, python-all-dev, diff --git a/debian/python-apt.install b/debian/python-apt.install index 4910e8ed..efd54743 100644 --- a/debian/python-apt.install +++ b/debian/python-apt.install @@ -1,3 +1,3 @@ -debian/tmp/usr/lib/python* -debian/tmp/usr/share/locale -debian/tmp/usr/share/python-apt +usr/lib/python* +usr/share/locale +usr/share/python-apt -- cgit v1.2.3 From 270a8f2e01e6f961e7501f3cefb64d2bf8f70069 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 14:58:35 +0200 Subject: Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 --- debian/changelog | 3 ++- debian/control | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 8c1b0e67..70157470 100644 --- a/debian/changelog +++ b/debian/changelog @@ -37,6 +37,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Unify all Configuration,ConfigurationPtr,ConfigurationSub into one type. * Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to work around a bug in debhelper. + * Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -52,7 +53,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Tue, 14 Jul 2009 20:42:03 +0200 + -- Julian Andres Klode Wed, 15 Jul 2009 14:56:24 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/debian/control b/debian/control index 78c55126..897ef3de 100644 --- a/debian/control +++ b/debian/control @@ -9,8 +9,8 @@ Build-Depends: apt-utils, cdbs, debhelper (>= 7), libapt-pkg-dev (>= 0.7.22~), - python-all-dbg, - python-all-dev, + python-all-dbg (>= 2.5.4-3), + python-all-dev (>= 2.5.4-3), python3.1-dev, python3.1-dbg, python-central (>= 0.5), -- cgit v1.2.3 From 57ce95170dc181c26633036f7c2adfd1c83192bf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 15:21:38 +0200 Subject: debian/rules: Add --install-layout=deb, debian/control: XS-Python-Version >= 2.5 --- debian/control | 2 +- debian/rules | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/control b/debian/control index 897ef3de..9e0fe3ea 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.2 -XS-Python-Version: all +XS-Python-Version: >= 2.5 Build-Depends: apt-utils, cdbs, debhelper (>= 7), diff --git a/debian/rules b/debian/rules index 7a6ff690..f9b08384 100755 --- a/debian/rules +++ b/debian/rules @@ -17,10 +17,11 @@ PY3K_VERSIONS := $(shell find /usr/bin/python3.? | sed s/.*python//) PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv +DEB_PYTHON_INSTALL_ARGS_ALL=--no-compile --install-layout=deb DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) # Define COMPAT_0_7 to get all the deprecated interfaces. -export CFLAGS+=-DCOMPAT_0_7 +export CFLAGS+=-DCOMPAT_0_7 -Wno-write-strings export DEBVER build/python-apt:: -- cgit v1.2.3 From 7581c5fb8a8d8e1e0a79c343cbd23725475f846c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 17:02:34 +0200 Subject: Simplify the whole building, build all Python versions with setup.py --- debian/changelog | 1 + debian/control | 4 +-- debian/python-apt.doc-base | 3 -- debian/python-apt.docs | 3 +- debian/rules | 35 +++------------------ po/python-apt.pot | 2 +- python/makefile | 27 ---------------- setup.py | 73 ++++++++++++++++++++----------------------- setup3.py | 77 ---------------------------------------------- 9 files changed, 43 insertions(+), 182 deletions(-) delete mode 100644 python/makefile mode change 100755 => 100644 setup.py delete mode 100644 setup3.py (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 70157470..5e3ec667 100644 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Upgrade to debhelper 7 and remove debian/tmp in python-apt.install, to work around a bug in debhelper. * Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 + * Simplify the whole building, build all Python versions with setup.py [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/debian/control b/debian/control index 9e0fe3ea..36a4d8d8 100644 --- a/debian/control +++ b/debian/control @@ -8,13 +8,13 @@ XS-Python-Version: >= 2.5 Build-Depends: apt-utils, cdbs, debhelper (>= 7), - libapt-pkg-dev (>= 0.7.22~), + libapt-pkg-dev (>= 0.7.12~), python-all-dbg (>= 2.5.4-3), python-all-dev (>= 2.5.4-3), python3.1-dev, python3.1-dbg, python-central (>= 0.5), - python-distutils-extra (>= 1.9.0), + python-distutils-extra (>= 2.0), python-gtk2, python-sphinx (>= 0.5), python-vte diff --git a/debian/python-apt.doc-base b/debian/python-apt.doc-base index d25926b7..e9b2040c 100644 --- a/debian/python-apt.doc-base +++ b/debian/python-apt.doc-base @@ -6,6 +6,3 @@ Section: Programming/Python Format: HTML Index: /usr/share/doc/python-apt/html/index.html Files: /usr/share/doc/python-apt/html/* - -Format: Text -Files: /usr/share/doc/python-apt/text/* diff --git a/debian/python-apt.docs b/debian/python-apt.docs index 6ba083f5..29219341 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -1,5 +1,4 @@ README apt/README.apt data/templates/README.templates -build/doc/html/ -build/doc/text/ +build/sphinx/html/ diff --git a/debian/rules b/debian/rules index f9b08384..967da911 100755 --- a/debian/rules +++ b/debian/rules @@ -11,56 +11,29 @@ DEB_PYTHON_PACKAGES_EXCLUDE=python-apt-dbg include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/python-distutils.mk -PY3K_VERSIONS := $(shell find /usr/bin/python3.? | sed s/.*python//) -2TO3_VERSION := $(lastword $(PY3K_VERSIONS)) +# Add python3 versions to the list of python versions +cdbs_python_build_versions += $(shell find /usr/bin/python3.? | sed s/.*python//) + -PKG=python-apt DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') DEB_COMPRESS_EXCLUDE:=.html .js _static/* _sources/* _sources/*/* .inv DEB_PYTHON_INSTALL_ARGS_ALL=--no-compile --install-layout=deb -DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) # Define COMPAT_0_7 to get all the deprecated interfaces. export CFLAGS+=-DCOMPAT_0_7 -Wno-write-strings export DEBVER -build/python-apt:: - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i setup3.py build; \ - done - -install/python-apt:: - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i ./setup3.py install --root $(CURDIR)/debian/python-apt \ - --install-layout=deb --no-compile; \ - done - -ifneq ($(PY3K_VERSIONS),) - find $(CURDIR)/debian/python-apt/usr/lib/python3*/dist-packages/ -name '*.py' \ - | xargs 2to3-$(2TO3_VERSION)| patch -p0 -endif - build/python-apt-dbg:: set -e; \ for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py build; \ done - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i-dbg setup3.py build; \ - done - install/python-apt-dbg:: for i in $(cdbs_python_build_versions); do \ python$$i-dbg ./setup.py install --root $(CURDIR)/debian/python-apt-dbg \ - --no-compile; \ + $(DEB_PYTHON_INSTALL_ARGS_ALL); \ done - - set -e; for i in $(PY3K_VERSIONS); do \ - python$$i-dbg ./setup3.py install --root $(CURDIR)/debian/python-apt-dbg \ - --install-layout=deb --no-compile; \ - done - find debian/python-apt-dbg \ ! -type d ! -name '*_d.so' | xargs rm -f find debian/python-apt-dbg -depth -empty -exec rmdir {} \; diff --git a/po/python-apt.pot b/po/python-apt.pot index 3f4fbb6b..3becb5e1 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-15 15:17+0200\n" +"POT-Creation-Date: 2009-07-15 16:51+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/makefile b/python/makefile deleted file mode 100644 index fff3a2e8..00000000 --- a/python/makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -*- make -*- -BASE=.. -SUBDIR=python - -# Bring in the default rules -include ../buildlib/defaults.mak - -# The apt_pkg module -MODULE=apt_pkg -SLIBS = -lapt-pkg -LIB_MAKES = apt-pkg/makefile -APT_PKG_SRC = apt_pkgmodule.cc configuration.cc generic.cc tag.cc string.cc \ - cache.cc pkgrecords.cc pkgsrcrecords.cc sourcelist.cc \ - depcache.cc progress.cc cdrom.cc acquire.cc pkgmanager.cc \ - indexfile.cc metaindex.cc hashstring.cc indexrecords.cc \ - policy.cc hashes.cc -SOURCE := $(APT_PKG_SRC) -include $(PYTHON_H) progress.h - -# The apt_int module.. -MODULE=apt_inst -SLIBS = -lapt-inst -lapt-pkg -LIB_MAKES = apt-inst/makefile -APT_INST_SRC = apt_instmodule.cc tar.cc generic.cc -SOURCE := $(APT_INST_SRC) -include $(PYTHON_H) - diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index 85f4c889..77853a4e --- a/setup.py +++ b/setup.py @@ -1,50 +1,59 @@ -#! /usr/bin/env python +#!/usr/bin/python +# Builds on python2.X and python3 # $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ import glob import os -import shutil import sys from distutils.core import setup, Extension -from distutils.sysconfig import parse_makefile -from DistUtilsExtra.command import build_extra, build_i18n +cmdclass = {} +try: + from DistUtilsExtra.command import build_extra, build_i18n + from DistUtilsExtra.auto import clean_build_tree + cmdclass['build'] = build_extra.build_extra + cmdclass['build_i18n'] = build_i18n.build_i18n + cmdclass['clean'] = clean_build_tree + build_extra.build_extra.sub_commands.append(("build_sphinx", + lambda x: 'build_sphinx' in cmdclass)) +except ImportError: + print('W: [python%s] DistUtilsExtra import error.' % sys.version[:3]) -# The apt_pkg module -files = map(lambda source: "python/"+source, - sorted(parse_makefile("python/makefile")["APT_PKG_SRC"].split())) +try: + from sphinx.setup_command import BuildDoc + cmdclass['build_sphinx'] = BuildDoc +except ImportError: + print('W: [python%s] Sphinx import error.' % sys.version[:3]) + +if sys.version_info[0] == 3: + from distutils.command.build_py import build_py_2to3 + cmdclass['build_py'] = build_py_2to3 + +# The apt_pkg module. +files = ['apt_pkgmodule.cc', 'acquire.cc', 'cache.cc', 'cdrom.cc', + 'configuration.c', 'depcache.cc', 'generic.cc', 'hashes.cc', + 'hashstring.cc', 'indexfile.cc', 'indexrecords.cc', 'metaindex.cc', + 'pkgmanager.cc', 'pkgrecords.cc', 'pkgsrcrecords.cc', 'policy.cc', + 'progress.cc', 'sourcelist.cc', 'string.cc', 'tag.cc'] +files = ['python/' + fname for fname in files] apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module -files = map(lambda source: "python/"+source, - sorted(parse_makefile("python/makefile")["APT_INST_SRC"].split())) +files = ["python/apt_instmodule.cc", "python/generic.cc", "python/tar.cc"] apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) # Replace the leading _ that is used in the templates for translation -templates = [] - -# build doc if len(sys.argv) > 1 and sys.argv[1] == "build": if not os.path.exists("build/data/templates/"): os.makedirs("build/data/templates") for template in glob.glob('data/templates/*.info.in'): source = open(template, "r") - build = open(os.path.join("build", template[:-3]), "w") - lines = source.readlines() - for line in lines: + build = open("build/" + template[:-3], "w") + for line in source: build.write(line.lstrip("_")) source.close() build.close() - -if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: - for dirname in "build/doc", "doc/build", "build/data", "build/mo": - if os.path.exists(dirname): - print "Removing", dirname - shutil.rmtree(dirname) - else: - print "Not removing", dirname, "because it does not exist" - setup(name="python-apt", description="Python bindings for APT", version=os.environ.get('DEBVER'), @@ -56,20 +65,6 @@ setup(name="python-apt", glob.glob('build/data/templates/*.info')), ('share/python-apt/templates', glob.glob('data/templates/*.mirrors'))], - cmdclass = {"build": build_extra.build_extra, - "build_i18n": build_i18n.build_i18n}, + cmdclass = cmdclass, license = 'GNU GPL', platforms = 'posix') - -if len(sys.argv) > 1 and sys.argv[1] == "build": - import sphinx - try: - import pygtk - except ImportError: - print >> sys.stderr, ('W: Not building documentation because python-' - 'gtk2 is not available at the moment.') - sys.exit(0) - sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/html"]) - sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/text"]) diff --git a/setup3.py b/setup3.py deleted file mode 100644 index a3cbdc8e..00000000 --- a/setup3.py +++ /dev/null @@ -1,77 +0,0 @@ -#! /usr/bin/env python3 -# $Id: setup.py,v 1.2 2002/01/08 07:13:21 jgg Exp $ -import glob -import os -import shutil -import sys - -from distutils.core import setup, Extension -from distutils.sysconfig import parse_makefile -#from DistUtilsExtra.command import build_extra, build_i18n - - -# The apt_pkg module -files = ["python/"+source for source in parse_makefile("python/makefile")["APT_PKG_SRC"].split()] -apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) - -# The apt_inst module -files = ["python/"+source for source in parse_makefile("python/makefile")["APT_INST_SRC"].split()] -apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"]) - -# Replace the leading _ that is used in the templates for translation -templates = [] - -# build doc -if len(sys.argv) > 1 and sys.argv[1] == "build": - if not os.path.exists("build/data/templates/"): - os.makedirs("build/data/templates") - for template in glob.glob('data/templates/*.info.in'): - source = open(template, "r") - build = open(os.path.join("build", template[:-3]), "w") - lines = source.readlines() - for line in lines: - build.write(line.lstrip("_")) - source.close() - build.close() - - -if len(sys.argv) > 1 and sys.argv[1] == "clean" and '-a' in sys.argv: - for dirname in "build/doc", "doc/build", "build/data", "build/mo": - if os.path.exists(dirname): - print("Removing", dirname) - shutil.rmtree(dirname) - else: - print("Not removing", dirname, "because it does not exist") - -setup(name="python-apt", - description="Python bindings for APT", - version=os.environ.get('DEBVER'), - author="APT Development Team", - author_email="deity@lists.debian.org", - ext_modules=[apt_pkg, apt_inst], - packages=['apt', 'apt.progress', 'aptsources'], - data_files = [('share/python-apt/templates', - glob.glob('build/data/templates/*.info')), - ('share/python-apt/templates', - glob.glob('data/templates/*.mirrors'))], -# cmdclass = {"build": build_extra.build_extra, -# "build_i18n": build_i18n.build_i18n}, - license = 'GNU GPL', - platforms = 'posix') - -if len(sys.argv) > 1 and sys.argv[1] == "build": - try: - import sphinx - except ImportError: - print(('W: Sphinx not available - Not building' - 'documentation'), file=sys.stderr) - try: - import pygtk - except ImportError: - print(('W: Not building documentation because python-' - 'gtk2 is not available at the moment.'), file=sys.stderr) - sys.exit(0) - sphinx.main(["sphinx", "-b", "html", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/html"]) - sphinx.main(["sphinx", "-b", "text", "-d", "build/doc/doctrees", - os.path.abspath("doc/source"), "build/doc/text"]) -- cgit v1.2.3 From aaf5907863bed9a044fa0e3e2eacd1ca2de53c59 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 15 Jul 2009 21:36:58 +0200 Subject: Introduce new progress (base) classes in apt_pkg: - apt_pkg.AcquireProgress - apt_pkg.OpProgress --- debian/changelog | 3 + python/acquireprogress.cc | 198 ++++++++++++++++++++++++++++++++++++++++++++++ python/apt_pkgmodule.cc | 2 + python/apt_pkgmodule.h | 2 + python/opprogress.cc | 173 ++++++++++++++++++++++++++++++++++++++++ python/progress.cc | 14 +++- setup.py | 5 +- 7 files changed, 393 insertions(+), 4 deletions(-) create mode 100644 python/acquireprogress.cc create mode 100644 python/opprogress.cc (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 5e3ec667..b2936ba1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -39,6 +39,9 @@ python-apt (0.7.92) UNRELEASED; urgency=low work around a bug in debhelper. * Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 * Simplify the whole building, build all Python versions with setup.py + * Introduce new progress (base) classes in apt_pkg: + - apt_pkg.AcquireProgress + - apt_pkg.OpProgress [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message diff --git a/python/acquireprogress.cc b/python/acquireprogress.cc new file mode 100644 index 00000000..ac3b8fd9 --- /dev/null +++ b/python/acquireprogress.cc @@ -0,0 +1,198 @@ +/* acquireprogress.cc - Base class for FetchProgress classes. + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "generic.h" +#include +#include + +typedef struct { + PyObject_HEAD + double last_bytes; + double current_cps; + double current_bytes; + double total_bytes; + double fetched_bytes; + unsigned long elapsed_time; + unsigned long total_items; + unsigned long current_items; +} PyAcquireProgressObject; + + +// DUMMY IMPLEMENTATIONS. +static char *acquireprogress_media_change_doc = + "media_change(media: str, drive: str) -> bool\n\n" + "Invoked when the user should be prompted to change the inserted\n" + "removable media.\n\n" + "This method should not return until the user has confirmed to the user\n" + "interface that the media change is complete.\n\n" + ":param:media The name of the media type that should be changed.\n" + ":param:drive The identifying name of the drive whose media should be\n" + " changed.\n\n" + "Return True if the user confirms the media change, False if it is\n" + "cancelled."; +static PyObject *acquireprogress_media_change(PyObject *self, PyObject *args) +{ + Py_RETURN_FALSE; +} + +static char *acquireprogress_ims_hit_doc = "ims_hit(item: AcquireItemDesc)\n\n" + "Invoked when an item is confirmed to be up-to-date. For instance,\n" + "when an HTTP download is informed that the file on the server was\n" + "not modified."; +static PyObject *acquireprogress_ims_hit(PyObject *self, PyObject *arg) +{ + // TODO: Add type check. + Py_RETURN_NONE; +} + +static char *acquireprogress_fetch_doc = "fetch(item: AcquireItemDesc)\n\n" + "Invoked when some of an item's data is fetched."; +static PyObject *acquireprogress_fetch(PyObject *self, PyObject *args) +{ + // TODO: Add type check. + Py_RETURN_NONE; +} + +static char *acquireprogress_done_doc = "done(item: AcquireItemDesc)\n\n" + "Invoked when an item is successfully and completely fetched."; +static PyObject *acquireprogress_done(PyObject *self, PyObject *args) +{ + // TODO: Add type check. + Py_RETURN_NONE; +} + +static char *acquireprogress_fail_doc = "fail(item: AcquireItemDesc)\n\n" + "Invoked when the process of fetching an item encounters a fatal error."; +static PyObject *acquireprogress_fail(PyObject *self, PyObject *args) +{ + // TODO: Add type check. + Py_RETURN_NONE; +} + +static char *acquireprogress_pulse_doc = "pulse(owner: Acquire) -> bool\n\n" + "Periodically invoked while the Acquire process is underway.\n\n" + "Return False if the user asked to cancel the whole Acquire process."; +static PyObject *acquireprogress_pulse(PyObject *self, PyObject *args) +{ + // TODO: Add type check. + Py_RETURN_TRUE; +} + +static char *acquireprogress_start_doc = "start()\n\n" + "Invoked when the Acquire process starts running."; +static PyObject *acquireprogress_start(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} + +static char *acquireprogress_stop_doc = "stop()\n\n" + "Invoked when the Acquire process stops running."; +static PyObject *acquireprogress_stop(PyObject *self, PyObject *args) +{ + Py_RETURN_NONE; +} + +static PyMethodDef acquireprogress_methods[] = { + {"media_change", acquireprogress_media_change, METH_VARARGS, + acquireprogress_media_change_doc}, + {"ims_hit",acquireprogress_ims_hit,METH_VARARGS, + acquireprogress_ims_hit_doc}, + {"fetch",acquireprogress_fetch,METH_VARARGS,acquireprogress_fetch_doc}, + {"done",acquireprogress_done,METH_VARARGS,acquireprogress_done_doc}, + {"fail",acquireprogress_fail,METH_VARARGS,acquireprogress_fail_doc}, + {"pulse",acquireprogress_pulse,METH_VARARGS,acquireprogress_pulse_doc}, + {"start",acquireprogress_start,METH_NOARGS,acquireprogress_start_doc}, + {"stop",acquireprogress_stop,METH_NOARGS,acquireprogress_stop_doc}, + {NULL} +}; + +static PyMemberDef acquireprogress_members[] = { + {"last_bytes", T_DOUBLE, offsetof(PyAcquireProgressObject, last_bytes), 0, + "The number of bytes fetched as of the previous call to pulse(),\n" + "including local items."}, + {"current_cps", T_DOUBLE, offsetof(PyAcquireProgressObject, current_cps), 0, + "The current rate of download, in bytes per second."}, + {"current_bytes", T_DOUBLE, offsetof(PyAcquireProgressObject, current_bytes), + 0, "The number of bytes fetched."}, + {"total_bytes", T_DOUBLE, offsetof(PyAcquireProgressObject, total_bytes), 0, + "The total number of bytes that need to be fetched. This member is\n" + "inaccurate, as new items might be enqueued while the download is\n" + "in progress!"}, + {"fetched_bytes", T_DOUBLE,offsetof(PyAcquireProgressObject, fetched_bytes), + 0, "The total number of bytes accounted for by items that were\n" + "successfully fetched."}, + {"elapsed_time", T_ULONG, offsetof(PyAcquireProgressObject, elapsed_time),0, + "The amount of time that has elapsed since the download started."}, + {"total_items", T_ULONG, offsetof(PyAcquireProgressObject, total_items),0, + "The total number of items that need to be fetched. This member is\n" + "inaccurate, as new items might be enqueued while the download is\n" + "in progress!"}, + {"current_items", T_ULONG, offsetof(PyAcquireProgressObject, current_items), + 0, "The number of items that have been successfully downloaded."}, + {NULL} +}; + +static char *acquireprogress_doc = "AcquireProgress()\n\n" + "A monitor object for downloads controlled by the Acquire class. This is\n" + "an mostly abstract class. You should subclass it and implement the\n" + "methods to get something useful."; + +PyTypeObject PyAcquireProgress_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "apt_pkg.AcquireProgress", // tp_name + sizeof(PyAcquireProgressObject), // tp_basicsize + 0, // tp_itemsize + // Methods + 0, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE, + acquireprogress_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + acquireprogress_methods, // tp_methods + acquireprogress_members, // tp_members + 0, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + PyType_GenericNew, // tp_new +}; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index bc2f4258..4f948847 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -621,6 +621,8 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"HashString",&PyHashString_Type); ADDTYPE(Module,"Policy",&PyPolicy_Type); ADDTYPE(Module,"Hashes",&PyHashes_Type); + ADDTYPE(Module,"OpProgress",&PyOpProgress_Type); + ADDTYPE(Module,"AcquireProgress",&PyAcquireProgress_Type); // Tag file constants PyModule_AddObject(Module,"REWRITE_PACKAGE_ORDER", CharCharToList(TFRewritePackageOrder)); diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 97be5d5c..34bc2ae5 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -112,6 +112,8 @@ extern PyTypeObject PyIndexRecords_Type; // Policy extern PyTypeObject PyPolicy_Type; extern PyTypeObject PyHashes_Type; +extern PyTypeObject PyOpProgress_Type; +extern PyTypeObject PyAcquireProgress_Type; #include "python-apt.h" #endif diff --git a/python/opprogress.cc b/python/opprogress.cc new file mode 100644 index 00000000..450e290a --- /dev/null +++ b/python/opprogress.cc @@ -0,0 +1,173 @@ +/* op-progress.cc - Base class for OpProgress classes. + * + * Copyright 2009 Julian Andres Klode + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "generic.h" +#include +#include + +typedef struct { + PyObject_HEAD + PyObject *op; + PyObject *subop; + int major_change; + float percent; +} PyOpProgressObject; + +static PyObject *opprogress_update(PyObject *Self, PyObject *args) +{ + Py_RETURN_NONE; +} + +static PyObject *opprogress_done(PyObject *Self, PyObject *args) +{ + Py_RETURN_NONE; +} + +static PyObject *opprogress_get_op(PyOpProgressObject *self, void *closure) +{ + return self->op; +} + +static int opprogress_set_op(PyOpProgressObject *self, PyObject *value, + void *closure) +{ + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, "Cannot delete 'op'"); + return -1; + } + if (!PyString_Check(value)) { + PyErr_SetString(PyExc_TypeError,"'op' must be a string."); + return -1; + } + Py_DECREF(self->op); + Py_INCREF(value); + + self->op = value; + return 0; +} + +static PyObject *opprogress_get_subop(PyOpProgressObject *self, void *closure) +{ + return self->subop; +} + +static int opprogress_set_subop(PyOpProgressObject *self, PyObject *value, + void *closure) +{ + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, "Cannot delete 'subop'."); + return -1; + } + if (!PyString_Check(value)) { + PyErr_SetString(PyExc_TypeError,"'subop' must be a string."); + return -1; + } + Py_DECREF(self->subop); + Py_INCREF(value); + self->subop = value; + return 0; +} + +static PyMethodDef opprogress_methods[] = { + {"update",opprogress_update,METH_NOARGS,"update()\n\nCalled periodically."}, + {"done",opprogress_done,METH_NOARGS,"update()\n\nCalled when done."}, + {NULL}, +}; + +static PyMemberDef opprogress_members[] = { + {"major_change", T_INT, offsetof(PyOpProgressObject, major_change), 0, + "Boolean value indicating whether the change is a major change."}, + {"percent", T_FLOAT, offsetof(PyOpProgressObject, percent), 0, + "Percentage of completion (float value)."}, + {NULL} +}; + +static PyGetSetDef opprogress_getset[] = { + {"op", (getter)opprogress_get_op, (setter)opprogress_set_op, + "Description of the current operation"}, + {"subop", (getter)opprogress_get_subop, (setter)opprogress_set_subop, + "Description of the current sub-operation"}, + {NULL}, +}; + +static void opprogress_dealloc(PyObject *self) +{ + Py_XDECREF(((PyOpProgressObject *)self)->op); + Py_XDECREF(((PyOpProgressObject *)self)->subop); + self->ob_type->tp_free(self); +} + +static PyObject *opprogress_new(PyTypeObject *type, PyObject *args, + PyObject *kwds) +{ + PyOpProgressObject *res = (PyOpProgressObject *)type->tp_alloc(type, 0); + res->op = PyString_FromString(""); + res->subop = PyString_FromString(""); + return (PyObject *)res; +} + +static char *opprogress_doc = "OpProgress()\n\n" + "A base class for writing custom operation progress classes. Subclasses\n" + "should override all the methods (and call the parent ones) but shall\n" + "not override any of the inherited descriptors because they may be\n" + "ignored."; + +PyTypeObject PyOpProgress_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "apt_pkg.OpProgress", // tp_name + sizeof(PyOpProgressObject), // tp_basicsize + 0, // tp_itemsize + // Methods + opprogress_dealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_BASETYPE, + opprogress_doc, // tp_doc + 0, // tp_traverse + 0, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + opprogress_methods, // tp_methods + opprogress_members, // tp_members + opprogress_getset, // tp_getset + 0, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + opprogress_new, // tp_new +}; diff --git a/python/progress.cc b/python/progress.cc index 44f27b0c..b1845f0a 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -15,6 +15,7 @@ #include #include "progress.h" #include "generic.h" +#include "apt_pkgmodule.h" // generic bool PyCallbackObj::RunSimpleCallback(const char* method_name, @@ -75,11 +76,20 @@ void PyOpProgress::Update() PyObject_SetAttrString(callbackInst, "majorChange", o); Py_XDECREF(o); + + // Build up the argument list... if(CheckChange(0.05)) { - PyObject *arglist = Py_BuildValue("(f)", Percent); - RunSimpleCallback("update", arglist); + if (PyObject_TypeCheck(callbackInst, &PyOpProgress_Type)) { + o = Py_BuildValue("f", Percent); + PyObject_SetAttrString(callbackInst, "percent", o); + RunSimpleCallback("update"); + Py_XDECREF(o); + } else { + PyObject *arglist = Py_BuildValue("(f)", Percent); + RunSimpleCallback("update", arglist); + } } }; diff --git a/setup.py b/setup.py index af373632..b6dde3f9 100644 --- a/setup.py +++ b/setup.py @@ -34,8 +34,9 @@ files = ['apt_pkgmodule.cc', 'acquire.cc', 'cache.cc', 'cdrom.cc', 'configuration.cc', 'depcache.cc', 'generic.cc', 'hashes.cc', 'hashstring.cc', 'indexfile.cc', 'indexrecords.cc', 'metaindex.cc', 'pkgmanager.cc', 'pkgrecords.cc', 'pkgsrcrecords.cc', 'policy.cc', - 'progress.cc', 'sourcelist.cc', 'string.cc', 'tag.cc'] -files = ['python/' + fname for fname in files] + 'progress.cc', 'sourcelist.cc', 'string.cc', 'tag.cc', + 'opprogress.cc', 'acquireprogress.cc'] +files = sorted(['python/' + fname for fname in files]) apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"]) # The apt_inst module -- cgit v1.2.3 From 4112520954a16ebbfdf7511670e68668e5a07173 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 30 Jul 2009 20:38:03 +0200 Subject: debian/control: Add 3.1 to XS-Python-Version. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/control b/debian/control index 7c3bfaac..9a8d16a2 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.2 -XS-Python-Version: >= 2.5 +XS-Python-Version: >= 2.5, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), -- cgit v1.2.3 From 7c19d9450b549180a6f0071f1d980dcf360c8921 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 30 Jul 2009 20:38:59 +0200 Subject: debian/rules: Add -DCOMPAT_0_7 to the CFLAGS again. --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/rules b/debian/rules index 6e2204cf..d5ebe29d 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,7 @@ #!/usr/bin/make -f export DH_PYCENTRAL=nomove export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') -export CFLAGS=-Wno-write-strings +export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 %: dh --with python-central $@ -- cgit v1.2.3 From ebe1f37a65cae8303bf86da13f3f2107cd73d1fe Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 30 Jul 2009 20:59:49 +0200 Subject: debian/control: Explicitly specify the versions to build for. --- debian/control | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/debian/control b/debian/control index 9a8d16a2..69bca37a 100644 --- a/debian/control +++ b/debian/control @@ -4,12 +4,14 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.2 -XS-Python-Version: >= 2.5, 3.1 +XS-Python-Version: 2.5, 2.6, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), - python-all-dbg (>= 2.5.4-3), - python-all-dev (>= 2.5.4-3), + python2.5-dbg, + python2.5-dev, + python2.6-dev, + python2.6-dbg, python3.1-dev, python3.1-dbg, python-central (>= 0.5), -- cgit v1.2.3 From 98e0bc92e8aad896fd9a56159f6a5ca002287f3b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 31 Jul 2009 21:00:04 +0200 Subject: debian/changelog: Rework latest changelog block to be more readable. --- debian/changelog | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index ce5c3b22..d07433fd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,17 +1,17 @@ python-apt (0.7.92) UNRELEASED; urgency=low - * Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141) - * Add apt_pkg.Policy class (Closes: #382725) - * Provide a C++ API in the package python-apt-dev (Closes: #334923) - * Allow types providing __new__() to be subclassed. - * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) - * Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to - mark a package as automatically installed. - * Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(), they cause segfaults - and memory leaks. Simply create a new cache instxead. - * Merge releases 0.7.10.4 - 0.7.12.0 from unstable - * Make AcquireFile a subclass of AcquireItem - * Make ConfigurationPtr,ConfigurationSub subclasses of Configuration. + * New features: + - Provide a C++ API in the package python-apt-dev (Closes: #334923). + - Add apt_pkg.HashString and apt_pkg.IndexRecords (Closes: #456141). + - Add apt_pkg.Policy class (Closes: #382725). + - Add apt_pkg.Hashes class. + - Allow types providing __new__() to be subclassed. + - Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to + mark a package as automatically installed. + - Make AcquireFile a subclass of AcquireItem, thus inheriting attributes. + - New progress handling in apt.progress.base and apt.progress.text. Still + missing Qt4 progress handlers. + * Unification of dependency handling: - apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb (i.e. < instead of <<) to match the interface of Version.depends_list_str @@ -20,15 +20,17 @@ python-apt (0.7.92) UNRELEASED; urgency=low + Closes: #468123 - there is no need anymore for binding CompType or CompTypeDeb, because we don't return integer values for CompType anymore. - * Introduce apt_pkg.Hashes class. - * Make AcquireItem objects raise ValueError instead of segfaulting when the Acquire() - object is shut down or the main object (e.g. AcquireFile) is deallocated. - * Unify all Configuration,ConfigurationPtr,ConfigurationSub into one type. - * Build-Depend on python-all-dev (>= 2.5.4-3), so we build for Python 2.6 - * Simplify the whole building, build all Python versions with setup.py - * Introduce new progress (base) classes in apt_pkg: - - apt_pkg.AcquireProgress - - apt_pkg.OpProgress + + * Bugfixes: + - Delete pointers correctly, fixing memory leaks (LP: #370149). + - Drop open() and close() in apt_pkg.Cache as they cause segfaults. + - Raise ValueError in AcquireItem if the Acquire process is shut down + instead of segfaulting. + + * Other stuff: + - Merge releases 0.7.10.4 - 0.7.12.0 from unstable. + - Merge Configuration,ConfigurationPtr,ConfigurationSub into one type. + - Simplify the whole build process by using a single setup.py. -- Julian Andres Klode Wed, 15 Jul 2009 14:56:24 +0200 -- cgit v1.2.3 From 992629cbd46b9cf830b8ab95e30f56bbcab4d724 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 31 Jul 2009 21:01:57 +0200 Subject: debian/changelog: Add note about documentation updates. --- debian/changelog | 1 + 1 file changed, 1 insertion(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index d07433fd..928493ad 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low - Merge releases 0.7.10.4 - 0.7.12.0 from unstable. - Merge Configuration,ConfigurationPtr,ConfigurationSub into one type. - Simplify the whole build process by using a single setup.py. + - The documentation has been restructured and enhanced with tutorials. -- Julian Andres Klode Wed, 15 Jul 2009 14:56:24 +0200 -- cgit v1.2.3 From 08674e660118758f32d220a26b4a525459317293 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 2 Aug 2009 18:23:28 +0200 Subject: Only recommend lsb-release instead of depending on it. Default to Debian unstable if lsb_release is not available. --- aptsources/distinfo.py | 13 +++++++++---- aptsources/distro.py | 25 +++++++++++++++++++------ debian/changelog | 4 +++- debian/control | 4 ++-- 4 files changed, 33 insertions(+), 13 deletions(-) (limited to 'debian') diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 2e5fd7bc..0614bd1c 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -21,9 +21,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import errno import os import gettext from os import getenv +from subprocess import Popen, PIPE import ConfigParser import re @@ -160,10 +162,13 @@ class DistInfo: #match_mirror_line = re.compile(r".+") if not dist: - pipe = os.popen("lsb_release -i -s") - dist = pipe.read().strip() - pipe.close() - del pipe + try: + dist = Popen(["lsb_release", "-i", "-s"], + stdout=PIPE).communicate()[0].strip() + except OSError, exc: + if exc.errno != errno.ENOENT: + print 'WARNING: lsb_release failed, using defaults:', exc + dist = "Debian" self.dist = dist diff --git a/aptsources/distro.py b/aptsources/distro.py index 5398d4a3..2cbad9fb 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -437,6 +437,20 @@ class UbuntuDistribution(Distribution): Distribution.get_mirrors( self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/") +def _lsb_release(): + """Call lsb_release --all and return a mapping.""" + from subprocess import Popen, PIPE + import errno + result = {'Codename': 'sid', 'Distributor ID': 'Debian', + 'Description': 'Debian GNU/Linux unstable (sid)', + 'Release': 'unstable'} + try: + out = Popen(['lsb_release', '--all'], stdout=PIPE).communicate()[0] + result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) + except OSError, exc: + if exc.errno != errno.ENOENT: + print 'WARNING: lsb_release failed, using defaults:', exc + return result def get_distro(id=None, codename=None, description=None, release=None): """ @@ -448,12 +462,11 @@ def get_distro(id=None, codename=None, description=None, release=None): """ # make testing easier if not (id and codename and description and release): - lsb_info = [] - for lsb_option in ["-i", "-c", "-d", "-r"]: - pipe = os.popen("lsb_release %s -s" % lsb_option) - lsb_info.append(pipe.read().strip()) - del pipe - (id, codename, description, release) = lsb_info + result = _lsb_release() + id = result['Distributor ID'] + codename = result['Codename'] + description = result['Description'] + release = result['Release'] if id == "Ubuntu": return UbuntuDistribution(id, codename, description, release) elif id == "Debian": diff --git a/debian/changelog b/debian/changelog index 928493ad..5f1f2967 100644 --- a/debian/changelog +++ b/debian/changelog @@ -32,8 +32,10 @@ python-apt (0.7.92) UNRELEASED; urgency=low - Merge Configuration,ConfigurationPtr,ConfigurationSub into one type. - Simplify the whole build process by using a single setup.py. - The documentation has been restructured and enhanced with tutorials. + - Only recommend lsb-release instead of depending on it. Default to + Debian unstable if lsb_release is not available. - -- Julian Andres Klode Wed, 15 Jul 2009 14:56:24 +0200 + -- Julian Andres Klode Sun, 02 Aug 2009 16:35:42 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/debian/control b/debian/control index 69bca37a..6b96a6be 100644 --- a/debian/control +++ b/debian/control @@ -24,8 +24,8 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, lsb-release -Recommends: iso-codes, libjs-jquery +Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} +Recommends: lsb-release, iso-codes, libjs-jquery Breaks: debdelta (<< 0.28~) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte -- cgit v1.2.3 From e643b71504412a6d70a10449845eecdd72529df0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 17 Aug 2009 16:21:41 +0200 Subject: python/arfile.cc: Introduce DebFile. This is the final commit which Closes: #536096, as everything doable with the functions can now be done using the classes. --- debian/changelog | 4 +- python/apt_instmodule.cc | 1 + python/apt_instmodule.h | 1 + python/arfile.cc | 171 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 176 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 1d735656..d644d7e6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low - Make AcquireFile a subclass of AcquireItem, thus inheriting attributes. - New progress handling in apt.progress.base and apt.progress.text. Still missing Qt4 progress handlers. + - Classes in apt_inst (Closes: #536096) * Unification of dependency handling: - apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb @@ -34,8 +35,9 @@ python-apt (0.7.92) UNRELEASED; urgency=low - The documentation has been restructured and enhanced with tutorials. - Only recommend lsb-release instead of depending on it. Default to Debian unstable if lsb_release is not available. + * - -- Julian Andres Klode Sun, 02 Aug 2009 16:35:42 +0200 + -- Julian Andres Klode Mon, 17 Aug 2009 16:19:51 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 3baaf985..9cb166ed 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -207,6 +207,7 @@ extern "C" void initapt_inst() ADDTYPE(module,"ArMember",&PyArMember_Type); ADDTYPE(module,"ArArchive",&PyArArchive_Type); + ADDTYPE(module,"DebFile",&PyDebFile_Type); ADDTYPE(module,"TarFile",&PyTarFile_Type); ADDTYPE(module,"TarMember",&PyTarMember_Type); RETURN(module); diff --git a/python/apt_instmodule.h b/python/apt_instmodule.h index 94ada0f8..9f978e44 100644 --- a/python/apt_instmodule.h +++ b/python/apt_instmodule.h @@ -22,6 +22,7 @@ extern char *doc_tarExtract; extern PyTypeObject PyArMember_Type; extern PyTypeObject PyArArchive_Type; +extern PyTypeObject PyDebFile_Type; extern PyTypeObject PyTarFile_Type; extern PyTypeObject PyTarMember_Type; diff --git a/python/arfile.cc b/python/arfile.cc index 5ac0f727..1abb738f 100644 --- a/python/arfile.cc +++ b/python/arfile.cc @@ -473,3 +473,174 @@ PyTypeObject PyArArchive_Type = { 0, // tp_alloc ararchive_new // tp_new }; + +/** + * Representation of a Debian package. + * + * This does not resemble debDebFile in apt-inst, but instead is a subclass + * of ArFile which adds properties for the control.tar.{lzma,bz2,gz} and + * data.tar.{lzma,bz2,gz} members which return TarFile objects. It also adds + * a descriptor 'version' which returns the content of 'debian-binary'. + * + * We are using it this way as it seems more natural to represent this special + * kind of AR archive as an AR archive with some extras. + */ +struct PyDebFileObject : PyArArchiveObject { + PyObject *data; + PyObject *control; + PyObject *debian_binary; +}; + +static PyObject *debfile_get_data(PyDebFileObject *self) +{ + return Py_INCREF(self->data), self->data; +} + +static PyObject *debfile_get_control(PyDebFileObject *self) +{ + return Py_INCREF(self->control), self->control; +} + +static PyObject *debfile_get_debian_binary(PyDebFileObject *self) +{ + return Py_INCREF(self->debian_binary), self->debian_binary; +} + +static PyObject *_gettar(PyDebFileObject *self, const ARArchive::Member *m, + const char *comp) +{ + if (!m) + return 0; + PyTarFileObject *tarfile = (PyTarFileObject*)CppOwnedPyObject_NEW(self,&PyTarFile_Type); + new (&tarfile->Fd) FileFd(self->Fd); + tarfile->min = m->Start; + tarfile->Object = new ExtractTar(self->Fd, m->Size, comp); + return tarfile; +} + + + +static PyObject *debfile_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyDebFileObject *self = (PyDebFileObject*)ararchive_new(type, args, kwds); + + // DebFile + self->control = _gettar(self, self->Object->FindMember("control.tar.gz"), + "gzip"); + if (!self->control) + return PyErr_Format(PyExc_SystemError, "No debian archive, missing %s", + "control.tar.gz"); + + self->data = _gettar(self, self->Object->FindMember("data.tar.gz"), + "gzip"); + if (!self->data) + self->data = _gettar(self, self->Object->FindMember("data.tar.bz2"), + "bzip2"); + if (!self->data) + self->data = _gettar(self, self->Object->FindMember("data.tar.lzma"), + "lzma"); + if (!self->data) + return PyErr_Format(PyExc_SystemError, "No debian archive, missing %s", + "data.tar.gz or data.tar.bz2 or data.tar.lzma"); + + + const ARArchive::Member *member = self->Object->FindMember("debian-binary"); + if (!member) + return PyErr_Format(PyExc_SystemError, "No debian archive, missing %s", + "debian-binary"); + + if (!self->Fd.Seek(member->Start)) + return HandleErrors(); + + char* value = new char[member->Size]; + self->Fd.Read(value, member->Size, true); + self->debian_binary = PyBytes_FromStringAndSize(value, member->Size); + delete[] value; + return self; +} + +static int debfile_traverse(PyObject *_self, visitproc visit, void* arg) +{ + PyDebFileObject *self = (PyDebFileObject*)_self; + Py_VISIT(self->data); + Py_VISIT(self->control); + Py_VISIT(self->debian_binary); + return PyArArchive_Type.tp_traverse(self, visit, arg); +} + +static int debfile_clear(PyObject *_self) { + PyDebFileObject *self = (PyDebFileObject*)_self; + Py_CLEAR(self->data); + Py_CLEAR(self->control); + Py_CLEAR(self->debian_binary); + return PyArArchive_Type.tp_clear(self); +} + +static void debfile_dealloc(PyObject *self) { + debfile_clear((PyDebFileObject *)self); + PyArArchive_Type.tp_dealloc(self); +} + +static PyGetSetDef debfile_getset[] = { + {"control",(getter)debfile_get_control,0, + "The TarFile object associated with the control.tar.gz member."}, + {"data",(getter)debfile_get_data,0, + "The TarFile object associated with the data.tar.{gz,bz2,lzma} member."}, + {"debian_binary",(getter)debfile_get_debian_binary,0, + "The package version, as contained in debian-binary."}, + {NULL} +}; + +static const char *debfile_doc = + "DebFile(file: str/int/file)\n\n" + "A DebFile object represents a file in the .deb package format.\n\n" + "The parameter 'file' may be a string specifying the path of a file, or\n" + "a file-like object providing the fileno() method. It may also be an int\n" + "specifying a file descriptor (returned by e.g. os.open()).\n" + "The recommended way is to pass in the path to the file.\n\n" + "It differs from ArArchive by providing the members 'control', 'data'\n" + "and 'version' for accessing the control.tar.gz,data.tar.{gz,bz2,lzma}\n" + ",debian-binary members in the archive."; + +PyTypeObject PyDebFile_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "apt_inst.DebFile", // tp_name + sizeof(PyDebFileObject), // tp_basicsize + 0, // tp_itemsize + // Methods + debfile_dealloc, // tp_dealloc + 0, // tp_print + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash + 0, // tp_call + 0, // tp_str + 0, // tp_getattro + 0, // tp_setattro + 0, // tp_as_buffer + Py_TPFLAGS_DEFAULT | // tp_flags + Py_TPFLAGS_HAVE_GC, + debfile_doc, // tp_doc + debfile_traverse, // tp_traverse + debfile_clear, // tp_clear + 0, // tp_richcompare + 0, // tp_weaklistoffset + 0, // tp_iter + 0, // tp_iternext + 0, // tp_methods + 0, // tp_members + debfile_getset, // tp_getset + &PyArArchive_Type, // tp_base + 0, // tp_dict + 0, // tp_descr_get + 0, // tp_descr_set + 0, // tp_dictoffset + 0, // tp_init + 0, // tp_alloc + debfile_new // tp_new +}; -- cgit v1.2.3 From f69208a3dc27357b19aad7879efca4300d56d8bb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 18 Aug 2009 13:40:51 +0200 Subject: debian/changelog: Classes in apt_inst now close LP: #44493. --- debian/changelog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index d644d7e6..d92ae907 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low - New progress handling in apt.progress.base and apt.progress.text. Still missing Qt4 progress handlers. - Classes in apt_inst (Closes: #536096) + + You can now use apt_inst.DebFile.data to access the data.tar.* member + regardless of its compression (LP: #44493) * Unification of dependency handling: - apt_pkg.parse_[src_]depends() now use CompType instead of CompTypeDeb @@ -37,7 +39,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low Debian unstable if lsb_release is not available. * - -- Julian Andres Klode Mon, 17 Aug 2009 16:19:51 +0200 + -- Julian Andres Klode Tue, 18 Aug 2009 13:38:55 +0200 python-apt (0.7.91) experimental; urgency=low -- cgit v1.2.3 From ade471a3a99d33ae848874dba94576f191d3c7ca Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 18 Aug 2009 15:33:16 +0200 Subject: debian/copyright: Update. --- debian/copyright | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/copyright b/debian/copyright index 8599328a..2df6807a 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,9 +1,17 @@ -Format-Specification: http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=443 +Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=59 Files: * Copyright: © 2004-2009 Canonical Ltd. + © 2009 Julian Andres Klode License: GPL-2+ +Files: tests/test_all.py, tests/test_hashes.py, utils/doclint.py +Copyright: © 2009 Julian Andres Klode +License: + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + Files: aptsources/*.py Copyright: © 2004-2009 Canonical Ltd. Copyright: © 2005 Gustavo Noronha Silva -- cgit v1.2.3 From e3c630140e6595126046866a40e11e90c74278f2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 18 Aug 2009 16:45:56 +0200 Subject: Set distribution to experimental --- debian/changelog | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index d92ae907..08035874 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.92) UNRELEASED; urgency=low +python-apt (0.7.92) experimental; urgency=low * New features: - Provide a C++ API in the package python-apt-dev (Closes: #334923). @@ -37,9 +37,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low - The documentation has been restructured and enhanced with tutorials. - Only recommend lsb-release instead of depending on it. Default to Debian unstable if lsb_release is not available. - * - -- Julian Andres Klode Tue, 18 Aug 2009 13:38:55 +0200 + -- Julian Andres Klode Tue, 18 Aug 2009 16:42:56 +0200 python-apt (0.7.91) experimental; urgency=low -- cgit v1.2.3 From 2ccb7545bb8c869f5f6192569a47a7522b6fbc83 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 25 Oct 2009 14:57:38 +0100 Subject: Add a tutorial on how to do things which are possible with apt-get, like apt-get --print-uris update (cf. #551164). --- debian/changelog | 4 ++- doc/source/examples/update-print-uris.py | 22 ++++++++++++++++ doc/source/tutorials/apt-get.rst | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 doc/source/examples/update-print-uris.py create mode 100644 doc/source/tutorials/apt-get.rst (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 7588d35a..fb3b72f9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ -python-apt (0.7.93) experimental; urgency=low +python-apt (0.7.93) UNRELEASED; urgency=low * Merge 0.7.13.0 - 0.7.13.3 from unstable. + * Add a tutorial on how to do things which are possible with apt-get, + like apt-get --print-uris update (cf. #551164). -- Julian Andres Klode Wed, 16 Sep 2009 19:26:17 +0200 diff --git a/doc/source/examples/update-print-uris.py b/doc/source/examples/update-print-uris.py new file mode 100644 index 00000000..f078cdc5 --- /dev/null +++ b/doc/source/examples/update-print-uris.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +"""Print out the URIs of all indexes files. + +This behaves somewhat like apt-get --print-uris update.""" +import apt_pkg + +def main(): + apt_pkg.init_config() + apt_pkg.init_system() + acquire = apt_pkg.Acquire() + slist = apt_pkg.SourceList() + # Read the list + slist.read_main_list() + # Add all indexes to the fetcher. + slist.get_indexes(acquire, True) + + # Now print the URI of every item. + for item in acquire.items: + print item.desc_uri + +if __name__ == '__main__': + main() diff --git a/doc/source/tutorials/apt-get.rst b/doc/source/tutorials/apt-get.rst new file mode 100644 index 00000000..575f0c46 --- /dev/null +++ b/doc/source/tutorials/apt-get.rst @@ -0,0 +1,45 @@ +Doing stuff :command:`apt-get` does +=================================== +:Author: Julian Andres Klode +:Release: |release| +:Date: |today| + +The following article will show how you can use python-apt to do actions done +by the :command:`apt-get` command. + + +Printing the URIs of all index files +------------------------------------ +We all now that we can print the URIs of all our index files by running a +simple ``apt-get -s --print-uris update``. We can do the same. Responsible for +the source entries is the class :class:`apt_pkg.SourceList`, which can be +combined with an :class:`apt_pkg.Acquire` object using :meth:`get_indexes`. + +First of all, we have to create the objects:: + + acquire = apt_pkg.Acquire() + slist = apt_pkg.SourceList() + +Now we have to parse /etc/apt/sources.list and its friends, by using +:meth:`apt_pkg.SourceList.read_main_list`:: + slist.read_main_list() + +Now the **slist** object knows about the location of the indexes. We now have +to load those indexes into the *acquire* object by calling +:meth:`apt_pkg.SourceList.get_indexes`:: + + slist.get_indexes(acquire, True) + +The first argument is the acquire object into which we will load these indexes, +and the second argument means that we want to fetch all indexes. Now the only +thing left to do is iterating over the list of items and printing out their +URIs. Luckily, there is :attr:`apt_pkg.Acquire.items` which allows us to +iterate over the items:: + + for item in acquire.items: + print item.desc_uri + +In the end a program could look like this: + +.. literalinclude:: ../examples/update-print-uris.py + -- cgit v1.2.3 From 28f42c1060c652e6f650ba4e046e3f8ab021d91b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 15:25:10 +0100 Subject: * Build for all supported Python versions. - Disable 2.6 and 3.1 builds previously available in experimental. --- debian/changelog | 4 +++- debian/control | 10 +++------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 532a7de7..450492c4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge debian-sid and debian-experimental. * Add a tutorial on how to do things which are possible with apt-get, like apt-get --print-uris update (cf. #551164). + * Build for all supported Python versions. + - Disable 2.6 and 3.1 builds previously available in experimental. [ Colin Watson ] * apt/progress/__init__.py: @@ -25,7 +27,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low * doc/source/apt_pkg/{cache.rst, index.rst}: - update documentation as well - -- Julian Andres Klode Wed, 16 Sep 2009 19:26:17 +0200 + -- Julian Andres Klode Fri, 15 Jan 2010 15:24:16 +0100 python-apt (0.7.92) experimental; urgency=low diff --git a/debian/control b/debian/control index c5508e9b..afece43c 100644 --- a/debian/control +++ b/debian/control @@ -4,16 +4,12 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.3 -XS-Python-Version: 2.5, 2.6, 3.1 +XS-Python-Version: all Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), - python2.5-dbg, - python2.5-dev, - python2.6-dev, - python2.6-dbg, - python3.1-dev, - python3.1-dbg, + python-all-dbg, + python-all-dev, python-central (>= 0.5), python-distutils-extra (>= 2.0), python-gtk2 [!kfreebsd-amd64 !kfreebsd-i386], -- cgit v1.2.3 From 6dae07e834445c193f392cf53a252b83c68f2bcd Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 15:42:44 +0100 Subject: Make all class-level constants have uppercase names. --- apt/cache.py | 14 +++++++------- apt/package.py | 4 ++-- apt/progress/base.py | 2 +- apt/progress/text.py | 2 +- debian/changelog | 1 + doc/source/library/apt_pkg.rst | 16 ++++++++-------- python/apt_pkgmodule.cc | 18 +++++++++--------- 7 files changed, 29 insertions(+), 28 deletions(-) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index eea06d56..d339f377 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -223,9 +223,9 @@ class Cache(object): transient = False err_msg = "" for item in fetcher.items: - if item.status == item.stat_done: + if item.status == item.STAT_DONE: continue - if item.stat_idle: + if item.STAT_IDLE: transient = True continue err_msg += "Failed to fetch %s %s\n" % (item.desc_uri, @@ -311,7 +311,7 @@ class Cache(object): pulse_interval) if res == apt_pkg.Acquire.result_cancelled and raise_on_error: raise FetchCancelledException() - if res == apt_pkg.Acquire.result_failed and raise_on_error: + if res == apt_pkg.Acquire.RESULT_FAILED and raise_on_error: raise FetchFailedException() else: return res @@ -369,17 +369,17 @@ class Cache(object): # then install res = self.install_archives(pm, install_progress) - if res == pm.result_completed: + if res == pm.RESULT_COMPLETED: break - elif res == pm.result_failed: + elif res == pm.RESULT_FAILED: raise SystemError("installArchives() failed") - elif res == pm.result_incomplete: + elif res == pm.RESULT_INCOMPLETE: pass else: raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res) # reload the fetcher for media swaping fetcher.shutdown() - return (res == pm.result_completed) + return (res == pm.RESULT_COMPLETED) def clear(self): """ Unmark all changes """ diff --git a/apt/package.py b/apt/package.py index 315a7589..8171f57d 100644 --- a/apt/package.py +++ b/apt/package.py @@ -500,7 +500,7 @@ class Version(object): self.size, base, destfile=destfile) acq.run() - if acqfile.status != acqfile.stat_done: + if acqfile.status != acqfile.STAT_DONE: raise FetchError("The item %r could not be fetched: %s" % (acqfile.destfile, acqfile.error_text)) print self._records.filename @@ -548,7 +548,7 @@ class Version(object): acq.run() for item in acq.items: - if item.status != item.stat_done: + if item.status != item.STAT_DONE: raise FetchError("The item %r could not be fetched: %s" % (item.destfile, item.error_text)) diff --git a/apt/progress/base.py b/apt/progress/base.py index fd6bc475..adb39e93 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -192,7 +192,7 @@ class InstallProgress(object): os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", str(self.writefd.fileno()), "-i", obj)) except Exception: - os._exit(apt_pkg.PackageManager.result_failed) + os._exit(apt_pkg.PackageManager.RESULT_FAILED) self.child_pid = pid res = self.wait_child() diff --git a/apt/progress/text.py b/apt/progress/text.py index 3a6d3e65..796577e2 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -125,7 +125,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress): def fail(self, item): """Called when an item is failed.""" base.AcquireProgress.fail(self, item) - if item.owner.status == item.owner.stat_done: + if item.owner.status == item.owner.STAT_DONE: self._write(_("Ign ") + item.description) else: self._write(_("Err ") + item.description) diff --git a/debian/changelog b/debian/changelog index a7204a0a..acd9c3ca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low - Disable 2.6 and 3.1 builds previously available in experimental. * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. + * Make all class-level constants have uppercase names. [ Colin Watson ] * apt/progress/__init__.py: diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst index 5876fb8d..c3a74267 100644 --- a/doc/source/library/apt_pkg.rst +++ b/doc/source/library/apt_pkg.rst @@ -282,21 +282,21 @@ Working with the cache Fix the installation if a package could not be downloaded. - .. attribute:: result_completed + .. attribute:: RESULT_COMPLETED A constant for checking whether the the result is 'completed'. Compare it against the return value of :meth:`PackageManager.get_archives` or :meth:`PackageManager.do_install`. - .. attribute:: result_failed + .. attribute:: RESULT_FAILED A constant for checking whether the the result is 'failed'. Compare it against the return value of :meth:`PackageManager.get_archives` or :meth:`PackageManager.do_install`. - .. attribute:: result_incomplete + .. attribute:: RESULT_INCOMPLETE A constant for checking whether the the result is 'incomplete'. @@ -1110,23 +1110,23 @@ installation. Integer, representing the status of the item. - .. attribute:: stat_idle + .. attribute:: STAT_IDLE Constant for comparing :attr:`AcquireItem.status`. - .. attribute:: stat_fetching + .. attribute:: STAT_FETCHING Constant for comparing :attr:`AcquireItem.status` - .. attribute:: stat_done + .. attribute:: STAT_DONE Constant for comparing :attr:`AcquireItem.status` - .. attribute:: stat_error + .. attribute:: STAT_ERROR Constant for comparing :attr:`AcquireItem.status` - .. attribute:: stat_auth_error + .. attribute:: STAT_AUTH_ERROR Constant for comparing :attr:`AcquireItem.status` diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index f20b0c87..cdd23705 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -670,7 +670,7 @@ extern "C" void initapt_pkg() Py_BuildValue("i", pkgAcquire::Cancelled)); PyDict_SetItemString(PyAcquire_Type.tp_dict, "result_continue", Py_BuildValue("i", pkgAcquire::Continue)); - PyDict_SetItemString(PyAcquire_Type.tp_dict, "result_failed", + PyDict_SetItemString(PyAcquire_Type.tp_dict, "RESULT_FAILED", Py_BuildValue("i", pkgAcquire::Failed)); #ifdef COMPAT_0_7 PyDict_SetItemString(PyAcquire_Type.tp_dict, "ResultCancelled", @@ -702,11 +702,11 @@ extern "C" void initapt_pkg() // PackageManager constants - PyDict_SetItemString(PyPackageManager_Type.tp_dict, "result_completed", + PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_COMPLETED", Py_BuildValue("i", pkgPackageManager::Completed)); - PyDict_SetItemString(PyPackageManager_Type.tp_dict, "result_failed", + PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_FAILED", Py_BuildValue("i", pkgPackageManager::Failed)); - PyDict_SetItemString(PyPackageManager_Type.tp_dict, "result_incomplete", + PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_INCOMPLETE", Py_BuildValue("i", pkgPackageManager::Incomplete)); #ifdef COMPAT_0_7 @@ -719,15 +719,15 @@ extern "C" void initapt_pkg() #endif // AcquireItem Constants. - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "stat_idle", + PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_IDLE", Py_BuildValue("i", pkgAcquire::Item::StatIdle)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "stat_fetching", + PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_FETCHING", Py_BuildValue("i", pkgAcquire::Item::StatFetching)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "stat_done", + PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_DONE", Py_BuildValue("i", pkgAcquire::Item::StatDone)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "stat_error", + PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_ERROR", Py_BuildValue("i", pkgAcquire::Item::StatError)); - PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "stat_auth_error", + PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_AUTH_ERROR", Py_BuildValue("i", pkgAcquire::Item::StatAuthError)); #ifdef COMPAT_0_7 -- cgit v1.2.3 From 5b348d4e1c0377eb1086cdaf05b20b860a1467eb Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 15:43:53 +0100 Subject: Build for all supported Python versions newer than 2.5. --- debian/changelog | 2 +- debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index acd9c3ca..e455d2ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,7 +4,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge debian-sid and debian-experimental. * Add a tutorial on how to do things which are possible with apt-get, like apt-get --print-uris update (cf. #551164). - * Build for all supported Python versions. + * Build for all supported Python versions newer than 2.5. - Disable 2.6 and 3.1 builds previously available in experimental. * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. diff --git a/debian/control b/debian/control index afece43c..3554942a 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.3 -XS-Python-Version: all +XS-Python-Version: >= 2.5 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), -- cgit v1.2.3 From 9050a3414388b942696173c828ed9d5d2c963409 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 15:52:48 +0100 Subject: debian/changelog: Fix indentation. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index e455d2ed..35a949db 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,9 +6,9 @@ python-apt (0.7.93) UNRELEASED; urgency=low like apt-get --print-uris update (cf. #551164). * Build for all supported Python versions newer than 2.5. - Disable 2.6 and 3.1 builds previously available in experimental. - * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error + * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. - * Make all class-level constants have uppercase names. + * Make all class-level constants have uppercase names. [ Colin Watson ] * apt/progress/__init__.py: -- cgit v1.2.3 From 34b01eb60ec315bc542d0cad7239091219a8388c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Jan 2010 19:09:10 +0100 Subject: Rewrite apt.progress.gtk2 documentation by hand and drop python-gtk2 build-time dependency. --- debian/changelog | 2 + debian/control | 4 +- doc/source/library/apt.progress.gtk2.rst | 128 +++++++++++++++++++++++++++---- 3 files changed, 118 insertions(+), 16 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 35a949db..c2b8d7e6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. * Make all class-level constants have uppercase names. + * Rewrite apt.progress.gtk2 documentation by hand and drop python-gtk2 + build-time dependency. [ Colin Watson ] * apt/progress/__init__.py: diff --git a/debian/control b/debian/control index 3554942a..294deb1a 100644 --- a/debian/control +++ b/debian/control @@ -12,9 +12,7 @@ Build-Depends: apt-utils, python-all-dev, python-central (>= 0.5), python-distutils-extra (>= 2.0), - python-gtk2 [!kfreebsd-amd64 !kfreebsd-i386], - python-sphinx (>= 0.5), - python-vte [!kfreebsd-amd64 !kfreebsd-i386] + python-sphinx (>= 0.5) Vcs-Bzr: http://bzr.debian.org/apt/python-apt/debian-sid Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes diff --git a/doc/source/library/apt.progress.gtk2.rst b/doc/source/library/apt.progress.gtk2.rst index b16c903c..6c00e731 100644 --- a/doc/source/library/apt.progress.gtk2.rst +++ b/doc/source/library/apt.progress.gtk2.rst @@ -1,27 +1,129 @@ :mod:`apt.progress.gtk2` --- Progress reporting for GTK+ interfaces =================================================================== -.. automodule:: apt.progress.gtk2 +.. module:: apt.progress.gtk2 + +The :mod:`apt.progress.gtk2` module provides classes with GObject signals and +a class with a GTK+ widget for progress handling. GObject progress classes ------------------------- +.. class:: GInstallProgress + + An implementation of :class:`apt.progress.base.InstallProgress` supporting + GObject signals. The class emits the following signals: + + .. describe:: status-changed(status: str, percent: int) + + Emitted when the status of an operation changed. + + .. describe:: status-started() + + Emitted when the installation started. + + .. describe:: status-finished() + + Emitted when the installation finished. + + .. describe:: status-timeout() + + Emitted when a timeout happens + + .. describe:: status-error() + + Emitted in case of an error. + + .. describe:: status-conffile() + + Emitted when a conffile update is happening. + + +.. class:: GFetchProgress + + An implementation of :class:`apt.progress.old.FetchProgress` supporting + GObject signals. The class emits the following signals: + + .. describe:: status-changed(description: str, percent: int) + + Emitted when the status of the fetcher changed, e.g. when the + percentage increased. + + .. describe:: status-started() + + Emitted when the fetcher starts to fetch. + + .. describe:: status-finished() + + Emitted when the fetcher finished. + + +.. class:: GDpkgInstallProgress + + An implementation of :class:`apt.progress.base.InstallProgress` supporting + GObject signals. This is the same as :class:`GInstallProgress` and is thus + completely deprecated. + +.. class:: GOpProgress + + An implementation of :class:`apt.progress.old.FetchProgress` supporting + GObject signals. The class emits the following signals: + + .. describe:: status-changed(operation: str, percent: int) + + Emitted when the status of an operation changed. + + .. describe:: status-started() + + Emitted when it starts - Not implemented yet. + + .. describe:: status-finished() + + Emitted when all operations have finished. + +GTK+ Widget +----------- +.. class:: GtkAptProgress + + Graphical progress for installation/fetch/operations, providing + a progress bar, a terminal and a status bar for showing the progress + of package manipulation tasks. + + .. method:: cancel_download() + + Cancel a currently running download. + + .. method:: clear() + + Reset all status information. + + .. attribute:: dpkg_install + + Return the install progress handler for dpkg. + + .. attribute:: fetch + + Return the fetch progress handler. + + .. method:: hide_terminal() -.. autoclass:: GDpkgInstallProgress - :members: + Hide the expander with the terminal widget. -.. autoclass:: GFetchProgress - :members: + .. attribute:: install + + Return the install progress handler. -.. autoclass:: GInstallProgress - :members: + .. attribute:: open -.. autoclass:: GOpProgress - :members: + Return the cache opening progress handler. + + .. method:: show() + + Show the Box -GTK+ Class ----------- -.. autoclass:: GtkAptProgress - :members: + .. method:: show_terminal(expanded=False) + + Show an expander with a terminal widget which provides a way to + interact with dpkg. Example -- cgit v1.2.3 From 008a45f23d6999269f10978c3cb3ac11240451f9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 17 Jan 2010 12:54:16 +0100 Subject: * Build for Python 2.5, 2.6 and 3.1; 2.6 and 3.1 hit unstable on Jan 16. - Use DH_PYCENTRAL=nomove for now because include-links seems broken --- debian/changelog | 4 ++-- debian/control | 10 +++++++--- debian/rules | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index c2b8d7e6..ba6dbd40 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Merge debian-sid and debian-experimental. * Add a tutorial on how to do things which are possible with apt-get, like apt-get --print-uris update (cf. #551164). - * Build for all supported Python versions newer than 2.5. - - Disable 2.6 and 3.1 builds previously available in experimental. + * Build for Python 2.5, 2.6 and 3.1; 2.6 and 3.1 hit unstable on Jan 16. + - Use DH_PYCENTRAL=nomove for now because include-links seems broken * Merge lp:~forest-bond/python-apt/cache-is-virtual-package-catch-key-error - Return False in Cache.is_virtual_package if the package does not exist. * Make all class-level constants have uppercase names. diff --git a/debian/control b/debian/control index 294deb1a..81fc00ee 100644 --- a/debian/control +++ b/debian/control @@ -4,12 +4,16 @@ Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.3 -XS-Python-Version: >= 2.5 +XS-Python-Version: 2.5, 2.6, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), libapt-pkg-dev (>= 0.7.22~), - python-all-dbg, - python-all-dev, + python2.5-dbg, + python2.5-dev, + python2.6-dev, + python2.6-dbg, + python3.1-dev, + python3.1-dbg, python-central (>= 0.5), python-distutils-extra (>= 2.0), python-sphinx (>= 0.5) diff --git a/debian/rules b/debian/rules index 6c9f6fb6..1a45a710 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,6 @@ #!/usr/bin/make -f -export DH_PYCENTRAL=include-links +# Should be include-links, but that somehow fails. +export DH_PYCENTRAL=nomove export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p') export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 -- cgit v1.2.3 From 875d039bdfa15a02968ab8188584fae790a92d5f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 17 Jan 2010 13:12:32 +0100 Subject: aptsources: Make all classes subclasses of object. --- aptsources/distinfo.py | 10 +++++----- aptsources/distro.py | 2 +- aptsources/sourceslist.py | 4 ++-- debian/changelog | 2 ++ 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'debian') diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 0614bd1c..0aa34f20 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -36,7 +36,7 @@ def _(s): return gettext.dgettext("python-apt", s) -class Template: +class Template(object): def __init__(self): self.name = None @@ -66,7 +66,7 @@ class Template: return False -class Component: +class Component(object): def __init__(self, name, desc=None, long_desc=None): self.name = name @@ -91,7 +91,7 @@ class Component: return self.description_long -class Mirror: +class Mirror(object): ''' Storage for mirror related information ''' def __init__(self, proto, hostname, dir, location=None): @@ -124,7 +124,7 @@ class Mirror: self.location = location -class Repository: +class Repository(object): def __init__(self, proto, dir): self.proto = proto @@ -145,7 +145,7 @@ def split_url(url): return split -class DistInfo: +class DistInfo(object): def __init__(self, dist = None, diff --git a/aptsources/distro.py b/aptsources/distro.py index 2cbad9fb..5a6301bd 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -38,7 +38,7 @@ class NoDistroTemplateException(Exception): pass -class Distribution: +class Distribution(object): def __init__(self, id, codename, description, release): """ Container for distribution specific informations """ diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index 710bfe15..76bea43a 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -74,7 +74,7 @@ def uniq(s): return list(set(s)) -class SourceEntry: +class SourceEntry(object): """ single sources.list entry """ def __init__(self, line, file=None): @@ -394,7 +394,7 @@ class SourcesList(object): return (parents, used_child_templates) -class SourceEntryMatcher: +class SourceEntryMatcher(object): """ matcher class to make a source entry look nice lots of predefined matchers to make it i18n/gettext friendly """ diff --git a/debian/changelog b/debian/changelog index ba6dbd40..b955b155 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * Make all class-level constants have uppercase names. * Rewrite apt.progress.gtk2 documentation by hand and drop python-gtk2 build-time dependency. + * aptsources: + - Make all classes subclasses of object. [ Colin Watson ] * apt/progress/__init__.py: -- cgit v1.2.3 From 773c5de21c809c7fe07eefafa252efa0b6758744 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 17 Jan 2010 13:22:34 +0100 Subject: aptsources/distro.py: Support Python 3, decode lsb_release results using utf-8. --- aptsources/distro.py | 2 ++ debian/changelog | 1 + 2 files changed, 3 insertions(+) (limited to 'debian') diff --git a/aptsources/distro.py b/aptsources/distro.py index 5a6301bd..ff1bed89 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -446,6 +446,8 @@ def _lsb_release(): 'Release': 'unstable'} try: out = Popen(['lsb_release', '--all'], stdout=PIPE).communicate()[0] + # Convert to unicode string, needed for Python 3.1 + out = out.decode("utf-8") result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) except OSError, exc: if exc.errno != errno.ENOENT: diff --git a/debian/changelog b/debian/changelog index b955b155..646b9efe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low build-time dependency. * aptsources: - Make all classes subclasses of object. + - distro.py: Support Python 3, decode lsb_release results using utf-8. [ Colin Watson ] * apt/progress/__init__.py: -- cgit v1.2.3 From a1f06a125e59bf06ea8fccea9b584097221c0032 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 17 Jan 2010 15:41:44 +0100 Subject: apt/progress/base.py: Fix some parsing of dpkg status fd. --- apt/progress/base.py | 12 +++++++++--- debian/changelog | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/apt/progress/base.py b/apt/progress/base.py index 4df26f26..64bb22dc 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -223,13 +223,18 @@ class InstallProgress(object): return elif line.startswith('status'): try: - (base, pkgname, status, status_str) = line.split(": ", 3) + (base, pkgname, status, status_str) = line.split(":", 3) except ValueError: - (base, pkgname, status) = line.split(": ", 2) + (base, pkgname, status) = line.split(":", 2) elif line.startswith('processing'): - (status, status_str, pkgname) = line.split(": ", 2) + (status, status_str, pkgname) = line.split(":", 2) self.processing(pkgname.strip(), status_str.strip()) + # Always strip the status message + pkgname = pkgname.strip() + status_str = status_str.strip() + status = status.strip() + if status == 'pmerror' or status == 'error': self.error(pkgname, status_str) elif status == 'conffile-prompt' or status == 'pmconffile': @@ -237,6 +242,7 @@ class InstallProgress(object): if match: self.conffile(match.group(1), match.group(2)) elif status == "pmstatus": + # FIXME: Float comparison if float(percent) != self.percent or status_str != self.status: self.status_change(pkgname, float(percent), status_str.strip()) self.percent = float(percent) diff --git a/debian/changelog b/debian/changelog index 646b9efe..5001f1fe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low * aptsources: - Make all classes subclasses of object. - distro.py: Support Python 3, decode lsb_release results using utf-8. + * apt/progress/base.py: + - Fix some parsing of dpkg status fd. [ Colin Watson ] * apt/progress/__init__.py: -- cgit v1.2.3 From 3c0c2fa47e2a519005f4c07dac8b1e09c86eeee4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 17 Jan 2010 15:48:16 +0100 Subject: apt/progress/text.py: Replace one print statement with a .write() call. --- apt/progress/text.py | 2 +- debian/changelog | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/apt/progress/text.py b/apt/progress/text.py index 796577e2..5e45c1db 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -41,7 +41,7 @@ class TextProgress(object): def _write(self, msg, newline=True, maximize=False): """Write the message on the terminal, fill remaining space.""" self._file.write("\r") - print >> self._file, msg, + self._file.write(msg) # Fill remaining stuff with whitespace if self._width > len(msg): diff --git a/debian/changelog b/debian/changelog index 5001f1fe..7b711e1d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ python-apt (0.7.93) UNRELEASED; urgency=low - distro.py: Support Python 3, decode lsb_release results using utf-8. * apt/progress/base.py: - Fix some parsing of dpkg status fd. + * apt/progress/text.py: + - Replace one print statement with a .write() call. [ Colin Watson ] * apt/progress/__init__.py: -- cgit v1.2.3 From 2e32d8d27f84b585ef8196a28bdd2e649de02607 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 20 Jan 2010 17:06:11 +0100 Subject: Rename apt_pkg.PackageIndexFile to apt_pkg.IndexFile. --- debian/changelog | 1 + doc/source/c++/api.rst | 20 +++++++-------- doc/source/library/apt_pkg.rst | 6 ++--- python/apt_pkgmodule.cc | 4 +-- python/apt_pkgmodule.h | 2 +- python/indexfile.cc | 58 +++++++++++++++++++++--------------------- python/metaindex.cc | 2 +- python/pkgsrcrecords.cc | 2 +- python/python-apt.h | 10 ++++---- python/sourcelist.cc | 4 +-- 10 files changed, 55 insertions(+), 54 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 7b711e1d..409cf44e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low - Fix some parsing of dpkg status fd. * apt/progress/text.py: - Replace one print statement with a .write() call. + * Rename apt_pkg.PackageIndexFile to apt_pkg.IndexFile. [ Colin Watson ] * apt/progress/__init__.py: diff --git a/doc/source/c++/api.rst b/doc/source/c++/api.rst index 2abd3ab8..749e2bc0 100644 --- a/doc/source/c++/api.rst +++ b/doc/source/c++/api.rst @@ -564,31 +564,31 @@ PackageFile (pkgCache::PkgFileIterator) Return the :ctype:`pkgCache::PkgFileIterator` reference contained in the Python object *object*. -PackageIndexFile (pkgIndexFile) +IndexFile (pkgIndexFile) -------------------------------------- -.. cvar:: PyTypeObject PyPackageIndexFile_Type +.. cvar:: PyTypeObject PyIndexFile_Type - The type object for :class:`apt_pkg.PackageIndexFile` objects. + The type object for :class:`apt_pkg.IndexFile` objects. -.. cfunction:: int PyPackageIndexFile_Check(PyObject *object) +.. cfunction:: int PyIndexFile_Check(PyObject *object) - Check that the object *object* is an :class:`apt_pkg.PackageIndexFile` object, or + Check that the object *object* is an :class:`apt_pkg.IndexFile` object, or a subclass thereof. -.. cfunction:: int PyPackageIndexFile_CheckExact(PyObject *object) +.. cfunction:: int PyIndexFile_CheckExact(PyObject *object) - Check that the object *object* is an :class:`apt_pkg.PackageIndexFile` object + Check that the object *object* is an :class:`apt_pkg.IndexFile` object and no subclass thereof. -.. cfunction:: PyObject* PyPackageIndexFile_FromCpp(pkgIndexFile *cpp, bool delete=false, PyObject *owner) +.. cfunction:: PyObject* PyIndexFile_FromCpp(pkgIndexFile *cpp, bool delete=false, PyObject *owner) - Create a new :class:`apt_pkg.PackageIndexFile` object from the :ctype:`pkgIndexFile` + Create a new :class:`apt_pkg.IndexFile` object from the :ctype:`pkgIndexFile` pointer given by the parameter *cpp*. If the parameter *delete* is true, the object pointed to by *cpp* will be deleted when the reference count of the returned object reaches 0. The parameter *owner* should be a PyObject of the type :cdata:`PyMetaIndex_Type`. -.. cfunction:: pkgIndexFile* PyPackageIndexFile_ToCpp(PyObject *object) +.. cfunction:: pkgIndexFile* PyIndexFile_ToCpp(PyObject *object) Return the :ctype:`pkgIndexFile` pointer contained in the Python object *object*. diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst index c3a74267..90b3062a 100644 --- a/doc/source/library/apt_pkg.rst +++ b/doc/source/library/apt_pkg.rst @@ -731,7 +731,7 @@ Index Files .. attribute:: index_files -.. class:: PackageIndexFile +.. class:: IndexFile .. method:: archive_uri(path) @@ -743,7 +743,7 @@ Index Files .. attribute:: describe - A description of the :class:`PackageIndexFile`. + A description of the :class:`IndexFile`. .. attribute:: exists @@ -1790,7 +1790,7 @@ Other classes .. method:: find_index(pkgfile) - Return a :class:`PackageIndexFile` object for the :class:`PackageFile` + Return a :class:`IndexFile` object for the :class:`PackageFile` *pkgfile*. .. method:: read_main_list diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 56594c61..df443c10 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -545,7 +545,7 @@ static struct _PyAptPkgAPIStruct API = { &PyMetaIndex_Type, // metaindex_type &PyPackage_Type, // package_type &PyPackageFile_Type, // packagefile_type - &PyPackageIndexFile_Type, // packageindexfile_type + &PyIndexFile_Type, // packageindexfile_type &PyPackageList_Type, // packagelist_type &PyPackageManager_Type, // packagemanager_type &PyPackageRecords_Type, // packagerecords_type @@ -638,7 +638,7 @@ extern "C" void initapt_pkg() ADDTYPE(Module,"DepCache",&PyDepCache_Type); ADDTYPE(Module,"ProblemResolver",&PyProblemResolver_Type); /* ========================= indexfile.cc ========================= */ - ADDTYPE(Module,"PackageIndexFile",&PyPackageIndexFile_Type); // NO __new__() + ADDTYPE(Module,"IndexFile",&PyIndexFile_Type); // NO __new__() /* ========================= metaindex.cc ========================= */ ADDTYPE(Module,"MetaIndex",&PyMetaIndex_Type); // NO __new__() /* ========================= pkgmanager.cc ========================= */ diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 97ba05a7..bc2f747b 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -103,7 +103,7 @@ extern PyTypeObject PySourceList_Type; PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args); // pkgSourceList -extern PyTypeObject PyPackageIndexFile_Type; +extern PyTypeObject PyIndexFile_Type; // metaIndex extern PyTypeObject PyMetaIndex_Type; diff --git a/python/indexfile.cc b/python/indexfile.cc index a6f8904e..7accaa50 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -15,7 +15,7 @@ #include -static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args) +static PyObject *IndexFileArchiveURI(PyObject *Self,PyObject *Args) { pkgIndexFile *File = GetCpp(Self); char *path; @@ -25,38 +25,38 @@ static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args) return HandleErrors(Safe_FromString(File->ArchiveURI(path).c_str())); } -static PyMethodDef PackageIndexFileMethods[] = +static PyMethodDef IndexFileMethods[] = { - {"archive_uri",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, + {"archive_uri",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, #ifdef COMPAT_0_7 - {"ArchiveURI",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, + {"ArchiveURI",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, #endif {} }; #define File (GetCpp(Self)) -static PyObject *PackageIndexFileGetLabel(PyObject *Self,void*) { +static PyObject *IndexFileGetLabel(PyObject *Self,void*) { return Safe_FromString(File->GetType()->Label); } -static PyObject *PackageIndexFileGetDescribe(PyObject *Self,void*) { +static PyObject *IndexFileGetDescribe(PyObject *Self,void*) { return Safe_FromString(File->Describe().c_str()); } -static PyObject *PackageIndexFileGetExists(PyObject *Self,void*) { +static PyObject *IndexFileGetExists(PyObject *Self,void*) { return Py_BuildValue("i",(File->Exists())); } -static PyObject *PackageIndexFileGetHasPackages(PyObject *Self,void*) { +static PyObject *IndexFileGetHasPackages(PyObject *Self,void*) { return Py_BuildValue("i",(File->HasPackages())); } -static PyObject *PackageIndexFileGetSize(PyObject *Self,void*) { +static PyObject *IndexFileGetSize(PyObject *Self,void*) { return Py_BuildValue("i",(File->Size())); } -static PyObject *PackageIndexFileGetIsTrusted(PyObject *Self,void*) { +static PyObject *IndexFileGetIsTrusted(PyObject *Self,void*) { return Py_BuildValue("i",(File->IsTrusted())); } #undef File #define S(x) (x ? x : "") -static PyObject *PackageIndexFileRepr(PyObject *Self) +static PyObject *IndexFileRepr(PyObject *Self) { pkgIndexFile *File = GetCpp(Self); return PyString_FromFormat("), // tp_basicsize 0, // tp_itemsize // Methods @@ -100,7 +100,7 @@ PyTypeObject PyPackageIndexFile_Type = 0, // tp_getattr 0, // tp_setattr 0, // tp_compare - PackageIndexFileRepr, // tp_repr + IndexFileRepr, // tp_repr 0, // tp_as_number 0, // tp_as_sequence 0, // tp_as_mapping @@ -118,9 +118,9 @@ PyTypeObject PyPackageIndexFile_Type = 0, // tp_weaklistoffset 0, // tp_iter 0, // tp_iternext - PackageIndexFileMethods, // tp_methods + IndexFileMethods, // tp_methods 0, // tp_members - PackageIndexFileGetSet, // tp_getset + IndexFileGetSet, // tp_getset }; diff --git a/python/metaindex.cc b/python/metaindex.cc index 4e059f0c..2c5b0bd9 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -38,7 +38,7 @@ static PyObject *MetaIndexGetIndexFiles(PyObject *Self,void*) { I != indexFiles->end(); I++) { CppOwnedPyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self, &PyPackageIndexFile_Type,*I); + Obj = CppOwnedPyObject_NEW(Self, &PyIndexFile_Type,*I); // Do not delete pkgIndexFile*, they are managed by metaIndex. Obj->NoDelete = true; PyList_Append(List,Obj); diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 086ec8d5..0b54c2fe 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -124,7 +124,7 @@ static PyObject *PkgSrcRecordsGetIndex(PyObject *Self,void*) { return 0; const pkgIndexFile &tmp = Struct.Last->Index(); CppOwnedPyObject *PyObj; - PyObj = CppOwnedPyObject_NEW(Self,&PyPackageIndexFile_Type, + PyObj = CppOwnedPyObject_NEW(Self,&PyIndexFile_Type, (pkgIndexFile*)&tmp); // Do not delete the pkgIndexFile*, it is managed by PkgSrcRecords::Parser. PyObj->NoDelete=true; diff --git a/python/python-apt.h b/python/python-apt.h index 08242c08..3e413dff 100644 --- a/python/python-apt.h +++ b/python/python-apt.h @@ -79,7 +79,7 @@ struct _PyAptPkgAPIStruct { # define PyMetaIndex_Type *(_PyAptPkg_API->metaindex_type) # define PyPackage_Type *(_PyAptPkg_API->package_type) # define PyPackageFile_Type *(_PyAptPkg_API->packagefile_type) -# define PyPackageIndexFile_Type *(_PyAptPkg_API->packageindexfile_type) +# define PyIndexFile_Type *(_PyAptPkg_API->packageindexfile_type) # define PyPackageList_Type *(_PyAptPkg_API->packagelist_type) # define PyPackageManager_Type *(_PyAptPkg_API->packagemanager_type) # define PyPackageRecords_Type *(_PyAptPkg_API->packagerecords_type) @@ -140,7 +140,7 @@ static int import_apt_pkg(void) { # define PyMetaIndex_Check(op) PyObject_TypeCheck(op, &PyMetaIndex_Type) # define PyPackage_Check(op) PyObject_TypeCheck(op, &PyPackage_Type) # define PyPackageFile_Check(op) PyObject_TypeCheck(op, &PyPackageFile_Type) -# define PyPackageIndexFile_Check(op) PyObject_TypeCheck(op, &PyPackageIndexFile_Type) +# define PyIndexFile_Check(op) PyObject_TypeCheck(op, &PyIndexFile_Type) # define PyPackageList_Check(op) PyObject_TypeCheck(op, &PyPackageList_Type) # define PyPackageManager_Check(op) PyObject_TypeCheck(op, &PyPackageManager_Type) # define PyPackageRecords_Check(op) PyObject_TypeCheck(op, &PyPackageRecords_Type) @@ -172,7 +172,7 @@ static int import_apt_pkg(void) { # define PyMetaIndex_CheckExact(op) (op->op_type == &PyMetaIndex_Type) # define PyPackage_CheckExact(op) (op->op_type == &PyPackage_Type) # define PyPackageFile_CheckExact(op) (op->op_type == &PyPackageFile_Type) -# define PyPackageIndexFile_CheckExact(op) (op->op_type == &PyPackageIndexFile_Type) +# define PyIndexFile_CheckExact(op) (op->op_type == &PyIndexFile_Type) # define PyPackageList_CheckExact(op) (op->op_type == &PyPackageList_Type) # define PyPackageManager_CheckExact(op) (op->op_type == &PyPackageManager_Type) # define PyPackageRecords_CheckExact(op) (op->op_type == &PyPackageRecords_Type) @@ -205,7 +205,7 @@ static int import_apt_pkg(void) { # define PyMetaIndex_ToCpp GetCpp # define PyPackage_ToCpp GetCpp # define PyPackageFile_ToCpp GetCpp -# define PyPackageIndexFile_ToCpp GetCpp +# define PyIndexFile_ToCpp GetCpp //# define PyPackageList_ToCpp GetCpp // NOT EXPORTED. # define PyPackageManager_ToCpp GetCpp //# define PyPackageRecords_ToCpp GetCpp // NOT EXPORTED @@ -256,7 +256,7 @@ inline CppOwnedPyObject *FromCppOwned(PyTypeObject *pytype, Cpp const &obj, # define PyIndexRecords_FromCpp(...) FromCpp(&PyIndexRecords_Type,##__VA_ARGS__) # define PyMetaIndex_FromCpp(...) FromCppOwned(&PyMetaIndex_Type,##__VA_ARGS__) # define PyPackage_FromCpp(...) FromCppOwned(&PyPackage_Type,##__VA_ARGS__) -# define PyPackageIndexFile_FromCpp(...) FromCppOwned(&PyPackageIndexFile_Type,##__VA_ARGS__) +# define PyIndexFile_FromCpp(...) FromCppOwned(&PyIndexFile_Type,##__VA_ARGS__) # define PyPackageFile_FromCpp(...) FromCppOwned(&PyPackageFile_Type,##__VA_ARGS__) //# define PyPackageList_FromCpp(...) FromCppOwned(&PyPackageList_Type,##__VA_ARGS__) # define PyPackageManager_FromCpp(...) FromCpp(&PyPackageManager_Type,##__VA_ARGS__) diff --git a/python/sourcelist.cc b/python/sourcelist.cc index e86f7fd3..52c0e6a8 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -35,13 +35,13 @@ static PyObject *PkgSourceListFindIndex(PyObject *Self,PyObject *Args) pkgIndexFile *index; if(list->FindIndex(i, index)) { - pyPkgIndexFile = CppOwnedPyObject_NEW(pyPkgFileIter,&PyPackageIndexFile_Type,index); + pyPkgIndexFile = CppOwnedPyObject_NEW(pyPkgFileIter,&PyIndexFile_Type,index); // Do not delete the pkgIndexFile*, it is managed by pkgSourceList. pyPkgIndexFile->NoDelete = true; return pyPkgIndexFile; } - //&PyPackageIndexFile_Type,&pyPkgIndexFile) + //&PyIndexFile_Type,&pyPkgIndexFile) Py_INCREF(Py_None); return Py_None; -- cgit v1.2.3 From 35e4bc6a39f3862e597484736ec82c040b992f4b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 20 Jan 2010 17:06:41 +0100 Subject: Release 0.7.93 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 409cf44e..d9cc2dfe 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.93) UNRELEASED; urgency=low +python-apt (0.7.93) unstable; urgency=low [ Julian Andres Klode ] * Merge debian-sid and debian-experimental. @@ -40,7 +40,7 @@ python-apt (0.7.93) UNRELEASED; urgency=low * doc/source/apt_pkg/{cache.rst, index.rst}: - update documentation as well - -- Julian Andres Klode Fri, 15 Jan 2010 15:24:16 +0100 + -- Julian Andres Klode Wed, 20 Jan 2010 17:06:20 +0100 python-apt (0.7.92) experimental; urgency=low -- cgit v1.2.3 From 511ca4dd916413a5f6a0ae140cfc678695bb006f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 23 Jan 2010 15:36:36 +0100 Subject: Fix reference counting for old progress classes (Closes: #566370). --- debian/changelog | 6 ++++++ python/progress.cc | 22 +++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index d9cc2dfe..6f5cd696 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-apt (0.7.93.1) UNRELEASED; urgency=low + + * Fix reference counting for old progress classes (Closes: #566370). + + -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 + python-apt (0.7.93) unstable; urgency=low [ Julian Andres Klode ] diff --git a/python/progress.cc b/python/progress.cc index 22ce39a4..63d9eede 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -124,8 +124,11 @@ bool PyFetchProgress::MediaChange(string Media, string Drive) //std::cout << "MediaChange" << std::endl; PyObject *arglist = Py_BuildValue("(ss)", Media.c_str(), Drive.c_str()); PyObject *result; - if(! RunSimpleCallback("media_change", arglist, &result)) - RunSimpleCallback("mediaChange", arglist, &result); + + if(PyObject_HasAttrString(callbackInst, "media_change")) + RunSimpleCallback("media_change", arglist, &result); + else + RunSimpleCallback("mediaChange", arglist, &result); bool res = true; if(!PyArg_Parse(result, "b", &res)) { @@ -157,8 +160,10 @@ void PyFetchProgress::UpdateStatus(pkgAcquire::ItemDesc &Itm, int status) arglist = Py_BuildValue("(sssi)", Itm.URI.c_str(), Itm.Description.c_str(), Itm.ShortDesc.c_str(), status); - if(!RunSimpleCallback("update_status", arglist)) - RunSimpleCallback("updateStatus", arglist); + if(PyObject_HasAttrString(callbackInst, "update_status")) + RunSimpleCallback("update_status", arglist); + else + RunSimpleCallback("updateStatus", arglist); } void PyFetchProgress::IMSHit(pkgAcquire::ItemDesc &Itm) @@ -536,8 +541,10 @@ bool PyCdromProgress::ChangeCdrom() { PyObject *arglist = Py_BuildValue("()"); PyObject *result; - if(!RunSimpleCallback("change_cdrom", arglist, &result)) - RunSimpleCallback("changeCdrom", arglist, &result); + if (PyObject_HasAttrString(callbackInst, "change_cdrom")) + RunSimpleCallback("change_cdrom", arglist, &result); + else + RunSimpleCallback("changeCdrom", arglist, &result); bool res = true; if(!PyArg_Parse(result, "b", &res)) @@ -555,7 +562,8 @@ bool PyCdromProgress::AskCdromName(string &Name) PyObject *result; // New style: String on success, None on failure. - if (RunSimpleCallback("ask_cdrom_name", arglist, &result)) { + if (PyObject_HasAttrString(callbackInst, "ask_cdrom_name")) { + RunSimpleCallback("ask_cdrom_name", arglist, &result); if(result == Py_None) return false; if(!PyArg_Parse(result, "s", &new_name)) -- cgit v1.2.3 From e29ff27343b203fd4150d6171efdc7e6ae5a68bf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 23 Jan 2010 16:19:27 +0100 Subject: apt/cache.py: Fix Cache.update() to not raise errors on successful updates. --- apt/cache.py | 11 ++++++----- debian/changelog | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index 2f097f6b..2a62ddce 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -307,11 +307,12 @@ class Cache(object): try: if fetch_progress is None: fetch_progress = apt.progress.FetchProgress() - res = self._cache.update(fetch_progress, self._list, - pulse_interval) - if res == apt_pkg.Acquire.RESULT_CANCELLED and raise_on_error: - raise FetchCancelledException() - if res == apt_pkg.Acquire.RESULT_FAILED and raise_on_error: + try: + res = self._cache.update(fetch_progress, self._list, + pulse_interval) + except SystemError, e: + raise FetchFailedException(e) + if not res and raise_on_error: raise FetchFailedException() else: return res diff --git a/debian/changelog b/debian/changelog index 6f5cd696..95ca5b41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * Fix reference counting for old progress classes (Closes: #566370). + * apt/cache.py: + - Fix Cache.update() to not raise errors on successful updates. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 -- cgit v1.2.3 From c654ae4c10bf40922e2ecf8f1b7fe1c2b97a06aa Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 23 Jan 2010 19:21:26 +0100 Subject: * python/progress.cc: - Fix some threading issues (add some missing PyCbObj_BEGIN_ALLOW_THREADS) --- debian/changelog | 2 ++ python/progress.cc | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 95ca5b41..3fa0852f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * Fix reference counting for old progress classes (Closes: #566370). * apt/cache.py: - Fix Cache.update() to not raise errors on successful updates. + * python/progress.cc: + - Fix some threading issues (add some missing PyCbObj_BEGIN_ALLOW_THREADS) -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/progress.cc b/python/progress.cc index 63d9eede..0fc01085 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -133,6 +133,7 @@ bool PyFetchProgress::MediaChange(string Media, string Drive) bool res = true; if(!PyArg_Parse(result, "b", &res)) { // no return value or None, assume false + PyCbObj_BEGIN_ALLOW_THREADS return false; } @@ -201,12 +202,15 @@ void PyFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) PyCbObj_END_ALLOW_THREADS if (PyObject_HasAttrString(callbackInst, "fail")) { RunSimpleCallback("fail", TUPLEIZE(PyAcquire_GetItemDesc(pyAcquire, &Itm))); + PyCbObj_BEGIN_ALLOW_THREADS return; } // Ignore certain kinds of transient failures (bad code) - if (Itm.Owner->Status == pkgAcquire::Item::StatIdle) + if (Itm.Owner->Status == pkgAcquire::Item::StatIdle) { + PyCbObj_BEGIN_ALLOW_THREADS return; + } if (Itm.Owner->Status == pkgAcquire::Item::StatDone) { @@ -262,8 +266,10 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) pkgAcquireStatus::Pulse(Owner); //std::cout << "Pulse" << std::endl; - if(callbackInst == 0) + if(callbackInst == 0) { + PyCbObj_BEGIN_ALLOW_THREADS return false; + } setattr(callbackInst, "last_bytes", "d", LastBytes); setattr(callbackInst, "current_cps", "d", CurrentCPS); @@ -496,6 +502,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) if (result == NULL) { std::cerr << "waitChild method invalid" << std::endl; PyErr_Print(); + PyCbObj_BEGIN_ALLOW_THREADS return pkgPackageManager::Failed; } if(!PyArg_Parse(result, "i", &res) ) { -- cgit v1.2.3 From 89752fb6d465c78026befcc5a61e8af655587ad7 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 23 Jan 2010 19:24:04 +0100 Subject: python/acquire-item.cc: Support items without an owner set. --- debian/changelog | 2 ++ python/acquire-item.cc | 38 ++++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 3fa0852f..87202817 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - Fix Cache.update() to not raise errors on successful updates. * python/progress.cc: - Fix some threading issues (add some missing PyCbObj_BEGIN_ALLOW_THREADS) + * python/acquire-item.cc: + - Support items without an owner set. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/acquire-item.cc b/python/acquire-item.cc index 1fb66080..73aec1d6 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -178,26 +178,28 @@ static void acquireitem_dealloc(PyObject *self) { pkgAcquire::Item *item = PyAcquireItem_ToCpp(self); PyAcquireObject *Owner = (PyAcquireObject *)GetOwner(self); - PyAcquireItems item_struct = Owner->items[item]; - // TODO: Unregister the object in the owner. - if (!((CppOwnedPyObject*)self)->NoDelete) { - if (item_struct.file != 0 && item_struct.file != self) - item_struct.file->Object = 0; - if (item_struct.item != 0 && item_struct.item != self) { - item_struct.item->Object = 0; - Py_DECREF(item_struct.item); + if (Owner != NULL) { + PyAcquireItems item_struct = Owner->items[item]; + // TODO: Unregister the object in the owner. + if (!((CppOwnedPyObject*)self)->NoDelete) { + if (item_struct.file != 0 && item_struct.file != self) + item_struct.file->Object = 0; + if (item_struct.item != 0 && item_struct.item != self) { + item_struct.item->Object = 0; + Py_DECREF(item_struct.item); + } + if (item_struct.desc != 0) { + item_struct.desc->Object = 0; + Py_DECREF(item_struct.desc); + } + Owner->items.erase(item); } - if (item_struct.desc != 0) { - item_struct.desc->Object = 0; - Py_DECREF(item_struct.desc); + else { + if (item_struct.file == self) + item_struct.file = 0; + if (item_struct.item == self) + item_struct.item = 0; } - Owner->items.erase(item); - } - else { - if (item_struct.file == self) - item_struct.file = 0; - if (item_struct.item == self) - item_struct.item = 0; } CppOwnedDeallocPtr(self); -- cgit v1.2.3 From 3836c5cfae107ea242c22d8dfbc42322cbe08186 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 24 Jan 2010 17:56:30 +0100 Subject: * python/tarfile.cc: - When extracting, only allocate a new buffer if the old one was too small. - Do not segfault if TarFile.go() is called without a member name. --- debian/changelog | 3 +++ python/tarfile.cc | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 87202817..f766ef24 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,9 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - Fix some threading issues (add some missing PyCbObj_BEGIN_ALLOW_THREADS) * python/acquire-item.cc: - Support items without an owner set. + * python/tarfile.cc: + - When extracting, only allocate a new buffer if the old one was too small. + - Do not segfault if TarFile.go() is called without a member name. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/tarfile.cc b/python/tarfile.cc index 9c3797fb..c1e5f48d 100644 --- a/python/tarfile.cc +++ b/python/tarfile.cc @@ -49,6 +49,8 @@ public: bool error; // Place where the copy of the data is stored. char *copy; + // The size of the copy + size_t copy_size; virtual bool DoItem(Item &Itm,int &Fd); virtual bool FinishedFile(Item &Itm,int Fd); @@ -72,8 +74,12 @@ public: bool PyDirStream::DoItem(Item &Itm, int &Fd) { if (!member || strcmp(Itm.Name, member) == 0) { - delete[] copy; - copy = new char[Itm.Size]; + // Allocate a new buffer if the old one is too small. + if (copy == NULL || copy_size < Itm.Size) { + delete[] copy; + copy = new char[Itm.Size]; + copy_size = Itm.Size; + } Fd = -2; } return true; @@ -91,7 +97,7 @@ bool PyDirStream::FinishedFile(Item &Itm,int Fd) if (member && strcmp(Itm.Name, member) != 0) // Skip non-matching Items, if a specific one is requested. return true; - + // Clear the old objects and create new ones. Py_XDECREF(py_member); Py_XDECREF(py_data); @@ -366,7 +372,7 @@ static PyObject *tarfile_go(PyObject *self, PyObject *args) char *member = 0; if (PyArg_ParseTuple(args,"O|s",&callback,&member) == 0) return 0; - if (strcmp(member, "") == 0) + if (member && strcmp(member, "") == 0) member = 0; pkgDirStream Extract; PyDirStream stream(callback, member); -- cgit v1.2.3 From e50d26301902821870d4e53ceab42464d7ee91f4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 24 Jan 2010 18:29:00 +0100 Subject: Clone all pkgDirStream::Item's so apt_pkg.TarMember object can be used outside of the callback function passed to go(). --- debian/changelog | 2 ++ python/tarfile.cc | 73 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 45 insertions(+), 30 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index f766ef24..276f1e89 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * python/tarfile.cc: - When extracting, only allocate a new buffer if the old one was too small. - Do not segfault if TarFile.go() is called without a member name. + - Clone all pkgDirStream::Item's so apt_pkg.TarMember object can be used + outside of the callback function passed to go(). -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/tarfile.cc b/python/tarfile.cc index c1e5f48d..775ae22e 100644 --- a/python/tarfile.cc +++ b/python/tarfile.cc @@ -40,8 +40,6 @@ class PyDirStream : public pkgDirStream public: PyObject *callback; - // The current member and data. - CppOwnedPyObject *py_member; PyObject *py_data; // The requested member or NULL. const char *member; @@ -58,14 +56,13 @@ public: unsigned long Size,unsigned long Pos); PyDirStream(PyObject *callback, const char *member=0) : callback(callback), - py_member(0), py_data(0), member(member), error(false), copy(0) + py_data(0), member(member), error(false), copy(0) { Py_XINCREF(callback); } virtual ~PyDirStream() { Py_XDECREF(callback); - Py_XDECREF(py_member); Py_XDECREF(py_data); delete[] copy; } @@ -98,33 +95,49 @@ bool PyDirStream::FinishedFile(Item &Itm,int Fd) // Skip non-matching Items, if a specific one is requested. return true; - // Clear the old objects and create new ones. - Py_XDECREF(py_member); Py_XDECREF(py_data); - py_member = CppOwnedPyObject_NEW(0, &PyTarMember_Type, &Itm); - py_member->NoDelete = true; py_data = PyBytes_FromStringAndSize(copy, Itm.Size); if (!callback) return true; + + // The current member and data. + CppOwnedPyObject *py_member; + py_member = CppOwnedPyObject_NEW(0, &PyTarMember_Type); + // Clone our object, including the strings in it. + py_member->Object = Itm; + py_member->Object.Name = new char[strlen(Itm.Name)+1]; + py_member->Object.LinkTarget = new char[strlen(Itm.LinkTarget)+1]; + strcpy(py_member->Object.Name, Itm.Name); + strcpy(py_member->Object.LinkTarget,Itm.LinkTarget); + py_member->NoDelete = true; error = PyObject_CallFunctionObjArgs(callback, py_member, py_data, 0) == 0; + // Clear the old objects and create new ones. + Py_XDECREF(py_member); return (!error); } +void tarmember_dealloc(PyObject *self) { + // We cloned those strings, delete them again. + delete[] GetCpp(self).Name; + delete[] GetCpp(self).LinkTarget; + CppOwnedDealloc(self); +} + // The tarfile.TarInfo interface for our TarMember class. static PyObject *tarmember_isblk(PyObject *self, PyObject *args) { - return PyBool_FromLong(GetCpp(self)->Type == + return PyBool_FromLong(GetCpp(self).Type == pkgDirStream::Item::BlockDevice); } static PyObject *tarmember_ischr(PyObject *self, PyObject *args) { - return PyBool_FromLong(GetCpp(self)->Type == + return PyBool_FromLong(GetCpp(self).Type == pkgDirStream::Item::CharDevice); } static PyObject *tarmember_isdev(PyObject *self, PyObject *args) { - pkgDirStream::Item::Type_t type = GetCpp(self)->Type; + pkgDirStream::Item::Type_t type = GetCpp(self).Type; return PyBool_FromLong(type == pkgDirStream::Item::CharDevice || type == pkgDirStream::Item::BlockDevice || type == pkgDirStream::Item::FIFO); @@ -132,24 +145,24 @@ static PyObject *tarmember_isdev(PyObject *self, PyObject *args) static PyObject *tarmember_isdir(PyObject *self, PyObject *args) { - return PyBool_FromLong(GetCpp(self)->Type == + return PyBool_FromLong(GetCpp(self).Type == pkgDirStream::Item::Directory); } static PyObject *tarmember_isfifo(PyObject *self, PyObject *args) { - return PyBool_FromLong(GetCpp(self)->Type == + return PyBool_FromLong(GetCpp(self).Type == pkgDirStream::Item::FIFO); } static PyObject *tarmember_isfile(PyObject *self, PyObject *args) { - return PyBool_FromLong(GetCpp(self)->Type == + return PyBool_FromLong(GetCpp(self).Type == pkgDirStream::Item::File); } static PyObject *tarmember_islnk(PyObject *self, PyObject *args) { - return PyBool_FromLong(GetCpp(self)->Type == + return PyBool_FromLong(GetCpp(self).Type == pkgDirStream::Item::HardLink); } static PyObject *tarmember_isreg(PyObject *self, PyObject *args) @@ -158,58 +171,58 @@ static PyObject *tarmember_isreg(PyObject *self, PyObject *args) } static PyObject *tarmember_issym(PyObject *self, PyObject *args) { - return PyBool_FromLong(GetCpp(self)->Type == + return PyBool_FromLong(GetCpp(self).Type == pkgDirStream::Item::SymbolicLink); } static PyObject *tarmember_get_name(PyObject *self, void *closure) { - return PyString_FromString(GetCpp(self)->Name); + return PyString_FromString(GetCpp(self).Name); } static PyObject *tarmember_get_linkname(PyObject *self, void *closure) { - return Safe_FromString(GetCpp(self)->LinkTarget); + return Safe_FromString(GetCpp(self).LinkTarget); } static PyObject *tarmember_get_mode(PyObject *self, void *closure) { - return Py_BuildValue("k", GetCpp(self)->Mode); + return Py_BuildValue("k", GetCpp(self).Mode); } static PyObject *tarmember_get_uid(PyObject *self, void *closure) { - return Py_BuildValue("k", GetCpp(self)->UID); + return Py_BuildValue("k", GetCpp(self).UID); } static PyObject *tarmember_get_gid(PyObject *self, void *closure) { - return Py_BuildValue("k", GetCpp(self)->GID); + return Py_BuildValue("k", GetCpp(self).GID); } static PyObject *tarmember_get_size(PyObject *self, void *closure) { - return Py_BuildValue("k", GetCpp(self)->Size); + return Py_BuildValue("k", GetCpp(self).Size); } static PyObject *tarmember_get_mtime(PyObject *self, void *closure) { - return Py_BuildValue("k", GetCpp(self)->MTime); + return Py_BuildValue("k", GetCpp(self).MTime); } static PyObject *tarmember_get_major(PyObject *self, void *closure) { - return Py_BuildValue("k", GetCpp(self)->Major); + return Py_BuildValue("k", GetCpp(self).Major); } static PyObject *tarmember_get_minor(PyObject *self, void *closure) { - return Py_BuildValue("k", GetCpp(self)->Minor); + return Py_BuildValue("k", GetCpp(self).Minor); } static PyObject *tarmember_repr(PyObject *self) { return PyString_FromFormat("<%s object: name:'%s'>", self->ob_type->tp_name, - GetCpp(self)->Name); + GetCpp(self).Name); } @@ -256,10 +269,10 @@ static const char *tarmember_doc = PyTypeObject PyTarMember_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_inst.TarMember", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppOwnedPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + tarmember_dealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -277,8 +290,8 @@ PyTypeObject PyTarMember_Type = { Py_TPFLAGS_DEFAULT | // tp_flags Py_TPFLAGS_HAVE_GC, tarmember_doc, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppOwnedTraverse, // tp_traverse + CppOwnedClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter -- cgit v1.2.3 From 2bb149489844096c55e9e90379795930171a6f73 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 27 Jan 2010 13:51:27 +0100 Subject: Drop the segfault prevention measures from the Acquire code, as they fail to work. A replacement will be added once destruction callbacks are added in APT. --- debian/changelog | 3 ++ python/acquire-item.cc | 48 +------------------ python/acquire.cc | 124 +++++++++++++------------------------------------ python/apt_pkgmodule.h | 1 + python/progress.cc | 47 ++++++++++--------- python/progress.h | 1 + 6 files changed, 64 insertions(+), 160 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 276f1e89..9b505a58 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,9 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - Do not segfault if TarFile.go() is called without a member name. - Clone all pkgDirStream::Item's so apt_pkg.TarMember object can be used outside of the callback function passed to go(). + * Drop the segfault prevention measures from the Acquire code, as they fail + to work. A replacement will be added once destruction callbacks are added + in APT. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/acquire-item.cc b/python/acquire-item.cc index 24780f1c..059f1802 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -28,22 +28,6 @@ using namespace std; - - -struct PyAcquireItems { - CppOwnedPyObject *file; - CppOwnedPyObject *item; - CppOwnedPyObject *desc; -}; - -typedef map item_map; - -// Keep a vector to PyAcquireItemObject pointers, so we can set the Object -// pointers to NULL when deallocating the main object (mostly AcquireFile). -struct PyAcquireObject : public CppPyObject { - item_map items; -}; - inline pkgAcquire::Item *acquireitem_tocpp(PyObject *self) { pkgAcquire::Item *itm = GetCpp(self); @@ -163,45 +147,18 @@ static PyObject *acquireitem_repr(PyObject *Self) pkgAcquire::Item *Itm = acquireitem_tocpp(Self); if (Itm == 0) return 0; - return PyString_FromFormat("<%s object: " "Status: %i Complete: %i Local: %i IsTrusted: %i " "FileSize: %lu DestFile:'%s' " "DescURI: '%s' ID:%lu ErrorText: '%s'>", Self->ob_type->tp_name, Itm->Status, Itm->Complete, Itm->Local, Itm->IsTrusted(), - Itm->FileSize, Itm->DestFile.c_str(), Itm->DescURI().c_str(), + Itm->FileSize, Itm->DestFile.c_str(), Itm->DescURI().c_str(), Itm->ID,Itm->ErrorText.c_str()); } static void acquireitem_dealloc(PyObject *self) { - pkgAcquire::Item *item = PyAcquireItem_ToCpp(self); - PyAcquireObject *Owner = (PyAcquireObject *)GetOwner(self); - if (Owner != NULL) { - PyAcquireItems item_struct = Owner->items[item]; - // TODO: Unregister the object in the owner. - if (!((CppOwnedPyObject*)self)->NoDelete) { - if (item_struct.file != 0 && item_struct.file != self) - item_struct.file->Object = 0; - if (item_struct.item != 0 && item_struct.item != self) { - item_struct.item->Object = 0; - Py_DECREF(item_struct.item); - } - if (item_struct.desc != 0) { - item_struct.desc->Object = 0; - Py_DECREF(item_struct.desc); - } - Owner->items.erase(item); - } - else { - if (item_struct.file == self) - item_struct.file = 0; - if (item_struct.item == self) - item_struct.item = 0; - } - } - CppOwnedDeallocPtr(self); } @@ -267,9 +224,6 @@ static PyObject *acquirefile_new(PyTypeObject *type, PyObject *Args, PyObject * destFile); // short-desc CppOwnedPyObject *AcqFileObj = CppOwnedPyObject_NEW(pyfetcher, type); AcqFileObj->Object = af; - - - ((PyAcquireObject *)pyfetcher)->items[af].file = AcqFileObj; return AcqFileObj; } diff --git a/python/acquire.cc b/python/acquire.cc index 789f994e..bcb76d67 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -30,43 +30,18 @@ #include -typedef CppOwnedPyObject PyAcquireWorkerObject; -struct PyAcquireItems { - CppOwnedPyObject *file; - CppOwnedPyObject *item; - CppOwnedPyObject *desc; -}; - -typedef map item_map; -typedef map worker_map; - -// Keep a vector to PyAcquireItemObject pointers, so we can set the Object -// pointers to NULL when deallocating the main object (mostly AcquireFile). -struct PyAcquireObject : public CppPyObject { - item_map items; - worker_map workers; -}; - - static PyObject *acquireworker_get_current_item(PyObject *self, void *closure) { pkgAcquire::Worker *worker = GetCpp(self); - - if (worker->CurrentItem == NULL) { + pkgAcquire::ItemDesc *desc = worker->CurrentItem; + if (desc == NULL) { Py_RETURN_NONE; } - - PyObject *PyAcquire = GetOwner(self); - - if (PyAcquire) - return PyAcquire_GetItemDesc(PyAcquire, worker->CurrentItem); - else { - PyObject *PyItem = PyAcquireItem_FromCpp(worker->CurrentItem->Owner); - PyObject *ret = PyAcquireItemDesc_FromCpp(worker->CurrentItem,false, - PyItem); - Py_DECREF(PyItem); - return ret; - } + PyObject *PyAcq = GetOwner(self); + PyObject *PyItem = PyAcquireItem_FromCpp(desc->Owner, false, PyAcq); + PyObject *PyDesc = PyAcquireItemDesc_FromCpp(desc, false, PyItem); + Py_XDECREF(PyItem); + return PyDesc; } static PyObject *acquireworker_get_status(PyObject *self, void *closure) @@ -134,17 +109,28 @@ PyTypeObject PyAcquireWorker_Type = { acquireworker_getset, // tp_getset }; + +static pkgAcquire::ItemDesc* acquireitemdesc_tocpp(PyObject *self) { + pkgAcquire::ItemDesc *item = GetCpp(self); + if (item == NULL) + PyErr_SetString(PyExc_ValueError, "Acquire has been shutdown"); + return item; +} + static PyObject *acquireitemdesc_get_uri(PyObject *self, void *closure) { - return CppPyString(GetCpp(self)->URI); + pkgAcquire::ItemDesc *item = acquireitemdesc_tocpp(self); + return item ? CppPyString(item->URI) : NULL; } static PyObject *acquireitemdesc_get_description(PyObject *self, void *closure) { - return CppPyString(GetCpp(self)->Description); + pkgAcquire::ItemDesc *item = acquireitemdesc_tocpp(self); + return item ? CppPyString(item->Description) : NULL; } static PyObject *acquireitemdesc_get_shortdesc(PyObject *self, void *closure) { - return CppPyString(GetCpp(self)->ShortDesc); + pkgAcquire::ItemDesc *item = acquireitemdesc_tocpp(self); + return item ? CppPyString(item->ShortDesc) : NULL; } static PyObject *acquireitemdesc_get_owner(CppOwnedPyObject *self, void *closure) { @@ -153,7 +139,7 @@ static PyObject *acquireitemdesc_get_owner(CppOwnedPyObjectOwner; } else if (self->Object) { - self->Owner = PyAcquireItem_FromCpp(self->Object->Owner); + self->Owner = PyAcquireItem_FromCpp(self->Object->Owner, false, NULL); Py_INCREF(self->Owner); return self->Owner; } @@ -214,31 +200,6 @@ PyTypeObject PyAcquireItemDesc_Type = { 0, // tp_new }; - -// Acquire - -PyObject *PyAcquire_GetItem(PyObject *self, pkgAcquire::Item *item) -{ - PyAcquireItems &item_struct = ((PyAcquireObject *)self)->items[item]; - if (! item_struct.item) { - item_struct.item = PyAcquireItem_FromCpp(item,false,self); - } - Py_INCREF(item_struct.item); - return item_struct.item; -} - -PyObject *PyAcquire_GetItemDesc(PyObject *self, pkgAcquire::ItemDesc *item) -{ - PyAcquireItems &item_struct = ((PyAcquireObject *)self)->items[item->Owner]; - if (! item_struct.item) - item_struct.item = PyAcquireItem_FromCpp(item->Owner,false,self); - if (! item_struct.desc) - item_struct.desc = PyAcquireItemDesc_FromCpp(item,false, - item_struct.item); - Py_INCREF(item_struct.desc); - return item_struct.desc; -} - static PyObject *PkgAcquireRun(PyObject *Self,PyObject *Args) { pkgAcquire *fetcher = GetCpp(Self); @@ -252,34 +213,19 @@ static PyObject *PkgAcquireRun(PyObject *Self,PyObject *Args) return HandleErrors(Py_BuildValue("i",run)); } + static PyObject *PkgAcquireShutdown(PyObject *Self,PyObject *Args) { pkgAcquire *fetcher = GetCpp(Self); - if (PyArg_ParseTuple(Args, "") == 0) return 0; - fetcher->Shutdown(); - - // TODO: Delete all objects here - item_map &items = ((PyAcquireObject *)Self)->items; - for (item_map::iterator I = items.begin(); I != items.end(); I++) { - if ((*I).second.file) - (*I).second.file->Object = NULL; - if ((*I).second.item) { - (*I).second.item->Object = NULL; - Py_DECREF((*I).second.item); - } - if ((*I).second.desc) { - (*I).second.desc->Object = NULL; - Py_DECREF((*I).second.desc); - } - } - items.clear(); Py_INCREF(Py_None); return HandleErrors(Py_None); } + + static PyMethodDef PkgAcquireMethods[] = { {"run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"}, {"shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"}, @@ -312,8 +258,7 @@ static PyObject *PkgAcquireGetWorkers(PyObject *self, void *closure) CppOwnedPyObject *PyWorker = NULL; for (pkgAcquire::Worker *Worker = Owner->WorkersBegin(); Worker != 0; Worker = Owner->WorkerStep(Worker)) { - PyWorker = CppOwnedPyObject_NEW(self,&PyAcquireWorker_Type, Worker); - PyWorker->NoDelete = true; + PyWorker = PyAcquireWorker_FromCpp(Worker, false, self); PyList_Append(List, PyWorker); Py_DECREF(PyWorker); } @@ -326,7 +271,7 @@ static PyObject *PkgAcquireGetItems(PyObject *Self,void*) PyObject *Obj; for (pkgAcquire::ItemIterator I = fetcher->ItemsBegin(); I != fetcher->ItemsEnd(); I++) { - Obj = PyAcquire_GetItem(Self, *I); + Obj = PyAcquireItem_FromCpp(*I, false, Self); PyList_Append(List,Obj); Py_DECREF(Obj); } @@ -368,14 +313,11 @@ static PyObject *PkgAcquireNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) fetcher = new pkgAcquire(); } - PyAcquireObject *FetcherObj = (PyAcquireObject *) - CppPyObject_NEW(type, fetcher); + PyObject *FetcherObj = CppPyObject_NEW(type, fetcher); if (progress != 0) progress->setPyAcquire(FetcherObj); // prepare our map of items. - new (&FetcherObj->items) item_map(); - new (&FetcherObj->workers) worker_map(); return FetcherObj; } @@ -383,11 +325,9 @@ static PyObject *PkgAcquireNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) * Create a new apt_pkg.Acquire Python object from the pkgAcquire object. */ PyObject *PyAcquire_FromCpp(pkgAcquire *fetcher, bool Delete) { - PyAcquireObject *FetcherObj = (PyAcquireObject *)CppPyObject_NEW(&PyAcquire_Type, fetcher); - new (&FetcherObj->items) item_map(); - new (&FetcherObj->workers) worker_map(); - FetcherObj->NoDelete = (!Delete); - return FetcherObj; + CppPyObject *obj = CppPyObject_NEW(&PyAcquire_Type, fetcher); + obj->NoDelete = (!Delete); + return obj; } static char *doc_PkgAcquire = @@ -399,7 +339,7 @@ static char *doc_PkgAcquire = PyTypeObject PyAcquire_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Acquire", // tp_name - sizeof(PyAcquireObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods CppDeallocPtr, // tp_dealloc diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 5a5a6c6f..ec6cf10e 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -123,6 +123,7 @@ extern PyTypeObject PySystemLock_Type; extern PyTypeObject PyFileLock_Type; PyObject *PyAcquire_FromCpp(pkgAcquire *fetcher, bool Delete); +PyObject *PyAcquireItem_FromCpp(pkgAcquire::Item *item, bool Delete, PyObject *owner); #include "python-apt.h" #endif diff --git a/python/progress.cc b/python/progress.cc index 0fc01085..b69149d5 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -17,7 +17,6 @@ #include "generic.h" #include "apt_pkgmodule.h" - /** * Set an attribute on an object, after creating the value with * Py_BuildValue(fmt, arg). Afterwards, decrease its refcount and return @@ -118,6 +117,16 @@ void PyOpProgress::Done() // apt interface +PyObject *PyFetchProgress::GetDesc(pkgAcquire::ItemDesc *item) { + if (!pyAcquire && item->Owner && item->Owner->GetOwner()) { + pyAcquire = PyAcquire_FromCpp(item->Owner->GetOwner(), false); + } + PyObject *pyItem = PyAcquireItem_FromCpp(item->Owner, false, pyAcquire); + PyObject *pyDesc = PyAcquireItemDesc_FromCpp(item, false, pyItem); + Py_DECREF(pyItem); + return pyDesc; +} + bool PyFetchProgress::MediaChange(string Media, string Drive) { PyCbObj_END_ALLOW_THREADS @@ -171,7 +180,7 @@ void PyFetchProgress::IMSHit(pkgAcquire::ItemDesc &Itm) { PyCbObj_END_ALLOW_THREADS if (PyObject_HasAttrString(callbackInst, "ims_hit")) - RunSimpleCallback("ims_hit", TUPLEIZE(PyAcquire_GetItemDesc(pyAcquire, &Itm))); + RunSimpleCallback("ims_hit", TUPLEIZE(GetDesc(&Itm))); else UpdateStatus(Itm, DLHit); PyCbObj_BEGIN_ALLOW_THREADS @@ -181,7 +190,7 @@ void PyFetchProgress::Fetch(pkgAcquire::ItemDesc &Itm) { PyCbObj_END_ALLOW_THREADS if (PyObject_HasAttrString(callbackInst, "fetch")) - RunSimpleCallback("fetch", TUPLEIZE(PyAcquire_GetItemDesc(pyAcquire, &Itm))); + RunSimpleCallback("fetch", TUPLEIZE(GetDesc(&Itm))); else UpdateStatus(Itm, DLQueued); PyCbObj_BEGIN_ALLOW_THREADS @@ -191,7 +200,7 @@ void PyFetchProgress::Done(pkgAcquire::ItemDesc &Itm) { PyCbObj_END_ALLOW_THREADS if (PyObject_HasAttrString(callbackInst, "done")) - RunSimpleCallback("done", TUPLEIZE(PyAcquire_GetItemDesc(pyAcquire, &Itm))); + RunSimpleCallback("done", TUPLEIZE(GetDesc(&Itm))); else UpdateStatus(Itm, DLDone); PyCbObj_BEGIN_ALLOW_THREADS @@ -201,7 +210,7 @@ void PyFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) { PyCbObj_END_ALLOW_THREADS if (PyObject_HasAttrString(callbackInst, "fail")) { - RunSimpleCallback("fail", TUPLEIZE(PyAcquire_GetItemDesc(pyAcquire, &Itm))); + RunSimpleCallback("fail", TUPLEIZE(GetDesc(&Itm))); PyCbObj_BEGIN_ALLOW_THREADS return; } @@ -219,7 +228,7 @@ void PyFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) if (PyObject_HasAttrString(callbackInst, "fail")) - RunSimpleCallback("fail", TUPLEIZE(PyAcquire_GetItemDesc(pyAcquire, &Itm))); + RunSimpleCallback("fail", TUPLEIZE(GetDesc(&Itm))); else UpdateStatus(Itm, DLFailed); PyCbObj_BEGIN_ALLOW_THREADS @@ -279,24 +288,15 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) setattr(callbackInst, "elapsed_time", "k", ElapsedTime); setattr(callbackInst, "current_items", "k", CurrentItems); setattr(callbackInst, "total_items", "k", TotalItems); -#ifdef COMPAT_0_7 - setattr(callbackInst, "currentCPS", "d", CurrentCPS); - setattr(callbackInst, "currentBytes", "d", CurrentBytes); - setattr(callbackInst, "totalBytes", "d", TotalBytes); - setattr(callbackInst, "fetchedBytes", "d", FetchedBytes); - setattr(callbackInst, "currentItems", "k", CurrentItems); - setattr(callbackInst, "totalItems", "k", TotalItems); -#endif // New style -#ifdef COMPAT_0_7 if (!PyObject_HasAttrString(callbackInst, "updateStatus")) { -#else - { -#endif PyObject *result1; bool res1 = true; + if (pyAcquire == NULL) { + pyAcquire = PyAcquire_FromCpp(Owner, false); + } Py_INCREF(pyAcquire); if (RunSimpleCallback("pulse", TUPLEIZE(pyAcquire) , &result1)) { @@ -308,11 +308,14 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) } PyCbObj_BEGIN_ALLOW_THREADS return true; - - - } #ifdef COMPAT_0_7 + setattr(callbackInst, "currentCPS", "d", CurrentCPS); + setattr(callbackInst, "currentBytes", "d", CurrentBytes); + setattr(callbackInst, "totalBytes", "d", TotalBytes); + setattr(callbackInst, "fetchedBytes", "d", FetchedBytes); + setattr(callbackInst, "currentItems", "k", CurrentItems); + setattr(callbackInst, "totalItems", "k", TotalItems); // Go through the list of items and add active items to the // activeItems vector. map activeItemMap; @@ -401,6 +404,8 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) PyCbObj_BEGIN_ALLOW_THREADS // fetching can be canceld by returning false return res; +#else + return false; #endif } diff --git a/python/progress.h b/python/progress.h index 7e75652b..4e66c771 100644 --- a/python/progress.h +++ b/python/progress.h @@ -64,6 +64,7 @@ struct PyFetchProgress : public pkgAcquireStatus, public PyCallbackObj { protected: PyObject *pyAcquire; + PyObject *GetDesc(pkgAcquire::ItemDesc *item); public: enum { DLDone, DLQueued, DLFailed, DLHit, DLIgnored -- cgit v1.2.3 From d24964f86e1108f88d55a9580bbd6d2e482562dd Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 27 Jan 2010 15:11:39 +0100 Subject: Merge the CppOwnedPyObject C++ class into CppPyObject. --- debian/changelog | 1 + python/acquire-item.cc | 18 ++++---- python/acquire.cc | 24 +++++----- python/apt_instmodule.h | 2 +- python/apt_pkgmodule.cc | 4 +- python/arfile.cc | 32 +++++++------- python/cache.cc | 114 ++++++++++++++++++++++++------------------------ python/cdrom.cc | 2 +- python/configuration.cc | 8 ++-- python/depcache.cc | 42 +++++++++--------- python/generic.h | 93 ++++++++++----------------------------- python/hashes.cc | 2 +- python/hashstring.cc | 2 +- python/indexfile.cc | 8 ++-- python/indexrecords.cc | 2 +- python/metaindex.cc | 8 ++-- python/pkgmanager.cc | 2 +- python/pkgrecords.cc | 10 ++--- python/pkgsrcrecords.cc | 8 ++-- python/policy.cc | 14 +++--- python/python-apt.h | 61 +++++++++++--------------- python/sourcelist.cc | 10 ++--- python/tag.cc | 10 ++--- python/tarfile.cc | 20 ++++----- 24 files changed, 219 insertions(+), 278 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 9b505a58..08bf564b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * Drop the segfault prevention measures from the Acquire code, as they fail to work. A replacement will be added once destruction callbacks are added in APT. + * Merge the CppOwnedPyObject C++ class into CppPyObject. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/acquire-item.cc b/python/acquire-item.cc index 059f1802..d5f9ad10 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -159,13 +159,13 @@ static PyObject *acquireitem_repr(PyObject *Self) static void acquireitem_dealloc(PyObject *self) { - CppOwnedDeallocPtr(self); + CppDeallocPtr(self); } PyTypeObject PyAcquireItem_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireItem", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods acquireitem_dealloc, // tp_dealloc @@ -186,8 +186,8 @@ PyTypeObject PyAcquireItem_Type = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "AcquireItem Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -222,7 +222,7 @@ static PyObject *acquirefile_new(PyTypeObject *type, PyObject *Args, PyObject * shortDescr, destDir, destFile); // short-desc - CppOwnedPyObject *AcqFileObj = CppOwnedPyObject_NEW(pyfetcher, type); + CppPyObject *AcqFileObj = CppPyObject_NEW(pyfetcher, type); AcqFileObj->Object = af; return AcqFileObj; } @@ -237,7 +237,7 @@ static char *acquirefile_doc = PyTypeObject PyAcquireFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireFile", // tp_name - sizeof(CppOwnedPyObject),// tp_basicsize + sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize // Methods acquireitem_dealloc, // tp_dealloc @@ -259,8 +259,8 @@ PyTypeObject PyAcquireFile_Type = { Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, acquirefile_doc, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -309,7 +309,7 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) shortDescr, destDir, destFile); // short-desc - CppPyObject *AcqFileObj = CppPyObject_NEW(&PyAcquireFile_Type); + CppPyObject *AcqFileObj = CppPyObject_NEW(NULL, &PyAcquireFile_Type); AcqFileObj->Object = af; AcqFileObj->NoDelete = true; diff --git a/python/acquire.cc b/python/acquire.cc index bcb76d67..cd7f7709 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -77,10 +77,10 @@ static PyGetSetDef acquireworker_getset[] = { PyTypeObject PyAcquireWorker_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireWorker", // tp_name - sizeof(CppOwnedPyObject),// tp_basicsize + sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -98,8 +98,8 @@ PyTypeObject PyAcquireWorker_Type = { Py_TPFLAGS_DEFAULT| // tp_flags Py_TPFLAGS_HAVE_GC, 0, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -132,7 +132,7 @@ static PyObject *acquireitemdesc_get_shortdesc(PyObject *self, void *closure) pkgAcquire::ItemDesc *item = acquireitemdesc_tocpp(self); return item ? CppPyString(item->ShortDesc) : NULL; } -static PyObject *acquireitemdesc_get_owner(CppOwnedPyObject *self, void *closure) +static PyObject *acquireitemdesc_get_owner(CppPyObject *self, void *closure) { if (self->Owner != NULL) { Py_INCREF(self->Owner); @@ -160,10 +160,10 @@ static char *acquireitemdesc_doc = PyTypeObject PyAcquireItemDesc_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.AcquireItemDesc", // tp_name - sizeof(CppOwnedPyObject),// tp_basicsize + sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -181,8 +181,8 @@ PyTypeObject PyAcquireItemDesc_Type = { (Py_TPFLAGS_DEFAULT | // tp_flags Py_TPFLAGS_HAVE_GC), acquireitemdesc_doc, // tp_doc - CppOwnedTraverse,// tp_traverse - CppOwnedClear, // tp_clear + CppTraverse,// tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -255,7 +255,7 @@ static PyObject *PkgAcquireGetWorkers(PyObject *self, void *closure) { PyObject *List = PyList_New(0); pkgAcquire *Owner = GetCpp(self); - CppOwnedPyObject *PyWorker = NULL; + CppPyObject *PyWorker = NULL; for (pkgAcquire::Worker *Worker = Owner->WorkersBegin(); Worker != 0; Worker = Owner->WorkerStep(Worker)) { PyWorker = PyAcquireWorker_FromCpp(Worker, false, self); @@ -313,7 +313,7 @@ static PyObject *PkgAcquireNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) fetcher = new pkgAcquire(); } - PyObject *FetcherObj = CppPyObject_NEW(type, fetcher); + PyObject *FetcherObj = CppPyObject_NEW(NULL, type, fetcher); if (progress != 0) progress->setPyAcquire(FetcherObj); @@ -325,7 +325,7 @@ static PyObject *PkgAcquireNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) * Create a new apt_pkg.Acquire Python object from the pkgAcquire object. */ PyObject *PyAcquire_FromCpp(pkgAcquire *fetcher, bool Delete) { - CppPyObject *obj = CppPyObject_NEW(&PyAcquire_Type, fetcher); + CppPyObject *obj = CppPyObject_NEW(NULL, &PyAcquire_Type, fetcher); obj->NoDelete = (!Delete); return obj; } diff --git a/python/apt_instmodule.h b/python/apt_instmodule.h index 2b07261b..f6b337f4 100644 --- a/python/apt_instmodule.h +++ b/python/apt_instmodule.h @@ -27,7 +27,7 @@ extern PyTypeObject PyDebFile_Type; extern PyTypeObject PyTarFile_Type; extern PyTypeObject PyTarMember_Type; -struct PyTarFileObject : public CppOwnedPyObject { +struct PyTarFileObject : public CppPyObject { int min; FileFd Fd; }; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 64db74d2..e77fd3ca 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -56,7 +56,7 @@ static PyObject *newConfiguration(PyObject *self,PyObject *args) { PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is " "deprecated. Use apt_pkg.Configuration() instead.", 1); - return CppOwnedPyObject_NEW(NULL, &PyConfiguration_Type, new Configuration()); + return CppPyObject_NEW(NULL, &PyConfiguration_Type, new Configuration()); } #endif /*}}}*/ @@ -599,7 +599,7 @@ extern "C" void initapt_pkg() #endif // Global variable linked to the global configuration class - CppOwnedPyObject *Config = CppOwnedPyObject_NEW(NULL, &PyConfiguration_Type); + CppPyObject *Config = CppPyObject_NEW(NULL, &PyConfiguration_Type); Config->Object = _config; // Global configuration, should never be deleted. Config->NoDelete = true; diff --git a/python/arfile.cc b/python/arfile.cc index 1abb738f..4f95a791 100644 --- a/python/arfile.cc +++ b/python/arfile.cc @@ -93,10 +93,10 @@ static const char *armember_doc = PyTypeObject PyArMember_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_inst.ArMember", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -114,8 +114,8 @@ PyTypeObject PyArMember_Type = { Py_TPFLAGS_DEFAULT | // tp_flags Py_TPFLAGS_HAVE_GC, armember_doc, // tp_doc - CppOwnedTraverse,// tp_traverse - CppOwnedClear, // tp_clear + CppTraverse,// tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -135,7 +135,7 @@ public: } }; -struct PyArArchiveObject : public CppOwnedPyObject { +struct PyArArchiveObject : public CppPyObject { FileFd Fd; }; @@ -146,7 +146,7 @@ static const char *ararchive_getmember_doc = static PyObject *ararchive_getmember(PyArArchiveObject *self, PyObject *arg) { const char *name; - CppOwnedPyObject *ret; + CppPyObject *ret; if (! (name = PyObject_AsString(arg))) return 0; @@ -157,7 +157,7 @@ static PyObject *ararchive_getmember(PyArArchiveObject *self, PyObject *arg) } // Create our object. - ret = CppOwnedPyObject_NEW(self,&PyArMember_Type); + ret = CppPyObject_NEW(self,&PyArMember_Type); ret->Object = const_cast(member); ret->NoDelete = true; return ret; @@ -302,7 +302,7 @@ static PyObject *ararchive_gettar(PyArArchiveObject *self, PyObject *args) return 0; } - PyTarFileObject *tarfile = (PyTarFileObject*)CppOwnedPyObject_NEW(self,&PyTarFile_Type); + PyTarFileObject *tarfile = (PyTarFileObject*)CppPyObject_NEW(self,&PyTarFile_Type); new (&tarfile->Fd) FileFd(self->Fd); tarfile->min = member->Start; tarfile->Object = new ExtractTar(self->Fd, member->Size, comp); @@ -317,8 +317,8 @@ static PyObject *ararchive_getmembers(PyArArchiveObject *self) PyObject *list = PyList_New(0); ARArchive::Member *member = self->Object->Members(); do { - CppOwnedPyObject *ret; - ret = CppOwnedPyObject_NEW(self,&PyArMember_Type); + CppPyObject *ret; + ret = CppPyObject_NEW(self,&PyArMember_Type); ret->Object = member; ret->NoDelete = true; PyList_Append(list, ret); @@ -380,14 +380,14 @@ static PyObject *ararchive_new(PyTypeObject *type, PyObject *args, // We receive a filename. if ((filename = (char*)PyObject_AsString(file))) { - self = (PyArArchiveObject *)CppOwnedPyObject_NEW(0,type); + self = (PyArArchiveObject *)CppPyObject_NEW(0,type); new (&self->Fd) FileFd(filename,FileFd::ReadOnly); } // We receive a file object. else if ((fileno = PyObject_AsFileDescriptor(file)) != -1) { // Clear the error set by PyObject_AsString(). PyErr_Clear(); - self = (PyArArchiveObject *)CppOwnedPyObject_NEW(file,type); + self = (PyArArchiveObject *)CppPyObject_NEW(file,type); new (&self->Fd) FileFd(fileno,false); } else { @@ -402,7 +402,7 @@ static PyObject *ararchive_new(PyTypeObject *type, PyObject *args, static void ararchive_dealloc(PyObject *self) { ((PyArArchiveObject *)(self))->Fd.~FileFd(); - CppOwnedDeallocPtr(self); + CppDeallocPtr(self); } // Return bool or -1 (exception). @@ -455,8 +455,8 @@ PyTypeObject PyArArchive_Type = { Py_TPFLAGS_DEFAULT | // tp_flags Py_TPFLAGS_HAVE_GC, ararchive_doc, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset (getiterfunc)ararchive_iter, // tp_iter @@ -511,7 +511,7 @@ static PyObject *_gettar(PyDebFileObject *self, const ARArchive::Member *m, { if (!m) return 0; - PyTarFileObject *tarfile = (PyTarFileObject*)CppOwnedPyObject_NEW(self,&PyTarFile_Type); + PyTarFileObject *tarfile = (PyTarFileObject*)CppPyObject_NEW(self,&PyTarFile_Type); new (&tarfile->Fd) FileFd(self->Fd); tarfile->min = m->Start; tarfile->Object = new ExtractTar(self->Fd, m->Size, comp); diff --git a/python/cache.cc b/python/cache.cc index 6bbf0766..fe6e8b68 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -73,7 +73,7 @@ static PyObject *CreateProvides(PyObject *Owner,pkgCache::PrvIterator I) { PyObject *Obj; PyObject *Ver; - Ver = CppOwnedPyObject_NEW(Owner,&PyVersion_Type, + Ver = CppPyObject_NEW(Owner,&PyVersion_Type, I.OwnerVer()); Obj = Py_BuildValue("ssN",I.ParentPkg().Name(),I.ProvideVersion(), Ver); @@ -162,7 +162,7 @@ static PyMethodDef PkgCacheMethods[] = static PyObject *PkgCacheGetPackages(PyObject *Self, void*) { pkgCache *Cache = GetCpp(Self); - return CppOwnedPyObject_NEW(Self,&PyPackageList_Type,Cache->PkgBegin()); + return CppPyObject_NEW(Self,&PyPackageList_Type,Cache->PkgBegin()); } static PyObject *PkgCacheGetPackageCount(PyObject *Self, void*) { @@ -200,7 +200,7 @@ static PyObject *PkgCacheGetFileList(PyObject *Self, void*) { for (pkgCache::PkgFileIterator I = Cache->FileBegin(); I.end() == false; I++) { PyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self,&PyPackageFile_Type,I); + Obj = CppPyObject_NEW(Self,&PyPackageFile_Type,I); PyList_Append(List,Obj); Py_DECREF(Obj); } @@ -250,7 +250,7 @@ static PyObject *CacheMapOp(PyObject *Self,PyObject *Arg) return 0; } - return CppOwnedPyObject_NEW(Self,&PyPackage_Type,Pkg); + return CppPyObject_NEW(Self,&PyPackage_Type,Pkg); } static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) @@ -292,11 +292,11 @@ static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return HandleErrors(); } - CppOwnedPyObject *CacheFileObj = - CppOwnedPyObject_NEW(0,&PyCacheFile_Type, Cache); + CppPyObject *CacheFileObj = + CppPyObject_NEW(0,&PyCacheFile_Type, Cache); - CppOwnedPyObject *CacheObj = - CppOwnedPyObject_NEW(CacheFileObj,type, + CppPyObject *CacheObj = + CppPyObject_NEW(CacheFileObj,type, (pkgCache *)(*Cache)); // Do not delete the pointer to the pkgCache, it is managed by pkgCacheFile. @@ -317,10 +317,10 @@ PyTypeObject PyCache_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Cache", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -339,8 +339,8 @@ PyTypeObject PyCache_Type = Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), doc_PkgCache, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -364,10 +364,10 @@ PyTypeObject PyCacheFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "pkgCacheFile", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -418,7 +418,7 @@ static PyObject *PkgListItem(PyObject *iSelf,Py_ssize_t Index) } } - return CppOwnedPyObject_NEW(GetOwner(iSelf),&PyPackage_Type, + return CppPyObject_NEW(GetOwner(iSelf),&PyPackage_Type, Self.Iter); } @@ -437,10 +437,10 @@ PyTypeObject PyPackageList_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageList", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -457,8 +457,8 @@ PyTypeObject PyPackageList_Type = 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags 0, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear }; #define Owner (GetOwner(Self)) @@ -470,7 +470,7 @@ PyTypeObject PyPackageList_Type = MkGet(PackageGetName,PyString_FromString(Pkg.Name())) MkGet(PackageGetSection,Safe_FromString(Pkg.Section())) -MkGet(PackageGetRevDependsList,CppOwnedPyObject_NEW(Owner, +MkGet(PackageGetRevDependsList,CppPyObject_NEW(Owner, &PyDependencyList_Type, Pkg.RevDependsList())) MkGet(PackageGetProvidesList,CreateProvides(Owner,Pkg.ProvidesList())) MkGet(PackageGetSelectedState,Py_BuildValue("i",Pkg->SelectedState)) @@ -493,7 +493,7 @@ static PyObject *PackageGetVersionList(PyObject *Self,void*) for (pkgCache::VerIterator I = Pkg.VersionList(); I.end() == false; I++) { PyObject *Obj; - Obj = CppOwnedPyObject_NEW(Owner,&PyVersion_Type,I); + Obj = CppPyObject_NEW(Owner,&PyVersion_Type,I); PyList_Append(List,Obj); Py_DECREF(Obj); } @@ -508,7 +508,7 @@ static PyObject *PackageGetCurrentVer(PyObject *Self,void*) Py_INCREF(Py_None); return Py_None; } - return CppOwnedPyObject_NEW(Owner,&PyVersion_Type, + return CppPyObject_NEW(Owner,&PyVersion_Type, Pkg.CurrentVer()); } @@ -558,10 +558,10 @@ PyTypeObject PyPackage_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Package", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -578,8 +578,8 @@ PyTypeObject PyPackage_Type = 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "Package Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear,// tp_clear + CppTraverse, // tp_traverse + CppClear,// tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -612,7 +612,7 @@ static PyObject *DescriptionGetFileList(PyObject *Self,void*) { PyObject *DescFile; PyObject *Obj; - DescFile = CppOwnedPyObject_NEW(Owner,&PyPackageFile_Type,I.File()); + DescFile = CppPyObject_NEW(Owner,&PyPackageFile_Type,I.File()); Obj = Py_BuildValue("Nl",DescFile,I.Index()); PyList_Append(List,Obj); Py_DECREF(Obj); @@ -643,10 +643,10 @@ PyTypeObject PyDescription_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Description", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -663,8 +663,8 @@ PyTypeObject PyDescription_Type = 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "apt_pkg.Description Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear,// tp_clear + CppTraverse, // tp_traverse + CppClear,// tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -711,7 +711,7 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, { PyObject *Obj; if (AsObj == true) - Obj = CppOwnedPyObject_NEW(Owner,&PyDependency_Type, + Obj = CppPyObject_NEW(Owner,&PyDependency_Type, Start); else { @@ -763,7 +763,7 @@ static PyObject *VersionGetFileList(PyObject *Self, void*) { { PyObject *PkgFile; PyObject *Obj; - PkgFile = CppOwnedPyObject_NEW(Owner,&PyPackageFile_Type,I.File()); + PkgFile = CppPyObject_NEW(Owner,&PyPackageFile_Type,I.File()); Obj = Py_BuildValue("Nl",PkgFile,I.Index()); PyList_Append(List,Obj); Py_DECREF(Obj); @@ -783,7 +783,7 @@ static PyObject *VersionGetDependsList(PyObject *Self, void*) { } static PyObject *VersionGetParentPkg(PyObject *Self, void*) { PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&PyPackage_Type, + return CppPyObject_NEW(Owner,&PyPackage_Type, Version_GetVer(Self).ParentPkg()); } static PyObject *VersionGetProvidesList(PyObject *Self, void*) { @@ -814,7 +814,7 @@ static PyObject *VersionGetDownloadable(PyObject *Self, void*) { static PyObject *VersionGetTranslatedDescription(PyObject *Self, void*) { pkgCache::VerIterator &Ver = GetCpp(Self); PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner, + return CppPyObject_NEW(Owner, &PyDescription_Type, Ver.TranslatedDescription()); } @@ -894,10 +894,10 @@ PyTypeObject PyVersion_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Version", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -914,8 +914,8 @@ PyTypeObject PyVersion_Type = 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "Version Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear,// tp_clear + CppTraverse, // tp_traverse + CppClear,// tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -1057,9 +1057,9 @@ static PyGetSetDef PackageFileGetSet[] = { PyTypeObject PyPackageFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageFile", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -1076,8 +1076,8 @@ PyTypeObject PyPackageFile_Type = { 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "apt_pkg.PackageFile Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -1113,7 +1113,7 @@ static PyObject *DepSmartTargetPkg(PyObject *Self,PyObject *Args) return Py_None; } - return CppOwnedPyObject_NEW(Owner,&PyPackage_Type,P); + return CppPyObject_NEW(Owner,&PyPackage_Type,P); } static PyObject *DepAllTargets(PyObject *Self,PyObject *Args) @@ -1129,7 +1129,7 @@ static PyObject *DepAllTargets(PyObject *Self,PyObject *Args) for (pkgCache::Version **I = Vers; *I != 0; I++) { PyObject *Obj; - Obj = CppOwnedPyObject_NEW(Owner,&PyVersion_Type, + Obj = CppPyObject_NEW(Owner,&PyVersion_Type, pkgCache::VerIterator(*Dep.Cache(),*I)); PyList_Append(List,Obj); Py_DECREF(Obj); @@ -1163,7 +1163,7 @@ static PyObject *DependencyGetTargetPkg(PyObject *Self,void*) { pkgCache::DepIterator &Dep = GetCpp(Self); PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&PyPackage_Type, + return CppPyObject_NEW(Owner,&PyPackage_Type, Dep.TargetPkg()); } @@ -1171,7 +1171,7 @@ static PyObject *DependencyGetParentVer(PyObject *Self,void*) { pkgCache::DepIterator &Dep = GetCpp(Self); PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&PyVersion_Type, + return CppPyObject_NEW(Owner,&PyVersion_Type, Dep.ParentVer()); } @@ -1179,7 +1179,7 @@ static PyObject *DependencyGetParentPkg(PyObject *Self,void*) { pkgCache::DepIterator &Dep = GetCpp(Self); PyObject *Owner = GetOwner(Self); - return CppOwnedPyObject_NEW(Owner,&PyPackage_Type, + return CppPyObject_NEW(Owner,&PyPackage_Type, Dep.ParentPkg()); } @@ -1240,10 +1240,10 @@ PyTypeObject PyDependency_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Dependency", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -1260,8 +1260,8 @@ PyTypeObject PyDependency_Type = 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "Dependency Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -1306,7 +1306,7 @@ static PyObject *RDepListItem(PyObject *iSelf,Py_ssize_t Index) } } - return CppOwnedPyObject_NEW(GetOwner(iSelf), + return CppPyObject_NEW(GetOwner(iSelf), &PyDependency_Type,Self.Iter); } @@ -1325,10 +1325,10 @@ PyTypeObject PyDependencyList_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.DependencyList", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -1345,8 +1345,8 @@ PyTypeObject PyDependencyList_Type = 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "DependencyList Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear }; /*}}}*/ diff --git a/python/cdrom.cc b/python/cdrom.cc index 4195c9cb..0b9ae578 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -109,7 +109,7 @@ static PyMethodDef cdrom_methods[] = { static PyObject *cdrom_new(PyTypeObject *type,PyObject *Args,PyObject *kwds) { - return CppPyObject_NEW(type); + return CppPyObject_NEW(NULL, type); } static char *cdrom_doc = diff --git a/python/configuration.cc b/python/configuration.cc index b2367c3e..0cad8db3 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -137,7 +137,7 @@ static PyObject *CnfSubTree(PyObject *Self,PyObject *Args) return 0; } - return CppOwnedPyObject_NEW(Self,&PyConfiguration_Type, + return CppPyObject_NEW(Self,&PyConfiguration_Type, new Configuration(Itm)); } @@ -473,7 +473,7 @@ static PyObject *CnfNew(PyTypeObject *type, PyObject *args, PyObject *kwds) { char *kwlist[] = {NULL}; if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) return 0; - return CppOwnedPyObject_NEW(NULL, type, new Configuration()); + return CppPyObject_NEW(NULL, type, new Configuration()); } // Type for a Normal Configuration object @@ -483,10 +483,10 @@ PyTypeObject PyConfiguration_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Configuration", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/depcache.cc b/python/depcache.cc index e78b9f4e..53459c32 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -219,7 +219,7 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) Py_INCREF(Py_None); return Py_None; } - CandidateObj = CppOwnedPyObject_NEW(PackageObj,&PyVersion_Type,I); + CandidateObj = CppPyObject_NEW(PackageObj,&PyVersion_Type,I); return CandidateObj; } @@ -625,8 +625,8 @@ static PyObject *PkgDepCacheGetPolicy(PyObject *Self,void*) { PyObject *Owner = GetOwner(Self); pkgDepCache *DepCache = GetCpp(Self); pkgPolicy *Policy = (pkgPolicy *)&DepCache->GetPolicy(); - CppOwnedPyObject *PyPolicy = - CppOwnedPyObject_NEW(Owner,&PyPolicy_Type,Policy); + CppPyObject *PyPolicy = + CppPyObject_NEW(Owner,&PyPolicy_Type,Policy); // Policy should not be deleted, it is managed by CacheFile. PyPolicy->NoDelete = true; return PyPolicy; @@ -668,8 +668,8 @@ static PyObject *PkgDepCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds // and now the depcache pkgDepCache *depcache = (pkgDepCache *)(*CacheF); - CppOwnedPyObject *DepCachePyObj; - DepCachePyObj = CppOwnedPyObject_NEW(Owner,type,depcache); + CppPyObject *DepCachePyObj; + DepCachePyObj = CppPyObject_NEW(Owner,type,depcache); // Do not delete the underlying pointer, it is managed by the cachefile. DepCachePyObj->NoDelete = true; @@ -684,10 +684,10 @@ PyTypeObject PyDepCache_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.DepCache", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -706,8 +706,8 @@ PyTypeObject PyDepCache_Type = Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), doc_PkgDepCache, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -751,8 +751,8 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec pkgDepCache *depcache = GetCpp(Owner); pkgProblemResolver *fixer = new pkgProblemResolver(depcache); - CppOwnedPyObject *PkgProblemResolverPyObj; - PkgProblemResolverPyObj = CppOwnedPyObject_NEW(Owner, + CppPyObject *PkgProblemResolverPyObj; + PkgProblemResolverPyObj = CppPyObject_NEW(Owner, type, fixer); HandleErrors(PkgProblemResolverPyObj); @@ -871,10 +871,10 @@ PyTypeObject PyProblemResolver_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ProblemResolver", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr,// tp_dealloc + CppDeallocPtr,// tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -893,8 +893,8 @@ PyTypeObject PyProblemResolver_Type = Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), "ProblemResolver Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -959,8 +959,8 @@ static PyObject *PkgActionGroupNew(PyTypeObject *type,PyObject *Args,PyObject *k pkgDepCache *depcache = GetCpp(Owner); pkgDepCache::ActionGroup *group = new pkgDepCache::ActionGroup(*depcache); - CppOwnedPyObject *PkgActionGroupPyObj; - PkgActionGroupPyObj = CppOwnedPyObject_NEW(Owner, + CppPyObject *PkgActionGroupPyObj; + PkgActionGroupPyObj = CppPyObject_NEW(Owner, type, group); HandleErrors(PkgActionGroupPyObj); @@ -987,10 +987,10 @@ PyTypeObject PyActionGroup_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.ActionGroup", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -1009,8 +1009,8 @@ PyTypeObject PyActionGroup_Type = Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), doc_PkgActionGroup, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/generic.h b/python/generic.h index d5d6e9fb..2b413a02 100644 --- a/python/generic.h +++ b/python/generic.h @@ -111,13 +111,17 @@ template struct CppPyObject : public PyObject // However if T doesn't have a default c'tor C++ doesn't generate one for // CppPyObject (since it can't know how it should initialize Object). // - // This causes problems then in CppOwnedPyObject, for which C++ can't create + // This causes problems then in CppPyObject, for which C++ can't create // a c'tor that calls the base class c'tor (which causes a compilation // error). // So basically having the c'tor here removes the need for T to have a // default c'tor, which is not always desireable. CppPyObject() { }; + // The owner of the object. The object keeps a reference to it during its + // lifetime. + PyObject *Owner; + // Flag which causes the underlying object to not be deleted. bool NoDelete; @@ -125,11 +129,6 @@ template struct CppPyObject : public PyObject T Object; }; -template struct CppOwnedPyObject : public CppPyObject -{ - PyObject *Owner; -}; - template inline T &GetCpp(PyObject *Obj) { @@ -139,121 +138,73 @@ inline T &GetCpp(PyObject *Obj) template inline PyObject *GetOwner(PyObject *Obj) { - return ((CppOwnedPyObject *)Obj)->Owner; + return ((CppPyObject *)Obj)->Owner; } -// Generic 'new' functions -template -inline CppPyObject *CppPyObject_NEW(PyTypeObject *Type) -{ - #ifdef ALLOC_DEBUG - std::cerr << "=== ALLOCATING " << Type->tp_name << " ===\n"; - #endif - CppPyObject *New = (CppPyObject*)Type->tp_alloc(Type, 0); - new (&New->Object) T; - return New; -} - -template -inline CppPyObject *CppPyObject_NEW(PyTypeObject *Type,A const &Arg) -{ - #ifdef ALLOC_DEBUG - std::cerr << "=== ALLOCATING " << Type->tp_name << " ===\n"; - #endif - CppPyObject *New = (CppPyObject*)Type->tp_alloc(Type, 0); - new (&New->Object) T(Arg); - return New; -} template -inline CppOwnedPyObject *CppOwnedPyObject_NEW(PyObject *Owner, - PyTypeObject *Type) +inline CppPyObject *CppPyObject_NEW(PyObject *Owner,PyTypeObject *Type) { #ifdef ALLOC_DEBUG std::cerr << "=== ALLOCATING " << Type->tp_name << "+ ===\n"; #endif - CppOwnedPyObject *New = (CppOwnedPyObject*)Type->tp_alloc(Type, 0); + CppPyObject *New = (CppPyObject*)Type->tp_alloc(Type, 0); new (&New->Object) T; New->Owner = Owner; Py_XINCREF(Owner); return New; } -template -inline CppOwnedPyObject *CppOwnedPyObject_NEW(PyObject *Owner, - PyTypeObject *Type,A const &Arg) +template +inline CppPyObject *CppPyObject_NEW(PyObject *Owner, PyTypeObject *Type,T const &Arg) { #ifdef ALLOC_DEBUG std::cerr << "=== ALLOCATING " << Type->tp_name << "+ ===\n"; #endif - CppOwnedPyObject *New = (CppOwnedPyObject*)Type->tp_alloc(Type, 0); + CppPyObject *New = (CppPyObject*)Type->tp_alloc(Type, 0); new (&New->Object) T(Arg); New->Owner = Owner; Py_XINCREF(Owner); return New; } -// Traversal and Clean for owned objects +// Traversal and Clean for objects template -int CppOwnedTraverse(PyObject *self, visitproc visit, void* arg) { - Py_VISIT(((CppOwnedPyObject *)self)->Owner); +int CppTraverse(PyObject *self, visitproc visit, void* arg) { + Py_VISIT(((CppPyObject *)self)->Owner); return 0; } template -int CppOwnedClear(PyObject *self) { - Py_CLEAR(((CppOwnedPyObject *)self)->Owner); +int CppClear(PyObject *self) { + Py_CLEAR(((CppPyObject *)self)->Owner); return 0; } -// Generic Dealloc type functions template -void CppDealloc(PyObject *Obj) -{ - #ifdef ALLOC_DEBUG - std::cerr << "=== DEALLOCATING " << Obj->ob_type->tp_name << " ===\n"; - #endif - if (!((CppPyObject*)Obj)->NoDelete) - GetCpp(Obj).~T(); - Obj->ob_type->tp_free(Obj); -} - -template -void CppOwnedDealloc(PyObject *iObj) +void CppDealloc(PyObject *iObj) { #ifdef ALLOC_DEBUG std::cerr << "=== DEALLOCATING " << iObj->ob_type->tp_name << "+ ===\n"; #endif - CppOwnedPyObject *Obj = (CppOwnedPyObject *)iObj; + CppPyObject *Obj = (CppPyObject *)iObj; if (!((CppPyObject*)Obj)->NoDelete) Obj->Object.~T(); - CppOwnedClear(iObj); + CppClear(iObj); iObj->ob_type->tp_free(iObj); } -// Pointer deallocation -// Generic Dealloc type functions -template -void CppDeallocPtr(PyObject *Obj) -{ - #ifdef ALLOC_DEBUG - std::cerr << "=== DEALLOCATING " << Obj->ob_type->tp_name << "* ===\n"; - #endif - if (!((CppPyObject*)Obj)->NoDelete) - delete GetCpp(Obj); - Obj->ob_type->tp_free(Obj); -} template -void CppOwnedDeallocPtr(PyObject *iObj) +void CppDeallocPtr(PyObject *iObj) { #ifdef ALLOC_DEBUG std::cerr << "=== DEALLOCATING " << iObj->ob_type->tp_name << "*+ ===\n"; #endif - CppOwnedPyObject *Obj = (CppOwnedPyObject *)iObj; + CppPyObject *Obj = (CppPyObject *)iObj; if (!((CppPyObject*)Obj)->NoDelete) delete Obj->Object; - CppOwnedClear(iObj); + CppClear(iObj); iObj->ob_type->tp_free(iObj); } diff --git a/python/hashes.cc b/python/hashes.cc index 0086c17a..d0b0fb0c 100644 --- a/python/hashes.cc +++ b/python/hashes.cc @@ -25,7 +25,7 @@ static PyObject *hashes_new(PyTypeObject *type,PyObject *args, PyObject *kwds) { - return CppPyObject_NEW(type); + return CppPyObject_NEW(NULL, type); } static int hashes_init(PyObject *self, PyObject *args, PyObject *kwds) diff --git a/python/hashstring.cc b/python/hashstring.cc index 90c80e4c..d4b7a3b2 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -31,7 +31,7 @@ static PyObject *hashstring_new(PyTypeObject *type,PyObject *Args, if (PyArg_ParseTupleAndKeywords(Args, kwds, "s|s:__new__", kwlist, &Type, &Hash) == 0) return 0; - CppPyObject *PyObj = CppPyObject_NEW(type); + CppPyObject *PyObj = CppPyObject_NEW(NULL, type); if (Hash) PyObj->Object = new HashString(Type,Hash); else // Type is the combined form now (i.e. type:hash) diff --git a/python/indexfile.cc b/python/indexfile.cc index 7accaa50..e8df9cf2 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -91,11 +91,11 @@ PyTypeObject PyIndexFile_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.IndexFile", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods // Not ..Ptr, because the pointer is managed somewhere else. - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -112,8 +112,8 @@ PyTypeObject PyIndexFile_Type = 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags "IndexFile Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/indexrecords.cc b/python/indexrecords.cc index 2d21362d..5750bf6b 100644 --- a/python/indexrecords.cc +++ b/python/indexrecords.cc @@ -30,7 +30,7 @@ static PyObject *indexrecords_new(PyTypeObject *type,PyObject *Args, if (PyArg_ParseTupleAndKeywords(Args, kwds, "", kwlist) == 0) return 0; indexRecords *records = new indexRecords(); - CppPyObject *New = CppPyObject_NEW(type, + CppPyObject *New = CppPyObject_NEW(NULL, type, records); return New; } diff --git a/python/metaindex.cc b/python/metaindex.cc index 2c5b0bd9..dee54521 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -37,8 +37,8 @@ static PyObject *MetaIndexGetIndexFiles(PyObject *Self,void*) { for (vector::const_iterator I = indexFiles->begin(); I != indexFiles->end(); I++) { - CppOwnedPyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self, &PyIndexFile_Type,*I); + CppPyObject *Obj; + Obj = CppPyObject_NEW(Self, &PyIndexFile_Type,*I); // Do not delete pkgIndexFile*, they are managed by metaIndex. Obj->NoDelete = true; PyList_Append(List,Obj); @@ -76,10 +76,10 @@ PyTypeObject PyMetaIndex_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.MetaIndex", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 58f2aaec..9b4a9ab7 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -31,7 +31,7 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) pkgPackageManager *pm = _system->CreatePM(GetCpp(Owner)); CppPyObject *PkgManagerObj = - CppPyObject_NEW(type,pm); + CppPyObject_NEW(NULL, type,pm); return PkgManagerObj; } diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index d34ba0d2..1e43b2e8 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -157,7 +157,7 @@ static PyObject *PkgRecordsNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) &Owner) == 0) return 0; - return HandleErrors(CppOwnedPyObject_NEW(Owner,type, + return HandleErrors(CppPyObject_NEW(Owner,type, GetCpp(Owner))); } @@ -165,10 +165,10 @@ PyTypeObject PyPackageRecords_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.PackageRecords", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -187,8 +187,8 @@ PyTypeObject PyPackageRecords_Type = Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), "Records Object", // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 0b54c2fe..41ee6276 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -123,8 +123,8 @@ static PyObject *PkgSrcRecordsGetIndex(PyObject *Self,void*) { if (Struct.Last == 0) return 0; const pkgIndexFile &tmp = Struct.Last->Index(); - CppOwnedPyObject *PyObj; - PyObj = CppOwnedPyObject_NEW(Self,&PyIndexFile_Type, + CppPyObject *PyObj; + PyObj = CppPyObject_NEW(Self,&PyIndexFile_Type, (pkgIndexFile*)&tmp); // Do not delete the pkgIndexFile*, it is managed by PkgSrcRecords::Parser. PyObj->NoDelete=true; @@ -252,7 +252,7 @@ static PyObject *PkgSrcRecordsNew(PyTypeObject *type,PyObject *args,PyObject *kw if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) return 0; - return HandleErrors(CppPyObject_NEW(type)); + return HandleErrors(CppPyObject_NEW(NULL, type)); } PyTypeObject PySourceRecords_Type = @@ -310,6 +310,6 @@ PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) if (PyArg_ParseTuple(Args,"") == 0) return 0; - return HandleErrors(CppPyObject_NEW(&PySourceRecords_Type)); + return HandleErrors(CppPyObject_NEW(NULL, &PySourceRecords_Type)); } #endif diff --git a/python/policy.cc b/python/policy.cc index 80670267..3e1ec589 100644 --- a/python/policy.cc +++ b/python/policy.cc @@ -34,7 +34,7 @@ static PyObject *policy_new(PyTypeObject *type,PyObject *Args, return 0; } pkgPolicy *policy = new pkgPolicy(GetCpp(cache)); - return CppOwnedPyObject_NEW(cache,&PyPolicy_Type,policy); + return CppPyObject_NEW(cache,&PyPolicy_Type,policy); } static char *policy_get_priority_doc = "get_priority(package: apt_pkg.Package)" @@ -61,7 +61,7 @@ PyObject *policy_get_candidate_ver(PyObject *self, PyObject *arg) { pkgPolicy *policy = GetCpp(self); pkgCache::PkgIterator pkg = GetCpp(arg); pkgCache::VerIterator ver = policy->GetCandidateVer(pkg); - return CppOwnedPyObject_NEW(arg,&PyVersion_Type, + return CppPyObject_NEW(arg,&PyVersion_Type, ver); } else { PyErr_SetString(PyExc_TypeError,"Argument must be of Package()."); @@ -81,7 +81,7 @@ static PyObject *policy_get_match(PyObject *self, PyObject *arg) { pkgPolicy *policy = GetCpp(self); pkgCache::PkgIterator pkg = GetCpp(arg); pkgCache::VerIterator ver = policy->GetMatch(pkg); - return CppOwnedPyObject_NEW(arg,&PyVersion_Type,ver); + return CppPyObject_NEW(arg,&PyVersion_Type,ver); } static char *policy_read_pinfile_doc = "read_pinfile(filename: str) -> bool\n\n" @@ -163,10 +163,10 @@ static char *policy_doc = "Policy(cache)\n\n" PyTypeObject PyPolicy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_pkg.Policy", // tp_name - sizeof(CppOwnedPyObject),// tp_basicsize + sizeof(CppPyObject),// tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDeallocPtr, // tp_dealloc + CppDeallocPtr, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -185,8 +185,8 @@ PyTypeObject PyPolicy_Type = { Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), policy_doc, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/python-apt.h b/python/python-apt.h index f8c21adc..6f688c93 100644 --- a/python/python-apt.h +++ b/python/python-apt.h @@ -218,22 +218,11 @@ static int import_apt_pkg(void) { # define PyTagSection_ToCpp GetCpp # define PyVersion_ToCpp GetCpp -// Python object creation, using two inline template functions and one variadic -// macro per type. +// Template using a simpler version of from cpp template -inline CppPyObject *FromCpp(PyTypeObject *pytype, Cpp obj, - bool Delete=false) +inline CppPyObject *FromCpp(PyTypeObject *pytype, Cpp const &obj, bool Delete=false, PyObject *Owner=NULL) { - CppPyObject *Obj = CppPyObject_NEW(pytype, obj); - Obj->NoDelete = (!Delete); - return Obj; -} - -template -inline CppOwnedPyObject *FromCppOwned(PyTypeObject *pytype, Cpp const &obj, - bool Delete=false, PyObject *Owner=NULL) -{ - CppOwnedPyObject *Obj = CppOwnedPyObject_NEW(Owner, pytype, obj); + CppPyObject *Obj = CppPyObject_NEW(Owner, pytype, obj); Obj->NoDelete = (!Delete); return Obj; } @@ -241,34 +230,34 @@ inline CppOwnedPyObject *FromCppOwned(PyTypeObject *pytype, Cpp const &obj, # ifndef APT_PKGMODULE_H # define PyAcquire_FromCpp _PyAptPkg_API->acquire_fromcpp #endif -# define PyAcquireFile_FromCpp(...) FromCppOwned(&PyAcquireFile_Type, ##__VA_ARGS__) -# define PyAcquireItem_FromCpp(...) FromCppOwned(&PyAcquireItem_Type,##__VA_ARGS__) -# define PyAcquireItemDesc_FromCpp(...) FromCppOwned(&PyAcquireItemDesc_Type,##__VA_ARGS__) -# define PyAcquireWorker_FromCpp(...) FromCppOwned(&PyAcquireWorker_Type,##__VA_ARGS__) -# define PyActionGroup_FromCpp(...) FromCppOwned(&PyActionGroup_Type,##__VA_ARGS__) -# define PyCache_FromCpp(...) FromCppOwned(&PyCache_Type,##__VA_ARGS__) +# define PyAcquireFile_FromCpp(...) FromCpp(&PyAcquireFile_Type, ##__VA_ARGS__) +# define PyAcquireItem_FromCpp(...) FromCpp(&PyAcquireItem_Type,##__VA_ARGS__) +# define PyAcquireItemDesc_FromCpp(...) FromCpp(&PyAcquireItemDesc_Type,##__VA_ARGS__) +# define PyAcquireWorker_FromCpp(...) FromCpp(&PyAcquireWorker_Type,##__VA_ARGS__) +# define PyActionGroup_FromCpp(...) FromCpp(&PyActionGroup_Type,##__VA_ARGS__) +# define PyCache_FromCpp(...) FromCpp(&PyCache_Type,##__VA_ARGS__) # define PyCacheFile_FromCpp(...) FromCpp(&PyCacheFile_Type,##__VA_ARGS__) # define PyCdrom_FromCpp(...) FromCpp(&PyCdrom_Type,##__VA_ARGS__) -# define PyConfiguration_FromCpp(...) FromCppOwned(&PyConfiguration_Type, ##__VA_ARGS__) -# define PyDepCache_FromCpp(...) FromCppOwned(&PyDepCache_Type,##__VA_ARGS__) -# define PyDependency_FromCpp(...) FromCppOwned(&PyDependency_Type,##__VA_ARGS__) -//# define PyDependencyList_FromCpp(...) FromCppOwned(&PyDependencyList_Type,##__VA_ARGS__) -# define PyDescription_FromCpp(...) FromCppOwned(&PyDescription_Type,##__VA_ARGS__) +# define PyConfiguration_FromCpp(...) FromCpp(&PyConfiguration_Type, ##__VA_ARGS__) +# define PyDepCache_FromCpp(...) FromCpp(&PyDepCache_Type,##__VA_ARGS__) +# define PyDependency_FromCpp(...) FromCpp(&PyDependency_Type,##__VA_ARGS__) +//# define PyDependencyList_FromCpp(...) FromCpp(&PyDependencyList_Type,##__VA_ARGS__) +# define PyDescription_FromCpp(...) FromCpp(&PyDescription_Type,##__VA_ARGS__) # define PyHashes_FromCpp(...) FromCpp(&PyHashes_Type,##__VA_ARGS__) # define PyHashString_FromCpp(...) FromCpp(&PyHashString_Type,##__VA_ARGS__) # define PyIndexRecords_FromCpp(...) FromCpp(&PyIndexRecords_Type,##__VA_ARGS__) -# define PyMetaIndex_FromCpp(...) FromCppOwned(&PyMetaIndex_Type,##__VA_ARGS__) -# define PyPackage_FromCpp(...) FromCppOwned(&PyPackage_Type,##__VA_ARGS__) -# define PyIndexFile_FromCpp(...) FromCppOwned(&PyIndexFile_Type,##__VA_ARGS__) -# define PyPackageFile_FromCpp(...) FromCppOwned(&PyPackageFile_Type,##__VA_ARGS__) -//# define PyPackageList_FromCpp(...) FromCppOwned(&PyPackageList_Type,##__VA_ARGS__) +# define PyMetaIndex_FromCpp(...) FromCpp(&PyMetaIndex_Type,##__VA_ARGS__) +# define PyPackage_FromCpp(...) FromCpp(&PyPackage_Type,##__VA_ARGS__) +# define PyIndexFile_FromCpp(...) FromCpp(&PyIndexFile_Type,##__VA_ARGS__) +# define PyPackageFile_FromCpp(...) FromCpp(&PyPackageFile_Type,##__VA_ARGS__) +//# define PyPackageList_FromCpp(...) FromCpp(&PyPackageList_Type,##__VA_ARGS__) # define PyPackageManager_FromCpp(...) FromCpp(&PyPackageManager_Type,##__VA_ARGS__) -//# define PyPackageRecords_FromCpp(...) FromCppOwned(&PyPackageRecords_Type,##__VA_ARGS__) -# define PyPolicy_FromCpp(...) FromCppOwned(&PyPolicy_Type,##__VA_ARGS__) -# define PyProblemResolver_FromCpp(...) FromCppOwned(&PyProblemResolver_Type,##__VA_ARGS__) +//# define PyPackageRecords_FromCpp(...) FromCpp(&PyPackageRecords_Type,##__VA_ARGS__) +# define PyPolicy_FromCpp(...) FromCpp(&PyPolicy_Type,##__VA_ARGS__) +# define PyProblemResolver_FromCpp(...) FromCpp(&PyProblemResolver_Type,##__VA_ARGS__) # define PySourceList_FromCpp(...) FromCpp(&PySourceList_Type,##__VA_ARGS__) //# define PySourceRecords_FromCpp(...) FromCpp(&PySourceRecords_Type,##__VA_ARGS__) -# define PyTagFile_FromCpp(...) FromCppOwned(&PyTagFile_Type,##__VA_ARGS__) -# define PyTagSection_FromCpp(...) FromCppOwned(&PyTagSection_Type,##__VA_ARGS__) -# define PyVersion_FromCpp(...) FromCppOwned(&PyVersion_Type,##__VA_ARGS__) +# define PyTagFile_FromCpp(...) FromCpp(&PyTagFile_Type,##__VA_ARGS__) +# define PyTagSection_FromCpp(...) FromCpp(&PyTagSection_Type,##__VA_ARGS__) +# define PyVersion_FromCpp(...) FromCpp(&PyVersion_Type,##__VA_ARGS__) #endif diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 52c0e6a8..b705d8b8 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -26,7 +26,7 @@ static PyObject *PkgSourceListFindIndex(PyObject *Self,PyObject *Args) { pkgSourceList *list = GetCpp(Self); PyObject *pyPkgFileIter; - CppOwnedPyObject *pyPkgIndexFile; + CppPyObject *pyPkgIndexFile; if (PyArg_ParseTuple(Args, "O!", &PyPackageFile_Type,&pyPkgFileIter) == 0) return 0; @@ -35,7 +35,7 @@ static PyObject *PkgSourceListFindIndex(PyObject *Self,PyObject *Args) pkgIndexFile *index; if(list->FindIndex(i, index)) { - pyPkgIndexFile = CppOwnedPyObject_NEW(pyPkgFileIter,&PyIndexFile_Type,index); + pyPkgIndexFile = CppPyObject_NEW(pyPkgFileIter,&PyIndexFile_Type,index); // Do not delete the pkgIndexFile*, it is managed by pkgSourceList. pyPkgIndexFile->NoDelete = true; return pyPkgIndexFile; @@ -92,8 +92,8 @@ static PyObject *PkgSourceListGetList(PyObject *Self,void*) for (vector::const_iterator I = list->begin(); I != list->end(); I++) { - CppOwnedPyObject *Obj; - Obj = CppOwnedPyObject_NEW(Self, &PyMetaIndex_Type,*I); + CppPyObject *Obj; + Obj = CppPyObject_NEW(Self, &PyMetaIndex_Type,*I); // Never delete metaIndex*, they are managed by the pkgSourceList. Obj->NoDelete = true; PyList_Append(List,Obj); @@ -115,7 +115,7 @@ static PyObject *PkgSourceListNew(PyTypeObject *type,PyObject *args,PyObject *kw char *kwlist[] = {0}; if (PyArg_ParseTupleAndKeywords(args,kwds,"",kwlist) == 0) return 0; - return CppPyObject_NEW(type,new pkgSourceList()); + return CppPyObject_NEW(NULL, type,new pkgSourceList()); } PyTypeObject PySourceList_Type = diff --git a/python/tag.cc b/python/tag.cc index b1a3e520..2aaf3beb 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -34,13 +34,13 @@ using namespace std; /*}}}*/ /* We need to keep a private copy of the data.. */ -struct TagSecData : public CppOwnedPyObject +struct TagSecData : public CppPyObject { char *Data; }; // The owner of the TagFile is a Python file object. -struct TagFileData : public CppOwnedPyObject +struct TagFileData : public CppPyObject { TagSecData *Section; FileFd Fd; @@ -68,7 +68,7 @@ void TagSecFree(PyObject *Obj) { TagSecData *Self = (TagSecData *)Obj; delete [] Self->Data; - CppOwnedDealloc(Obj); + CppDealloc(Obj); } /*}}}*/ // TagFileFree - Free a Tag File /*{{{*/ @@ -488,8 +488,8 @@ PyTypeObject PyTagSection_Type = Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC), doc_TagSec, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter diff --git a/python/tarfile.cc b/python/tarfile.cc index 775ae22e..aa9a39f6 100644 --- a/python/tarfile.cc +++ b/python/tarfile.cc @@ -102,8 +102,8 @@ bool PyDirStream::FinishedFile(Item &Itm,int Fd) return true; // The current member and data. - CppOwnedPyObject *py_member; - py_member = CppOwnedPyObject_NEW(0, &PyTarMember_Type); + CppPyObject *py_member; + py_member = CppPyObject_NEW(0, &PyTarMember_Type); // Clone our object, including the strings in it. py_member->Object = Itm; py_member->Object.Name = new char[strlen(Itm.Name)+1]; @@ -121,7 +121,7 @@ void tarmember_dealloc(PyObject *self) { // We cloned those strings, delete them again. delete[] GetCpp(self).Name; delete[] GetCpp(self).LinkTarget; - CppOwnedDealloc(self); + CppDealloc(self); } // The tarfile.TarInfo interface for our TarMember class. @@ -269,7 +269,7 @@ static const char *tarmember_doc = PyTypeObject PyTarMember_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "apt_inst.TarMember", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods tarmember_dealloc, // tp_dealloc @@ -290,8 +290,8 @@ PyTypeObject PyTarMember_Type = { Py_TPFLAGS_DEFAULT | // tp_flags Py_TPFLAGS_HAVE_GC, tarmember_doc, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter @@ -318,7 +318,7 @@ static PyObject *tarfile_new(PyTypeObject *type,PyObject *args,PyObject *kwds) &max,&comp) == 0) return 0; - self = (PyTarFileObject*)CppOwnedPyObject_NEW(file,type); + self = (PyTarFileObject*)CppPyObject_NEW(file,type); // We receive a filename. if ((filename = (char*)PyObject_AsString(file))) @@ -450,7 +450,7 @@ PyTypeObject PyTarFile_Type = { sizeof(PyTarFileObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print 0, // tp_getattr 0, // tp_setattr @@ -468,8 +468,8 @@ PyTypeObject PyTarFile_Type = { Py_TPFLAGS_DEFAULT | // tp_flags Py_TPFLAGS_HAVE_GC, tarfile_doc, // tp_doc - CppOwnedTraverse, // tp_traverse - CppOwnedClear, // tp_clear + CppTraverse, // tp_traverse + CppClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset 0, // tp_iter -- cgit v1.2.3 From 748f5005026e2698c7e9ff7e98f6a7799567c60e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 27 Jan 2010 17:45:22 +0100 Subject: Remove inline functions from the C++ API, export them instead (part 1) --- debian/changelog | 1 + python/apt_pkgmodule.cc | 35 +++++- python/apt_pkgmodule.h | 36 ++++++- python/python-apt.h | 276 ++++++++++++++++++++++++++++++------------------ 4 files changed, 245 insertions(+), 103 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 08bf564b..f3cea5b3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low to work. A replacement will be added once destruction callbacks are added in APT. * Merge the CppOwnedPyObject C++ class into CppPyObject. + * Remove inline functions from the C++ API, export them instead. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e77fd3ca..d2472395 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -527,36 +527,67 @@ static PyMethodDef methods[] = static struct _PyAptPkgAPIStruct API = { &PyAcquire_Type, // acquire_type &PyAcquire_FromCpp, // acquire_fromcpp + &PyAcquire_ToCpp, // acquire_tocpp &PyAcquireFile_Type, // acquirefile_type + &PyAcquireFile_ToCpp, // acquirefile_tocpp &PyAcquireItem_Type, // acquireitem_type + &PyAcquireItem_ToCpp, // acquireitem_type &PyAcquireItemDesc_Type, // acquireitemdesc_type + &PyAcquireItemDesc_ToCpp, // acquireitemdesc_tocpp &PyAcquireWorker_Type, // acquireworker_type + &PyAcquireWorker_ToCpp, // acquireworker_tocpp &PyActionGroup_Type, // actiongroup_type + &PyActionGroup_ToCpp, // actiongroup_type &PyCache_Type, // cache_type - &PyCacheFile_Type, // cachefile_type + &PyCache_ToCpp, // cache_tocpp + &PyCacheFile_Type, // cachefile_type + &PyCacheFile_ToCpp, // cachefile_tocpp &PyCdrom_Type, // cdrom_type + &PyCdrom_ToCpp, // cdrom_tocpp &PyConfiguration_Type, // configuration_type + &PyConfiguration_ToCpp, // configuration_tocpp &PyDepCache_Type, // depcache_type + &PyDepCache_ToCpp, // depcache_tocpp &PyDependency_Type, // dependency_type + &PyDependency_ToCpp, // dependency_type &PyDependencyList_Type, // dependencylist_type + 0, // FIXME: dependencylist_tocpp &PyDescription_Type, // description_type + &PyDescription_ToCpp, // description_tocpp &PyHashes_Type, // hashes_type + &PyHashes_ToCpp, // hashes_tocpp &PyHashString_Type, // hashstring_type + &PyHashString_ToCpp, // hashstring_tocpp &PyIndexRecords_Type, // indexrecords_type + &PyIndexRecords_ToCpp, // indexrecords_tocpp &PyMetaIndex_Type, // metaindex_type + &PyMetaIndex_ToCpp, // metaindex_tocpp &PyPackage_Type, // package_type + &PyPackage_ToCpp, // package_tocpp &PyPackageFile_Type, // packagefile_type - &PyIndexFile_Type, // packageindexfile_type + &PyPackageFile_ToCpp, // packagefile_tocpp + &PyIndexFile_Type, // packageindexfile_type + &PyIndexFile_ToCpp, // packageindexfile_tocpp &PyPackageList_Type, // packagelist_type + 0, // FIXME: packagelist_tocpp &PyPackageManager_Type, // packagemanager_type + &PyPackageManager_ToCpp, // packagemanager_type &PyPackageRecords_Type, // packagerecords_type + 0, // FIXME: packagerecords_tocpp &PyPolicy_Type, // policy_type + &PyPolicy_ToCpp, // policy_tocpp &PyProblemResolver_Type, // problemresolver_type + &PyProblemResolver_ToCpp, // problemresolver_tocpp &PySourceList_Type, // sourcelist_type + &PySourceList_ToCpp, // sourcelist_tocpp &PySourceRecords_Type, // sourcerecords_type + 0, // sourcerecords_tocpp &PyTagFile_Type, // tagfile_type + &PyTagFile_ToCpp, // tagfile_tocpp &PyTagSection_Type, // tagsection_type + &PyTagSection_ToCpp, // tagsection_tocpp &PyVersion_Type, // version_type + &PyVersion_ToCpp, // version_tocpp }; diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index ec6cf10e..a22a25f0 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -13,6 +13,7 @@ #include #include #include +#include "generic.h" // Configuration Stuff #define Configuration_Check(op) ((op)->ob_type == &PyConfiguration_Type) @@ -122,8 +123,41 @@ extern PyTypeObject PyAcquireWorker_Type; extern PyTypeObject PySystemLock_Type; extern PyTypeObject PyFileLock_Type; +// Functions to be exported in the public API. PyObject *PyAcquire_FromCpp(pkgAcquire *fetcher, bool Delete); -PyObject *PyAcquireItem_FromCpp(pkgAcquire::Item *item, bool Delete, PyObject *owner); +# define PyAcquire_ToCpp GetCpp +# define PyAcquireFile_ToCpp GetCpp +# define PyAcquireItem_ToCpp GetCpp +# define PyAcquireItemDesc_ToCpp GetCpp +# define PyAcquireWorker_ToCpp GetCpp +# define PyActionGroup_ToCpp GetCpp +# define PyCache_ToCpp GetCpp +# define PyCacheFile_ToCpp GetCpp +# define PyCdrom_ToCpp GetCpp +# define PyConfiguration_ToCpp GetCpp +# define PyDepCache_ToCpp GetCpp +# define PyDependency_ToCpp GetCpp +# define PyDependencyList_ToCpp GetCpp // TODO +# define PyDescription_ToCpp GetCpp +# define PyHashes_ToCpp GetCpp +# define PyHashString_ToCpp GetCpp +# define PyIndexRecords_ToCpp GetCpp +# define PyMetaIndex_ToCpp GetCpp +# define PyPackage_ToCpp GetCpp +# define PyPackageFile_ToCpp GetCpp +# define PyIndexFile_ToCpp GetCpp +# define PyPackageList_ToCpp GetCpp // TODO +# define PyPackageManager_ToCpp GetCpp +# define PyPackageRecords_ToCpp GetCpp // TODO +# define PyPolicy_ToCpp GetCpp +# define PyProblemResolver_ToCpp GetCpp +# define PySourceList_ToCpp GetCpp +# define PySourceRecords_ToCpp GetCpp // TODO +# define PyTagFile_ToCpp GetCpp +# define PyTagSection_ToCpp GetCpp +# define PyVersion_ToCpp GetCpp + + #include "python-apt.h" #endif diff --git a/python/python-apt.h b/python/python-apt.h index 6f688c93..7b34c249 100644 --- a/python/python-apt.h +++ b/python/python-apt.h @@ -1,7 +1,7 @@ /* * python-apt.h - Header file for the public interface. * - * Copyright 2009 Julian Andres Klode + * Copyright 2009-2010 Julian Andres Klode * * 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 @@ -23,103 +23,120 @@ #define PYTHON_APT_H #include #include "generic.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef PyObject *ActionGroupF(pkgDepCache::ActionGroup *); +typedef pkgDepCache::ActionGroup*& ActionGroupT(PyObject *self); struct _PyAptPkgAPIStruct { + // apt_pkg.Acquire (pkgAcquire*) PyTypeObject *acquire_type; - PyObject* (*acquire_fromcpp)(pkgAcquire *acquire, bool Delete); + PyObject* (*acquire_fromcpp)(pkgAcquire *acquire, bool Delete); + pkgAcquire*& (*acquire_tocpp)(PyObject *self); + // apt_pkg.AcquireFile PyTypeObject *acquirefile_type; + pkgAcqFile*& (*acquirefile_tocpp)(PyObject *self); + // apt_pkg.AcquireItem PyTypeObject *acquireitem_type; + pkgAcquire::Item*& (*acquireitem_tocpp)(PyObject *self); + // apt_pkg.AcquireItemDesc PyTypeObject *acquireitemdesc_type; + pkgAcquire::ItemDesc*& (*acquireitemdesc_tocpp)(PyObject *self); + PyTypeObject *acquireworker_type; + pkgAcquire::Worker*& (*acquireworker_tocpp)(PyObject *self); + PyTypeObject *actiongroup_type; + pkgDepCache::ActionGroup*& (*actiongroup_tocpp)(PyObject *self); + PyTypeObject *cache_type; + pkgCache*& (*cache_tocpp)(PyObject *self); + PyTypeObject *cachefile_type; + pkgCacheFile*& (*cachefile_tocpp)(PyObject *self); + PyTypeObject *cdrom_type; + pkgCdrom& (*cdrom_tocpp)(PyObject *self); + PyTypeObject *configuration_type; + Configuration*& (*configuration_tocpp)(PyObject *self); + PyTypeObject *depcache_type; + pkgDepCache*& (*depcache_tocpp)(PyObject *self); + PyTypeObject *dependency_type; + pkgCache::DepIterator& (*dependency_tocpp)(PyObject *self); + PyTypeObject *dependencylist_type; + void *dependencylist_tocpp; // FIXME: need packagelist_tocpp + PyTypeObject *description_type; + pkgCache::DescIterator& (*description_tocpp)(PyObject *self); + PyTypeObject *hashes_type; + Hashes& (*hashes_tocpp)(PyObject *self); + PyTypeObject *hashstring_type; + HashString*& (*hashstring_tocpp)(PyObject *self); + PyTypeObject *indexrecords_type; + indexRecords*& (*indexrecords_tocpp)(PyObject *self); + PyTypeObject *metaindex_type; + metaIndex*& (*metaindex_tocpp)(PyObject *self); + PyTypeObject *package_type; + pkgCache::PkgIterator& (*package_tocpp)(PyObject *self); + PyTypeObject *packagefile_type; + pkgCache::PkgFileIterator& (*packagefile_tocpp)(PyObject *self); + PyTypeObject *packageindexfile_type; + pkgIndexFile*& (*packageindexfile_tocpp)(PyObject *self); + PyTypeObject *packagelist_type; + void *packagelist_tocpp; // FIXME: need packagelist_tocpp + PyTypeObject *packagemanager_type; + pkgPackageManager*& (*packagemanager_tocpp)(PyObject *self); + PyTypeObject *packagerecords_type; + void *packagerecords_tocpp; // FIXME: need packagerecords_tocpp + PyTypeObject *policy_type; + pkgPolicy*& (*policy_tocpp)(PyObject *self); + PyTypeObject *problemresolver_type; + pkgProblemResolver*& (*problemresolver_tocpp)(PyObject *self); + PyTypeObject *sourcelist_type; + pkgSourceList*& (*sourcelist_tocpp)(PyObject *self); + PyTypeObject *sourcerecords_type; + void *sourcerecords_tocpp; // FIXME: need sourcerecords_tocpp + PyTypeObject *tagfile_type; + pkgTagFile& (*tagfile_tocpp)(PyObject *self); + PyTypeObject *tagsection_type; + pkgTagSection& (*tagsection_tocpp)(PyObject *self); + PyTypeObject *version_type; + pkgCache::VerIterator& (*version_tocpp)(PyObject *self); }; -# ifndef APT_PKGMODULE_H -# define PyAcquire_Type *(_PyAptPkg_API->acquire_type) -# define PyAcquireFile_Type *(_PyAptPkg_API->acquirefile_type) -# define PyAcquireItem_Type *(_PyAptPkg_API->acquireitem_type) -# define PyAcquireItemDesc_Type *(_PyAptPkg_API->acquireitemdesc_type) -# define PyAcquireWorker_Type *(_PyAptPkg_API->acquireworker_type) -# define PyActionGroup_Type *(_PyAptPkg_API->actiongroup_type) -# define PyCache_Type *(_PyAptPkg_API->cache_type) -# define PyCacheFile_Type *(_PyAptPkg_API->cachefile_type) -# define PyCdrom_Type *(_PyAptPkg_API->cdrom_type) -# define PyConfiguration_Type *(_PyAptPkg_API->configuration_type) -# define PyDepCache_Type *(_PyAptPkg_API->depcache_type) -# define PyDependency_Type *(_PyAptPkg_API->dependency_type) -# define PyDependencyList_Type *(_PyAptPkg_API->dependencylist_type) -# define PyDescription_Type *(_PyAptPkg_API->description_type) -# define PyHashes_Type *(_PyAptPkg_API->hashes_type) -# define PyHashString_Type *(_PyAptPkg_API->hashstring_type) -# define PyIndexRecords_Type *(_PyAptPkg_API->indexrecords_type) -# define PyMetaIndex_Type *(_PyAptPkg_API->metaindex_type) -# define PyPackage_Type *(_PyAptPkg_API->package_type) -# define PyPackageFile_Type *(_PyAptPkg_API->packagefile_type) -# define PyIndexFile_Type *(_PyAptPkg_API->packageindexfile_type) -# define PyPackageList_Type *(_PyAptPkg_API->packagelist_type) -# define PyPackageManager_Type *(_PyAptPkg_API->packagemanager_type) -# define PyPackageRecords_Type *(_PyAptPkg_API->packagerecords_type) -# define PyPolicy_Type *(_PyAptPkg_API->policy_type) -# define PyProblemResolver_Type *(_PyAptPkg_API->problemresolver_type) -# define PySourceList_Type *(_PyAptPkg_API->sourcelist_type) -# define PySourceRecords_Type *(_PyAptPkg_API->sourcerecords_type) -# define PyTagFile_Type *(_PyAptPkg_API->tagfile_type) -# define PyTagSection_Type *(_PyAptPkg_API->tagsection_type) -# define PyVersion_Type *(_PyAptPkg_API->version_type) - -// Creating - -static struct _PyAptPkgAPIStruct *_PyAptPkg_API; - -static int import_apt_pkg(void) { -# if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 - _PyAptPkg_API = (_PyAptPkgAPIStruct *)PyCapsule_Import("apt_pkg._C_API", 0); - return (_PyAptPkg_API != NULL) ? 0 : -1; -# else - - PyObject *module = PyImport_ImportModule("apt_pkg"); - - if (module == NULL) { - return -1; - } - if (module != NULL) { - PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API"); - if (c_api_object == NULL) - return -1; - if (PyCObject_Check(c_api_object)) - _PyAptPkg_API = (struct _PyAptPkgAPIStruct *)PyCObject_AsVoidPtr(c_api_object); - Py_DECREF(c_api_object); - } - return 0; -# endif // PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 -} -# endif // APT_PKGMODULE_H - // Checking macros. # define PyAcquire_Check(op) PyObject_TypeCheck(op, &PyAcquire_Type) # define PyAcquireFile_Check(op) PyObject_TypeCheck(op, &PyAcquireFile_Type) @@ -141,7 +158,7 @@ static int import_apt_pkg(void) { # define PyMetaIndex_Check(op) PyObject_TypeCheck(op, &PyMetaIndex_Type) # define PyPackage_Check(op) PyObject_TypeCheck(op, &PyPackage_Type) # define PyPackageFile_Check(op) PyObject_TypeCheck(op, &PyPackageFile_Type) -# define PyIndexFile_Check(op) PyObject_TypeCheck(op, &PyIndexFile_Type) +# define PyIndexFile_Check(op) PyObject_TypeCheck(op, &PyIndexFile_Type) # define PyPackageList_Check(op) PyObject_TypeCheck(op, &PyPackageList_Type) # define PyPackageManager_Check(op) PyObject_TypeCheck(op, &PyPackageManager_Type) # define PyPackageRecords_Check(op) PyObject_TypeCheck(op, &PyPackageRecords_Type) @@ -173,7 +190,7 @@ static int import_apt_pkg(void) { # define PyMetaIndex_CheckExact(op) (op->op_type == &PyMetaIndex_Type) # define PyPackage_CheckExact(op) (op->op_type == &PyPackage_Type) # define PyPackageFile_CheckExact(op) (op->op_type == &PyPackageFile_Type) -# define PyIndexFile_CheckExact(op) (op->op_type == &PyIndexFile_Type) +# define PyIndexFile_CheckExact(op) (op->op_type == &PyIndexFile_Type) # define PyPackageList_CheckExact(op) (op->op_type == &PyPackageList_Type) # define PyPackageManager_CheckExact(op) (op->op_type == &PyPackageManager_Type) # define PyPackageRecords_CheckExact(op) (op->op_type == &PyPackageRecords_Type) @@ -185,38 +202,98 @@ static int import_apt_pkg(void) { # define PyTagSection_CheckExact(op) (op->op_type == &PyTagSection_Type) # define PyVersion_CheckExact(op) (op->op_type == &PyVersion_Type) -// Get the underlying C++ reference or pointer from the Python object. -# define PyAcquire_ToCpp GetCpp -# define PyAcquireFile_ToCpp GetCpp -# define PyAcquireItem_ToCpp GetCpp -# define PyAcquireItemDesc_ToCpp GetCpp -# define PyAcquireWorker_ToCpp GetCpp -# define PyActionGroup_ToCpp GetCpp -# define PyCache_ToCpp GetCpp -# define PyCacheFile_ToCpp GetCpp -# define PyCdrom_ToCpp GetCpp -# define PyConfiguration_ToCpp GetCpp -# define PyDepCache_ToCpp GetCpp -# define PyDependency_ToCpp GetCpp -//# define PyDependencyList_ToCpp GetCpp // NOT EXPORTED -# define PyDescription_ToCpp GetCpp -# define PyHashes_ToCpp GetCpp -# define PyHashString_ToCpp GetCpp -# define PyIndexRecords_ToCpp GetCpp -# define PyMetaIndex_ToCpp GetCpp -# define PyPackage_ToCpp GetCpp -# define PyPackageFile_ToCpp GetCpp -# define PyIndexFile_ToCpp GetCpp -//# define PyPackageList_ToCpp GetCpp // NOT EXPORTED. -# define PyPackageManager_ToCpp GetCpp -//# define PyPackageRecords_ToCpp GetCpp // NOT EXPORTED -# define PyPolicy_ToCpp GetCpp -# define PyProblemResolver_ToCpp GetCpp -# define PySourceList_ToCpp GetCpp -//# define PySourceRecords_ToCpp GetCpp // NOT EXPORTED -# define PyTagFile_ToCpp GetCpp -# define PyTagSection_ToCpp GetCpp -# define PyVersion_ToCpp GetCpp +# ifndef APT_PKGMODULE_H +static struct _PyAptPkgAPIStruct *_PyAptPkg_API; + +static int import_apt_pkg(void) { +# if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 + _PyAptPkg_API = (_PyAptPkgAPIStruct *)PyCapsule_Import("apt_pkg._C_API", 0); + return (_PyAptPkg_API != NULL) ? 0 : -1; +# else + + PyObject *module = PyImport_ImportModule("apt_pkg"); + + if (module == NULL) { + return -1; + } + if (module != NULL) { + PyObject *c_api_object = PyObject_GetAttrString(module, "_C_API"); + if (c_api_object == NULL) + return -1; + if (PyCObject_Check(c_api_object)) + _PyAptPkg_API = (struct _PyAptPkgAPIStruct *)PyCObject_AsVoidPtr(c_api_object); + Py_DECREF(c_api_object); + } + return 0; +# endif // PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1 +} + +# define PyAcquire_Type *(_PyAptPkg_API->acquire_type) +# define PyAcquireFile_Type *(_PyAptPkg_API->acquirefile_type) +# define PyAcquireItem_Type *(_PyAptPkg_API->acquireitem_type) +# define PyAcquireItemDesc_Type *(_PyAptPkg_API->acquireitemdesc_type) +# define PyAcquireWorker_Type *(_PyAptPkg_API->acquireworker_type) +# define PyActionGroup_Type *(_PyAptPkg_API->actiongroup_type) +# define PyCache_Type *(_PyAptPkg_API->cache_type) +# define PyCacheFile_Type *(_PyAptPkg_API->cachefile_type) +# define PyCdrom_Type *(_PyAptPkg_API->cdrom_type) +# define PyConfiguration_Type *(_PyAptPkg_API->configuration_type) +# define PyDepCache_Type *(_PyAptPkg_API->depcache_type) +# define PyDependency_Type *(_PyAptPkg_API->dependency_type) +# define PyDependencyList_Type *(_PyAptPkg_API->dependencylist_type) +# define PyDescription_Type *(_PyAptPkg_API->description_type) +# define PyHashes_Type *(_PyAptPkg_API->hashes_type) +# define PyHashString_Type *(_PyAptPkg_API->hashstring_type) +# define PyIndexRecords_Type *(_PyAptPkg_API->indexrecords_type) +# define PyMetaIndex_Type *(_PyAptPkg_API->metaindex_type) +# define PyPackage_Type *(_PyAptPkg_API->package_type) +# define PyPackageFile_Type *(_PyAptPkg_API->packagefile_type) +# define PyIndexFile_Type *(_PyAptPkg_API->packageindexfile_type) +# define PyPackageList_Type *(_PyAptPkg_API->packagelist_type) +# define PyPackageManager_Type *(_PyAptPkg_API->packagemanager_type) +# define PyPackageRecords_Type *(_PyAptPkg_API->packagerecords_type) +# define PyPolicy_Type *(_PyAptPkg_API->policy_type) +# define PyProblemResolver_Type *(_PyAptPkg_API->problemresolver_type) +# define PySourceList_Type *(_PyAptPkg_API->sourcelist_type) +# define PySourceRecords_Type *(_PyAptPkg_API->sourcerecords_type) +# define PyTagFile_Type *(_PyAptPkg_API->tagfile_type) +# define PyTagSection_Type *(_PyAptPkg_API->tagsection_type) +# define PyVersion_Type *(_PyAptPkg_API->version_type) +// Code +# define PyAcquire_ToCpp _PyAptPkg_API->acquire_tocpp +# define PyAcquireFile_ToCpp _PyAptPkg_API->acquirefile_tocpp +# define PyAcquireItem_ToCpp _PyAptPkg_API->acquireitem_tocpp +# define PyAcquireItemDesc_ToCpp _PyAptPkg_API->acquireitemdesc_tocpp +# define PyAcquireWorker_ToCpp _PyAptPkg_API->acquireworker_tocpp +# define PyActionGroup_ToCpp _PyAptPkg_API->actiongroup_tocpp +# define PyCache_ToCpp _PyAptPkg_API->cache_tocpp +# define PyCacheFile_ToCpp _PyAptPkg_API->cachefile_tocpp +# define PyCdrom_ToCpp _PyAptPkg_API->cdrom_tocpp +# define PyConfiguration_ToCpp _PyAptPkg_API->configuration_tocpp +# define PyDepCache_ToCpp _PyAptPkg_API->depcache_tocpp +# define PyDependency_ToCpp _PyAptPkg_API->dependency_tocpp +# define PyDependencyList_ToCpp _PyAptPkg_API->dependencylist_tocpp // NULL +# define PyDescription_ToCpp _PyAptPkg_API->description_tocpp +# define PyHashes_ToCpp _PyAptPkg_API->hashes_tocpp +# define PyHashString_ToCpp _PyAptPkg_API->hashstring_tocpp +# define PyIndexRecords_ToCpp _PyAptPkg_API->indexrecords_tocpp +# define PyMetaIndex_ToCpp _PyAptPkg_API->metaindex_tocpp +# define PyPackage_ToCpp _PyAptPkg_API->package_tocpp +# define PyPackageFile_ToCpp _PyAptPkg_API->packagefile_tocpp +# define PyIndexFile_ToCpp _PyAptPkg_API->packageindexfile_tocpp +# define PyPackageList_ToCpp _PyAptPkg_API->packagelist_tocpp // NULL +# define PyPackageManager_ToCpp _PyAptPkg_API->packagemanager_tocpp +# define PyPackageRecords_ToCpp _PyAptPkg_API->packagerecords_tocpp +# define PyPolicy_ToCpp _PyAptPkg_API->policy_tocpp +# define PyProblemResolver_ToCpp _PyAptPkg_API->problemresolver_tocpp +# define PySourceList_ToCpp _PyAptPkg_API->sourcelist_tocpp +# define PySourceRecords_ToCpp _PyAptPkg_API->sourcerecords_tocpp // NULL +# define PyTagFile_ToCpp _PyAptPkg_API->tagfile_tocpp +# define PyTagSection_ToCpp _PyAptPkg_API->tagsection_tocpp +# define PyVersion_ToCpp _PyAptPkg_API->version_tocpp +// Get the C++ object +# define PyAcquire_FromCpp _PyAptPkg_API->acquire_fromcpp +# endif // APT_PKGMODULE_H // Template using a simpler version of from cpp template @@ -227,9 +304,7 @@ inline CppPyObject *FromCpp(PyTypeObject *pytype, Cpp const &obj, bool Dele return Obj; } -# ifndef APT_PKGMODULE_H -# define PyAcquire_FromCpp _PyAptPkg_API->acquire_fromcpp -#endif + # define PyAcquireFile_FromCpp(...) FromCpp(&PyAcquireFile_Type, ##__VA_ARGS__) # define PyAcquireItem_FromCpp(...) FromCpp(&PyAcquireItem_Type,##__VA_ARGS__) # define PyAcquireItemDesc_FromCpp(...) FromCpp(&PyAcquireItemDesc_Type,##__VA_ARGS__) @@ -261,3 +336,4 @@ inline CppPyObject *FromCpp(PyTypeObject *pytype, Cpp const &obj, bool Dele # define PyTagSection_FromCpp(...) FromCpp(&PyTagSection_Type,##__VA_ARGS__) # define PyVersion_FromCpp(...) FromCpp(&PyVersion_Type,##__VA_ARGS__) #endif + -- cgit v1.2.3 From 961c86bce5dc8448af5e6781d26b7561471b44c0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 31 Jan 2010 17:17:10 +0100 Subject: de.po: Update against new template --- debian/changelog | 2 + po/de.po | 180 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 95 insertions(+), 87 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index f3cea5b3..bfd7e5b7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low in APT. * Merge the CppOwnedPyObject C++ class into CppPyObject. * Remove inline functions from the C++ API, export them instead. + * Localization + - de.po: Update against new template -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/po/de.po b/po/de.po index f5cd912d..72d0a1c5 100644 --- a/po/de.po +++ b/po/de.po @@ -1,5 +1,6 @@ -# German translation of update-manager. +# German translation of python-apt. # Copyright (C) 2005 Michiel Sikkes +# Copyright (C) 2009 - 2010 Julian Andres Klode # This file is distributed under the same license as the update-manager package. # Initial version by an unknown artist. # Frank Arnold , 2005. @@ -7,12 +8,12 @@ # msgid "" msgstr "" -"Project-Id-Version: update-manager\n" +"Project-Id-Version: python-apt\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-07-19 15:59+0200\n" -"PO-Revision-Date: 2009-06-15 17:03+0200\n" +"POT-Creation-Date: 2010-01-31 17:09+0100\n" +"PO-Revision-Date: 2010-01-31 17:14+0100\n" "Last-Translator: Julian Andres Klode \n" -"Language-Team: German GNOME Translations \n" +"Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -26,246 +27,256 @@ msgstr "http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog" #. Description #: ../data/templates/Ubuntu.info.in:13 +msgid "Ubuntu 10.04 'Lucid Lynx'" +msgstr "Ubuntu 10.04 »Lucid Lynx«" + +#. Description +#: ../data/templates/Ubuntu.info.in:31 +msgid "Cdrom with Ubuntu 10.04 'Lucid Lynx'" +msgstr "CD mit Ubuntu 10.04 »Hardy Heron«" + +#. Description +#: ../data/templates/Ubuntu.info.in:74 msgid "Ubuntu 9.10 'Karmic Koala'" msgstr "Ubuntu 9.10 »Karmic Koala«" #. Description -#: ../data/templates/Ubuntu.info.in:31 +#: ../data/templates/Ubuntu.info.in:92 msgid "Cdrom with Ubuntu 9.10 'Karmic Koala'" msgstr "CD-ROM mit Ubuntu 9.10 »Karmic Koala«" #. Description -#: ../data/templates/Ubuntu.info.in:74 +#: ../data/templates/Ubuntu.info.in:135 msgid "Ubuntu 9.04 'Jaunty Jackalope'" msgstr "Ubuntu 9.04 »Jaunty Jackalope«" #. Description -#: ../data/templates/Ubuntu.info.in:92 +#: ../data/templates/Ubuntu.info.in:153 msgid "Cdrom with Ubuntu 9.04 'Jaunty Jackalope'" msgstr "CD-ROM mit Ubuntu 9.04 »Jaunty Jackalope«" #. Description -#: ../data/templates/Ubuntu.info.in:135 +#: ../data/templates/Ubuntu.info.in:196 msgid "Ubuntu 8.10 'Intrepid Ibex'" msgstr "Ubuntu 8.10 »Intrepid Ibex«" #. Description -#: ../data/templates/Ubuntu.info.in:153 +#: ../data/templates/Ubuntu.info.in:214 msgid "Cdrom with Ubuntu 8.10 'Intrepid Ibex'" msgstr "CD mit Ubuntu 8.10 »Intrepid Ibex«" #. Description -#: ../data/templates/Ubuntu.info.in:197 +#: ../data/templates/Ubuntu.info.in:258 msgid "Ubuntu 8.04 'Hardy Heron'" msgstr "Ubuntu 8.04 »Hardy Heron«" #. Description -#: ../data/templates/Ubuntu.info.in:215 +#: ../data/templates/Ubuntu.info.in:276 msgid "Cdrom with Ubuntu 8.04 'Hardy Heron'" msgstr "CD mit Ubuntu 8.04 »Hardy Heron«" #. Description -#: ../data/templates/Ubuntu.info.in:252 +#: ../data/templates/Ubuntu.info.in:313 msgid "Ubuntu 7.10 'Gutsy Gibbon'" msgstr "Ubuntu 7.10 »Gutsy Gibbon«" #. Description -#: ../data/templates/Ubuntu.info.in:270 +#: ../data/templates/Ubuntu.info.in:331 msgid "Cdrom with Ubuntu 7.10 'Gutsy Gibbon'" msgstr "CD mit Ubuntu 7.10 »Gutsy Gibbon«" #. Description -#: ../data/templates/Ubuntu.info.in:305 +#: ../data/templates/Ubuntu.info.in:366 msgid "Ubuntu 7.04 'Feisty Fawn'" msgstr "Ubuntu 7.04 »Feisty Fawn«" #. Description -#: ../data/templates/Ubuntu.info.in:323 +#: ../data/templates/Ubuntu.info.in:384 msgid "Cdrom with Ubuntu 7.04 'Feisty Fawn'" msgstr "CD mit Ubuntu 7.04 »Feisty Fawn«" #. Description -#: ../data/templates/Ubuntu.info.in:357 +#: ../data/templates/Ubuntu.info.in:418 msgid "Ubuntu 6.10 'Edgy Eft'" msgstr "Ubuntu 6.10 »Edgy Eft«" #. CompDescription -#: ../data/templates/Ubuntu.info.in:362 +#: ../data/templates/Ubuntu.info.in:423 msgid "Community-maintained" msgstr "Von der Ubuntu-Gemeinde betreut" #. CompDescription -#: ../data/templates/Ubuntu.info.in:368 +#: ../data/templates/Ubuntu.info.in:429 msgid "Restricted software" msgstr "Eingeschränkte Software" #. Description -#: ../data/templates/Ubuntu.info.in:375 +#: ../data/templates/Ubuntu.info.in:436 msgid "Cdrom with Ubuntu 6.10 'Edgy Eft'" msgstr "CD mit Ubuntu 6.10 »Edgy Eft«" #. Description -#: ../data/templates/Ubuntu.info.in:409 +#: ../data/templates/Ubuntu.info.in:470 msgid "Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "Ubuntu 6.06 LTS »Dapper Drake«" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:412 +#: ../data/templates/Ubuntu.info.in:473 msgid "Canonical-supported Open Source software" msgstr "Von Canonical unterstütze Open-Source-Software" #. CompDescription -#: ../data/templates/Ubuntu.info.in:414 +#: ../data/templates/Ubuntu.info.in:475 msgid "Community-maintained (universe)" msgstr "Von der Gemeinde betreut (universe)" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:415 +#: ../data/templates/Ubuntu.info.in:476 msgid "Community-maintained Open Source software" msgstr "Von der Ubuntu-Gemeinde betreute Open-Source-Software" #. CompDescription -#: ../data/templates/Ubuntu.info.in:417 +#: ../data/templates/Ubuntu.info.in:478 msgid "Non-free drivers" msgstr "Proprietäre Treiber" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:418 +#: ../data/templates/Ubuntu.info.in:479 msgid "Proprietary drivers for devices" msgstr "Proprietäre Gerätetreiber" #. CompDescription -#: ../data/templates/Ubuntu.info.in:420 +#: ../data/templates/Ubuntu.info.in:481 msgid "Restricted software (Multiverse)" msgstr "Eingeschränkte Software (Multiverse)" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:421 +#: ../data/templates/Ubuntu.info.in:482 msgid "Software restricted by copyright or legal issues" msgstr "Rechtlich eingeschränkte Software" #. Description -#: ../data/templates/Ubuntu.info.in:427 +#: ../data/templates/Ubuntu.info.in:488 msgid "Cdrom with Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "CD mit Ubuntu 6.06 LTS »Dapper Drake«" #. Description -#: ../data/templates/Ubuntu.info.in:439 +#: ../data/templates/Ubuntu.info.in:500 msgid "Important security updates" msgstr "Wichtige Sicherheitsaktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:444 +#: ../data/templates/Ubuntu.info.in:505 msgid "Recommended updates" msgstr "Empfohlene Aktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:449 +#: ../data/templates/Ubuntu.info.in:510 msgid "Pre-released updates" msgstr "Vorabveröffentlichte Aktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:454 +#: ../data/templates/Ubuntu.info.in:515 msgid "Unsupported updates" msgstr "Nicht unterstütze Aktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:461 +#: ../data/templates/Ubuntu.info.in:522 msgid "Ubuntu 5.10 'Breezy Badger'" msgstr "Ubuntu 5.10 »Breezy Badger«" #. Description -#: ../data/templates/Ubuntu.info.in:475 +#: ../data/templates/Ubuntu.info.in:536 msgid "Cdrom with Ubuntu 5.10 'Breezy Badger'" msgstr "CD mit Ubuntu 5.10 »Breezy Badger«" #. Description -#: ../data/templates/Ubuntu.info.in:487 +#: ../data/templates/Ubuntu.info.in:548 msgid "Ubuntu 5.10 Security Updates" msgstr "Ubuntu 5.10 Sicherheitsaktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:492 +#: ../data/templates/Ubuntu.info.in:553 msgid "Ubuntu 5.10 Updates" msgstr "Ubuntu 5.10 Aktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:497 +#: ../data/templates/Ubuntu.info.in:558 msgid "Ubuntu 5.10 Backports" msgstr "Ubuntu 5.10 Backports" #. Description -#: ../data/templates/Ubuntu.info.in:504 +#: ../data/templates/Ubuntu.info.in:565 msgid "Ubuntu 5.04 'Hoary Hedgehog'" msgstr "Ubuntu 5.04 »Hoary Hedgehog«" #. Description -#: ../data/templates/Ubuntu.info.in:518 +#: ../data/templates/Ubuntu.info.in:579 msgid "Cdrom with Ubuntu 5.04 'Hoary Hedgehog'" msgstr "CD mit Ubuntu 5.04 »Hoary Hedgehog«" #. CompDescription -#: ../data/templates/Ubuntu.info.in:521 ../data/templates/Debian.info.in:148 +#: ../data/templates/Ubuntu.info.in:582 ../data/templates/Debian.info.in:148 msgid "Officially supported" msgstr "Offiziell unterstützt" #. Description -#: ../data/templates/Ubuntu.info.in:530 +#: ../data/templates/Ubuntu.info.in:591 msgid "Ubuntu 5.04 Security Updates" msgstr "Ubuntu 5.04 Sicherheitsaktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:535 +#: ../data/templates/Ubuntu.info.in:596 msgid "Ubuntu 5.04 Updates" msgstr "Ubuntu 5.04 Aktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:540 +#: ../data/templates/Ubuntu.info.in:601 msgid "Ubuntu 5.04 Backports" msgstr "Ubuntu 5.04 Backports" #. Description -#: ../data/templates/Ubuntu.info.in:546 +#: ../data/templates/Ubuntu.info.in:607 msgid "Ubuntu 4.10 'Warty Warthog'" msgstr "Ubuntu 4.10 »Warty Warthog«" #. CompDescription -#: ../data/templates/Ubuntu.info.in:552 +#: ../data/templates/Ubuntu.info.in:613 msgid "Community-maintained (Universe)" msgstr "Von der Ubuntu-Gemeinde betreut (Universe)" #. CompDescription -#: ../data/templates/Ubuntu.info.in:554 +#: ../data/templates/Ubuntu.info.in:615 msgid "Non-free (Multiverse)" msgstr "Unfrei (Multiverse)" #. Description -#: ../data/templates/Ubuntu.info.in:560 +#: ../data/templates/Ubuntu.info.in:621 msgid "Cdrom with Ubuntu 4.10 'Warty Warthog'" msgstr "CD-ROM mit Ubuntu 4.10 »Warty Warthog«" #. CompDescription -#: ../data/templates/Ubuntu.info.in:563 +#: ../data/templates/Ubuntu.info.in:624 msgid "No longer officially supported" msgstr "Unterstützung ist ausgelaufen" #. CompDescription -#: ../data/templates/Ubuntu.info.in:565 +#: ../data/templates/Ubuntu.info.in:626 msgid "Restricted copyright" msgstr "Eingeschränktes Copyright" #. Description -#: ../data/templates/Ubuntu.info.in:572 +#: ../data/templates/Ubuntu.info.in:633 msgid "Ubuntu 4.10 Security Updates" msgstr "Ubuntu 4.10 Sicherheitsaktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:577 +#: ../data/templates/Ubuntu.info.in:638 msgid "Ubuntu 4.10 Updates" msgstr "Ubuntu 4.10 Aktualisierungen" #. Description -#: ../data/templates/Ubuntu.info.in:582 +#: ../data/templates/Ubuntu.info.in:643 msgid "Ubuntu 4.10 Backports" msgstr "Ubuntu 4.10 Backports" @@ -348,39 +359,39 @@ msgstr "Haupt-Server" msgid "Custom servers" msgstr "Benutzerdefinierte Server" -#: ../apt/progress/gtk2.py:259 +#: ../apt/progress/gtk2.py:259 ../apt/progress/gtk2.py:315 #, python-format msgid "Downloading file %(current)li of %(total)li with %(speed)s/s" msgstr "Datei %(current)li von %(total)li wird mit %(speed)s/s heruntergeladen" -#: ../apt/progress/gtk2.py:265 +#: ../apt/progress/gtk2.py:265 ../apt/progress/gtk2.py:321 #, python-format msgid "Downloading file %(current)li of %(total)li" msgstr "Datei %(current)li von %(total)li wird heruntergeladen" #. Setup some child widgets -#: ../apt/progress/gtk2.py:285 +#: ../apt/progress/gtk2.py:341 msgid "Details" msgstr "Details" -#: ../apt/progress/gtk2.py:367 +#: ../apt/progress/gtk2.py:429 msgid "Starting..." msgstr "Starte..." -#: ../apt/progress/gtk2.py:373 +#: ../apt/progress/gtk2.py:435 msgid "Complete" msgstr "Fertig" -#: ../apt/package.py:301 +#: ../apt/package.py:333 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "Ungültiger Unicode-Wert in Beschreibung für '%s' (%s). Bitte melden." -#: ../apt/package.py:937 ../apt/package.py:1043 +#: ../apt/package.py:989 ../apt/package.py:1095 msgid "The list of changes is not available" msgstr "Die Liste mit Änderungen ist momentan nicht verfügbar." -#: ../apt/package.py:1047 +#: ../apt/package.py:1099 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -393,7 +404,7 @@ msgstr "" "Bitte benutzen Sie http://launchpad.net/ubuntu/+source/%s/%s/+changelog\n" "bis die Liste verfügbar ist oder versuchen sie es später erneut." -#: ../apt/package.py:1053 +#: ../apt/package.py:1105 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." @@ -401,52 +412,47 @@ msgstr "" "Die Liste mit Änderungen konnte nicht heruntergeladen werden. \n" "Bitte überprüfen Sie Ihre Internet-Verbindung." -#: ../apt/debfile.py:56 -#, python-format -msgid "This is not a valid DEB archive, missing '%s' member" -msgstr "Dies ist kein gültiges DEB archive, es fehlt der Eintrag '%s'" - -#: ../apt/debfile.py:81 +#: ../apt/debfile.py:70 #, python-format -msgid "List of files for '%s'could not be read" +msgid "List of files for '%s' could not be read" msgstr "Die Liste der Dateien von ›%s‹ konnte nicht gelesen werden." -#: ../apt/debfile.py:149 +#: ../apt/debfile.py:138 #, python-format msgid "Dependency is not satisfiable: %s\n" msgstr "Abhängigkeit nicht erfüllbar: %s\n" -#: ../apt/debfile.py:173 +#: ../apt/debfile.py:162 #, python-format msgid "Conflicts with the installed package '%s'" msgstr "Steht in Konflikt zu dem installiertem Paket ›%s‹" -#: ../apt/debfile.py:319 +#: ../apt/debfile.py:308 #, python-format msgid "Wrong architecture '%s'" msgstr "Falsche Architektur ›%s‹" #. the deb is older than the installed -#: ../apt/debfile.py:325 +#: ../apt/debfile.py:314 msgid "A later version is already installed" msgstr "Eine spätere Version is bereits installiert." -#: ../apt/debfile.py:345 +#: ../apt/debfile.py:334 msgid "Failed to satisfy all dependencies (broken cache)" msgstr "Es konnten nicht alle Abhängigkeiten erfüllt werden (Cache defekt)" -#: ../apt/debfile.py:376 +#: ../apt/debfile.py:365 #, python-format msgid "Cannot install '%s'" msgstr "›%s‹ kann nicht installiert werden" -#: ../apt/debfile.py:484 +#: ../apt/debfile.py:473 #, python-format msgid "Install Build-Dependencies for source package '%s' that builds %s\n" msgstr "" "Installiere Bau-Abhängigkeiten für das Quellpaket ›%s‹ welches ›%s‹baut\n" -#: ../apt/debfile.py:494 +#: ../apt/debfile.py:483 msgid "An essential package would be removed" msgstr "Ein grundlegendes Paket müsste entfernt werden" @@ -455,27 +461,27 @@ msgstr "Ein grundlegendes Paket müsste entfernt werden" msgid "%c%s... Done" msgstr "%c%s... Fertig" -#: ../apt/progress/text.py:118 +#: ../apt/progress/text.py:120 msgid "Hit " msgstr "OK " -#: ../apt/progress/text.py:126 +#: ../apt/progress/text.py:129 msgid "Ign " msgstr "Ign " -#: ../apt/progress/text.py:128 +#: ../apt/progress/text.py:131 msgid "Err " msgstr "Fehl " -#: ../apt/progress/text.py:138 +#: ../apt/progress/text.py:142 msgid "Get:" msgstr "Hole:" -#: ../apt/progress/text.py:198 +#: ../apt/progress/text.py:202 msgid " [Working]" msgstr " [Verarbeite]" -#: ../apt/progress/text.py:208 +#: ../apt/progress/text.py:213 #, python-format msgid "" "Media change: please insert the disc labeled\n" @@ -487,22 +493,22 @@ msgstr "" "in Laufwerk »%s« und drücken Sie die Eingabetaste.\n" #. Trick for getting a translation from apt -#: ../apt/progress/text.py:216 +#: ../apt/progress/text.py:222 #, python-format msgid "Fetched %sB in %s (%sB/s)\n" msgstr "Es wurden %sB in %s geholt (%sB/s)\n" -#: ../apt/progress/text.py:229 +#: ../apt/progress/text.py:238 msgid "Please provide a name for this Disc, such as 'Debian 2.1r1 Disk 1'" msgstr "" "Bitte geben Sie einen Namen für die CD an, wie zum Beispiel »Debian 2.1r1 " "Disk 1«" -#: ../apt/progress/text.py:241 +#: ../apt/progress/text.py:254 msgid "Please insert a Disc in the drive and press enter" msgstr "" "Bitte legen Sie ein Medium ins Laufwerk und drücken Sie die Eingabetaste" -#: ../apt/cache.py:96 +#: ../apt/cache.py:127 msgid "Building data structures" msgstr "Datenstrukturen werden aufgebaut" -- cgit v1.2.3 From f18aca0bfc380337d99871f6255bd600c70015ca Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 31 Jan 2010 21:38:16 +0100 Subject: python/arfile.cc: Handle the case where ararchive_new returns NULL in debfile_new. --- debian/changelog | 2 ++ python/arfile.cc | 2 ++ 2 files changed, 4 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index bfd7e5b7..07263fe8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * Remove inline functions from the C++ API, export them instead. * Localization - de.po: Update against new template + * python/arfile.cc: + - Handle the case where ararchive_new returns NULL in debfile_new. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/python/arfile.cc b/python/arfile.cc index 4f95a791..4f3b4ad7 100644 --- a/python/arfile.cc +++ b/python/arfile.cc @@ -523,6 +523,8 @@ static PyObject *_gettar(PyDebFileObject *self, const ARArchive::Member *m, static PyObject *debfile_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyDebFileObject *self = (PyDebFileObject*)ararchive_new(type, args, kwds); + if (self == NULL) + return NULL; // DebFile self->control = _gettar(self, self->Object->FindMember("control.tar.gz"), -- cgit v1.2.3 From a3d3b31c936d7c244e7a3874ae6f453f75d5cf58 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 08:39:06 +0100 Subject: apt/progress/base.py: select.error objects do not have an errno attribute (Closes: #568005) --- apt/progress/base.py | 4 ++-- debian/changelog | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/apt/progress/base.py b/apt/progress/base.py index 0c0796d6..6636cccc 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -264,8 +264,8 @@ class InstallProgress(object): while True: try: select.select([self.statusfd], [], [], self.select_timeout) - except select.error, err: - if err.errno != errno.EINTR: + except select.error, (errno_, errstr): + if errno_ != errno.EINTR: raise self.update_interface() diff --git a/debian/changelog b/debian/changelog index 07263fe8..2a10635d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - de.po: Update against new template * python/arfile.cc: - Handle the case where ararchive_new returns NULL in debfile_new. + * apt/progress/base.py: + - select.error objects do not have an errno attribute (Closes: #568005) -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 -- cgit v1.2.3 From eda5f5556f353c2403f846d74104d000c00aff90 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 17:15:18 +0100 Subject: python/tarfile.cc: If only one member is requested, extract just that one. --- debian/changelog | 1 + python/tarfile.cc | 2 ++ 2 files changed, 3 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 2a10635d..51472a0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - Do not segfault if TarFile.go() is called without a member name. - Clone all pkgDirStream::Item's so apt_pkg.TarMember object can be used outside of the callback function passed to go(). + - If only one member is requested, extract just that one. * Drop the segfault prevention measures from the Acquire code, as they fail to work. A replacement will be added once destruction callbacks are added in APT. diff --git a/python/tarfile.cc b/python/tarfile.cc index aa9a39f6..6363af0f 100644 --- a/python/tarfile.cc +++ b/python/tarfile.cc @@ -78,6 +78,8 @@ bool PyDirStream::DoItem(Item &Itm, int &Fd) copy_size = Itm.Size; } Fd = -2; + } else { + Fd = -1; } return true; } -- cgit v1.2.3 From 8d311d4829312718fcb6ab3d0385f8fa7f5cf3e1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 17:30:49 +0100 Subject: doc/client-example.cc: Update against the new API. --- debian/changelog | 1 + doc/client-example.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 51472a0c..fd87a576 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - Handle the case where ararchive_new returns NULL in debfile_new. * apt/progress/base.py: - select.error objects do not have an errno attribute (Closes: #568005) + * doc/client-example.cc: Update against the new API. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/doc/client-example.cc b/doc/client-example.cc index 7f01b637..73fa3eed 100644 --- a/doc/client-example.cc +++ b/doc/client-example.cc @@ -32,7 +32,7 @@ extern "C" void initclient() { // Create a HashString, which will be added to the module. HashString *hash = new HashString("0966a120bb936bdc6fdeac445707aa6b"); // Create a Python object for the hashstring and add it to the module - PyModule_AddObject(Module, "hash", PyHashString_FromCpp(hash)); + PyModule_AddObject(Module, "hash", PyHashString_FromCpp(hash, false, NULL)); // Another example: Add the HashString type to the module. Py_INCREF(&PyHashString_Type); -- cgit v1.2.3 From 4609ac0f0102e5427419ed4c122c6824ca7d7716 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 17:31:23 +0100 Subject: Fix typo seperated => separated in multiple files (reported by lintian). --- debian/changelog | 1 + doc/source/library/apt_pkg.rst | 2 +- doc/source/whatsnew/0.7.100.rst | 2 +- python/hashstring.cc | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index fd87a576..368b45c6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * apt/progress/base.py: - select.error objects do not have an errno attribute (Closes: #568005) * doc/client-example.cc: Update against the new API. + * Fix typo seperated => separated in multiple files (reported by lintian). -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst index 90b3062a..7989a68a 100644 --- a/doc/source/library/apt_pkg.rst +++ b/doc/source/library/apt_pkg.rst @@ -1817,7 +1817,7 @@ String functions .. function:: check_domain_list(host, list) - See if Host is in a ',' seperated list, e.g.:: + See if Host is in a ',' separated list, e.g.:: apt_pkg.check_domain_list("alioth.debian.org","debian.net,debian.org") diff --git a/doc/source/whatsnew/0.7.100.rst b/doc/source/whatsnew/0.7.100.rst index 110336a3..a3888b3a 100644 --- a/doc/source/whatsnew/0.7.100.rst +++ b/doc/source/whatsnew/0.7.100.rst @@ -192,7 +192,7 @@ methods, functions, and their parameters the following rules apply: 3. Replace every [A-Z] with the corresponding [a-z] (descUri => desc_uri) As an exception, refixes such as 'de' (e.g. 'dequote') or 'un' (e.g. 'unlock') -are normally not seperated by underscores from the next word. There are also +are normally not separated by underscores from the next word. There are also some other exceptions which are listed here, and apply to any name containing this word: **filename**, **filesize**, **destdir**, **destfile**, **dequote**, **unlock**, **reinstall**, **pinfile**, **REINSTREQ**, **UNPACKED**, diff --git a/python/hashstring.cc b/python/hashstring.cc index d4b7a3b2..59d533f8 100644 --- a/python/hashstring.cc +++ b/python/hashstring.cc @@ -87,7 +87,7 @@ static char *hashstring_doc = "HashString(type, hash) OR HashString('type:hash')\n\n" "Create a new HashString object. The first form allows you to specify\n" "a type and a hash, and the second form a single string where type and\n" - "hash are seperated by a colon, e.g.::\n\n" + "hash are separated by a colon, e.g.::\n\n" " HashString('MD5Sum', '6cc1b6e6655e3555ac47e5b5fe26d04e')\n\n" "Valid options for 'type' are: MD5Sum, SHA1, SHA256."; PyTypeObject PyHashString_Type = { -- cgit v1.2.3 From 07442ba7f9449a1a3d1cce0faba8af3954f5e220 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 17:40:04 +0100 Subject: * debian/control: - Make python-apt-dev depend on ${misc:Depends} and recommend python-dev. --- debian/changelog | 2 ++ debian/control | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 368b45c6..7bcc80bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low - select.error objects do not have an errno attribute (Closes: #568005) * doc/client-example.cc: Update against the new API. * Fix typo seperated => separated in multiple files (reported by lintian). + * debian/control: + - Make python-apt-dev depend on ${misc:Depends} and recommend python-dev. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/debian/control b/debian/control index 81fc00ee..5ed54dbd 100644 --- a/debian/control +++ b/debian/control @@ -47,6 +47,7 @@ Architecture: any Section: debug Depends: python-dbg, python-apt (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +XB-Python-Version: ${python:Versions} Description: Python interface to libapt-pkg (debug extension) The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a @@ -56,7 +57,9 @@ Description: Python interface to libapt-pkg (debug extension) Package: python-apt-dev Architecture: all -Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10) +Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10), + ${misc:Depends} +Recommends: python-dev Description: Python interface to libapt-pkg (development files) The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a -- cgit v1.2.3 From 7516fccf52d03722a61a34b1e36f90808670c754 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 17:45:43 +0100 Subject: debian/changelog: Do not mention the typo itself, only the correct word. --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 7bcc80bf..867b9dab 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,7 +25,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * apt/progress/base.py: - select.error objects do not have an errno attribute (Closes: #568005) * doc/client-example.cc: Update against the new API. - * Fix typo seperated => separated in multiple files (reported by lintian). + * Fix typos of separated in multiple files (reported by lintian). * debian/control: - Make python-apt-dev depend on ${misc:Depends} and recommend python-dev. -- cgit v1.2.3 From 38141fc5f6918c5ae7ac7fd0061ee051c580b255 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 2 Feb 2010 18:01:17 +0100 Subject: debian/control: Set Standards-Version to 3.8.4. --- debian/changelog | 1 + debian/control | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 867b9dab..bba66321 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * Fix typos of separated in multiple files (reported by lintian). * debian/control: - Make python-apt-dev depend on ${misc:Depends} and recommend python-dev. + - Set Standards-Version to 3.8.4. -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 diff --git a/debian/control b/debian/control index 5ed54dbd..0c43f91e 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: python Priority: optional Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode -Standards-Version: 3.8.3 +Standards-Version: 3.8.4 XS-Python-Version: 2.5, 2.6, 3.1 Build-Depends: apt-utils, debhelper (>= 7.3.5), -- cgit v1.2.3 From 662183288bbe0eac0578fa714e9eed564fd2f21d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Feb 2010 17:45:42 +0100 Subject: Release 0.7.93.1. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 65ea74b8..c168de36 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.93.1) UNRELEASED; urgency=low +python-apt (0.7.93.1) unstable; urgency=low [ Julian Andres Klode ] * Fix reference counting for old progress classes (Closes: #566370). @@ -35,7 +35,7 @@ python-apt (0.7.93.1) UNRELEASED; urgency=low * apt/utils.py: - add some misc utils like get_release_filename_for_pkg() - -- Julian Andres Klode Sat, 23 Jan 2010 15:35:55 +0100 + -- Julian Andres Klode Fri, 05 Feb 2010 17:45:39 +0100 python-apt (0.7.93) unstable; urgency=low -- cgit v1.2.3 From fdb6cbdee070ae6671bdb5ed6b8a549aac1d8107 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Feb 2010 20:04:59 +0100 Subject: * Fix some places where the old API was still used: - apt/utils.py: Completely ported, previous one was old-API from Ubuntu. - apt/cache.py: Use the new progress classes instead of the old ones. - apt/package.py: Various smaller issues fixed, probably caused by merge. --- apt/cache.py | 12 ++++++------ apt/package.py | 8 ++++---- apt/utils.py | 38 +++++++++++++++++++------------------- debian/changelog | 9 +++++++++ 4 files changed, 38 insertions(+), 29 deletions(-) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index 2a62ddce..24d63361 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -306,7 +306,7 @@ class Cache(object): try: if fetch_progress is None: - fetch_progress = apt.progress.FetchProgress() + fetch_progress = apt.progress.base.AcquireProgress() try: res = self._cache.update(fetch_progress, self._list, pulse_interval) @@ -358,9 +358,9 @@ class Cache(object): # which is less than optimal! if fetch_progress is None: - fetch_progress = apt.progress.FetchProgress() + fetch_progress = apt.progress.base.AcquireProgress() if install_progress is None: - install_progress = apt.progress.InstallProgress() + install_progress = apt.progress.base.InstallProgress() pm = apt_pkg.PackageManager(self._depcache) fetcher = apt_pkg.Acquire(fetch_progress) @@ -602,7 +602,7 @@ def _test(): """Internal test code.""" print "Cache self test" apt_pkg.init() - cache = Cache(apt.progress.OpTextProgress()) + cache = Cache(apt.progress.text.OpProgress()) cache.connect("cache_pre_change", cache_pre_changed) cache.connect("cache_post_change", cache_post_changed) print ("aptitude" in cache) @@ -627,7 +627,7 @@ def _test(): os.mkdir(dir) apt_pkg.config.set("Dir::Cache::Archives", "/tmp/pytest") pm = apt_pkg.PackageManager(cache._depcache) - fetcher = apt_pkg.Acquire(apt.progress.TextFetchProgress()) + fetcher = apt_pkg.Acquire(apt.progress.text.AcquireProgress()) cache._fetch_archives(fetcher, pm) #sys.exit(1) @@ -644,7 +644,7 @@ def _test(): print len(filtered) print "Testing filtered cache (no argument)" - filtered = FilteredCache(progress=apt.progress.OpTextProgress()) + filtered = FilteredCache(progress=apt.progress.base.OpProgress()) filtered.cache.connect("cache_pre_change", cache_pre_changed) filtered.cache.connect("cache_post_change", cache_post_changed) filtered.cache.upgrade() diff --git a/apt/package.py b/apt/package.py index 8171f57d..7f736583 100644 --- a/apt/package.py +++ b/apt/package.py @@ -596,7 +596,7 @@ class VersionList(Sequence): except TypeError: # Dictionary interface item is a string. for ver in self._versions: - if ver.VerStr == item: + if ver.ver_str == item: return Version(self._package, ver) raise KeyError("Version: %r not found." % (item)) @@ -612,7 +612,7 @@ class VersionList(Sequence): item = item.version # Dictionary interface. for ver in self._versions: - if ver.VerStr == item: + if ver.ver_str == item: return True return False @@ -1127,12 +1127,12 @@ class Package(object): @property def is_inst_broken(self): """Return True if the to-be-installed package is broken.""" - return self._pcache._depcache.IsInstBroken(self._pkg) + return self._pcache._depcache.is_inst_broken(self._pkg) @property def is_now_broken(self): """Return True if the installed package is broken.""" - return self._pcache._depcache.IsNowBroken(self._pkg) + return self._pcache._depcache.is_now_broken(self._pkg) # depcache actions diff --git a/apt/utils.py b/apt/utils.py index df1d0397..8949c2ab 100644 --- a/apt/utils.py +++ b/apt/utils.py @@ -38,39 +38,39 @@ def get_release_date_from_release_file(path): """ if not path or not os.path.exists(path): return None - tag = apt_pkg.ParseTagFile(open(path)) - tag.Step() - if not tag.Section.has_key("Date"): + tag = apt_pkg.TagFile(open(path)) + tag.step() + if not "Date" in tag.section: return None - date = tag.Section["Date"] - return apt_pkg.StrToTime(date) + date = tag.section["Date"] + return apt_pkg.str_to_time(date) def get_release_filename_for_pkg(cache, pkgname, label, release): " get the release file that provides this pkg " - if not cache.has_key(pkgname): + if pkgname not in cache: return None pkg = cache[pkgname] ver = None # look for the version that comes from the repos with # the given label and origin - for aver in pkg._pkg.VersionList: - if aver == None or aver.FileList == None: + for aver in pkg._pkg.version_list: + if aver == None or aver.file_list == None: continue - for verFile, index in aver.FileList: + for ver_file, index in aver.file_list: #print verFile - if (verFile.Origin == label and - verFile.Label == label and - verFile.Archive == release): + if (ver_file.origin == label and + ver_file.label == label and + ver_file.archive == release): ver = aver if not ver: return None - indexfile = cache._list.FindIndex(ver.FileList[0][0]) - for metaindex in cache._list.List: - for m in metaindex.IndexFiles: + indexfile = cache._list.find_index(ver.file_list[0][0]) + for metaindex in cache._list.list: + for m in metaindex.index_files: if (indexfile and - indexfile.Describe == m.Describe and - indexfile.IsTrusted): - dir = apt_pkg.Config.FindDir("Dir::State::lists") - name = apt_pkg.URItoFileName(metaindex.URI)+"dists_%s_Release" % metaindex.Dist + indexfile.describe == m.describe and + indexfile.is_trusted): + dir = apt_pkg.config.find_dir("Dir::State::lists") + name = apt_pkg.uri_to_filename(metaindex.uri)+"dists_%s_Release" % metaindex.dist return dir+name return None diff --git a/debian/changelog b/debian/changelog index c168de36..d981c8b5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +python-apt (0.7.93.2) UNRELEASED; urgency=low + + * Fix some places where the old API was still used: + - apt/utils.py: Completely ported, previous one was old-API from Ubuntu. + - apt/cache.py: Use the new progress classes instead of the old ones. + - apt/package.py: Various smaller issues fixed, probably caused by merge. + + -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 + python-apt (0.7.93.1) unstable; urgency=low [ Julian Andres Klode ] -- cgit v1.2.3 From 0401747854d7fc26eb097663822e26a988cf4aa4 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 7 Feb 2010 20:26:46 +0100 Subject: * utils/migrate-0.8.py: - Improve C++ parsing and add apt.progress.old to the modules, reduces false positives. --- debian/changelog | 3 +++ utils/migrate-0.8.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index d981c8b5..b09fb684 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,9 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low - apt/utils.py: Completely ported, previous one was old-API from Ubuntu. - apt/cache.py: Use the new progress classes instead of the old ones. - apt/package.py: Various smaller issues fixed, probably caused by merge. + * utils/migrate-0.8.py: + - Improve C++ parsing and add apt.progress.old to the modules, reduces + false positives. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index dc919e1d..61059b2a 100755 --- a/utils/migrate-0.8.py +++ b/utils/migrate-0.8.py @@ -82,8 +82,10 @@ def find_deprecated_cpp(): break while lines and not ';' in line: - while lines and not 'COMPAT_0_7' in line: + while lines and not 'COMPAT_0_7' in line and not ';' in line: line = lines.pop(0) + if ';' in line: + continue if lines: line = lines.pop(0) while lines and not '#endif' in line: @@ -122,8 +124,8 @@ def find_deprecated_py(): """ modules = ('apt', 'apt.package', 'apt.cdrom', 'apt.cache', 'apt.debfile', - 'apt.progress', 'aptsources.distinfo', 'aptsources.distro', - 'aptsources.sourceslist') + 'apt.progress', 'apt.progress.old', 'aptsources.distinfo', + 'aptsources.distro', 'aptsources.sourceslist') import apt_pkg apt_pkg._COMPAT_0_7 = 0 -- cgit v1.2.3 From c8fa835540d60393f2a1168625bf5d5ae01c4538 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 15:34:24 +0100 Subject: python/tagfile.cc: Implement the iterator protocol in TagFile. --- apt/debfile.py | 3 +-- apt/utils.py | 6 +++--- debian/changelog | 2 ++ doc/source/library/apt_pkg.rst | 29 ++++++++++++++++++++++++++--- python/tag.cc | 36 +++++++++++++++++++++++++++++++----- 5 files changed, 63 insertions(+), 13 deletions(-) (limited to 'debian') diff --git a/apt/debfile.py b/apt/debfile.py index 65f43f20..e27917d5 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -448,9 +448,8 @@ class DscSrcPackage(DebPackage): fobj = open(file) tagfile = apt_pkg.TagFile(fobj) - sec = tagfile.section try: - while tagfile.step() == 1: + for sec in tagfile: for tag in depends_tags: if not tag in sec: continue diff --git a/apt/utils.py b/apt/utils.py index 8949c2ab..61d5d54f 100644 --- a/apt/utils.py +++ b/apt/utils.py @@ -39,10 +39,10 @@ def get_release_date_from_release_file(path): if not path or not os.path.exists(path): return None tag = apt_pkg.TagFile(open(path)) - tag.step() - if not "Date" in tag.section: + section = tag.next() + if not "Date" in section: return None - date = tag.section["Date"] + date = section["Date"] return apt_pkg.str_to_time(date) def get_release_filename_for_pkg(cache, pkgname, label, release): diff --git a/debian/changelog b/debian/changelog index b09fb684..fe0d3b9a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low * utils/migrate-0.8.py: - Improve C++ parsing and add apt.progress.old to the modules, reduces false positives. + * python/tagfile.cc: + - Implement the iterator protocol in TagFile. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst index 7989a68a..05b3e1fc 100644 --- a/doc/source/library/apt_pkg.rst +++ b/doc/source/library/apt_pkg.rst @@ -1407,9 +1407,32 @@ section as a string. .. class:: TagFile(file) An object which represents a typical debian control file. Can be used for - Packages, Sources, control, Release, etc. + Packages, Sources, control, Release, etc. Such an object provides two + kinds of API which should not be used together: - An example for working with a TagFile could look like:: + The first API implements the iterator protocol and should be used whenever + possible because it has less side effects than the other one. It may be + used e.g. with a for loop:: + + tagf = apt_pkg.TagFile(open('/var/lib/dpkg/status')) + for section in tagfile: + print section['Package'] + + .. method:: next() + + A TagFile is its own iterator. This method is part of the iterator + protocol and returns a :class:`TagSection` object for the next + section in the file. If there is no further section, this method + raises the :exc:`StopIteration` exception. + + From Python 3 on, this method is not available anymore, and the + global function ``next()`` replaces it. + + The second API uses a shared :class:`TagSection` object which is exposed + through the :attr:`section` attribute. This object is modified by calls + to :meth:`step` and :meth:`jump`. This API provides more control and may + use less memory, but is not recommended because it works by modifying + one object. It can be used like this:: tagf = apt_pkg.TagFile(open('/var/lib/dpkg/status')) tagf.step() @@ -1418,7 +1441,7 @@ section as a string. .. method:: step Step forward to the next section. This simply returns ``1`` if OK, and - ``0`` if there is no section + ``0`` if there is no section. .. method:: offset diff --git a/python/tag.cc b/python/tag.cc index 2aaf3beb..4971a03d 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -258,6 +258,28 @@ static PyObject *TagFileStep(PyObject *Self,PyObject *Args) return HandleErrors(Py_BuildValue("i",1)); } +// TagFile Wrappers /*{{{*/ +static PyObject *TagFileNext(PyObject *Self) +{ + TagFileData &Obj = *(TagFileData *)Self; + // Replace the section. + Py_CLEAR(Obj.Section); + Obj.Section = (TagSecData*)(&PyTagSection_Type)->tp_alloc(&PyTagSection_Type, 0); + new (&Obj.Section->Object) pkgTagSection(); + Obj.Section->Owner = Self; + Py_INCREF(Obj.Section->Owner); + Obj.Section->Data = 0; + if (Obj.Object.Step(Obj.Section->Object) == false) + return HandleErrors(NULL); + Py_INCREF(Obj.Section); + return HandleErrors(Obj.Section); +} + +static PyObject *TagFileIter(PyObject *Self) { + Py_INCREF(Self); + return Self; +} + static char *doc_Offset = "Offset() -> Integer"; static PyObject *TagFileOffset(PyObject *Self,PyObject *Args) { @@ -541,9 +563,13 @@ static PyGetSetDef TagFileGetSet[] = { static char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n" "TagFile() objects provide access to debian control files, which consists\n" "of multiple RFC822-like formatted sections.\n\n" - "A file may consists of multiple sections, and you can use Step() to move\n" - "forward. The current TagSection() is available via the attribute section" - ".\n\n" + "To provide access to those sections, TagFile objects provide an iterator\n" + "which yields TagSection objects for each section.\n\n" + "TagFile objects also provide another API which uses a shared TagSection\n" + "object in the 'section' member. The functions step() and jump() can be\n" + "used to navigate in the file; and offset() tells the current position.\n\n" + "It is important to not mix the use of both APIs, because this can have\n" + "unwanted effects.\n\n" "The parameter *file* refers to an object providing a fileno() method or\n" "a file descriptor (an integer)"; @@ -578,8 +604,8 @@ PyTypeObject PyTagFile_Type = TagFileClear, // tp_clear 0, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter - 0, // tp_iternext + TagFileIter, // tp_iter + TagFileNext, // tp_iternext TagFileMethods, // tp_methods 0, // tp_members TagFileGetSet, // tp_getset -- cgit v1.2.3 From f594f8f2b8e90717ccbdcc3d17ada3c7d0e9163a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 16:40:52 +0100 Subject: * data/templates/Debian.info.in: - Replace the MatchURI with one that really matches something. --- data/templates/Debian.info.in | 15 ++++++++------- debian/changelog | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'debian') diff --git a/data/templates/Debian.info.in b/data/templates/Debian.info.in index e5a1b424..9ea368d6 100644 --- a/data/templates/Debian.info.in +++ b/data/templates/Debian.info.in @@ -3,7 +3,7 @@ _ChangelogURI: http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changel Suite: squeeze RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ -MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian 6.0 'Squeeze' Component: main @@ -28,7 +28,7 @@ _Description: Security updates Suite: lenny RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ -MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian 5.0 'Lenny' Component: main @@ -53,7 +53,7 @@ _Description: Security updates Suite: etch RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ -MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian 4.0 'Etch' Component: main @@ -78,7 +78,7 @@ _Description: Security updates Suite: sarge RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ -MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian 3.1 'Sarge' Component: main @@ -103,7 +103,7 @@ _Description: Security updates Suite: stable RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ -MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian current stable release Component: main @@ -116,7 +116,7 @@ _CompDescription: Non-DFSG-compatible Software Suite: testing RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ -MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian testing Component: main @@ -129,7 +129,7 @@ _CompDescription: Non-DFSG-compatible Software Suite: sid RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ -MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian 'Sid' (unstable) Component: main @@ -142,6 +142,7 @@ _CompDescription: Non-DFSG-compatible Software Suite: unstable RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ +MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors _Description: Debian 'Sid' (unstable) Component: main diff --git a/debian/changelog b/debian/changelog index fe0d3b9a..ad42ddda 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low false positives. * python/tagfile.cc: - Implement the iterator protocol in TagFile. + * data/templates/Debian.info.in: + - Replace the MatchURI with one that really matches something. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 -- cgit v1.2.3 From dadba850a99f4ae87ac0a7a89b60bae849d76306 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 16:41:39 +0100 Subject: * tests: - Fix aptsources tests to use local data files if available. --- debian/changelog | 2 ++ tests/test_aptsources.py | 12 ++++++++---- tests/test_aptsources_ports.py | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index ad42ddda..57a42c60 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low - Implement the iterator protocol in TagFile. * data/templates/Debian.info.in: - Replace the MatchURI with one that really matches something. + * tests: + - Fix aptsources tests to use local data files if available. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 0ae05bf3..0f7f078b 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -16,6 +16,10 @@ class TestAptSources(unittest.TestCase): apt_pkg.init_system() apt_pkg.config.set("Dir::Etc", os.getcwd()) apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + if os.path.exists("../build/data/templates"): + self.templates = os.path.abspath("../build/data/templates") + else: + self.templates = "/usr/share/python-apt/templates/" def testIsMirror(self): """aptsources: Test mirror detection.""" @@ -30,7 +34,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test sources.list parsing.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) self.assertEqual(len(sources.list), 6) # test load sources.list = [] @@ -41,7 +45,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test additions to sources.list""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) # test to add something that is already there (main) before = copy.deepcopy(sources) sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/", @@ -91,7 +95,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test matcher""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list.testDistribution") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) distro = aptsources.distro.get_distro() distro.get_sources(sources) # test if all suits of the current distro were detected correctly @@ -104,7 +108,7 @@ class TestAptSources(unittest.TestCase): """aptsources: Test distribution detection.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" "sources.list.testDistribution") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) distro = aptsources.distro.get_distro() distro.get_sources(sources) # test if all suits of the current distro were detected correctly diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py index f837585b..991b532a 100644 --- a/tests/test_aptsources_ports.py +++ b/tests/test_aptsources_ports.py @@ -18,11 +18,15 @@ class TestAptSourcesPorts(unittest.TestCase): apt_pkg.config.set("Dir::Etc", os.path.abspath("data/aptsources_ports")) apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") + if os.path.exists("../build/data/templates"): + self.templates = os.path.abspath("../build/data/templates") + else: + self.templates = "/usr/share/python-apt/templates/" def testMatcher(self): """aptsources_ports: Test matcher.""" apt_pkg.config.set("Dir::Etc::sourcelist", "sources.list") - sources = aptsources.sourceslist.SourcesList() + sources = aptsources.sourceslist.SourcesList(True, self.templates) distro = aptsources.distro.get_distro("Ubuntu", "hardy", "desc", "8.04") distro.get_sources(sources) -- cgit v1.2.3 From 5d3142e5fb0d6d9389b5942ccca1d720262fb690 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 17:03:33 +0100 Subject: * aptsources/distro.py: - Call lsb_release with -idrc instead of --all. --- aptsources/distro.py | 4 ++-- debian/changelog | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/aptsources/distro.py b/aptsources/distro.py index ff1bed89..1e60a0ed 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -438,14 +438,14 @@ class UbuntuDistribution(Distribution): self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/") def _lsb_release(): - """Call lsb_release --all and return a mapping.""" + """Call lsb_release --idrc and return a mapping.""" from subprocess import Popen, PIPE import errno result = {'Codename': 'sid', 'Distributor ID': 'Debian', 'Description': 'Debian GNU/Linux unstable (sid)', 'Release': 'unstable'} try: - out = Popen(['lsb_release', '--all'], stdout=PIPE).communicate()[0] + out = Popen(['lsb_release', '-idrc'], stdout=PIPE).communicate()[0] # Convert to unicode string, needed for Python 3.1 out = out.decode("utf-8") result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) diff --git a/debian/changelog b/debian/changelog index 57a42c60..e076d029 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low - Implement the iterator protocol in TagFile. * data/templates/Debian.info.in: - Replace the MatchURI with one that really matches something. + * aptsources/distro.py: + - Call lsb_release with -idrc instead of --all. * tests: - Fix aptsources tests to use local data files if available. -- cgit v1.2.3 From eb37b3a44fe8e6f15de5211d89fcf63cdf2f6fa6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 17:05:58 +0100 Subject: test_all.py: Use local modules instead of system ones if possible. --- debian/changelog | 1 + tests/test_all.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index e076d029..c63d3a16 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low - Call lsb_release with -idrc instead of --all. * tests: - Fix aptsources tests to use local data files if available. + - test_all.py: Use local modules instead of system ones if possible. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/tests/test_all.py b/tests/test_all.py index ea74e09b..6900e0ad 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -7,9 +7,24 @@ """Run all available unit tests.""" import os import unittest +import sys if __name__ == '__main__': os.chdir(os.path.dirname(__file__)) + # Find the path to the built apt_pkg and apt_inst extensions + if os.path.exists("../build"): + from distutils.util import get_platform + from distutils.sysconfig import get_python_version + # Set the path to the build directory. + plat_specifier = ".%s-%s" % (get_platform(), get_python_version()) + if sys.version_info[0] >= 3 or sys.version_info[1] >= 6: + library_dir = "../build/lib%s%s" % (plat_specifier, + (sys.pydebug and "-pydebug" or "")) + else: + library_dir = "../build/lib%s%s" % ((sys.pydebug and "_d" or ""), + plat_specifier) + sys.path.insert(0, os.path.abspath(library_dir)) + for path in os.listdir('.'): if path.endswith('.py') and os.path.isfile(path): exec('from %s import *' % path[:-3]) -- cgit v1.2.3 From 24971a75407f0b28f2cb4e890545a0f5825af87d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 17:27:59 +0100 Subject: * data/templates/*.in: Switch MirrorsFile to relative filenames. - setup.py: Copy the mirror lists to the build directory - aptsources/distinfo.py: Support relative filenames for MirrorsFile. --- aptsources/distinfo.py | 3 +++ data/templates/Debian.info.in | 16 ++++++++-------- data/templates/Ubuntu.info.in | 32 ++++++++++++++++---------------- debian/changelog | 3 +++ setup.py | 4 ++++ 5 files changed, 34 insertions(+), 24 deletions(-) (limited to 'debian') diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 0aa34f20..19308348 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -220,6 +220,9 @@ class DistInfo(object): template.match_uri = value elif (field == 'MirrorsFile' or field == 'MirrorsFile-%s' % self.arch): + # Make the path absolute. + value = os.path.isabs(value) and value or \ + os.path.abspath(os.path.join(base_dir, value)) if value not in map_mirror_sets: mirror_set = {} try: diff --git a/data/templates/Debian.info.in b/data/templates/Debian.info.in index 9ea368d6..b9f70940 100644 --- a/data/templates/Debian.info.in +++ b/data/templates/Debian.info.in @@ -4,7 +4,7 @@ Suite: squeeze RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian 6.0 'Squeeze' Component: main _CompDescription: Officially supported @@ -29,7 +29,7 @@ Suite: lenny RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian 5.0 'Lenny' Component: main _CompDescription: Officially supported @@ -54,7 +54,7 @@ Suite: etch RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian 4.0 'Etch' Component: main _CompDescription: Officially supported @@ -79,7 +79,7 @@ Suite: sarge RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian 3.1 'Sarge' Component: main _CompDescription: Officially supported @@ -104,7 +104,7 @@ Suite: stable RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian current stable release Component: main _CompDescription: Officially supported @@ -117,7 +117,7 @@ Suite: testing RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian testing Component: main _CompDescription: Officially supported @@ -130,7 +130,7 @@ Suite: sid RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian 'Sid' (unstable) Component: main _CompDescription: Officially supported @@ -143,7 +143,7 @@ Suite: unstable RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org -MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +MirrorsFile: Debian.mirrors _Description: Debian 'Sid' (unstable) Component: main _CompDescription: Officially supported diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index 2335454f..1ca76927 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -8,8 +8,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: /usr/share/python-apt/templates/Ubuntu.mirrors -MirrorsFile-i386: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 10.04 'Lucid Lynx' Component: main _CompDescription: Officially supported @@ -69,8 +69,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: /usr/share/python-apt/templates/Ubuntu.mirrors -MirrorsFile-i386: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.10 'Karmic Koala' Component: main _CompDescription: Officially supported @@ -130,8 +130,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: /usr/share/python-apt/templates/Ubuntu.mirrors -MirrorsFile-i386: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.04 'Jaunty Jackalope' Component: main _CompDescription: Officially supported @@ -191,8 +191,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: /usr/share/python-apt/templates/Ubuntu.mirrors -MirrorsFile-i386: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.10 'Intrepid Ibex' Component: main _CompDescription: Officially supported @@ -253,8 +253,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: /usr/share/python-apt/templates/Ubuntu.mirrors -MirrorsFile-i386: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.04 'Hardy Heron' Component: main _CompDescription: Officially supported @@ -309,7 +309,7 @@ Suite: gutsy RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ MatchURI: archive.ubuntu.com/ubuntu -MirrorsFile: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 7.10 'Gutsy Gibbon' Component: main _CompDescription: Officially supported @@ -362,7 +362,7 @@ Suite: feisty RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ MatchURI: archive.ubuntu.com/ubuntu -MirrorsFile: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 7.04 'Feisty Fawn' Component: main _CompDescription: Officially supported @@ -414,7 +414,7 @@ Suite: edgy RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ MatchURI: archive.ubuntu.com/ubuntu -MirrorsFile: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 6.10 'Edgy Eft' Component: main _CompDescription: Officially supported @@ -466,7 +466,7 @@ Suite: dapper RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ MatchURI: archive.ubuntu.com/ubuntu -MirrorsFile: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 6.06 LTS 'Dapper Drake' Component: main _CompDescription: Officially supported @@ -518,7 +518,7 @@ Suite: breezy RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ MatchURI: archive.ubuntu.com/ubuntu -MirrorsFile: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 5.10 'Breezy Badger' Component: main _CompDescription: Officially supported @@ -561,7 +561,7 @@ Suite: hoary RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ MatchURI: archive.ubuntu.com/ubuntu -MirrorsFile: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 5.04 'Hoary Hedgehog' Component: main _CompDescription: Officially supported diff --git a/debian/changelog b/debian/changelog index c63d3a16..cfdc5301 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,9 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low * tests: - Fix aptsources tests to use local data files if available. - test_all.py: Use local modules instead of system ones if possible. + * data/templates/*.in: Switch MirrorsFile to relative filenames. + - setup.py: Copy the mirror lists to the build directory + - aptsources/distinfo.py: Support relative filenames for MirrorsFile. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/setup.py b/setup.py index 2fa8198b..b285fcee 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,10 @@ if len(sys.argv) > 1 and sys.argv[1] == "build": build.write(line.lstrip("_")) source.close() build.close() + for template in glob.glob('data/templates/*.mirrors'): + import shutil + shutil.copy(template, os.path.join("build", template)) + setup(name="python-apt", description="Python bindings for APT", -- cgit v1.2.3 From 930f6a2899b0b410777397fb206a8eba8c99100c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Feb 2010 17:28:19 +0100 Subject: * debian/rules: - Run tests during build time. --- debian/changelog | 2 ++ debian/rules | 5 +++++ 2 files changed, 7 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index cfdc5301..4b93dddc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low * data/templates/*.in: Switch MirrorsFile to relative filenames. - setup.py: Copy the mirror lists to the build directory - aptsources/distinfo.py: Support relative filenames for MirrorsFile. + * debian/rules: + - Run tests during build time. -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/debian/rules b/debian/rules index 1a45a710..24d0952e 100755 --- a/debian/rules +++ b/debian/rules @@ -19,3 +19,8 @@ override_dh_strip: override_dh_compress: dh_compress -X.js -X_static/* -X _sources/* -X_sources/*/* -X.inv + +override_dh_auto_test: + set -e; for python in $(shell pyversions -r); do \ + $$python tests/test_all.py -q; \ + done; -- cgit v1.2.3 From 972bf036a69f3f41ae5709568e246529b8e40ba5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Feb 2010 16:45:03 +0100 Subject: * apt/cache.py: - call install_progress.startUpdate()/finishUpdate() to keep compatibility with older code * apt/progress/base.py: - restore "self.statusfd, self.writefd" type, provide additional self.status_pipe and self.write_pipe file like objects --- apt/cache.py | 9 +++++---- apt/progress/base.py | 14 +++++++------- debian/changelog | 9 +++++++++ 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index 24d63361..b5733d98 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -328,15 +328,16 @@ class Cache(object): The second parameter *install_progress* refers to an InstallProgress() object of the module apt.progress. """ + # compat with older API try: - install_progress.start_update() - except AttributeError: install_progress.startUpdate() + except AttributeError: + install_progress.start_update() res = install_progress.run(pm) try: - install_progress.finish_update() - except AttributeError: install_progress.finishUpdate() + except AttributeError: + install_progress.finish_update() return res @deprecated_args diff --git a/apt/progress/base.py b/apt/progress/base.py index 6636cccc..ccf618f9 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -139,9 +139,9 @@ class InstallProgress(object): percent, select_timeout, status = 0.0, 0.1, "" def __init__(self): - (read, write) = os.pipe() - self.writefd = os.fdopen(write, "w") - self.statusfd = os.fdopen(read, "r") + (self.statusfd, self.writefd) = os.pipe() + self.write_pipe = os.fdopen(self.writefd, "w") + self.status_pipe = os.fdopen(self.statusfd, "r") fcntl.fcntl(self.statusfd, fcntl.F_SETFL, os.O_NONBLOCK) def start_update(self): @@ -190,10 +190,10 @@ class InstallProgress(object): # and the execution continues in the # parent code leading to very confusing bugs try: - os._exit(obj.do_install(self.writefd.fileno())) + os._exit(obj.do_install(self.write_pipe.fileno())) except AttributeError: os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", - str(self.writefd.fileno()), "-i", obj)) + str(self.write_pipe.fileno()), "-i", obj)) except Exception: os._exit(apt_pkg.PackageManager.RESULT_FAILED) @@ -208,7 +208,7 @@ class InstallProgress(object): def update_interface(self): """Update the interface.""" try: - line = self.statusfd.readline() + line = self.status_pipe.readline() except IOError, err: # resource temporarly unavailable is ignored if err.errno != errno.EAGAIN and err.errno != errno.EWOULDBLOCK: @@ -263,7 +263,7 @@ class InstallProgress(object): (pid, res) = (0, 0) while True: try: - select.select([self.statusfd], [], [], self.select_timeout) + select.select([self.status_pipe], [], [], self.select_timeout) except select.error, (errno_, errstr): if errno_ != errno.EINTR: raise diff --git a/debian/changelog b/debian/changelog index 4b93dddc..012a6e1d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low + [ Julian Andres Klode ] * Fix some places where the old API was still used: - apt/utils.py: Completely ported, previous one was old-API from Ubuntu. - apt/cache.py: Use the new progress classes instead of the old ones. @@ -21,6 +22,14 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low - aptsources/distinfo.py: Support relative filenames for MirrorsFile. * debian/rules: - Run tests during build time. + + [ Michael Vogt ] + * apt/cache.py: + - call install_progress.startUpdate()/finishUpdate() to keep + compatibility with older code + * apt/progress/base.py: + - restore "self.statusfd, self.writefd" type, provide additional + self.status_pipe and self.write_pipe file like objects -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 -- cgit v1.2.3 From 178f73f96a3752d492927bd6b8925b7967a0285c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Feb 2010 16:52:33 +0100 Subject: apt/progress/base.py: call pipe ends {write,status}_stream --- apt/progress/base.py | 12 ++++++------ debian/changelog | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'debian') diff --git a/apt/progress/base.py b/apt/progress/base.py index ccf618f9..88fee206 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -140,8 +140,8 @@ class InstallProgress(object): def __init__(self): (self.statusfd, self.writefd) = os.pipe() - self.write_pipe = os.fdopen(self.writefd, "w") - self.status_pipe = os.fdopen(self.statusfd, "r") + self.write_stream = os.fdopen(self.writefd, "w") + self.status_stream = os.fdopen(self.statusfd, "r") fcntl.fcntl(self.statusfd, fcntl.F_SETFL, os.O_NONBLOCK) def start_update(self): @@ -190,10 +190,10 @@ class InstallProgress(object): # and the execution continues in the # parent code leading to very confusing bugs try: - os._exit(obj.do_install(self.write_pipe.fileno())) + os._exit(obj.do_install(self.write_stream.fileno())) except AttributeError: os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", - str(self.write_pipe.fileno()), "-i", obj)) + str(self.write_stream.fileno()), "-i", obj)) except Exception: os._exit(apt_pkg.PackageManager.RESULT_FAILED) @@ -208,7 +208,7 @@ class InstallProgress(object): def update_interface(self): """Update the interface.""" try: - line = self.status_pipe.readline() + line = self.status_stream.readline() except IOError, err: # resource temporarly unavailable is ignored if err.errno != errno.EAGAIN and err.errno != errno.EWOULDBLOCK: @@ -263,7 +263,7 @@ class InstallProgress(object): (pid, res) = (0, 0) while True: try: - select.select([self.status_pipe], [], [], self.select_timeout) + select.select([self.status_stream], [], [], self.select_timeout) except select.error, (errno_, errstr): if errno_ != errno.EINTR: raise diff --git a/debian/changelog b/debian/changelog index 012a6e1d..8c488e0b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,7 +29,7 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low compatibility with older code * apt/progress/base.py: - restore "self.statusfd, self.writefd" type, provide additional - self.status_pipe and self.write_pipe file like objects + self.status_stream and self.write_stream file like objects -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 -- cgit v1.2.3 From 478a5ebf8c3e7bb4b17981e51d6341309bba3df6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Feb 2010 17:27:59 +0100 Subject: * python/progress.cc: - try to call compatibility functions first, then new functions --- debian/changelog | 2 ++ python/progress.cc | 45 ++++++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 8c488e0b..ddb94ecf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low * apt/progress/base.py: - restore "self.statusfd, self.writefd" type, provide additional self.status_stream and self.write_stream file like objects + * python/progress.cc: + - try to call compatibility functions first, then new functions -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 diff --git a/python/progress.cc b/python/progress.cc index bedad935..ee8f9348 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -134,10 +134,10 @@ bool PyFetchProgress::MediaChange(string Media, string Drive) PyObject *arglist = Py_BuildValue("(ss)", Media.c_str(), Drive.c_str()); PyObject *result; - if(PyObject_HasAttrString(callbackInst, "media_change")) - RunSimpleCallback("media_change", arglist, &result); - else + if(PyObject_HasAttrString(callbackInst, "mediaChange")) RunSimpleCallback("mediaChange", arglist, &result); + else + RunSimpleCallback("media_change", arglist, &result); bool res = true; if(!PyArg_Parse(result, "b", &res)) { @@ -170,10 +170,10 @@ void PyFetchProgress::UpdateStatus(pkgAcquire::ItemDesc &Itm, int status) arglist = Py_BuildValue("(sssi)", Itm.URI.c_str(), Itm.Description.c_str(), Itm.ShortDesc.c_str(), status); - if(PyObject_HasAttrString(callbackInst, "update_status")) - RunSimpleCallback("update_status", arglist); - else + if(PyObject_HasAttrString(callbackInst, "updateStatus")) RunSimpleCallback("updateStatus", arglist); + else + RunSimpleCallback("update_status", arglist); } void PyFetchProgress::IMSHit(pkgAcquire::ItemDesc &Itm) @@ -496,10 +496,10 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) if(PyObject_HasAttrString(callbackInst, "waitChild") || PyObject_HasAttrString(callbackInst, "wait_child")) { PyObject *method; - if (PyObject_HasAttrString(callbackInst, "wait_child")) - method = PyObject_GetAttrString(callbackInst, "wait_child"); - else + if (PyObject_HasAttrString(callbackInst, "waitChild")) method = PyObject_GetAttrString(callbackInst, "waitChild"); + else + method = PyObject_GetAttrString(callbackInst, "wait_child"); //std::cerr << "custom waitChild found" << std::endl; PyObject *arglist = Py_BuildValue("(i)",child_id); PyObject *result = PyObject_CallObject(method, arglist); @@ -553,10 +553,10 @@ bool PyCdromProgress::ChangeCdrom() { PyObject *arglist = Py_BuildValue("()"); PyObject *result; - if (PyObject_HasAttrString(callbackInst, "change_cdrom")) - RunSimpleCallback("change_cdrom", arglist, &result); - else + if (PyObject_HasAttrString(callbackInst, "changeCdrom")) RunSimpleCallback("changeCdrom", arglist, &result); + else + RunSimpleCallback("change_cdrom", arglist, &result); bool res = true; if(!PyArg_Parse(result, "b", &res)) @@ -573,8 +573,17 @@ bool PyCdromProgress::AskCdromName(string &Name) bool res; PyObject *result; + // Old style: (True, name) on success, (False, name) on failure. + if (PyObject_HasAttrString(callbackInst, "askAdromName")) { + RunSimpleCallback("ask_cdrom_name", arglist, &result); + if(!PyArg_Parse(result, "(bs)", &res, &new_name)) + std::cerr << "AskCdromName: result could not be parsed" << std::endl; + // set the new name + Name = string(new_name); + return res; + } // New style: String on success, None on failure. - if (PyObject_HasAttrString(callbackInst, "ask_cdrom_name")) { + else { RunSimpleCallback("ask_cdrom_name", arglist, &result); if(result == Py_None) return false; @@ -583,15 +592,5 @@ bool PyCdromProgress::AskCdromName(string &Name) else Name = string(new_name); return true; - } - // Old style: (True, name) on success, (False, name) on failure. - else { - RunSimpleCallback("askCdromName", arglist, &result); - if(!PyArg_Parse(result, "(bs)", &res, &new_name)) - std::cerr << "AskCdromName: result could not be parsed" << std::endl; - // set the new name - Name = string(new_name); - - return res; } } -- cgit v1.2.3 From 13361b7bfa6aa00c02ab9639317495bd2c4ab0a5 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 27 Feb 2010 13:57:32 +0100 Subject: * python/cache.cc: - Implement Cache.__len__() and Cache.__contains__() (Closes: #571443). --- debian/changelog | 2 ++ python/cache.cc | 27 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index ddb94ecf..25553644 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low false positives. * python/tagfile.cc: - Implement the iterator protocol in TagFile. + * python/cache.cc: + - Implement Cache.__len__() and Cache.__contains__() (Closes: #571443). * data/templates/Debian.info.in: - Replace the MatchURI with one that really matches something. * aptsources/distro.py: diff --git a/python/cache.cc b/python/cache.cc index fe6e8b68..5743d9df 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -253,6 +253,16 @@ static PyObject *CacheMapOp(PyObject *Self,PyObject *Arg) return CppPyObject_NEW(Self,&PyPackage_Type,Pkg); } +// Check whether the cache contains a package with a given name. +static int CacheContains(PyObject *Self,PyObject *Arg) +{ + // Get the name of the package, unicode and normal strings. + const char *Name = PyObject_AsString(Arg); + if (Name == NULL) + return 0; + return (GetCpp(Self)->FindPkg(Name).end() == false); +} + static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) { PyObject *pyCallbackInst = 0; @@ -305,14 +315,21 @@ static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) return CacheObj; } +static Py_ssize_t CacheMapLen(PyObject *Self) +{ + return GetCpp(Self)->HeaderP->PackageCount; +} + static char *doc_PkgCache = "Cache([progress]) -> Cache() object.\n\n" "The cache provides access to the packages and other stuff.\n\n" "The optional parameter *progress* can be used to specify an \n" "apt.progress.OpProgress() object (or similar) which displays\n" - "the opening progress.\n\n" - "If not specified, the progress is displayed in simple text form."; - -static PyMappingMethods CacheMap = {0,CacheMapOp,0}; + "the opening progress. If not specified, the progress is\n" + "displayed in simple text form.\n\n" + "The cache can be used like a mapping of package names to Package\n" + "objects."; +static PySequenceMethods CacheSeq = {0,0,0,0,0,0,0,CacheContains,0,0}; +static PyMappingMethods CacheMap = {CacheMapLen,CacheMapOp,0}; PyTypeObject PyCache_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) @@ -327,7 +344,7 @@ PyTypeObject PyCache_Type = 0, // tp_compare 0, // tp_repr 0, // tp_as_number - 0, // tp_as_sequence + &CacheSeq, // tp_as_sequence &CacheMap, // tp_as_mapping 0, // tp_hash 0, // tp_call -- cgit v1.2.3 From a169fd15520d61303639c0dfa2aabec3f6446fb6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 27 Feb 2010 17:31:39 +0100 Subject: * python: - Handle deprecated attributes and methods in the tp_gettattro slot, this allows us to easily warn if a deprecated function is used. --- debian/changelog | 7 ++-- python/acquire-item.cc | 13 +------- python/acquire.cc | 12 +------ python/cache.cc | 88 ++++--------------------------------------------- python/cdrom.cc | 8 +++-- python/configuration.cc | 16 +-------- python/depcache.cc | 46 ++------------------------ python/generic.cc | 62 ++++++++++++++++++++++++++++++++++ python/generic.h | 6 ++++ python/indexfile.cc | 13 +------- python/metaindex.cc | 8 +---- python/pkgmanager.cc | 7 +--- python/pkgrecords.cc | 19 +---------- python/pkgsrcrecords.cc | 14 +------- python/sourcelist.cc | 10 +----- python/tag.cc | 19 ++--------- 16 files changed, 98 insertions(+), 250 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 25553644..e5945ef4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.93.2) UNRELEASED; urgency=low +python-apt (0.7.93.2) unstable; urgency=low [ Julian Andres Klode ] * Fix some places where the old API was still used: @@ -8,6 +8,9 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low * utils/migrate-0.8.py: - Improve C++ parsing and add apt.progress.old to the modules, reduces false positives. + * python: + - Handle deprecated attributes and methods in the tp_gettattro slot, this + allows us to easily warn if a deprecated function is used. * python/tagfile.cc: - Implement the iterator protocol in TagFile. * python/cache.cc: @@ -35,7 +38,7 @@ python-apt (0.7.93.2) UNRELEASED; urgency=low * python/progress.cc: - try to call compatibility functions first, then new functions - -- Julian Andres Klode Sun, 07 Feb 2010 19:58:40 +0100 + -- Julian Andres Klode Sat, 27 Feb 2010 14:00:43 +0100 python-apt (0.7.93.1) unstable; urgency=low diff --git a/python/acquire-item.cc b/python/acquire-item.cc index d5f9ad10..09f0d643 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -128,17 +128,6 @@ static PyGetSetDef acquireitem_getset[] = { {"is_trusted",acquireitem_get_is_trusted}, {"local",acquireitem_get_local}, {"status",acquireitem_get_status}, -#ifdef COMPAT_0_7 - {"Complete",acquireitem_get_complete}, - {"DescURI",acquireitem_get_desc_uri}, - {"DestFile",acquireitem_get_destfile}, - {"ErrorText",acquireitem_get_error_text}, - {"FileSize",acquireitem_get_filesize}, - {"ID",acquireitem_get_id}, - {"IsTrusted",acquireitem_get_is_trusted}, - {"Local",acquireitem_get_local}, - {"Status",acquireitem_get_status}, -#endif {} }; @@ -180,7 +169,7 @@ PyTypeObject PyAcquireItem_Type = { 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | diff --git a/python/acquire.cc b/python/acquire.cc index 5e22280e..cc9ee310 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -229,10 +229,6 @@ static PyObject *PkgAcquireShutdown(PyObject *Self,PyObject *Args) static PyMethodDef PkgAcquireMethods[] = { {"run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"}, {"shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"}, -#ifdef COMPAT_0_7 - {"Run",PkgAcquireRun,METH_VARARGS,"Run the fetcher"}, - {"Shutdown",PkgAcquireShutdown, METH_VARARGS,"Shutdown the fetcher"}, -#endif {} }; @@ -284,12 +280,6 @@ static PyGetSetDef PkgAcquireGetSet[] = { {"workers",PkgAcquireGetWorkers}, {"partial_present",PkgAcquireGetPartialPresent}, {"total_needed",PkgAcquireGetTotalNeeded}, -#ifdef COMPAT_0_7 - {"FetchNeeded",PkgAcquireGetFetchNeeded}, - {"Items",PkgAcquireGetItems}, - {"PartialPresent",PkgAcquireGetPartialPresent}, - {"TotalNeeded",PkgAcquireGetTotalNeeded}, -#endif {} }; @@ -354,7 +344,7 @@ PyTypeObject PyAcquire_Type = { 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/cache.cc b/python/cache.cc index 5743d9df..3c9bc785 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -153,7 +153,6 @@ static PyMethodDef PkgCacheMethods[] = { {"update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, #ifdef COMPAT_0_7 - {"Update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, {"Open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, {"Close", PkgCacheClose, METH_VARARGS,"Close the cache"}, #endif @@ -216,16 +215,6 @@ static PyGetSetDef PkgCacheGetSet[] = { {"provides_count",PkgCacheGetProvidesCount}, {"ver_file_count",PkgCacheGetVerFileCount}, {"version_count",PkgCacheGetVersionCount}, -#ifdef COMPAT_0_7 - {"DependsCount",PkgCacheGetDependsCount}, - {"FileList",PkgCacheGetFileList}, - {"PackageCount",PkgCacheGetPackageCount}, - {"PackageFileCount",PkgCacheGetPackageFileCount}, - {"Packages",PkgCacheGetPackages}, - {"ProvidesCount",PkgCacheGetProvidesCount}, - {"VerFileCount",PkgCacheGetVerFileCount}, - {"VersionCount",PkgCacheGetVersionCount}, -#endif {} }; @@ -349,7 +338,7 @@ PyTypeObject PyCache_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags @@ -543,21 +532,6 @@ static PyGetSetDef PackageGetSet[] = { {"important",PackageGetImportant}, {"version_list",PackageGetVersionList}, {"current_ver",PackageGetCurrentVer}, - #ifdef COMPAT_0_7 - {"Name",PackageGetName}, - {"Section",PackageGetSection}, - {"RevDependsList",PackageGetRevDependsList}, - {"ProvidesList",PackageGetProvidesList}, - {"SelectedState",PackageGetSelectedState}, - {"InstState",PackageGetInstState}, - {"CurrentState",PackageGetCurrentState}, - {"ID",PackageGetID}, - {"Auto",PackageGetAuto}, - {"Essential",PackageGetEssential}, - {"Important",PackageGetImportant}, - {"VersionList",PackageGetVersionList}, - {"CurrentVer",PackageGetCurrentVer}, - #endif {} }; @@ -590,7 +564,7 @@ PyTypeObject PyPackage_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags @@ -641,10 +615,6 @@ static PyGetSetDef DescriptionGetSet[] = { {"language_code",DescriptionGetLanguageCode}, {"md5",DescriptionGetMd5}, {"file_list",DescriptionGetFileList}, - #ifdef COMPAT_0_7 - {"LanguageCode",DescriptionGetLanguageCode}, - {"FileList",DescriptionGetFileList}, - #endif {} }; @@ -675,7 +645,7 @@ PyTypeObject PyDescription_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags @@ -886,24 +856,6 @@ static PyGetSetDef VersionGetSet[] = { {"size",VersionGetSize}, {"translated_description",VersionGetTranslatedDescription}, {"ver_str",VersionGetVerStr}, -#ifdef COMPAT_0_7 - {"Arch",VersionGetArch}, - {"DependsList",VersionGetDependsList}, - {"DependsListStr",VersionGetDependsListStr}, - {"Downloadable",VersionGetDownloadable}, - {"FileList",VersionGetFileList}, - {"Hash",VersionGetHash}, - {"ID",VersionGetID}, - {"InstalledSize",VersionGetInstalledSize}, - {"ParentPkg",VersionGetParentPkg}, - {"Priority",VersionGetPriority}, - {"PriorityStr",VersionGetPriorityStr}, - {"ProvidesList",VersionGetProvidesList}, - {"Section",VersionGetSection}, - {"Size",VersionGetSize}, - {"TranslationDescription",VersionGetTranslatedDescription}, - {"VerStr",VersionGetVerStr}, -#endif {} }; @@ -926,7 +878,7 @@ PyTypeObject PyVersion_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags @@ -1053,21 +1005,6 @@ static PyGetSetDef PackageFileGetSet[] = { {(char*)"site",PackageFile_GetSite}, {(char*)"size",PackageFile_GetSize}, {(char*)"version",PackageFile_GetVersion}, - #ifdef COMPAT_0_7 - {"Architecture",PackageFile_GetArchitecture}, - {"Archive",PackageFile_GetArchive}, - {"Component",PackageFile_GetComponent}, - {"FileName",PackageFile_GetFileName}, - {"ID",PackageFile_GetID}, - {"IndexType",PackageFile_GetIndexType}, - {"Label",PackageFile_GetLabel}, - {"NotAutomatic",PackageFile_GetNotAutomatic}, - {"NotSource",PackageFile_GetNotSource}, - {"Origin",PackageFile_GetOrigin}, - {"Site",PackageFile_GetSite}, - {"Size",PackageFile_GetSize}, - {"Version",PackageFile_GetVersion}, - #endif {} }; @@ -1088,7 +1025,7 @@ PyTypeObject PyPackageFile_Type = { 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags @@ -1158,10 +1095,6 @@ static PyMethodDef DependencyMethods[] = { {"smart_target_pkg",DepSmartTargetPkg,METH_VARARGS,"Returns the natural Target or None"}, {"all_targets",DepAllTargets,METH_VARARGS,"Returns all possible Versions that match this dependency"}, -#ifdef COMPAT_0_7 - {"SmartTargetPkg",DepSmartTargetPkg,METH_VARARGS,"Returns the natural Target or None"}, - {"AllTargets",DepAllTargets,METH_VARARGS,"Returns all possible Versions that match this dependency"}, -#endif {} }; @@ -1240,15 +1173,6 @@ static PyGetSetDef DependencyGetSet[] = { {"parent_ver",DependencyGetParentVer}, {"target_pkg",DependencyGetTargetPkg}, {"target_ver",DependencyGetTargetVer}, -#ifdef COMPAT_0_7 - {"CompType",DependencyGetCompType}, - {"DepType",DependencyGetDepType}, - {"ID",DependencyGetID}, - {"ParentPkg",DependencyGetParentPkg}, - {"ParentVer",DependencyGetParentVer}, - {"TargetPkg",DependencyGetTargetPkg}, - {"TargetVer",DependencyGetTargetVer}, -#endif {} }; @@ -1272,7 +1196,7 @@ PyTypeObject PyDependency_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags diff --git a/python/cdrom.cc b/python/cdrom.cc index 0b9ae578..9eae49dc 100644 --- a/python/cdrom.cc +++ b/python/cdrom.cc @@ -78,6 +78,9 @@ 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(Self); PyObject *pyCdromProgressInst = 0; @@ -101,8 +104,7 @@ static PyMethodDef cdrom_methods[] = { {"add",cdrom_add,METH_VARARGS,cdrom_add_doc}, {"ident",cdrom_ident,METH_VARARGS,cdrom_ident_doc}, #ifdef COMPAT_0_7 - {"Add",cdrom_add,METH_VARARGS,"Add(progress) -> Add a cdrom"}, - {"Ident",cdrom_ident_old,METH_VARARGS,"Ident(progress) -> Ident a cdrom"}, + {"Ident",cdrom_ident_old,METH_VARARGS,"DEPRECATED. DO NOT USE"}, #endif {} }; @@ -134,7 +136,7 @@ PyTypeObject PyCdrom_Type = { 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/configuration.cc b/python/configuration.cc index 974f6f3d..299e06ec 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -446,20 +446,6 @@ static PyMethodDef CnfMethods[] = {"value_list",CnfValueList,METH_VARARGS,doc_ValueList}, {"my_tag",CnfMyTag,METH_VARARGS,doc_MyTag}, {"clear",CnfClear,METH_VARARGS,doc_Clear}, -#ifdef COMPAT_0_7 - {"Find",CnfFind,METH_VARARGS,doc_Find}, - {"FindFile",CnfFindFile,METH_VARARGS,doc_FindFile}, - {"FindDir",CnfFindDir,METH_VARARGS,doc_FindDir}, - {"FindI",CnfFindI,METH_VARARGS,doc_FindI}, - {"FindB",CnfFindB,METH_VARARGS,doc_FindB}, - {"Set",CnfSet,METH_VARARGS,doc_Set}, - {"Exists",CnfExists,METH_VARARGS,doc_Exists}, - {"SubTree",CnfSubTree,METH_VARARGS,doc_SubTree}, - {"List",CnfList,METH_VARARGS,doc_List}, - {"ValueList",CnfValueList,METH_VARARGS,doc_ValueList}, - {"MyTag",CnfMyTag,METH_VARARGS,doc_MyTag}, - {"Clear",CnfClear,METH_VARARGS,doc_Clear}, -#endif // Python Special {"keys",CnfKeys,METH_VARARGS,doc_Keys}, #if PY_MAJOR_VERSION < 3 @@ -498,7 +484,7 @@ PyTypeObject PyConfiguration_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/depcache.cc b/python/depcache.cc index 53459c32..8b4e02b5 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -569,34 +569,8 @@ static PyMethodDef PkgDepCacheMethods[] = {"marked_keep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"}, {"marked_reinstall",PkgDepCacheMarkedReinstall,METH_VARARGS,"Is pkg marked for reinstall"}, {"marked_downgrade",PkgDepCacheMarkedDowngrade,METH_VARARGS,"Is pkg marked for downgrade"}, - // Action {"commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"}, -#ifdef COMPAT_0_7 - {"Init",PkgDepCacheInit,METH_VARARGS,"Init the depcache (done on construct automatically)"}, - {"GetCandidateVer",PkgDepCacheGetCandidateVer,METH_VARARGS,"Get candidate version"}, - {"SetCandidateVer",PkgDepCacheSetCandidateVer,METH_VARARGS,"Set candidate version"}, - {"Upgrade",PkgDepCacheUpgrade,METH_VARARGS,"Perform Upgrade (optional boolean argument if dist-upgrade should be performed)"}, - {"FixBroken",PkgDepCacheFixBroken,METH_VARARGS,"Fix broken packages"}, - {"ReadPinFile",PkgDepCacheReadPinFile,METH_VARARGS,"Read the pin policy"}, - {"MinimizeUpgrade",PkgDepCacheMinimizeUpgrade, METH_VARARGS,"Go over the entire set of packages and try to keep each package marked for upgrade. If a conflict is generated then the package is restored."}, - {"MarkKeep",PkgDepCacheMarkKeep,METH_VARARGS,"Mark package for keep"}, - {"MarkDelete",PkgDepCacheMarkDelete,METH_VARARGS,"Mark package for delete (optional boolean argument if it should be purged)"}, - {"MarkInstall",PkgDepCacheMarkInstall,METH_VARARGS,"Mark package for Install"}, - {"SetReInstall",PkgDepCacheSetReInstall,METH_VARARGS,"Set if the package should be reinstalled"}, - {"IsUpgradable",PkgDepCacheIsUpgradable,METH_VARARGS,"Is pkg upgradable"}, - {"IsNowBroken",PkgDepCacheIsNowBroken,METH_VARARGS,"Is pkg is now broken"}, - {"IsInstBroken",PkgDepCacheIsInstBroken,METH_VARARGS,"Is pkg broken on the current install"}, - {"IsGarbage",PkgDepCacheIsGarbage,METH_VARARGS,"Is pkg garbage (mark-n-sweep)"}, - {"IsAutoInstalled",PkgDepCacheIsAutoInstalled,METH_VARARGS,"Is pkg marked as auto installed"}, - {"MarkedInstall",PkgDepCacheMarkedInstall,METH_VARARGS,"Is pkg marked for install"}, - {"MarkedUpgrade",PkgDepCacheMarkedUpgrade,METH_VARARGS,"Is pkg marked for upgrade"}, - {"MarkedDelete",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for delete"}, - {"MarkedKeep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"}, - {"MarkedReinstall",PkgDepCacheMarkedReinstall,METH_VARARGS,"Is pkg marked for reinstall"}, - {"MarkedDowngrade",PkgDepCacheMarkedDowngrade,METH_VARARGS,"Is pkg marked for downgrade"}, - {"Commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"}, -#endif {} }; @@ -641,14 +615,6 @@ static PyGetSetDef PkgDepCacheGetSet[] = { {"keep_count",PkgDepCacheGetKeepCount}, {"usr_size",PkgDepCacheGetUsrSize}, {"policy",PkgDepCacheGetPolicy}, - #ifdef COMPAT_0_7 - {"BrokenCount",PkgDepCacheGetBrokenCount}, - {"DebSize",PkgDepCacheGetDebSize}, - {"DelCount",PkgDepCacheGetDelCount}, - {"InstCount",PkgDepCacheGetInstCount}, - {"KeepCount",PkgDepCacheGetKeepCount}, - {"UsrSize",PkgDepCacheGetUsrSize}, - #endif {} }; @@ -699,7 +665,7 @@ PyTypeObject PyDepCache_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags @@ -856,14 +822,6 @@ static PyMethodDef PkgProblemResolverMethods[] = // Actions {"resolve", PkgProblemResolverResolve, METH_VARARGS, "Try to intelligently resolve problems by installing and removing packages"}, {"resolve_by_keep", PkgProblemResolverResolveByKeep, METH_VARARGS, "Try to resolv problems only by using keep"}, - #ifdef COMPAT_0_7 - {"Protect", PkgProblemResolverProtect, METH_VARARGS, "Protect(PkgIterator)"}, - {"Remove", PkgProblemResolverRemove, METH_VARARGS, "Remove(PkgIterator)"}, - {"Clear", PkgProblemResolverClear, METH_VARARGS, "Clear(PkgIterator)"}, - {"InstallProtect", PkgProblemResolverInstallProtect, METH_VARARGS, "ProtectInstalled()"}, - {"Resolve", PkgProblemResolverResolve, METH_VARARGS, "Try to intelligently resolve problems by installing and removing packages"}, - {"ResolveByKeep", PkgProblemResolverResolveByKeep, METH_VARARGS, "Try to resolv problems only by using keep"}, - #endif {} }; @@ -886,7 +844,7 @@ PyTypeObject PyProblemResolver_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/generic.cc b/python/generic.cc index 640f0862..7af34d39 100644 --- a/python/generic.cc +++ b/python/generic.cc @@ -48,6 +48,68 @@ PyObject *HandleErrors(PyObject *Res) PyErr_SetString(PyExc_SystemError,Err.c_str()); 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, "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"); + 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 { + PyErr_Restore(ptype, pvalue, ptraceback); + } + Py_DECREF(newattr); + } + 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 7d2d6d3e..31c1bc2d 100644 --- a/python/generic.h +++ b/python/generic.h @@ -227,4 +227,10 @@ PyObject *HandleErrors(PyObject *Res = 0); const char **ListToCharChar(PyObject *List,bool NullTerm = false); PyObject *CharCharToList(const char **List,unsigned long Size = 0); +# ifdef COMPAT_0_7 +PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr); +# else +# define _PyAptObject_getattro 0 +# endif + #endif diff --git a/python/indexfile.cc b/python/indexfile.cc index e8df9cf2..c6d0b1cc 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -28,9 +28,6 @@ static PyObject *IndexFileArchiveURI(PyObject *Self,PyObject *Args) static PyMethodDef IndexFileMethods[] = { {"archive_uri",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, - #ifdef COMPAT_0_7 - {"ArchiveURI",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, - #endif {} }; @@ -76,14 +73,6 @@ static PyGetSetDef IndexFileGetSet[] = { {"is_trusted",IndexFileGetIsTrusted}, {"label",IndexFileGetLabel}, {"size",IndexFileGetSize}, - #ifdef COMPAT_0_7 - {"Describe",IndexFileGetDescribe}, - {"Exists",IndexFileGetExists}, - {"HasPackages",IndexFileGetHasPackages}, - {"IsTrusted",IndexFileGetIsTrusted}, - {"Label",IndexFileGetLabel}, - {"Size",IndexFileGetSize}, - #endif {} }; @@ -107,7 +96,7 @@ PyTypeObject PyIndexFile_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, // tp_flags diff --git a/python/metaindex.cc b/python/metaindex.cc index dee54521..2dcade7d 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -52,12 +52,6 @@ static PyGetSetDef MetaIndexGetSet[] = { {"index_files",MetaIndexGetIndexFiles}, {"is_trusted",MetaIndexGetIsTrusted}, {"uri",MetaIndexGetURI}, - #ifdef COMPAT_0_7 - {"Dist",MetaIndexGetDist}, - {"IndexFiles",MetaIndexGetIndexFiles}, - {"IsTrusted",MetaIndexGetIsTrusted}, - {"URI",MetaIndexGetURI}, - #endif {} }; @@ -91,7 +85,7 @@ PyTypeObject PyMetaIndex_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer Py_TPFLAGS_DEFAULT, // tp_flags diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index 9b4a9ab7..2fda14ee 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -100,11 +100,6 @@ static PyMethodDef PkgManagerMethods[] = {"get_archives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"}, {"do_install",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"}, {"fix_missing",PkgManagerFixMissing,METH_VARARGS,"Fix the install if a pkg couldn't be downloaded"}, -#ifdef COMPAT_0_7 - {"GetArchives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"}, - {"DoInstall",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"}, - {"FixMissing",PkgManagerFixMissing,METH_VARARGS,"Fix the install if a pkg couldn't be downloaded"}, -#endif {} }; @@ -128,7 +123,7 @@ PyTypeObject PyPackageManager_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index 1e43b2e8..0e00edcd 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -50,9 +50,6 @@ static PyObject *PkgRecordsLookup(PyObject *Self,PyObject *Args) static PyMethodDef PkgRecordsMethods[] = { {"lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"}, - #ifdef COMPAT_0_7 - {"Lookup",PkgRecordsLookup,METH_VARARGS,"Changes to a new package"}, - #endif {} }; @@ -132,20 +129,6 @@ static PyGetSetDef PkgRecordsGetSet[] = { {"short_desc",PkgRecordsGetShortDesc}, {"source_pkg",PkgRecordsGetSourcePkg}, {"source_ver",PkgRecordsGetSourceVer}, -#ifdef COMPAT_0_7 - {"FileName",PkgRecordsGetFileName}, - {"Homepage",PkgRecordsGetHomepage}, - {"LongDesc",PkgRecordsGetLongDesc}, - {"MD5Hash",PkgRecordsGetMD5Hash}, - {"Maintainer",PkgRecordsGetMaintainer}, - {"Name",PkgRecordsGetName}, - {"Record",PkgRecordsGetRecord}, - {"SHA1Hash",PkgRecordsGetSHA1Hash}, - {"SHA256Hash",PkgRecordsGetSHA256Hash}, - {"ShortDesc",PkgRecordsGetShortDesc}, - {"SourcePkg",PkgRecordsGetSourcePkg}, - {"SourceVer",PkgRecordsGetSourceVer}, -#endif {} }; @@ -180,7 +163,7 @@ PyTypeObject PyPackageRecords_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index 41ee6276..95f35f23 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -71,10 +71,6 @@ static PyMethodDef PkgSrcRecordsMethods[] = { {"lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup}, {"restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart}, -#ifdef COMPAT_0_7 - {"Lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup}, - {"Restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart}, -#endif {} }; @@ -234,15 +230,7 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = { {"section",PkgSrcRecordsGetSection}, {"version",PkgSrcRecordsGetVersion}, #ifdef COMPAT_0_7 - {"Binaries",PkgSrcRecordsGetBinaries}, {"BuildDepends",PkgSrcRecordsGetBuildDepends_old,0,"Deprecated function and deprecated output format."}, - {"Files",PkgSrcRecordsGetFiles}, - {"Index",PkgSrcRecordsGetIndex}, - {"Maintainer",PkgSrcRecordsGetMaintainer}, - {"Package",PkgSrcRecordsGetPackage}, - {"Record",PkgSrcRecordsGetRecord}, - {"Section",PkgSrcRecordsGetSection}, - {"Version",PkgSrcRecordsGetVersion}, #endif {} }; @@ -274,7 +262,7 @@ PyTypeObject PySourceRecords_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/sourcelist.cc b/python/sourcelist.cc index b705d8b8..6184fee3 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -77,11 +77,6 @@ static PyMethodDef PkgSourceListMethods[] = {"find_index",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex}, {"read_main_list",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList}, {"get_indexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListGetIndexes}, -#ifdef COMPAT_0_7 - {"FindIndex",PkgSourceListFindIndex,METH_VARARGS,doc_PkgSourceListFindIndex}, - {"ReadMainList",PkgSourceListReadMainList,METH_VARARGS,doc_PkgSourceListReadMainList}, - {"GetIndexes",PkgSourceListGetIndexes,METH_VARARGS,doc_PkgSourceListGetIndexes}, -#endif {} }; @@ -104,9 +99,6 @@ static PyObject *PkgSourceListGetList(PyObject *Self,void*) static PyGetSetDef PkgSourceListGetSet[] = { {"list",PkgSourceListGetList,0,"A list of MetaIndex() objects.",0}, -#ifdef COMPAT_0_7 - {"List",PkgSourceListGetList,0,"A list of MetaIndex() objects.",0}, -#endif {} }; @@ -137,7 +129,7 @@ PyTypeObject PySourceList_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags diff --git a/python/tag.cc b/python/tag.cc index 4971a03d..6d327d27 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -458,12 +458,6 @@ static PyMethodDef TagSecMethods[] = {"find_raw",TagSecFindRaw,METH_VARARGS,doc_FindRaw}, {"find_flag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, {"bytes",TagSecBytes,METH_VARARGS,doc_Bytes}, -#ifdef COMPAT_0_7 - {"Find",TagSecFind,METH_VARARGS,doc_Find}, - {"FindRaw",TagSecFindRaw,METH_VARARGS,doc_FindRaw}, - {"FindFlag",TagSecFindFlag,METH_VARARGS,doc_FindFlag}, - {"Bytes",TagSecBytes,METH_VARARGS,doc_Bytes}, -#endif // Python Special {"keys",TagSecKeys,METH_VARARGS,doc_Keys}, @@ -503,7 +497,7 @@ PyTypeObject PyTagSection_Type = 0, // tp_hash 0, // tp_call TagSecStr, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags @@ -536,11 +530,6 @@ static PyMethodDef TagFileMethods[] = {"step",TagFileStep,METH_VARARGS,doc_Step}, {"offset",TagFileOffset,METH_VARARGS,doc_Offset}, {"jump",TagFileJump,METH_VARARGS,doc_Jump}, -#ifdef COMPAT_0_7 - {"Step",TagFileStep,METH_VARARGS,doc_Step}, - {"Offset",TagFileOffset,METH_VARARGS,doc_Offset}, - {"Jump",TagFileJump,METH_VARARGS,doc_Jump}, -#endif {} }; @@ -554,12 +543,10 @@ static PyObject *TagFileGetSection(PyObject *Self,void*) { static PyGetSetDef TagFileGetSet[] = { {"section",TagFileGetSection,0,"Return a TagSection.",0}, -#ifdef COMPAT_0_7 - {"Section",TagFileGetSection,0,"Return a TagSection.",0}, -#endif {} }; + static char *doc_TagFile = "TagFile(file) -> TagFile() object. \n\n" "TagFile() objects provide access to debian control files, which consists\n" "of multiple RFC822-like formatted sections.\n\n" @@ -593,7 +580,7 @@ PyTypeObject PyTagFile_Type = 0, // tp_hash 0, // tp_call 0, // tp_str - 0, // tp_getattro + _PyAptObject_getattro, // tp_getattro 0, // tp_setattro 0, // tp_as_buffer (Py_TPFLAGS_DEFAULT | // tp_flags -- cgit v1.2.3 From a123b39f6e3dc69c9db46dd00550fc04c1ee9399 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 27 Feb 2010 17:48:53 +0100 Subject: Ship the list of deprecated things in the apt_pkg and apt_inst modules inside the script itself, so we don't have to parse the source code anymore. --- debian/changelog | 3 ++ debian/python-apt.docs | 1 + utils/migrate-0.8.py | 131 ++++++++++++++++++++++++++++--------------------- 3 files changed, 80 insertions(+), 55 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index e5945ef4..9a05185d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,9 @@ python-apt (0.7.93.2) unstable; urgency=low * utils/migrate-0.8.py: - Improve C++ parsing and add apt.progress.old to the modules, reduces false positives. + - Ship the list of deprecated things in the apt_pkg and apt_inst modules + inside the script itself, so we don't have to parse the source code + anymore. * python: - Handle deprecated attributes and methods in the tp_gettattro slot, this allows us to easily warn if a deprecated function is used. diff --git a/debian/python-apt.docs b/debian/python-apt.docs index 1bfc7c1c..c4191c81 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -4,3 +4,4 @@ TODO apt/README.apt data/templates/README.templates build/sphinx/html/ +utils/migrate-0.8.py diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index 61059b2a..d0d8e9a1 100755 --- a/utils/migrate-0.8.py +++ b/utils/migrate-0.8.py @@ -44,7 +44,7 @@ from collections import defaultdict from textwrap import fill color=False -if sys.argv[1] in ('-c', '--color', '--colour'): +if len(sys.argv) > 1 and sys.argv[1] in ('-c', '--color', '--colour'): color=True del sys.argv[1] @@ -55,6 +55,75 @@ if '-h' in sys.argv or '--help' in sys.argv or not sys.argv[1:]: if os.path.dirname(__file__).endswith('utils'): sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) +deprecated_cpp_stuff = set([ + '.Add', '.AllTargets', '.Arch', '.Architecture', '.Archive', + '.ArchiveURI', '.Auto', '.Base64Encode', '.Binaries', '.BrokenCount', + '.BuildDepends', '.Bytes', '.CheckDep', '.CheckDomainList', '.Clear', + '.Close', '.Commit', '.CompType', '.Complete', '.Component', '.Config', + '.CurStateConfigFiles', '.CurStateHalfConfigured', + '.CurStateHalfInstalled', '.CurStateInstalled', '.CurStateNotInstalled', + '.CurStateUnPacked', '.CurrentState', '.CurrentVer', '.Date', + '.DeQuoteString', '.DebSize', '.DelCount', '.DepType', '.DependsCount', + '.DependsList', '.DependsListStr', '.DescURI', '.Describe', '.DestFile', + '.Dist', '.DoInstall', '.Downloadable', '.ErrorText', '.Essential', + '.Exists', '.FetchNeeded', '.FileList', '.FileName', '.FileSize', + '.Files', '.Find', '.FindB', '.FindDir', '.FindFile', '.FindFlag', + '.FindI', '.FindIndex', '.FindRaw', '.FixBroken', '.FixMissing', + '.GetAcquire', '.GetArchives', '.GetCache', '.GetCandidateVer', + '.GetCdrom', '.GetDepCache', '.GetIndexes', '.GetLock', + '.GetPackageManager', '.GetPkgAcqFile', '.GetPkgActionGroup', + '.GetPkgProblemResolver', '.GetPkgRecords', '.GetPkgSourceList', + '.GetPkgSrcRecords', '.HasPackages', '.Hash', '.Homepage', '.ID', + '.Ident', '.Important', '.Index', '.IndexFiles', '.IndexType', '.Init', + '.InitConfig', '.InitSystem', '.InstCount', '.InstState', + '.InstStateHold', '.InstStateHoldReInstReq', '.InstStateOk', + '.InstStateReInstReq', '.InstallProtect', '.InstalledSize', + '.IsAutoInstalled', '.IsGarbage', '.IsInstBroken', '.IsNowBroken', + '.IsTrusted', '.IsUpgradable', '.Items', '.Jump', '.KeepCount', + '.Label', '.LanguageCode', '.LibVersion', '.List', '.Local', + '.LongDesc', '.Lookup', '.MD5Hash', '.Maintainer', '.MarkDelete', + '.MarkInstall', '.MarkKeep', '.MarkedDelete', '.MarkedDowngrade', + '.MarkedInstall', '.MarkedKeep', '.MarkedReinstall', '.MarkedUpgrade', + '.MinimizeUpgrade', '.MyTag', '.Name', '.NotAutomatic', '.NotSource', + '.Offset', '.Open', '.Origin', '.Package', '.PackageCount', + '.PackageFileCount', '.Packages', '.ParentPkg', '.ParentVer', + '.ParseCommandLine', '.ParseDepends', '.ParseSection', + '.ParseSrcDepends', '.ParseTagFile', '.PartialPresent', + '.PkgSystemLock', '.PkgSystemUnLock', '.PriExtra', '.PriImportant', + '.PriOptional', '.PriRequired', '.PriStandard', '.Priority', + '.PriorityStr', '.Protect', '.ProvidesCount', '.ProvidesList', + '.QuoteString', '.ReadConfigDir', '.ReadConfigFile', + '.ReadConfigFileISC', '.ReadMainList', '.ReadPinFile', '.Record', + '.Remove', '.Resolve', '.ResolveByKeep', '.Restart', '.RevDependsList', + '.RewriteSection', '.RewriteSourceOrder', '.Run', '.SHA1Hash', + '.SHA256Hash', '.Section', '.SelStateDeInstall', '.SelStateHold', + '.SelStateInstall', '.SelStatePurge', '.SelStateUnknown', + '.SelectedState', '.Set', '.SetCandidateVer', '.SetReInstall', + '.ShortDesc', '.Shutdown', '.Site', '.Size', '.SizeToStr', + '.SmartTargetPkg', '.SourcePkg', '.SourceVer', '.Status', '.Step', + '.StrToTime', '.StringToBool', '.SubTree', '.TargetPkg', '.TargetVer', + '.Time', '.TimeRFC1123', '.TimeToStr', '.TotalNeeded', + '.TranslationDescription', '.URI', '.URItoFileName', '.Update', + '.Upgrade', '.UpstreamVersion', '.UsrSize', '.ValueList', + '.VerFileCount', '.VerStr', '.Version', '.VersionCompare', + '.VersionCount', '.VersionList', '.newConfiguration', 'Base64Encode', + 'CheckDep', 'CheckDomainList', 'Config', 'CurStateConfigFiles', + 'CurStateHalfConfigured', 'CurStateHalfInstalled', 'CurStateInstalled', + 'CurStateNotInstalled', 'CurStateUnPacked', 'Date', 'DeQuoteString', + 'GetAcquire', 'GetCache', 'GetCdrom', 'GetDepCache', 'GetLock', + 'GetPackageManager', 'GetPkgAcqFile', 'GetPkgActionGroup', + 'GetPkgProblemResolver', 'GetPkgRecords', 'GetPkgSourceList', + 'GetPkgSrcRecords', 'InitConfig', 'InitSystem', 'InstStateHold', + 'InstStateHoldReInstReq', 'InstStateOk', 'InstStateReInstReq', + 'LibVersion', 'ParseCommandLine', 'ParseDepends', 'ParseSection', + 'ParseSrcDepends', 'ParseTagFile', 'PkgSystemLock', 'PkgSystemUnLock', + 'PriExtra', 'PriImportant', 'PriOptional', 'PriRequired', 'PriStandard', + 'QuoteString', 'ReadConfigDir', 'ReadConfigFile', 'ReadConfigFileISC', + 'RewriteSection', 'RewriteSourceOrder', 'SelStateDeInstall', + 'SelStateHold', 'SelStateInstall', 'SelStatePurge', 'SelStateUnknown', + 'SizeToStr', 'StrToTime', 'StringToBool', 'Time', 'TimeRFC1123', + 'TimeToStr', 'URItoFileName', 'UpstreamVersion', 'VersionCompare', + 'newConfiguration']) def do_color(string, words): """Colorize (red) the given words in the given string.""" @@ -66,61 +135,13 @@ def do_color(string, words): r"\2" + "\033[0m\\3", string) return string - -def find_deprecated_cpp(): - """Find all the deprecated functions and attributes.""" - is_open=False - all_old = set() - for fname in glob.glob('python/*.cc'): - lines = list(open(fname, 'r')) - while lines: - line = lines.pop(0) - while lines and not ('static PyMethodDef' in line or - 'static PyGetSetDef' in line): - line = lines.pop(0) - if not lines: - break - - while lines and not ';' in line: - while lines and not 'COMPAT_0_7' in line and not ';' in line: - line = lines.pop(0) - if ';' in line: - continue - if lines: - line = lines.pop(0) - while lines and not '#endif' in line: - name = line.split(",")[0].strip().strip('{"') - if not 'module' in fname: - name = '.' + name - else: - all_old.add('.' + name) - all_old.add(name) - line = lines.pop(0) - # Let's handle constants in the apt_pkg module - lines = list(open('python/apt_pkgmodule.cc')) - while lines: - while lines and not 'COMPAT_0_7' in line: - line = lines.pop(0) - if lines: - lines.pop(0) - while lines and not '#endif' in line: - if 'PyModule_Add' in line: - name = line.split(",")[1].strip().strip('"') - if name != '_COMPAT_0_7': - all_old.add('.' + name) - all_old.add(name) - line = lines.pop(0) - return all_old - - def find_deprecated_py(): - """Same as find_deprecated_cpp(), but for apt and aptsources. - - We import apt_pkg, set _COMPAT_0_7 to 0, import apt and aptsources and - create a list of all attributes. + """Find all the deprecated functions and attributes. - No we remove the imported modules, reimport them (with _COMPAT_0_7=1), - and see which functions have been removed. + Import apt_pkg, set _COMPAT_0_7 to 0, import apt and aptsources and + create a list of all attributes. Then remove the imported modules, + reimport them (with _COMPAT_0_7=1), and see which functions do not + exist anymore. """ modules = ('apt', 'apt.package', 'apt.cdrom', 'apt.cache', 'apt.debfile', @@ -204,7 +225,7 @@ if color: 'simply highlight the matched words (like grep).', 79) print -all_old = find_deprecated_cpp() +all_old = deprecated_cpp_stuff if not '-P' in sys.argv: all_old |= find_deprecated_py() -- cgit v1.2.3 From c6fd687e9b48133d025ccc47ff397087f5752203 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 27 Feb 2010 18:31:57 +0100 Subject: * debian/python-apt.install: - Install utils/migrate-0.8.py to /usr/share/python-apt/. --- debian/changelog | 2 ++ debian/python-apt.docs | 1 - debian/python-apt.install | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 9a05185d..5f060a9c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,8 @@ python-apt (0.7.93.2) unstable; urgency=low - aptsources/distinfo.py: Support relative filenames for MirrorsFile. * debian/rules: - Run tests during build time. + * debian/python-apt.install: + - Install utils/migrate-0.8.py to /usr/share/python-apt/. [ Michael Vogt ] * apt/cache.py: diff --git a/debian/python-apt.docs b/debian/python-apt.docs index c4191c81..1bfc7c1c 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -4,4 +4,3 @@ TODO apt/README.apt data/templates/README.templates build/sphinx/html/ -utils/migrate-0.8.py diff --git a/debian/python-apt.install b/debian/python-apt.install index ca86ed11..29028531 100644 --- a/debian/python-apt.install +++ b/debian/python-apt.install @@ -4,3 +4,5 @@ usr/lib/python*/*/*/ usr/lib/python*/*/*.egg-info usr/share/locale usr/share/python-apt +# Install the migration helper +utils/migrate-0.8.py usr/share/python-apt -- cgit v1.2.3 From 90629ce9f2b8d9b3efab8b30ed89f8a2df7d1286 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 27 Feb 2010 18:33:37 +0100 Subject: Upload 0.7.93.2 to unstable --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 5f060a9c..e9603695 100644 --- a/debian/changelog +++ b/debian/changelog @@ -43,7 +43,7 @@ python-apt (0.7.93.2) unstable; urgency=low * python/progress.cc: - try to call compatibility functions first, then new functions - -- Julian Andres Klode Sat, 27 Feb 2010 14:00:43 +0100 + -- Julian Andres Klode Sat, 27 Feb 2010 18:33:11 +0100 python-apt (0.7.93.1) unstable; urgency=low -- cgit v1.2.3 From a1d306a3ffb95790b2dad1b0104456a5bc593634 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 27 Feb 2010 23:29:44 +0100 Subject: * data/templates/Ubuntu.info.in: - Use generic MirrorsFile key instead of per-architecture ones in order to fix FTBFS on !amd64 !i386 (Closes: #571752) --- data/templates/Ubuntu.info.in | 15 +++++---------- debian/changelog | 8 ++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'debian') diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index 1ca76927..a84cbc2b 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -8,8 +8,7 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: Ubuntu.mirrors -MirrorsFile-i386: Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 10.04 'Lucid Lynx' Component: main _CompDescription: Officially supported @@ -69,8 +68,7 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: Ubuntu.mirrors -MirrorsFile-i386: Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 9.10 'Karmic Koala' Component: main _CompDescription: Officially supported @@ -130,8 +128,7 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: Ubuntu.mirrors -MirrorsFile-i386: Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 9.04 'Jaunty Jackalope' Component: main _CompDescription: Officially supported @@ -191,8 +188,7 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: Ubuntu.mirrors -MirrorsFile-i386: Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 8.10 'Intrepid Ibex' Component: main _CompDescription: Officially supported @@ -253,8 +249,7 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile-amd64: Ubuntu.mirrors -MirrorsFile-i386: Ubuntu.mirrors +MirrorsFile: Ubuntu.mirrors _Description: Ubuntu 8.04 'Hardy Heron' Component: main _CompDescription: Officially supported diff --git a/debian/changelog b/debian/changelog index e9603695..fd3161be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +python-apt (0.7.93.3) unstable; urgency=low + + * data/templates/Ubuntu.info.in: + - Use generic MirrorsFile key instead of per-architecture ones in + order to fix FTBFS on !amd64 !i386 (Closes: #571752) + + -- Julian Andres Klode Sat, 27 Feb 2010 23:26:45 +0100 + python-apt (0.7.93.2) unstable; urgency=low [ Julian Andres Klode ] -- cgit v1.2.3 From fec077050264e24d5259d4d9c3f43abb4fd4d294 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 1 Mar 2010 16:13:40 +0100 Subject: * python/acquire-item.cc: - Add AcquireItem.partialsize member. --- debian/changelog | 7 +++++++ python/acquire-item.cc | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index fd3161be..2d1c1892 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.93.4) unstable; urgency=low + + * python/acquire-item.cc: + - Add AcquireItem.partialsize member. + + -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 + python-apt (0.7.93.3) unstable; urgency=low * data/templates/Ubuntu.info.in: diff --git a/python/acquire-item.cc b/python/acquire-item.cc index 09f0d643..cdb4a4bc 100644 --- a/python/acquire-item.cc +++ b/python/acquire-item.cc @@ -92,6 +92,12 @@ static PyObject *acquireitem_get_local(PyObject *self, void *closure) return item ? PyBool_FromLong(item->Local) : 0; } +static PyObject *acquireitem_get_partialsize(PyObject *self, void *closure) +{ + pkgAcquire::Item *item = acquireitem_tocpp(self); + return item ? Py_BuildValue("i", item->PartialSize) : 0; +} + static PyObject *acquireitem_get_status(PyObject *self, void *closure) { pkgAcquire::Item *item = acquireitem_tocpp(self); @@ -127,6 +133,7 @@ static PyGetSetDef acquireitem_getset[] = { {"mode",acquireitem_get_mode}, {"is_trusted",acquireitem_get_is_trusted}, {"local",acquireitem_get_local}, + {"partialsize",acquireitem_get_partialsize}, {"status",acquireitem_get_status}, {} }; -- cgit v1.2.3 From 28fcce3fe36ab2c3855d4c3766490272a7310392 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 1 Mar 2010 17:00:37 +0100 Subject: * apt/package.py: - Create a string class BaseDependency.__dstr which makes '>' equal to '>>' and '<' equal to '<<' (compatibility). --- apt/package.py | 12 +++++++++++- debian/changelog | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/apt/package.py b/apt/package.py index 7f736583..84a1f1e6 100644 --- a/apt/package.py +++ b/apt/package.py @@ -70,9 +70,19 @@ class BaseDependency(object): pre_depend - Boolean value whether this is a pre-dependency. """ + class __dstr(str): + """Helper to make > match >> and < match <<""" + + def __eq__(self, other): + return str.__eq__(self, other) or str.__eq__(2 * self, other) + + def __ne__(self, other): + return str.__eq__(self, other) and str.__ne__(2 * self, other) + + def __init__(self, name, rel, ver, pre, rawtype=None): self.name = name - self.relation = rel + self.relation = len(rel) == 1 and self.__dstr(rel) or rel self.version = ver self.pre_depend = pre self.rawtype = rawtype diff --git a/debian/changelog b/debian/changelog index 2d1c1892..ff189eb1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ python-apt (0.7.93.4) unstable; urgency=low * python/acquire-item.cc: - Add AcquireItem.partialsize member. + * apt/package.py: + - Create a string class BaseDependency.__dstr which makes '>' equal to + '>>' and '<' equal to '<<' (compatibility). -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 -- cgit v1.2.3 From a72f4f9fd0ce0e8c1e49486fd779003b7f05c882 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 1 Mar 2010 17:28:20 +0100 Subject: * apt/progress/text.py: - Drop InstallProgress, it's useless to keep this alias around. --- apt/progress/text.py | 2 -- debian/changelog | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/apt/progress/text.py b/apt/progress/text.py index 5e45c1db..95f18831 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -257,5 +257,3 @@ class CdromProgress(base.CdromProgress, TextProgress): return (raw_input() == '') except KeyboardInterrupt: return False - -InstallProgress = base.InstallProgress diff --git a/debian/changelog b/debian/changelog index ff189eb1..1c1575a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ python-apt (0.7.93.4) unstable; urgency=low * apt/package.py: - Create a string class BaseDependency.__dstr which makes '>' equal to '>>' and '<' equal to '<<' (compatibility). + * apt/progress/text.py: + - Drop InstallProgress, it's useless to keep this alias around. -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 -- cgit v1.2.3 From a5f0b3a05f85e5c24d0cbc6f5cfd3834346e79aa Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 14:33:03 +0100 Subject: Use the binary package version in Version.fetch_source() if the source version is not specified (i.e. in the normal case). --- apt/package.py | 3 ++- debian/changelog | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/apt/package.py b/apt/package.py index 6bf9554b..7c739aab 100644 --- a/apt/package.py +++ b/apt/package.py @@ -537,9 +537,10 @@ class Version(object): dsc = None record = self._records src.lookup(record.source_pkg) + source_version = record.source_ver or self._cand.ver_str try: - while record.source_ver != src.version: + while source_version != src.version: src.lookup(record.source_pkg) except AttributeError: raise ValueError("No source for %r" % self) diff --git a/debian/changelog b/debian/changelog index 1c1575a0..30a1182a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ python-apt (0.7.93.4) unstable; urgency=low * apt/package.py: - Create a string class BaseDependency.__dstr which makes '>' equal to '>>' and '<' equal to '<<' (compatibility). + - Use the binary package version in Version.fetch_source() if the + source version is not specified (i.e. in the normal case). * apt/progress/text.py: - Drop InstallProgress, it's useless to keep this alias around. -- cgit v1.2.3 From 8cb1f8fb9968d91f8f1bbece3f93aaeda36f0801 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 16:25:30 +0100 Subject: * apt/progress/old.py: - Let the new method call the old one; e.g. status_update() now calls self.statusUpdate(). This improves compatibility for sub classes. --- apt/progress/old.py | 89 ++++++++++++++++++++++++++++++++++++++--------------- debian/changelog | 3 ++ 2 files changed, 67 insertions(+), 25 deletions(-) (limited to 'debian') diff --git a/apt/progress/old.py b/apt/progress/old.py index c64eee57..0d75b756 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -40,6 +40,10 @@ __all__ = [] class OpProgress(base.OpProgress): """Abstract class to implement reporting on cache opening.""" + def __init__(self): + warnings.warn("apt.progress.OpProgress is deprecated.", + DeprecationWarning, stacklevel=2) + subOp = AttributeDeprecatedBy('subop') Op = AttributeDeprecatedBy('op') @@ -47,6 +51,11 @@ class OpProgress(base.OpProgress): class OpTextProgress(OpProgress, text.OpProgress): """A simple text based cache open reporting class.""" + def __init__(self): + text.OpProgress.__init__(self) + warnings.warn("apt.progress.OpTextProgress is deprecated.", + DeprecationWarning, stacklevel=2) + class FetchProgress(object): """Report the download/fetching progress.""" @@ -65,7 +74,8 @@ class FetchProgress(object): self.totalBytes = 0 self.totalItems = 0 self.currentCPS = 0 - warnings.warn("FetchProgress() is deprecated.", DeprecationWarning) + warnings.warn("apt.progress.FetchProgress is deprecated.", + DeprecationWarning, stacklevel=2) def start(self): """Called when the fetching starts.""" @@ -160,27 +170,54 @@ class TextFetchProgress(FetchProgress): return raw_input() not in ('c', 'C') -class CdromProgress(base.CdromProgress): - """Report the cdrom add progress. +class CdromProgress(object): + """Report the cdrom add progress.""" - This class has been replaced by apt_pkg.CdromProgress. - """ - _basetype = base.CdromProgress - askCdromName = function_deprecated_by(_basetype.ask_cdrom_name) - changeCdrom = function_deprecated_by(_basetype.change_cdrom) - del _basetype + def __init__(self): + warnings.warn("apt.progress.CdromProgress is deprecated.", + DeprecationWarning, stacklevel=2) + + def askCdromName(self): + """Ask for a cdrom name""" + + def changeCdrom(self): + """Change cdrom""" + + def update(self, text, current): + """Update.""" class DumbInstallProgress(base.InstallProgress): - """Report the install progress. + """Report the install progress.""" - Subclass this class to implement install progress reporting. - """ + def __init__(self): + warnings.warn("apt.progress.*InstallProgress are deprecated.", + DeprecationWarning, stacklevel=2) + + def updateInterface(self): + # *_stream were not available in the old progress reporting classes, + # create the attributes if they do not exist yet; as they are used + # in base.InstallProgress.update_interface(). + if hasattr(self, "writefd") and not hasattr(self, "write_stream"): + self.write_stream = os.fdopen(self.writefd, "w") + if hasattr(self, "statusfd") and not hasattr(self, "status_stream"): + self.status_stream = os.fdopen(self.statusfd, "r") + base.InstallProgress.update_interface(self) + + def update_interface(self): + self.updateInterface() + + def startUpdate(self): + base.InstallProgress.start_update(self) + + def start_update(self): + self.startUpdate() - startUpdate = function_deprecated_by(base.InstallProgress.start_update) - finishUpdate = function_deprecated_by(base.InstallProgress.finish_update) - updateInterface = function_deprecated_by( - base.InstallProgress.update_interface) + def finishUpdate(self): + base.InstallProgress.finish_update(self) + + def finish_update(self): + self.finishUpdate() class InstallProgress(DumbInstallProgress, base.InstallProgress): @@ -191,16 +228,18 @@ class InstallProgress(DumbInstallProgress, base.InstallProgress): """ selectTimeout = AttributeDeprecatedBy('select_timeout') - statusChange = function_deprecated_by(base.InstallProgress.status_change) - updateInterface = function_deprecated_by( - base.InstallProgress.update_interface) - waitChild = function_deprecated_by(base.InstallProgress.wait_child) + + def statusChange(self, pkg, percent, status): + base.InstallProgress.status_change(self, pkg, percent, status) def status_change(self, pkg, percent, status): - """(Abstract) Called when the APT status changed.""" - # compat with 0.7 - if apt_pkg._COMPAT_0_7 and hasattr(self, "statusChange"): - self.statusChange(pkg, percent, status) + self.statusChange(pkg, percent, status) + + def waitChild(self): + base.InstallProgress.wait_child(self) + + def wait_child(self): + self.waitChild() class DpkgInstallProgress(InstallProgress): @@ -214,4 +253,4 @@ class DpkgInstallProgress(InstallProgress): # Deprecated stuff self.debfile = debfile self.debname = os.path.basename(debfile).split("_")[0] - return base.InstallProgress(self, debfile) + return base.InstallProgress.run(self, debfile) diff --git a/debian/changelog b/debian/changelog index 30a1182a..79b3d810 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ python-apt (0.7.93.4) unstable; urgency=low source version is not specified (i.e. in the normal case). * apt/progress/text.py: - Drop InstallProgress, it's useless to keep this alias around. + * apt/progress/old.py: + - Let the new method call the old one; e.g. status_update() now calls + self.statusUpdate(). This improves compatibility for sub classes. -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 -- cgit v1.2.3 From 1dcd5eb6190ed6a3552cb2d491bc0272f60e613a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 16:44:10 +0100 Subject: * Merge with Ubuntu: - util/get_ubuntu_mirrors_from_lp.py: + rewritten to use +archivemirrors-rss and feedburner - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this for Debian mirrors) - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) --- .bzr-builddeb/default.conf | 3 ++ debian/changelog | 6 ++++ debian/control | 2 +- pre-build.sh | 11 ++++++ utils/get_ubuntu_mirrors_from_lp.py | 72 ++++++++----------------------------- 5 files changed, 35 insertions(+), 59 deletions(-) create mode 100755 pre-build.sh (limited to 'debian') diff --git a/.bzr-builddeb/default.conf b/.bzr-builddeb/default.conf index 3a08d607..c39d2e3d 100644 --- a/.bzr-builddeb/default.conf +++ b/.bzr-builddeb/default.conf @@ -1,2 +1,5 @@ [BUILDDEB] native = True + +[HOOKS] +pre-build = ./pre-build.sh diff --git a/debian/changelog b/debian/changelog index 79b3d810..0aab0c2a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,12 @@ python-apt (0.7.93.4) unstable; urgency=low * apt/progress/old.py: - Let the new method call the old one; e.g. status_update() now calls self.statusUpdate(). This improves compatibility for sub classes. + * Merge with Ubuntu: + - util/get_ubuntu_mirrors_from_lp.py: + + rewritten to use +archivemirrors-rss and feedburner + - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this + for Debian mirrors) + - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 diff --git a/debian/control b/debian/control index 0c43f91e..4db6c164 100644 --- a/debian/control +++ b/debian/control @@ -24,7 +24,7 @@ Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} Recommends: lsb-release, iso-codes, libjs-jquery -Breaks: debdelta (<< 0.28~) +Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte XB-Python-Version: ${python:Versions} diff --git a/pre-build.sh b/pre-build.sh new file mode 100755 index 00000000..6d019603 --- /dev/null +++ b/pre-build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +echo "updating Ubuntu mirror list from launchpad" +if [ -n "$https_proxy" ]; then + echo "disabling https_proxy as Python's urllib doesn't support it; see #94130" + unset https_proxy +fi +utils/get_ubuntu_mirrors_from_lp.py > data/templates/Ubuntu.mirrors + +echo "updating Debian mirror list" +( cd utils; ./get_debian_mirrors.py; ) diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py index b912f28d..3c183b6d 100755 --- a/utils/get_ubuntu_mirrors_from_lp.py +++ b/utils/get_ubuntu_mirrors_from_lp.py @@ -24,68 +24,24 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import urllib2 -import re +import feedparser import sys -# the list of official Ubuntu servers -mirrors = [] -# path to the local mirror list -list_path = "../data/templates/Ubuntu.mirrors" - - -try: - f = open("/usr/share/iso-codes/iso_3166.tab", "r") - lines = f.readlines() - f.close() -except: - print "Could not read country information" - sys.exit(1) +d = feedparser.parse("https://launchpad.net/ubuntu/+archivemirrors-rss") +#d = feedparser.parse(open("+archivemirrors-rss")) countries = {} -for line in lines: - parts = line.split("\t") - countries[parts[1].strip()] = parts[0].lower() - -req = urllib2.Request("https://launchpad.net/ubuntu/+archivemirrors") -print "Downloading mirrors list from Launchpad..." -try: - uri=urllib2.urlopen(req) - content = uri.read() - uri.close() -except: - print "Failed to download or extract the mirrors list!" - sys.exit(1) - -content = content.replace("\n", "") - -content_splits = re.split(r'.+?', - content)[0]) -lines=[] - - -def find(split): - country = re.search(r"(.+?)", split) - if not country: - return - if country.group(1) in countries: - lines.append("#LOC:%s" % countries[country.group(1)].upper()) - else: - lines.append("#LOC:%s" % country.group(1)) - # FIXME: currently the protocols are hardcoded: ftp http - urls = re.findall(r')' - '(((http)|(ftp)).+?)">', - split) - map(lambda u: lines.append(u[0]), urls) +for entry in d.entries: + countrycode = entry.mirror_countrycode + if not countrycode in countries: + countries[countrycode] = set() + for link in entry.links: + countries[countrycode].add(link.href) -map(find, content_splits) -print "Writing local mirrors list: %s" % list_path -list = open(list_path, "w") -for line in lines: - list.write("%s\n" % line) -list.close() -print "Done." +keys = countries.keys() +keys.sort() +for country in keys: + print "#LOC:%s" % country + print "\n".join(countries[country]) -- cgit v1.2.3 From 809ff1217079cb8e4790a1bc8f1fe187c8ded358 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 19:37:43 +0100 Subject: * tests/data/aptsources/sources.list.testDistribution: - change one mirror which is not on the mirror list anymore. --- debian/changelog | 2 + po/python-apt.pot | 140 ++++++++++----------- .../data/aptsources/sources.list.testDistribution | 4 +- 3 files changed, 74 insertions(+), 72 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 0aab0c2a..cb825163 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ python-apt (0.7.93.4) unstable; urgency=low - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this for Debian mirrors) - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) + * tests/data/aptsources/sources.list.testDistribution: + - change one mirror which is not on the mirror list anymore. -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 diff --git a/po/python-apt.pot b/po/python-apt.pot index 36a04eae..b67d7988 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2010-01-31 17:09+0100\n" +"POT-Creation-Date: 2010-03-03 19:34+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,257 +23,257 @@ msgid "http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:13 +#: ../data/templates/Ubuntu.info.in:12 msgid "Ubuntu 10.04 'Lucid Lynx'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:31 +#: ../data/templates/Ubuntu.info.in:30 msgid "Cdrom with Ubuntu 10.04 'Lucid Lynx'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:74 +#: ../data/templates/Ubuntu.info.in:72 msgid "Ubuntu 9.10 'Karmic Koala'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:92 +#: ../data/templates/Ubuntu.info.in:90 msgid "Cdrom with Ubuntu 9.10 'Karmic Koala'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:135 +#: ../data/templates/Ubuntu.info.in:132 msgid "Ubuntu 9.04 'Jaunty Jackalope'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:153 +#: ../data/templates/Ubuntu.info.in:150 msgid "Cdrom with Ubuntu 9.04 'Jaunty Jackalope'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:196 +#: ../data/templates/Ubuntu.info.in:192 msgid "Ubuntu 8.10 'Intrepid Ibex'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:214 +#: ../data/templates/Ubuntu.info.in:210 msgid "Cdrom with Ubuntu 8.10 'Intrepid Ibex'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:258 +#: ../data/templates/Ubuntu.info.in:253 msgid "Ubuntu 8.04 'Hardy Heron'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:276 +#: ../data/templates/Ubuntu.info.in:271 msgid "Cdrom with Ubuntu 8.04 'Hardy Heron'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:313 +#: ../data/templates/Ubuntu.info.in:308 msgid "Ubuntu 7.10 'Gutsy Gibbon'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:331 +#: ../data/templates/Ubuntu.info.in:326 msgid "Cdrom with Ubuntu 7.10 'Gutsy Gibbon'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:366 +#: ../data/templates/Ubuntu.info.in:361 msgid "Ubuntu 7.04 'Feisty Fawn'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:384 +#: ../data/templates/Ubuntu.info.in:379 msgid "Cdrom with Ubuntu 7.04 'Feisty Fawn'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:418 +#: ../data/templates/Ubuntu.info.in:413 msgid "Ubuntu 6.10 'Edgy Eft'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:423 +#: ../data/templates/Ubuntu.info.in:418 msgid "Community-maintained" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:429 +#: ../data/templates/Ubuntu.info.in:424 msgid "Restricted software" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:436 +#: ../data/templates/Ubuntu.info.in:431 msgid "Cdrom with Ubuntu 6.10 'Edgy Eft'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:470 +#: ../data/templates/Ubuntu.info.in:465 msgid "Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:473 +#: ../data/templates/Ubuntu.info.in:468 msgid "Canonical-supported Open Source software" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:475 +#: ../data/templates/Ubuntu.info.in:470 msgid "Community-maintained (universe)" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:476 +#: ../data/templates/Ubuntu.info.in:471 msgid "Community-maintained Open Source software" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:478 +#: ../data/templates/Ubuntu.info.in:473 msgid "Non-free drivers" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:479 +#: ../data/templates/Ubuntu.info.in:474 msgid "Proprietary drivers for devices" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:481 +#: ../data/templates/Ubuntu.info.in:476 msgid "Restricted software (Multiverse)" msgstr "" #. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:482 +#: ../data/templates/Ubuntu.info.in:477 msgid "Software restricted by copyright or legal issues" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:488 +#: ../data/templates/Ubuntu.info.in:483 msgid "Cdrom with Ubuntu 6.06 LTS 'Dapper Drake'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:500 +#: ../data/templates/Ubuntu.info.in:495 msgid "Important security updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:505 +#: ../data/templates/Ubuntu.info.in:500 msgid "Recommended updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:510 +#: ../data/templates/Ubuntu.info.in:505 msgid "Pre-released updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:515 +#: ../data/templates/Ubuntu.info.in:510 msgid "Unsupported updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:522 +#: ../data/templates/Ubuntu.info.in:517 msgid "Ubuntu 5.10 'Breezy Badger'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:536 +#: ../data/templates/Ubuntu.info.in:531 msgid "Cdrom with Ubuntu 5.10 'Breezy Badger'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:548 +#: ../data/templates/Ubuntu.info.in:543 msgid "Ubuntu 5.10 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:553 +#: ../data/templates/Ubuntu.info.in:548 msgid "Ubuntu 5.10 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:558 +#: ../data/templates/Ubuntu.info.in:553 msgid "Ubuntu 5.10 Backports" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:565 +#: ../data/templates/Ubuntu.info.in:560 msgid "Ubuntu 5.04 'Hoary Hedgehog'" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:579 +#: ../data/templates/Ubuntu.info.in:574 msgid "Cdrom with Ubuntu 5.04 'Hoary Hedgehog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:582 ../data/templates/Debian.info.in:148 +#: ../data/templates/Ubuntu.info.in:577 ../data/templates/Debian.info.in:149 msgid "Officially supported" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:591 +#: ../data/templates/Ubuntu.info.in:586 msgid "Ubuntu 5.04 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:596 +#: ../data/templates/Ubuntu.info.in:591 msgid "Ubuntu 5.04 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:601 +#: ../data/templates/Ubuntu.info.in:596 msgid "Ubuntu 5.04 Backports" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:607 +#: ../data/templates/Ubuntu.info.in:602 msgid "Ubuntu 4.10 'Warty Warthog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:613 +#: ../data/templates/Ubuntu.info.in:608 msgid "Community-maintained (Universe)" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:615 +#: ../data/templates/Ubuntu.info.in:610 msgid "Non-free (Multiverse)" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:621 +#: ../data/templates/Ubuntu.info.in:616 msgid "Cdrom with Ubuntu 4.10 'Warty Warthog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:624 +#: ../data/templates/Ubuntu.info.in:619 msgid "No longer officially supported" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:626 +#: ../data/templates/Ubuntu.info.in:621 msgid "Restricted copyright" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:633 +#: ../data/templates/Ubuntu.info.in:628 msgid "Ubuntu 4.10 Security Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:638 +#: ../data/templates/Ubuntu.info.in:633 msgid "Ubuntu 4.10 Updates" msgstr "" #. Description -#: ../data/templates/Ubuntu.info.in:643 +#: ../data/templates/Ubuntu.info.in:638 msgid "Ubuntu 4.10 Backports" msgstr "" @@ -324,17 +324,17 @@ msgid "Debian testing" msgstr "" #. Description -#: ../data/templates/Debian.info.in:146 +#: ../data/templates/Debian.info.in:147 msgid "Debian 'Sid' (unstable)" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:150 +#: ../data/templates/Debian.info.in:151 msgid "DFSG-compatible Software with Non-Free Dependencies" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:152 +#: ../data/templates/Debian.info.in:153 msgid "Non-DFSG-compatible Software" msgstr "" @@ -356,39 +356,39 @@ msgstr "" msgid "Custom servers" msgstr "" -#: ../apt/progress/gtk2.py:259 ../apt/progress/gtk2.py:315 +#: ../apt/progress/gtk2.py:260 ../apt/progress/gtk2.py:316 #, python-format msgid "Downloading file %(current)li of %(total)li with %(speed)s/s" msgstr "" -#: ../apt/progress/gtk2.py:265 ../apt/progress/gtk2.py:321 +#: ../apt/progress/gtk2.py:266 ../apt/progress/gtk2.py:322 #, python-format msgid "Downloading file %(current)li of %(total)li" msgstr "" #. Setup some child widgets -#: ../apt/progress/gtk2.py:341 +#: ../apt/progress/gtk2.py:342 msgid "Details" msgstr "" -#: ../apt/progress/gtk2.py:429 +#: ../apt/progress/gtk2.py:430 msgid "Starting..." msgstr "" -#: ../apt/progress/gtk2.py:435 +#: ../apt/progress/gtk2.py:436 msgid "Complete" msgstr "" -#: ../apt/package.py:333 +#: ../apt/package.py:342 #, python-format msgid "Invalid unicode in description for '%s' (%s). Please report." msgstr "" -#: ../apt/package.py:989 ../apt/package.py:1095 +#: ../apt/package.py:999 ../apt/package.py:1105 msgid "The list of changes is not available" msgstr "" -#: ../apt/package.py:1099 +#: ../apt/package.py:1109 #, python-format msgid "" "The list of changes is not available yet.\n" @@ -397,23 +397,23 @@ msgid "" "until the changes become available or try again later." msgstr "" -#: ../apt/package.py:1105 +#: ../apt/package.py:1115 msgid "" "Failed to download the list of changes. \n" "Please check your Internet connection." msgstr "" -#: ../apt/debfile.py:70 +#: ../apt/debfile.py:73 #, python-format msgid "List of files for '%s' could not be read" msgstr "" -#: ../apt/debfile.py:138 +#: ../apt/debfile.py:141 #, python-format msgid "Dependency is not satisfiable: %s\n" msgstr "" -#: ../apt/debfile.py:162 +#: ../apt/debfile.py:165 #, python-format msgid "Conflicts with the installed package '%s'" msgstr "" @@ -437,12 +437,12 @@ msgstr "" msgid "Cannot install '%s'" msgstr "" -#: ../apt/debfile.py:473 +#: ../apt/debfile.py:472 #, python-format msgid "Install Build-Dependencies for source package '%s' that builds %s\n" msgstr "" -#: ../apt/debfile.py:483 +#: ../apt/debfile.py:482 msgid "An essential package would be removed" msgstr "" @@ -493,6 +493,6 @@ msgstr "" msgid "Please insert a Disc in the drive and press enter" msgstr "" -#: ../apt/cache.py:127 +#: ../apt/cache.py:131 msgid "Building data structures" msgstr "" diff --git a/tests/data/aptsources/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution index 4ff0fae6..79224a34 100644 --- a/tests/data/aptsources/sources.list.testDistribution +++ b/tests/data/aptsources/sources.list.testDistribution @@ -6,8 +6,8 @@ deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates restricted deb http://de.archive.ubuntu.com/ubuntu/ hardy-security main deb http://de.archive.ubuntu.com/ubuntu/ hardy-security multiverse deb http://ftp.debian.org/debian sid main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main -deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main +deb http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ hardy main +deb http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ hardy-backports main deb http://archive.ubuntu.com/ubuntu/ intrepid main deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main -- cgit v1.2.3 From 60fa1ae39d5911d7051cfbeb1016db9d47ca331a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 3 Mar 2010 19:40:22 +0100 Subject: python/generic.cc: Map UntranslatedDepType to dep_type_untranslated. --- debian/changelog | 2 ++ python/generic.cc | 1 + 2 files changed, 3 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index cb825163..7986b91c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.93.4) unstable; urgency=low * python/acquire-item.cc: - Add AcquireItem.partialsize member. + * python/generic.cc: + - Map UntranslatedDepType to dep_type_untranslated. * apt/package.py: - Create a string class BaseDependency.__dstr which makes '>' equal to '>>' and '<' equal to '<<' (compatibility). diff --git a/python/generic.cc b/python/generic.cc index 7af34d39..d3f6a6d6 100644 --- a/python/generic.cc +++ b/python/generic.cc @@ -66,6 +66,7 @@ static PyObject *_PyApt_NewNameForAttribute(const char *attr) { 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; -- cgit v1.2.3 From 4b434cde19d25e2acc238699834f1a2a72540ca2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Mar 2010 18:14:43 +0100 Subject: * python/tag.cc: - Hack the TagFile iterator to not use shared storage (Closes: #572596): Scan once, duplicate the section data, and scan again. --- debian/changelog | 3 +++ python/tag.cc | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 7986b91c..77e1dde1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,9 @@ python-apt (0.7.93.4) unstable; urgency=low - Add AcquireItem.partialsize member. * python/generic.cc: - Map UntranslatedDepType to dep_type_untranslated. + * python/tag.cc: + - Hack the TagFile iterator to not use shared storage (Closes: #572596): + Scan once, duplicate the section data, and scan again. * apt/package.py: - Create a string class BaseDependency.__dstr which makes '>' equal to '>>' and '<' equal to '<<' (compatibility). diff --git a/python/tag.cc b/python/tag.cc index 6d327d27..c7edcb31 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -271,6 +271,22 @@ static PyObject *TagFileNext(PyObject *Self) Obj.Section->Data = 0; if (Obj.Object.Step(Obj.Section->Object) == false) return HandleErrors(NULL); + + // Bug-Debian: http://bugs.debian.org/572596 + // Duplicate the data here and scan the duplicated section data; in order + // to not use any shared storage. + // TODO: Provide an API in apt-pkg to do this; this is really ugly. + + // Fetch old section data + const char *Start; + const char *Stop; + Obj.Section->Object.GetSection(Start,Stop); + // Duplicate the data + Obj.Section->Data = new char[Stop-Start]; + strncpy(Obj.Section->Data, Start, Stop-Start); + // Rescan it + Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start); + Py_INCREF(Obj.Section); return HandleErrors(Obj.Section); } -- cgit v1.2.3 From 7ebf48f29064579cf4752aa5bf9c4663b49c2792 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Mar 2010 15:04:39 +0100 Subject: apt/package.py: Always return unicode strings in Package.get_changelog (Closes: #572998). --- apt/package.py | 20 +++++++++++++------- debian/changelog | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'debian') diff --git a/apt/package.py b/apt/package.py index 7c739aab..0c026504 100644 --- a/apt/package.py +++ b/apt/package.py @@ -981,7 +981,7 @@ class Package(object): which if set, prevents the download. """ # Return a cached changelog if available - if self._changelog != "": + if self._changelog != u"": return self._changelog if uri is None: @@ -996,7 +996,8 @@ class Package(object): "/%(src_section)s/%(prefix)s/%(src_pkg)s" \ "/%(src_pkg)s_%(src_ver)s/changelog" else: - return _("The list of changes is not available") + res = _("The list of changes is not available") + return res if isinstance(res, unicode) else res.decode("utf-8") # get the src package name src_pkg = self.candidate.source_name @@ -1066,15 +1067,15 @@ class Package(object): # Check if the download was canceled if cancel_lock and cancel_lock.isSet(): - return "" + return u"" changelog_file = urllib2.urlopen(uri) # do only get the lines that are new - changelog = "" + changelog = u"" regexp = "^%s \((.*)\)(.*)$" % (re.escape(src_pkg)) while True: # Check if the download was canceled if cancel_lock and cancel_lock.isSet(): - return "" + return u"" # Read changelog line by line line_raw = changelog_file.readline() if line_raw == "": @@ -1094,6 +1095,7 @@ class Package(object): changelog_ver = match.group(1) if changelog_ver and ":" in changelog_ver: changelog_ver = changelog_ver.split(":", 1)[1] + if (installed and apt_pkg.version_compare( changelog_ver, installed) <= 0): break @@ -1103,17 +1105,21 @@ class Package(object): # Print an error if we failed to extract a changelog if len(changelog) == 0: changelog = _("The list of changes is not available") + if not isinstance(changelog, unicode): + changelog = changelog.decode("utf-8") self._changelog = changelog except urllib2.HTTPError: - return _("The list of changes is not available yet.\n\n" + res = _("The list of changes is not available yet.\n\n" "Please use http://launchpad.net/ubuntu/+source/%s/" "%s/+changelog\n" "until the changes become available or try again " "later.") % (src_pkg, src_ver) + return res if isinstance(res, unicode) else res.decode("utf-8") except (IOError, httplib.BadStatusLine): - return _("Failed to download the list of changes. \nPlease " + res = _("Failed to download the list of changes. \nPlease " "check your Internet connection.") + return res if isinstance(res, unicode) else res.decode("utf-8") finally: socket.setdefaulttimeout(timeout) return self._changelog diff --git a/debian/changelog b/debian/changelog index 77e1dde1..ce6ddf7f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,7 @@ python-apt (0.7.93.4) unstable; urgency=low '>>' and '<' equal to '<<' (compatibility). - Use the binary package version in Version.fetch_source() if the source version is not specified (i.e. in the normal case). + - Always return unicode strings in Package.get_changelog (Closes: #572998). * apt/progress/text.py: - Drop InstallProgress, it's useless to keep this alias around. * apt/progress/old.py: -- cgit v1.2.3 From 87634e1309c3f413be5246bfd78d0ad3765c5da6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Mar 2010 16:21:41 +0100 Subject: * utils/get_debian_mirrors.py: - Parse Mirrors.masterlist instead of the HTML web page. --- debian/changelog | 2 ++ pre-build.sh | 2 +- utils/get_debian_mirrors.py | 78 ++++++++++++--------------------------------- 3 files changed, 24 insertions(+), 58 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index ce6ddf7f..97c72763 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ python-apt (0.7.93.4) unstable; urgency=low - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) * tests/data/aptsources/sources.list.testDistribution: - change one mirror which is not on the mirror list anymore. + * utils/get_debian_mirrors.py: + - Parse Mirrors.masterlist instead of the HTML web page. -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 diff --git a/pre-build.sh b/pre-build.sh index 6d019603..026a491e 100755 --- a/pre-build.sh +++ b/pre-build.sh @@ -8,4 +8,4 @@ fi utils/get_ubuntu_mirrors_from_lp.py > data/templates/Ubuntu.mirrors echo "updating Debian mirror list" -( cd utils; ./get_debian_mirrors.py; ) +utils/get_debian_mirrors.py > data/templates/Debian.mirrors diff --git a/utils/get_debian_mirrors.py b/utils/get_debian_mirrors.py index 9fb783bd..395c21da 100755 --- a/utils/get_debian_mirrors.py +++ b/utils/get_debian_mirrors.py @@ -1,13 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/python +# get_debian_mirrors.py - Parse Mirrors.masterlist and create a mirror list. # -# get_debian_mirrors.py -# -# Download the latest list with available mirrors from the Debian -# website and extract the hosts from the raw page -# -# Copyright (c) 2006, 2009 Free Software Foundation Europe -# -# Author: Sebastian Heinlein +# Copyright (c) 2010 Julian Andres Klode # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -23,52 +17,22 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA - +import collections import urllib2 -import re -import os -import commands -import sys - -# the list of official Ubuntu servers -mirrors = [] -# path to the local mirror list -list_path = "../data/templates/Debian.mirrors" - -req = urllib2.Request("http://www.debian.org/mirror/mirrors_full") -match = re.compile("^.*>([A-Za-z0-9-.\/_]+)<\/a>.*\n$") -match_location = re.compile('^

.*') -match_sites = re.compile('^Site: ([A-Za-z0-9-.\ \/_,]+)<\/tt>.*\n$') - - -def add_sites(line, proto, sites, mirror_type): - path = match.sub(r"\1", line) - for site in sites: - mirror_type.append("%s://%s%s\n" % (proto, site.lstrip(), path)) - - -try: - print "Downloading mirrors list from the Debian website..." - uri=urllib2.urlopen(req) - for line in uri.readlines(): - if line.startswith('

Packages over HTTP'): - add_sites(line, "http", sites, mirrors) - elif line.startswith('
Packages over FTP'): - add_sites(line, "ftp", sites, mirrors) - uri.close() -except: - print "Failed to download or to extract the mirrors list!" - sys.exit(1) - -print "Writing local mirrors list: %s" % list_path -list = open(list_path, "w") -for mirror in mirrors: - list.write("%s" % mirror) -list.close() -print "Done." +from debian_bundle import deb822 + +mirrors = collections.defaultdict(set) +masterlist = urllib2.urlopen("http://cvs.debian.org/webwml/webwml/english/" + "mirror/Mirrors.masterlist?revision=HEAD") + +for mirror in deb822.Deb822.iter_paragraphs(masterlist): + country = mirror["Country"].split(None, 1)[0] + site = mirror["Site"] + for proto in 'http', 'ftp': + if "Archive-%s" % proto in mirror: + mirrors[country].add("%s://%s%s" % (proto, site, + mirror["Archive-%s" % proto])) + +for country in sorted(mirrors): + print "#LOC:%s" % country + print "\n".join(sorted(mirrors[country])) -- cgit v1.2.3 From 5dcb4f67ca94d79f05cbd0940bbb5a7796a05bca Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 8 Mar 2010 16:33:23 +0100 Subject: * utils/get_ubuntu_mirrors_from_lp.py: - Sort the mirror list of each country. --- data/templates/Debian.mirrors | 812 +++++++++++++++++++++--------------- data/templates/Ubuntu.mirrors | 356 ++++++++-------- debian/changelog | 2 + utils/get_ubuntu_mirrors_from_lp.py | 2 +- 4 files changed, 646 insertions(+), 526 deletions(-) (limited to 'debian') diff --git a/data/templates/Debian.mirrors b/data/templates/Debian.mirrors index cfad790b..f7c24139 100644 --- a/data/templates/Debian.mirrors +++ b/data/templates/Debian.mirrors @@ -1,575 +1,693 @@ #LOC:AR -http://debian.logiclinux.com/debian/ -ftp://ftp.ccc.uba.ar/pub/linux/debian/debian/ ftp://debian.torredehanoi.org/debian/ +ftp://ftp.ccc.uba.ar/pub/linux/debian/debian/ +http://debian.logiclinux.com/debian/ +http://debian.torredehanoi.org/debian/ +http://ftp.ccc.uba.ar/pub/linux/debian/debian/ #LOC:AT -ftp://ftp.at.debian.org/debian/ -ftp://debian.sil.at/debian/ -ftp://ftp.debian.at/debian/ -ftp://gd.tuwien.ac.at/opsys/linux/debian/ -ftp://ftp.tuwien.ac.at/opsys/linux/debian/ +ftp://debian.inode.at/debian/ +ftp://debian.lagis.at/debian/ ftp://debian.mur.at/debian/ -ftp://algo.mur.at/debian/ -ftp://spider.mur.at/debian/ +ftp://ftp.at.debian.org/debian/ ftp://ftp.tu-graz.ac.at/mirror/debian/ -ftp://ftp.tugraz.at/mirror/debian/ ftp://ftp.univie.ac.at/systems/linux/debian/debian/ -ftp://debian.inode.at/debian/ -ftp://debian.lagis.at/debian/ +ftp://gd.tuwien.ac.at/opsys/linux/debian/ +http://debian.inode.at/debian/ +http://debian.lagis.at/debian/ +http://debian.mur.at/debian/ +http://ftp.at.debian.org/debian/ +http://ftp.tu-graz.ac.at/mirror/debian/ +http://ftp.univie.ac.at/systems/linux/debian/debian/ +http://gd.tuwien.ac.at/opsys/linux/debian/ #LOC:AU ftp://ftp.au.debian.org/debian/ -ftp://mirror.linux.org.au/debian/ -ftp://mirror.aarnet.edu.au/debian/ +ftp://ftp.iinet.net.au/debian/debian/ ftp://ftp.monash.edu.au/pub/linux/debian/ +ftp://ftp.netspace.net.au/pub/debian/ ftp://ftp.uwa.edu.au/debian/ +ftp://mirror.aarnet.edu.au/debian/ +ftp://mirror.cse.unsw.edu.au/debian/ ftp://mirror.eftel.com/debian/ -ftp://mirror.q-net.net.au/debian/ -ftp://mirror.datafast.net.au/debian/ -ftp://mirror.pacific.net.au/debian/ -ftp://ftp.iinet.net.au/debian/debian/ ftp://mirror.optus.net/debian/ -ftp://mirror.optusnet.com.au/debian/ -ftp://mirror.cse.unsw.edu.au/debian/ -ftp://ftp.netspace.net.au/pub/debian/ -ftp://mirror.waia.asn.au/debian/ +ftp://mirror.pacific.net.au/debian/ ftp://mirror.transact.net.au/debian/ +ftp://mirror.waia.asn.au/debian/ +http://ftp.au.debian.org/debian/ +http://ftp.iinet.net.au/debian/debian/ +http://ftp.monash.edu.au/pub/linux/debian/ +http://ftp.netspace.net.au/pub/debian/ +http://ftp.uwa.edu.au/debian/ +http://mirror.aarnet.edu.au/debian/ +http://mirror.cse.unsw.edu.au/debian/ +http://mirror.eftel.com/debian/ +http://mirror.optus.net/debian/ +http://mirror.pacific.net.au/debian/ +http://mirror.transact.net.au/debian/ +http://mirror.waia.asn.au/debian/ #LOC:BA ftp://ftp.ba.debian.org/debian/ -ftp://mirror.debian.com.ba/debian/ +http://ftp.ba.debian.org/debian/ #LOC:BE ftp://ftp.be.debian.org/debian/ -ftp://mirror.be.gbxs.net/debian/ -ftp://ftp.easynet.be/debian/ ftp://ftp.belnet.be/debian/ ftp://ftp.debian.skynet.be/debian/ +ftp://ftp.easynet.be/debian/ +http://ftp.be.debian.org/debian/ +http://ftp.belnet.be/debian/ +http://ftp.debian.skynet.be/ftp/debian/ +http://ftp.easynet.be/ftp/debian/ #LOC:BG -ftp://ftp.bg.debian.org/debian/ -ftp://debian.spnet.net/debian/ +ftp://debian.ipacct.com/debian/ ftp://debian.ludost.net/debian/ -ftp://marla.ludost.net/debian/ -ftp://ftp.uni-sofia.bg/debian/ -ftp://debian.telecoms.bg/debian/ ftp://debian.mnet.bg/debian/ ftp://debian.networx-bg.com/debian/ -ftp://debian.ipacct.com/debian/ +ftp://debian.telecoms.bg/debian/ +ftp://ftp.bg.debian.org/debian/ +ftp://ftp.uni-sofia.bg/debian/ +http://debian.ipacct.com/debian/ +http://debian.ludost.net/debian/ +http://debian.mnet.bg/debian/ +http://debian.networx-bg.com/debian/ +http://debian.telecoms.bg/debian/ +http://ftp.bg.debian.org/debian/ +http://ftp.uni-sofia.bg/debian/ #LOC:BR -ftp://ftp.br.debian.org/debian/ -ftp://debian.c3sl.ufpr.br/debian/ ftp://debian.das.ufsc.br/pub/debian/ -http://download.unesp.br/linux/debian/ -http://sft.if.usp.br/debian/ -http://fma.if.usp.br/debian/ -ftp://linorg.usp.br/debian/ -http://linux.iq.usp.br/debian/ -http://torio.iq.usp.br/debian/ -ftp://ftp.pucpr.br/debian/ ftp://debian.las.ic.unicamp.br/debian/ -http://debian.pop-sc.rnp.br/debian/ -http://mirror.pop-sc.rnp.br/debian/ ftp://debs.ifsul.edu.br/debian/ +ftp://ftp.br.debian.org/debian/ +ftp://ftp.pucpr.br/debian/ +ftp://linorg.usp.br/debian/ +http://debian.las.ic.unicamp.br/debian/ +http://debian.pop-sc.rnp.br/debian/ +http://debs.ifsul.edu.br/debian/ +http://download.unesp.br/linux/debian/ +http://ftp.br.debian.org/debian/ +http://linorg.usp.br/debian/ +http://linux.iq.usp.br/debian/ +http://sft.if.usp.br/debian/ #LOC:BY -http://linux.org.by/debian/ ftp://ftp.mgts.by/debian/ +http://ftp.mgts.by/debian/ +http://linux.org.by/debian/ #LOC:CA +ftp://debian.mirror.iweb.ca/debian/ +ftp://debian.mirror.rafal.ca/debian/ +ftp://debian.savoirfairelinux.net/debian/ ftp://ftp.ca.debian.org/debian/ -http://debian.yorku.ca/debian/ ftp://ftp3.nrc.ca/debian/ -ftp://ftp3.ca.debian.org/debian/ ftp://mirror.cpsc.ucalgary.ca/debian/ -http://mirror.peer1.net/debian/ -ftp://debian.mirror.rafal.ca/debian/ -ftp://mirror.mountaincable.net/debian/ -ftp://ftp4.ca.debian.org/debian/ -ftp://debian.savoirfairelinux.net/debian/ -ftp://gpl.savoirfairelinux.net/debian/ -ftp://debian.mirror.iweb.ca/debian/ -ftp://ftp2.ca.debian.org/debian/ ftp://mirror.csclub.uwaterloo.ca/debian/ ftp://mirror.its.dal.ca/debian/ +http://debian.mirror.iweb.ca/debian/ +http://debian.mirror.rafal.ca/debian/ +http://debian.savoirfairelinux.net/debian/ +http://debian.yorku.ca/debian/ +http://ftp.ca.debian.org/debian/ +http://ftp3.nrc.ca/debian/ +http://mirror.cpsc.ucalgary.ca/mirror/debian.org/debian/ +http://mirror.csclub.uwaterloo.ca/debian/ +http://mirror.its.dal.ca/debian/ +http://mirror.peer1.net/debian/ #LOC:CH ftp://ftp.ch.debian.org/debian/ -ftp://debian.ethz.ch/debian/ ftp://mirror.switch.ch/mirror/debian/ http://debian.csg.uzh.ch/debian/ +http://ftp.ch.debian.org/debian/ +http://mirror.switch.ch/ftp/mirror/debian/ #LOC:CL ftp://ftp.cl.debian.org/debian/ -ftp://debian.netlinux.cl/debian/ -http://debian.ubiobio.cl/debian/ http://debian.ciencias.uchile.cl/debian/ +http://debian.ubiobio.cl/debian/ http://debian.utalca.cl/debian/ +http://ftp.cl.debian.org/debian/ #LOC:CN ftp://mirrors.geekbone.org/debian/ ftp://www.anheng.com.cn/debian/ -ftp://debian.bjlx.org.cn/debian/ -ftp://www.watertest.com.cn/debian/ -ftp://www.anheng.com.cn/debian/ +http://mirrors.geekbone.org/debian/ +http://www.anheng.com.cn/debian/ #LOC:CR ftp://mirrors.ucr.ac.cr/debian/ -ftp://espejos.ucr.ac.cr/debian/ +http://mirrors.ucr.ac.cr/debian/ #LOC:CZ -ftp://ftp.cz.debian.org/debian/ -ftp://ftp.debian.cz/debian/ -ftp://www.debian.cz/debian/ -ftp://debian.sh.cvut.cz/debian/ -ftp://ftp.sh.cvut.cz/debian/ -ftp://ftp.zcu.cz/mirrors/debian/ -ftp://debian.mirror.web4u.cz/ -ftp://ftp.cvut.cz/debian/ -ftp://ftp.fs.cvut.cz/debian/ ftp://debian.ignum.cz/debian/ -ftp://ucho.ignum.cz/debian/ ftp://debian.mirror.dkm.cz/debian/ +ftp://debian.mirror.web4u.cz/ +ftp://debian.sh.cvut.cz/debian/ ftp://debian.superhosting.cz/debian/ +ftp://ftp.cvut.cz/debian/ +ftp://ftp.cz.debian.org/debian/ +ftp://ftp.zcu.cz/mirrors/debian/ +http://debian.ignum.cz/debian/ +http://debian.mirror.dkm.cz/debian/ +http://debian.mirror.web4u.cz/ +http://debian.sh.cvut.cz/debian/ +http://debian.superhosting.cz/debian/ +http://ftp.cvut.cz/debian/ +http://ftp.cz.debian.org/debian/ +http://ftp.zcu.cz/mirrors/debian/ #LOC:DE -ftp://ftp.de.debian.org/debian/ -ftp://ftp1.de.debian.org/debian/ -ftp://debian.inf.tu-dresden.de/debian/ -ftp://ftp2.de.debian.org/debian/ -ftp://ftp.rfc822.org/debian/ -ftp://source.rfc822.org/debian/ -ftp://ftp.tu-clausthal.de/pub/linux/debian/ -ftp://pegasus.rz.tu-clausthal.de/pub/linux/debian/ +ftp://artfiles.org/debian/ +ftp://debian.cruisix.net/debian/ +ftp://debian.morphium.info/debian/ +ftp://debian.netcologne.de/debian/ +ftp://debian.tu-bs.de/debian/ ftp://debian.uni-duisburg-essen.de/debian/ -ftp://ftp.freenet.de/debian/ -ftp://ftp.informatik.rwth-aachen.de/pub/Linux/debian/ -ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/debian/ ftp://ftp-stud.fht-esslingen.de/debian/ -ftp://ftp.stw-bonn.de/debian/ +ftp://ftp.de.debian.org/debian/ +ftp://ftp.freenet.de/debian/ ftp://ftp.fu-berlin.de/pub/unix/linux/mirrors/debian/ -ftp://Hefe.ZEDAT.FU-Berlin.DE/pub/unix/linux/mirrors/debian/ -ftp://debian.tu-bs.de/debian/ -ftp://ftp.uni-koeln.de/debian/ +ftp://ftp.hosteurope.de/pub/linux/debian/ +ftp://ftp.informatik.hu-berlin.de/pub/Linux/debian/ +ftp://ftp.informatik.rwth-aachen.de/pub/Linux/debian/ +ftp://ftp.informatik.uni-frankfurt.de/pub/Mirrors/debian.org/debian/ ftp://ftp.mpi-sb.mpg.de/pub/linux/debian/ +ftp://ftp.plusline.de/pub/debian/ +ftp://ftp.rrzn.uni-hannover.de/debian/debian/ +ftp://ftp.stw-bonn.de/debian/ ftp://ftp.tu-chemnitz.de/pub/linux/debian/debian/ -ftp://ftp.uni-kl.de/debian/ +ftp://ftp.tu-clausthal.de/pub/linux/debian/ ftp://ftp.uni-bayreuth.de/debian/ -ftp://btr0x2.rz.uni-bayreuth.de/debian/ -ftp://ftp.informatik.hu-berlin.de/pub/Linux/debian/ +ftp://ftp.uni-kl.de/debian/ +ftp://ftp.uni-koeln.de/debian/ +ftp://ftp2.de.debian.org/debian/ ftp://ftp5.gwdg.de/pub/linux/debian/debian/ -ftp://ftp.hosteurope.de/pub/linux/debian/ -ftp://ftp.informatik.uni-frankfurt.de/pub/Mirrors/debian.org/debian/ -ftp://ftp.cs.uni-frankfurt.de/pub/Mirrors/debian.org/debian/ -ftp://debian.netcologne.de/debian/ -ftp://artfiles.org/debian/ -http://debian.intergenia.de/debian/ -http://debian.server4you.de/debian/ -http://debian.vserver.de/debian/ -http://debian.plusserver.de/debian/ -ftp://debian.cruisix.net/debian/ -ftp://ftp.rrzn.uni-hannover.de/debian/debian/ -http://debian.charite.de/debian/ -ftp://ftp.plusline.de/pub/debian/ ftp://mirror.ayous.org/debian/ -ftp://debian.morphium.info/debian/ ftp://mirror.giantix-server.de/debian/ +http://artfiles.org/debian/ +http://debian.charite.de/debian/ +http://debian.cruisix.net/debian/ +http://debian.intergenia.de/debian/ +http://debian.morphium.info/debian/ +http://debian.netcologne.de/debian/ +http://debian.tu-bs.de/debian/ +http://debian.uni-duisburg-essen.de/debian/ +http://ftp-stud.fht-esslingen.de/debian/ +http://ftp.de.debian.org/debian/ +http://ftp.freenet.de/debian/ +http://ftp.hosteurope.de/pub/linux/debian/ +http://ftp.informatik.rwth-aachen.de/ftp/pub/Linux/debian/ +http://ftp.informatik.uni-frankfurt.de/debian/ +http://ftp.plusline.de/debian/ +http://ftp.stw-bonn.de/debian/ +http://ftp.tu-chemnitz.de/pub/linux/debian/debian/ +http://ftp.tu-clausthal.de/pub/linux/debian/ +http://ftp.uni-bayreuth.de/debian/ +http://ftp.uni-kl.de/debian/ +http://ftp.uni-koeln.de/debian/ +http://ftp2.de.debian.org/debian/ +http://ftp5.gwdg.de/pub/linux/debian/debian/ +http://mirror.ayous.org/debian/ +http://mirror.giantix-server.de/debian/ #LOC:DK ftp://ftp.dk.debian.org/debian/ -ftp://mirrors.dotsrc.org/debian/ ftp://mirrors.telianet.dk/debian/ -ftp://mirrors.dk.telia.net/debian/ +http://ftp.dk.debian.org/debian/ +http://mirrors.telianet.dk/debian/ #LOC:EE ftp://ftp.ee.debian.org/debian/ -ftp://ftp.aso.ee/debian/ -ftp://ftp.ria.ee/debian/ +http://ftp.ee.debian.org/debian/ #LOC:ES -ftp://ftp.es.debian.org/debian/ -ftp://ftp.gul.uc3m.es/debian/ -ftp://ftp.gul.es/debian/ -ftp://ftp.cica.es/debian/ +ftp://debian.grn.cat/debian/ ftp://ftp.caliu.cat/debian/ +ftp://ftp.cica.es/debian/ +ftp://ftp.es.debian.org/debian/ ftp://ftp.gva.es/mirror/debian/ -ftp://frigga.gva.es/mirror/debian/ ftp://ftp.udc.es/debian/ -ftp://debian.grn.cat/debian/ -ftp://ftp.grn.es/debian/ -ftp://ftp.grn.cat/debian/ +http://debian.grn.cat/debian/ +http://ftp.caliu.cat/debian/ +http://ftp.cica.es/debian/ +http://ftp.es.debian.org/debian/ +http://ftp.gva.es/mirror/debian/ +http://ftp.udc.es/debian/ #LOC:FI ftp://ftp.fi.debian.org/debian/ -ftp://trumpetti.atm.tut.fi/debian/ ftp://ftp.funet.fi/pub/linux/mirrors/debian/ ftp://ftp.jyu.fi/debian/ -ftp://lennon.cc.jyu.fi/debian/ ftp://ftp.seclan.com/debian/ +http://ftp.fi.debian.org/debian/ +http://ftp.funet.fi/pub/linux/mirrors/debian/ +http://ftp.jyu.fi/debian/ +http://ftp.seclan.com/debian/ #LOC:FR +ftp://debian.advalem.net/debian/ +ftp://debian.cict.fr/debian/ +ftp://debian.ens-cachan.fr/debian/ +ftp://debian.med.univ-tours.fr/debian/ +ftp://debian.mines.inpl-nancy.fr/debian/ +ftp://debian.mirror.inra.fr/debian/ +ftp://debian.mirrors.easynet.fr/debian/ +ftp://debian.polytech-lille.fr/debian/ +ftp://debian.revolsys.fr/debian/ +ftp://debian.univ-reims.fr/debian/ +ftp://ftp.crihan.fr/debian/ ftp://ftp.fr.debian.org/debian/ -ftp://debian.proxad.net/debian/ -ftp://ftpmirror.proxad.net/debian/ -ftp://ftp2.fr.debian.org/debian/ -ftp://ftp.oleane.net/debian/ ftp://ftp.iut-bm.univ-fcomte.fr/debian/ -ftp://debian.iut-bm.univ-fcomte.fr/debian/ -ftp://debian.polytech-lille.fr/debian/ -ftp://ftp.eudil.fr/debian/ -ftp://ftp.proxad.net/mirrors/ftp.debian.org/ -ftp://ftp.free.fr/mirrors/ftp.debian.org/ -ftp://ftp.online.fr/mirrors/ftp.debian.org/ -ftp://ftp.proxad.fr/mirrors/ftp.debian.org/ ftp://ftp.lip6.fr/pub/linux/distributions/debian/ -ftp://debian.ens-cachan.fr/debian/ -ftp://ftp.ens-cachan.fr/debian/ +ftp://ftp.nerim.net/debian/ +ftp://ftp.proxad.net/mirrors/ftp.debian.org/ ftp://ftp.u-picardie.fr/mirror/debian/ -ftp://debian.mirrors.easynet.fr/debian/ -ftp://tengu.easynet.fr/debian/ ftp://ftp.u-strasbg.fr/debian/ -ftp://debian.cict.fr/debian/ +ftp://ftp.univ-nantes.fr/debian/ +ftp://ftp.univ-pau.fr/pub/mirrors/debian/ +ftp://ftp2.fr.debian.org/debian/ ftp://mir1.ovh.net/debian/ -http://mir2.ovh.net/debian/ -http://mirror.ovh.net/debian/ -ftp://ftp.nerim.net/debian/ -ftp://ftp.crihan.fr/debian/ -ftp://debian.mines.inpl-nancy.fr/debian/ -ftp://ftp.mines.inpl-nancy.fr/debian/ -ftp://webb.ens-cachan.fr/debian/ -ftp://debian.ens-cachan.fr/debian/ ftp://mirrors.ircam.fr/pub/debian/ -ftp://debian.mirror.inra.fr/debian/ -ftp://debian.med.univ-tours.fr/debian/ -ftp://ftp.univ-pau.fr/pub/mirrors/debian/ -ftp://ftp.univ-nantes.fr/debian/ -ftp://vacuum.univ-nantes.fr/debian/ +ftp://webb.ens-cachan.fr/debian/ +http://debian.advalem.net/debian/ +http://debian.cict.fr/debian/ +http://debian.ens-cachan.fr/ftp/debian/ +http://debian.med.univ-tours.fr/debian/ +http://debian.mines.inpl-nancy.fr/debian/ +http://debian.mirror.inra.fr/debian/ +http://debian.mirrors.easynet.fr/ +http://debian.polytech-lille.fr/debian/ +http://debian.revolsys.fr/debian/ +http://debian.univ-reims.fr/debian/ +http://ftp.crihan.fr/debian/ +http://ftp.fr.debian.org/debian/ +http://ftp.iut-bm.univ-fcomte.fr/debian/ +http://ftp.lip6.fr/pub/linux/distributions/debian/ +http://ftp.nerim.net/debian/ +http://ftp.u-picardie.fr/mirror/debian/ +http://ftp.u-strasbg.fr/debian/ +http://ftp.univ-pau.fr/linux/mirrors/debian/ +http://ftp2.fr.debian.org/debian/ +http://mir1.ovh.net/debian/ +http://mir2.ovh.net/debian/ http://mirrors.compuscene.org/debian/ -http://ns34892.ovh.net/debian/ -ftp://debian.revolsys.fr/debian/ -ftp://debian.univ-reims.fr/debian/ -ftp://debian.advalem.net/debian/ +http://mirrors.ircam.fr/pub/debian/ +http://webb.ens-cachan.fr/debian/ #LOC:GB -ftp://ftp.uk.debian.org/debian/ -ftp://free.hands.com/debian/ -ftp://debian.hands.com/debian/ -ftp://open.hands.com/debian/ -http://debian.man.ac.uk/debian/ -http://www.mirrorservice.org/sites/ftp.debian.org/debian/ ftp://ftp.mirrorservice.org/sites/ftp.debian.org/debian/ ftp://ftp.ticklers.org/debian/ -ftp://rib.ticklers.org/debian/ +ftp://ftp.uk.debian.org/debian/ +ftp://mirror.ox.ac.uk/debian/ ftp://mirror.positive-internet.com/debian/ +ftp://mirror.sov.uk.goscomb.net/debian/ +ftp://mirrors.melbourne.co.uk/debian/ ftp://the.earth.li/debian/ ftp://ukdebian.mirror.anlx.net/debian/ -ftp://mirror.ox.ac.uk/debian/ -ftp://mirror.sov.uk.goscomb.net/debian/ +http://debian.man.ac.uk/debian/ +http://ftp.ticklers.org/debian/ +http://ftp.uk.debian.org/debian/ +http://mirror.ox.ac.uk/debian/ +http://mirror.positive-internet.com/debian/ +http://mirror.sov.uk.goscomb.net/debian/ +http://mirrors.melbourne.co.uk/debian/ +http://the.earth.li/debian/ +http://ukdebian.mirror.anlx.net/debian/ +http://www.mirrorservice.org/sites/ftp.debian.org/debian/ #LOC:GR -ftp://ftp.gr.debian.org/debian/ -ftp://ftp.ntua.gr/debian/ ftp://debian.otenet.gr/pub/linux/debian/ ftp://ftp.cc.uoc.gr/mirrors/linux/debian/ +ftp://ftp.gr.debian.org/debian/ ftp://ftp.uoi.gr/debian/ +http://debian.otenet.gr/debian/ +http://ftp.cc.uoc.gr/mirrors/linux/debian/ +http://ftp.gr.debian.org/debian/ +http://ftp.uoi.gr/debian/ #LOC:HK ftp://ftp.hk.debian.org/debian/ +http://ftp.hk.debian.org/debian/ #LOC:HR +ftp://debian.iskon.hr/debian/ +ftp://ftp.carnet.hr/debian/ ftp://ftp.hr.debian.org/debian/ -ftp://debian.carnet.hr/debian/ ftp://ftp.irb.hr/debian/ -ftp://ftp.carnet.hr/debian/ -ftp://debian.iskon.hr/debian/ +http://debian.iskon.hr/debian/ +http://ftp.carnet.hr/debian/ +http://ftp.hr.debian.org/debian/ +http://ftp.irb.hr/debian/ #LOC:HU -ftp://ftp.hu.debian.org/debian/ -ftp://ftp.fsn.hu/debian/ -ftp://ftp.kfki.hu/pub/linux/debian/ -ftp://ftp.bme.hu/debian/ ftp://debian.mirrors.crysys.hu/debian/ ftp://debian.sth.sze.hu/debian/ -ftp://mirrors.sth.sze.hu/debian/ +ftp://ftp.bme.hu/debian/ +ftp://ftp.hu.debian.org/debian/ +ftp://ftp.kfki.hu/pub/linux/debian/ +http://debian.mirrors.crysys.hu/debian/ +http://debian.sth.sze.hu/debian/ +http://ftp.bme.hu/debian/ +http://ftp.hu.debian.org/debian/ +http://ftp.kfki.hu/linux/debian/ #LOC:ID ftp://kebo.vlsm.org/debian/ -ftp://surabaya.vlsm.org/debian/ -ftp://katmai.its.ac.id/debian/ ftp://mirror.unej.ac.id/debian/ +http://kebo.vlsm.org/debian/ +http://mirror.unej.ac.id/debian/ #LOC:IE -ftp://ftp.ie.debian.org/debian/ -ftp://debian.heanet.ie/debian/ -ftp://canyonero.heanet.ie/debian/ ftp://ftp.esat.net/pub/linux/debian/ +ftp://ftp.ie.debian.org/debian/ +http://ftp.esat.net/pub/linux/debian/ +http://ftp.ie.debian.org/debian/ #LOC:IL http://debian.co.il/debian/ -http://debian.interhost.co.il/debian/ http://mirror.isoc.org.il/pub/debian/ #LOC:IN ftp://ftp.iitm.ac.in/debian/ ftp://mirror.cse.iitk.ac.in/debian/ +http://ftp.iitm.ac.in/debian/ +http://mirror.cse.iitk.ac.in/debian/ #LOC:IS ftp://ftp.is.debian.org/debian/ -ftp://ftp.rhnet.is/debian/ +http://ftp.is.debian.org/debian/ #LOC:IT +ftp://debian.bononia.it/debian/ +ftp://debian.dynamica.it/debian/ +ftp://debian.fastbull.org/debian/ +ftp://debian.fastweb.it/debian/ +ftp://freedom.dicea.unifi.it/pub/linux/debian/ ftp://ftp.it.debian.org/debian/ -ftp://ftp.bofh.it/debian/ -ftp://vlad-tepes.bofh.it/debian/ ftp://giano.com.dist.unige.it/debian/ -ftp://freedom.dicea.unifi.it/pub/linux/debian/ ftp://mi.mirror.garr.it/mirrors/debian/ -ftp://debian.fastweb.it/debian/ -ftp://debian.fastbull.org/debian/ -ftp://debian.dynamica.it/debian/ +http://debian.bononia.it/debian/ +http://debian.dynamica.it/debian/ +http://debian.fastbull.org/debian/ +http://debian.fastweb.it/debian/ +http://freedom.dicea.unifi.it/ftp/pub/linux/debian/ +http://ftp.it.debian.org/debian/ +http://giano.com.dist.unige.it/debian/ +http://mi.mirror.garr.it/mirrors/debian/ http://mirror.units.it/debian/ -ftp://debian.bononia.it/debian/ #LOC:JP -ftp://ftp2.jp.debian.org/debian/ -ftp://ftp.debian.or.jp/debian/ -ftp://http.debian.or.jp/debian/ -ftp://ftp.jp.debian.org/debian/ -ftp://cdn.debian.or.jp/debian/ -ftp://ftp.nara.wide.ad.jp/debian/ -ftp://ftp.aist-nara.ac.jp/debian/ -ftp://ftp.dti.ad.jp/pub/Linux/debian/ +ftp://dennou-h.gfd-dennou.org/debian/ ftp://dennou-k.gfd-dennou.org/debian/ -ftp://dennou-k.gaia.h.kyoto-u.ac.jp/debian/ ftp://dennou-q.gfd-dennou.org/debian/ -ftp://dennou-q.geo.kyushu-u.ac.jp/debian/ -ftp://ftp.yz.yamagata-u.ac.jp/debian/ -ftp://linux.yz.yamagata-u.ac.jp/debian/ -ftp://ftp.riken.jp/Linux/debian/debian/ -ftp://ftp.riken.go.jp/Linux/debian/debian/ +ftp://ftp.dti.ad.jp/pub/Linux/debian/ ftp://ftp.jaist.ac.jp/pub/Linux/Debian/ +ftp://ftp.jp.debian.org/debian/ +ftp://ftp.nara.wide.ad.jp/debian/ +ftp://ftp.riken.jp/Linux/debian/debian/ +ftp://ftp.yz.yamagata-u.ac.jp/debian/ +ftp://ftp2.jp.debian.org/debian/ +http://dennou-h.gfd-dennou.org/debian/ +http://dennou-k.gfd-dennou.org/debian/ +http://dennou-q.gfd-dennou.org/debian/ +http://ftp.dti.ad.jp/pub/Linux/debian/ +http://ftp.jaist.ac.jp/pub/Linux/Debian/ +http://ftp.jp.debian.org/debian/ +http://ftp.nara.wide.ad.jp/debian/ +http://ftp.riken.jp/Linux/debian/debian/ +http://ftp.yz.yamagata-u.ac.jp/debian/ +http://ftp2.jp.debian.org/debian/ http://www.cohsoft.com/debian/ -ftp://dennou-h.gfd-dennou.org/debian/ -ftp://dennou-h.ees.hokudai.ac.jp/debian/ #LOC:KR -ftp://ftp.kr.debian.org/debian/ -ftp://ftp.kaist.ac.kr/debian/ ftp://ftp.daum.net/debian/ +ftp://ftp.kr.debian.org/debian/ +http://ftp.daum.net/debian/ +http://ftp.kr.debian.org/debian/ #LOC:KZ ftp://mirror.neolabs.kz/debian/ +http://mirror.neolabs.kz/debian/ #LOC:LT -ftp://ftp.litnet.lt/debian/ -ftp://debina.ktu.lt/debian/ ftp://debian.balt.net/debian/ +ftp://ftp.litnet.lt/debian/ +http://debian.balt.net/debian/ +http://ftp.litnet.lt/debian/ #LOC:LU ftp://debian.mirror.root.lu/debian/ +http://debian.mirror.root.lu/debian/ #LOC:LV -ftp://koyanet.lv/debian/ -ftp://ftp.koyanet.lv/debian/ ftp://debian.linux.edu.lv/debian/ +ftp://koyanet.lv/debian/ +http://debian.linux.edu.lv/debian/ +http://koyanet.lv/debian/ #LOC:MD ftp://debian.md/debian/ +http://debian.md/debian/ #LOC:MN ftp://mirror.debian.mn/debian/ +http://mirror.debian.mn/debian/ #LOC:MT http://debian.res.um.edu.mt/debian/ #LOC:MX ftp://ftp.mx.debian.org/debian/ -ftp://debian.unam.mx/debian/ -ftp://nisamox.fciencias.unam.mx/debian/ ftp://mmc.geofisica.unam.mx/debian/ -#LOC:MY +http://ftp.mx.debian.org/debian/ +http://mmc.geofisica.unam.mx/debian/ #LOC:NC ftp://ftp.nc.debian.org/debian/ -ftp://debian.nautile.nc/debian/ +http://ftp.nc.debian.org/debian/ #LOC:NI http://debian.uni.edu.ni/debian/ #LOC:NL +ftp://debian.mirror.cambrium.nl/debian/ +ftp://ftp.debian.nl/debian/ ftp://ftp.nl.debian.org/debian/ -ftp://ftp.snt.utwente.nl/debian/ ftp://ftp.nluug.nl/pub/os/Linux/distr/debian/ -ftp://mirrors.nl.kernel.org/debian/ ftp://ftp.surfnet.nl/pub/os/Linux/distr/debian/ -ftp://ftp.debian.nl/debian/ -ftp://download.xs4all.nl/debian/ ftp://ftp.tiscali.nl/pub/mirrors/debian/ -ftp://debian.mirror.cambrium.nl/debian/ +ftp://mirrors.nl.kernel.org/debian/ +http://debian.mirror.cambrium.nl/debian/ +http://ftp.debian.nl/debian/ +http://ftp.nl.debian.org/debian/ +http://ftp.nluug.nl/pub/os/Linux/distr/debian/ +http://ftp.surfnet.nl/os/Linux/distr/debian/ +http://ftp.tiscali.nl/debian/ +http://mirrors.nl.kernel.org/debian/ #LOC:NO ftp://ftp.no.debian.org/debian/ -ftp://ftp.uninett.no/debian/ -ftp://ftp.uio.no/debian/ +http://ftp.no.debian.org/debian/ #LOC:NZ ftp://ftp.nz.debian.org/debian/ -ftp://ftp.citylink.co.nz/debian/ +http://ftp.nz.debian.org/debian/ #LOC:PF ftp://repository.linux.pf/debian/ +http://repository.linux.pf/debian/ #LOC:PL -ftp://ftp.pl.debian.org/debian/ -ftp://ftp.task.gda.pl/debian/ ftp://ftp.icm.edu.pl/pub/Linux/debian/ -ftp://sunsite.icm.edu.pl/pub/Linux/debian/ +ftp://ftp.man.poznan.pl/pub/linux/debian/debian/ ftp://ftp.man.szczecin.pl/pub/Linux/debian/ -ftp://rubycon.man.szczecin.pl/pub/Linux/debian/ -ftp://ftp.vectranet.pl/debian/ +ftp://ftp.pl.debian.org/debian/ ftp://ftp.pwr.wroc.pl/debian/ -ftp://ftp.man.poznan.pl/pub/linux/debian/debian/ +ftp://ftp.vectranet.pl/debian/ ftp://piotrkosoft.net/pub/mirrors/debian/ -ftp://ftp.man.oswiecim.pl/pub/mirrors/debian/ +http://ftp.icm.edu.pl/pub/Linux/debian/ +http://ftp.man.poznan.pl/pub/linux/debian/debian/ +http://ftp.pl.debian.org/debian/ +http://ftp.pwr.wroc.pl/debian/ +http://ftp.vectranet.pl/debian/ +http://piotrkosoft.net/pub/mirrors/debian/ #LOC:PT -ftp://ftp.pt.debian.org/debian/ -ftp://ftp.uevora.pt/debian/ -ftp://ftp.eq.uc.pt/pub/software/Linux/debian/ -ftp://debian.ua.pt/debian/ -ftp://ftp.ua.pt/debian/ -ftp://mirrors.nfsi.pt/debian/ -ftp://mirrors.fe.up.pt/debian/ ftp://cesium.di.uminho.pt/pub/debian/ ftp://debian.netvisao.pt/debian/ -http://debian.dcc.fc.up.pt/debian/ +ftp://debian.ua.pt/debian/ +ftp://ftp.eq.uc.pt/pub/software/Linux/debian/ +ftp://ftp.pt.debian.org/debian/ ftp://mirror.sim.ul.pt/debian/ +ftp://mirrors.fe.up.pt/debian/ +ftp://mirrors.nfsi.pt/debian/ +http://cesium.di.uminho.pt/pub/debian/ +http://debian.dcc.fc.up.pt/debian/ +http://debian.netvisao.pt/ +http://debian.ua.pt/debian/ +http://ftp.eq.uc.pt/software/Linux/debian/ +http://ftp.pt.debian.org/debian/ +http://mirror.sim.ul.pt/debian/ +http://mirrors.fe.up.pt/debian/ +http://mirrors.nfsi.pt/debian/ #LOC:RO -ftp://ftp.ro.debian.org/debian/ -ftp://ftp.iasi.roedu.net/debian/ ftp://ftp.lug.ro/debian/ +ftp://ftp.ro.debian.org/debian/ +http://ftp.lug.ro/debian/ +http://ftp.ro.debian.org/debian/ #LOC:RU -ftp://ftp.ru.debian.org/debian/ -ftp://ftp.chg.ru/debian/ ftp://debian.nsu.ru/debian/ -ftp://ftp.psn.ru/debian/ -ftp://server.psn.ru/debian/ ftp://ftp.corbina.net/debian/ -ftp://mirror.yandex.ru/debian/ -ftp://ftp.yandex.ru/debian/ ftp://ftp.debian.chuvsu.ru/debian/ -ftp://debian.chuvsu.ru/debian/ +ftp://ftp.psn.ru/debian/ +ftp://ftp.ru.debian.org/debian/ ftp://mirror.svk.su/debian/ +ftp://mirror.yandex.ru/debian/ ftp://mirror2.corbina.ru/debian/ +http://debian.nsu.ru/debian/ +http://ftp.debian.chuvsu.ru/debian/ +http://ftp.psn.ru/debian/ +http://ftp.ru.debian.org/debian/ +http://mirror.svk.su/debian/ +http://mirror.yandex.ru/debian/ +http://mirror2.corbina.ru/debian/ #LOC:SE -ftp://ftp.se.debian.org/debian/ -ftp://ftp.acc.umu.se/debian/ -ftp://ftp.sunet.se/pub/Linux/distributions/debian/ -ftp://mirrors.se.kernel.org/debian/ -ftp://ftp.port80.se/debian/ -ftp://ftp.ds.karen.hj.se/debian/ -ftp://ftp.ds.hj.se/debian/ ftp://debian.bsnet.se/debian/ -ftp://gelehallon.bsnet.se/debian/ ftp://debian.lth.se/debian/ -ftp://ftp.ddg.lth.se/debian/ ftp://ftp.df.lth.se/debian/ +ftp://ftp.ds.karen.hj.se/debian/ +ftp://ftp.port80.se/debian/ +ftp://ftp.se.debian.org/debian/ +ftp://ftp.sunet.se/pub/Linux/distributions/debian/ +ftp://mirrors.se.kernel.org/debian/ +http://debian.bsnet.se/debian/ +http://debian.lth.se/debian/ +http://ftp.df.lth.se/debian/ +http://ftp.ds.karen.hj.se/debian/ +http://ftp.port80.se/debian/ +http://ftp.se.debian.org/debian/ +http://ftp.sunet.se/pub/Linux/distributions/debian/ +http://mirrors.se.kernel.org/debian/ #LOC:SG ftp://mirror.nus.edu.sg/pub/Debian/ -ftp://mirror.comp.nus.edu.sg/pub/Debian/ +http://mirror.nus.edu.sg/Debian/ #LOC:SI -ftp://ftp.si.debian.org/debian/ -ftp://debian.prunk.si/debian/ -ftp://ftp.arnes.si/packages/debian/ ftp://debian.camtp.uni-mb.si/debian/ +ftp://ftp.arnes.si/packages/debian/ +ftp://ftp.si.debian.org/debian/ +http://debian.camtp.uni-mb.si/debian/ +http://ftp.arnes.si/pub/packages/debian/ +http://ftp.si.debian.org/debian/ #LOC:SK -ftp://ftp.sk.debian.org/debian/ -ftp://ftp.debian.sk/debian/ -ftp://debian.sk/debian/ -ftp://mirrors.nextra.sk/debian/ ftp://debian.ynet.sk/debian/ -ftp://mirror.ynet.sk/debian/ ftp://ftp.antik.sk/debian/ -ftp://debian.antik.sk/debian/ -ftp://ubuntu.antik.sk/debian/ +ftp://ftp.sk.debian.org/debian/ +http://debian.ynet.sk/debian/ +http://ftp.antik.sk/debian/ +http://ftp.sk.debian.org/debian/ #LOC:SV http://debian.ues.edu.sv/debian/ -http://linux.ues.edu.sv/debian/ #LOC:TH +ftp://ftp.debianclub.org/debian/ ftp://ftp.th.debian.org/debian/ -ftp://ftp.coe.psu.ac.th/debian/ -ftp://debian.coe.psu.ac.th/debian/ ftp://ftp.v6.coe.psu.ac.th/debian/ -ftp://debian.coe.psu.ac.th/debian/ http://debian.thaios.net/debian/ -ftp://ftp.debianclub.org/debian/ +http://ftp.debianclub.org/debian/ +http://ftp.th.debian.org/debian/ +http://ftp.v6.coe.psu.ac.th/debian/ #LOC:TR -ftp://ftp.tr.debian.org/debian/ -ftp://debian.ankara.edu.tr/debian/ -ftp://ftp.ankara.edu.tr/debian/ +ftp://debian.comu.edu.tr/debian/ ftp://ftp.linux.org.tr/debian/ +ftp://ftp.metu.edu.tr/debian/ +ftp://ftp.tr.debian.org/debian/ ftp://godel.cs.bilgi.edu.tr/debian/ +http://debian.comu.edu.tr/debian/ http://debian.eso-es.net/debian/ -ftp://debian.comu.edu.tr/debian/ -ftp://ftp.metu.edu.tr/debian/ +http://ftp.linux.org.tr/debian/ +http://ftp.metu.edu.tr/debian/ +http://ftp.tr.debian.org/debian/ +http://godel.cs.bilgi.edu.tr/debian/ #LOC:TW -ftp://ftp.tw.debian.org/debian/ -ftp://debian.linux.org.tw/debian/ +ftp://debian.csie.nctu.edu.tw/debian/ ftp://debian.csie.ntu.edu.tw/pub/debian/ -ftp://ftp.twaren.net/debian/ -ftp://linux.cdpa.nsysu.edu.tw/debian/ -ftp://opensource.nchc.org.tw/debian/ -ftp://os.nchc.org.tw/debian/ -ftp://ftp.isu.edu.tw/debian/ ftp://debian.nctu.edu.tw/debian/ -ftp://mirror.nttu.edu.tw/debian/ -ftp://debian.csie.nctu.edu.tw/debian/ -ftp://ftp.ncnu.edu.tw/debian/ -ftp://ftp4.ncnu.edu.tw/debian/ ftp://ftp.cse.yzu.edu.tw/pub/Linux/debian/debian/ -ftp://ftp.oss.tw/pub/Linux/debian/debian/ +ftp://ftp.isu.edu.tw/debian/ +ftp://ftp.ncnu.edu.tw/debian/ ftp://ftp.tcc.edu.tw/debian/ ftp://ftp.tku.edu.tw/debian/ +ftp://ftp.tw.debian.org/debian/ +ftp://ftp.twaren.net/debian/ +ftp://mirror.nttu.edu.tw/debian/ +ftp://opensource.nchc.org.tw/debian/ +http://debian.csie.nctu.edu.tw/debian/ +http://debian.csie.ntu.edu.tw/debian/ +http://debian.nctu.edu.tw/debian/ +http://ftp.cse.yzu.edu.tw/pub/Linux/debian/debian/ +http://ftp.isu.edu.tw/debian/ +http://ftp.ncnu.edu.tw/debian/ +http://ftp.tcc.edu.tw/debian/ +http://ftp.tku.edu.tw/debian/ +http://ftp.tw.debian.org/debian/ +http://ftp.twaren.net/debian/ +http://mirror.nttu.edu.tw/debian/ +http://opensource.nchc.org.tw/debian/ #LOC:UA -ftp://ftp.ua.debian.org/debian/ -ftp://debian.org.ua/debian/ -ftp://lumpy.3logic.net/debian/ ftp://debian.osdn.org.ua/pub/Debian/debian/ ftp://ftp.3logic.net/debian/ -ftp://borg.3logic.net/debian/ -ftp://mirror.mirohost.net/debian/ -ftp://deb.mirohost.net/debian/ +ftp://ftp.ua.debian.org/debian/ ftp://ftp2.debian.org.ua/debian/ -ftp://mirror.3logic.net/debian/ +ftp://mirror.mirohost.net/debian/ +http://debian.osdn.org.ua/debian/ +http://ftp.ua.debian.org/debian/ +http://ftp2.debian.org.ua/debian/ +http://mirror.mirohost.net/debian/ #LOC:US -ftp://ftp.us.debian.org/debian/ -ftp://http.us.debian.org/debian/ -ftp://ftp.gtlib.gatech.edu/pub/debian/ -ftp://zaphod.gtlib.gatech.edu/pub/debian/ -ftp://ftp.egr.msu.edu/debian/ -ftp://ike.egr.msu.edu/debian/ +ftp://carroll.aset.psu.edu/pub/linux/distributions/debian/ +ftp://debian.cites.uiuc.edu/pub/debian/ +ftp://debian.cs.binghamton.edu/debian/ +ftp://debian.lcs.mit.edu/debian/ +ftp://debian.mirror.frontiernet.net/debian/ +ftp://debian.mirrors.tds.net/debian/ +ftp://debian.osuosl.org/debian/ +ftp://debian.secsup.org/pub/linux/debian/ +ftp://debian.uchicago.edu/debian/ ftp://distro.ibiblio.org/debian/ ftp://ftp-mirror.internap.com/pub/debian/ -ftp://mirror.cs.wisc.edu/debian/ -ftp://ftp.uwsg.indiana.edu/linux/debian/ -ftp://uwsg.iu.edu/linux/debian/ -ftp://ftp.ndlug.nd.edu/debian/ -ftp://debian.uchicago.edu/debian/ -ftp://linux.uchicago.edu/debian/ -ftp://carroll.aset.psu.edu/pub/linux/distributions/debian/ -ftp://carroll.cac.psu.edu/pub/linux/distributions/debian/ -ftp://gladiator.real-time.com/linux/debian/ -ftp://mirrors.kernel.org/debian/ -ftp://mirrors.xmission.com/debian/ -ftp://mirror.xmission.com/debian/ +ftp://ftp.egr.msu.edu/debian/ +ftp://ftp.grokthis.net/debian/ +ftp://ftp.gtlib.gatech.edu/pub/debian/ ftp://ftp.keystealth.org/debian/ ftp://ftp.lug.udel.edu/pub/debian/ -ftp://debian.lcs.mit.edu/debian/ -ftp://debian.csail.mit.edu/debian/ -http://linux.csua.berkeley.edu/debian/ -http://screwdriver.csua.berkeley.edu/debian/ +ftp://ftp.ndlug.nd.edu/debian/ ftp://ftp.silug.org/pub/debian/ -ftp://ftp.luci.org/pub/debian/ -ftp://ftp.kspei.com/pub/debian/ -ftp://debian.secsup.org/pub/linux/debian/ -ftp://debian.osuosl.org/debian/ -ftp://debian.oregonstate.edu/debian/ -ftp://ftp.oregonstate.edu/debian/ -ftp://ftp.osuosl.org/debian/ -ftp://mirror.anl.gov/pub/debian/ -http://sluglug.ucsc.edu/debian/ -ftp://mirrors.geeks.org/debian/ -ftp://mirrors.usc.edu/pub/linux/distributions/debian/ +ftp://ftp.uga.edu/debian/ +ftp://ftp.us.debian.org/debian/ +ftp://ftp.uwsg.indiana.edu/linux/debian/ +ftp://gladiator.real-time.com/linux/debian/ ftp://lug.mtu.edu/debian/ -ftp://debian.mirrors.tds.net/debian/ -ftp://debian.cites.uiuc.edu/pub/debian/ -ftp://bazaar.cites.uiuc.edu/pub/debian/ -ftp://cosmos.cites.uiuc.edu/pub/debian/ -ftp://mirrors.tummy.com/debian/ -ftp://debian.mirror.frontiernet.net/debian/ +ftp://mirror.anl.gov/pub/debian/ ftp://mirror.cc.columbia.edu/pub/linux/debian/debian/ -ftp://ftp.grokthis.net/debian/ -http://mirrors.xenir.com/debian/ -http://debian.mirrors.easynews.com/linux/debian/ -http://mirrors.easynews.com/linux/debian/ -ftp://ftp.uga.edu/debian/ -ftp://linuxserv.uga.edu/debian/ -http://mirror.steadfast.net/debian/ -http://ftp.utexas.edu/debian/ -http://ftp.the.net/debian/ +ftp://mirror.cs.wisc.edu/debian/ ftp://mirror.fdcservers.net/debian/ +ftp://mirror.its.uidaho.edu/debian/ ftp://mirror.rit.edu/debian/ +ftp://mirrors.bloomu.edu/debian/ +ftp://mirrors.geeks.org/debian/ +ftp://mirrors.hosef.org/debian/ +ftp://mirrors.kernel.org/debian/ +ftp://mirrors.tummy.com/debian/ +ftp://mirrors.usc.edu/pub/linux/distributions/debian/ +ftp://mirrors.xmission.com/debian/ +http://carroll.aset.psu.edu/pub/linux/distributions/debian/ +http://debian.cites.uiuc.edu/pub/debian/ http://debian.corenetworks.net/debian/ -ftp://mirror.its.uidaho.edu/debian/ -ftp://debian.cs.binghamton.edu/debian/ +http://debian.cs.binghamton.edu/debian/ +http://debian.lcs.mit.edu/debian/ +http://debian.mirror.frontiernet.net/debian/ +http://debian.mirrors.easynews.com/linux/debian/ +http://debian.mirrors.tds.net/debian/ +http://debian.osuosl.org/debian/ +http://debian.secsup.org/ +http://debian.uchicago.edu/debian/ +http://debian.usu.edu/debian/ +http://distro.ibiblio.org/debian/ +http://ftp-mirror.internap.com/pub/debian/ +http://ftp.egr.msu.edu/debian/ +http://ftp.grokthis.net/debian/ +http://ftp.gtlib.gatech.edu/debian/ +http://ftp.keystealth.orgdebian/ +http://ftp.lug.udel.edu/pub/debian/ +http://ftp.ndlug.nd.edu/mirrors/debian/ +http://ftp.silug.org/pub/debian/ +http://ftp.uga.edu/debian/ +http://ftp.us.debian.org/debian/ +http://ftp.utexas.edu/debian/ +http://ftp.uwsg.indiana.edu/linux/debian/ +http://linux.csua.berkeley.edu/debian/ +http://lug.mtu.edu/debian/ +http://mirror.anl.gov/debian/ +http://mirror.cc.columbia.edu/pub/linux/debian/debian/ +http://mirror.cs.wisc.edu/debian/ +http://mirror.fdcservers.net/debian/ http://mirror.hmc.edu/debian/ -http://worblehat.math.hmc.edu/debian/ -ftp://mirrors.hosef.org/debian/ +http://mirror.its.uidaho.edu/pub/debian/ +http://mirror.rit.edu/debian/ +http://mirror.steadfast.net/debian/ +http://mirrors.bloomu.edu/debian/ +http://mirrors.geeks.org/debian/ +http://mirrors.hosef.org/debian/ +http://mirrors.kernel.org/debian/ http://mirrors.modwest.com/debian/ -ftp://mirrors.bloomu.edu/debian/ -http://debian.usu.edu/debian/ -http://mirror.usu.edu/debian/ -http://mirrors.usu.edu/debian/ +http://mirrors.tummy.com/debian/ +http://mirrors.usc.edu/pub/linux/distributions/debian/ +http://mirrors.xenir.com/debian/ +http://mirrors.xmission.com/debian/ +http://sluglug.ucsc.edu/debian/ #LOC:UZ ftp://debian.stream.uz/debian/ -ftp://debian.uz/debian/ +http://debian.stream.uz/debian/ #LOC:VE http://debian.unesr.edu.ve/debian/ #LOC:ZA -ftp://ftp.sun.ac.za/debian/ ftp://debian.mirror.ac.za/debian/ ftp://ftp.is.co.za/debian/ +ftp://ftp.sun.ac.za/debian/ +http://debian.mirror.ac.za/debian/ +http://ftp.sun.ac.za/ftp/debian/ diff --git a/data/templates/Ubuntu.mirrors b/data/templates/Ubuntu.mirrors index 0bf0206b..ee88b772 100644 --- a/data/templates/Ubuntu.mirrors +++ b/data/templates/Ubuntu.mirrors @@ -3,67 +3,70 @@ http://ftp.ccc.uba.ar/pub/linux/ubuntu/ http://ubuntu.innova-red.net/ubuntu/ http://ubuntu.patan.com.ar/ubuntu/ #LOC:AT -http://ubuntu.uni-klu.ac.at/ubuntu/ -http://ubuntu.lagis.at/ubuntu/ -http://ubuntu.inode.at/ubuntu/ http://gd.tuwien.ac.at/opsys/linux/ubuntu/archive/ +http://ubuntu.inode.at/ubuntu/ +http://ubuntu.lagis.at/ubuntu/ +http://ubuntu.uni-klu.ac.at/ubuntu/ #LOC:AU http://ftp.iinet.net.au/pub/ubuntu/ -http://mirror.optus.net/ubuntu/ +http://ftp.netspace.net.au/pub/ubuntu/ http://mirror.aarnet.edu.au/pub/ubuntu/archive/ http://mirror.files.bigpond.com/ubuntu/ -http://mirror.pacific.net.au/linux/ubuntu/ -http://ftp.netspace.net.au/pub/ubuntu/ http://mirror.internode.on.net/pub/ubuntu/ubuntu/ -http://mirror.waia.asn.au/ubuntu/ http://mirror.netspace.net.au/pub/ubuntu/ +http://mirror.optus.net/ubuntu/ +http://mirror.pacific.net.au/linux/ubuntu/ +http://mirror.waia.asn.au/ubuntu/ #LOC:BA http://archive.ubuntu.com.ba/ubuntu/ #LOC:BE -http://ubuntu.mirrors.skynet.be/pub/ubuntu.com/ubuntu/ http://ftp.belnet.be/mirror/ubuntu.com/ubuntu/ http://gaosu.rave.org/ubuntu/ +http://ubuntu.mirrors.skynet.be/pub/ubuntu.com/ubuntu/ #LOC:BG http://ubuntu.hitsol.net/ubuntu/ -http://ubuntu.nano-box.net/ubuntu/ -http://ubuntu.linux-bg.org/ubuntu/ http://ubuntu.ipacct.com/ubuntu/ +http://ubuntu.linux-bg.org/ubuntu/ +http://ubuntu.nano-box.net/ubuntu/ #LOC:BO http://espejo.softwarelibre.gob.bo/archive.ubuntu.com/ubuntu/ #LOC:BR -http://mirror.globo.com/ubuntu/archive/ -http://ubuntu.interlegis.gov.br/ubuntu/ http://br.archive.ubuntu.com/ubuntu/ http://espelhos.edugraf.ufsc.br/ubuntu/ +http://mirror.globo.com/ubuntu/archive/ +http://sft.if.usp.br/ubuntu/ +http://ubuntu.interlegis.gov.br/ubuntu/ http://ubuntu.mirror.pop-sc.rnp.br/ubuntu/ +http://ubuntu.ufba.br/ubuntu/ http://www.las.ic.unicamp.br/pub/ubuntu/ -http://sft.if.usp.br/ubuntu/ #LOC:BY +http://ftp.byfly.by/ubuntu/ http://linux.org.by/ubuntu/ http://mirror.datacenter.by/ubuntu/ -http://ftp.byfly.by/ubuntu/ #LOC:CA -http://gpl.savoirfairelinux.net/pub/mirrors/ubuntu/ -http://ubuntu.mirror.iweb.ca/ ftp://ftp.cs.mun.ca/pub/mirror/ubuntu/ -http://mirror.its.dal.ca/ubuntu/ +http://gpl.savoirfairelinux.net/pub/mirrors/ubuntu/ +http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ http://mirror.csclub.uwaterloo.ca/ubuntu/ +http://mirror.its.dal.ca/ubuntu/ http://ubuntu.arcticnetwork.ca/ +http://ubuntu.mirror.iweb.ca/ http://ubuntu.mirror.rafal.ca/ubuntu/ -http://mirror.cpsc.ucalgary.ca/mirror/ubuntu.com/packages/ #LOC:CH http://mirror.switch.ch/ftp/mirror/ubuntu/ #LOC:CL http://ftp.tecnoera.com/ubuntu/ +http://mirror.gnucv.cl/ubuntu/ #LOC:CN -http://mirrors.sohu.com/ubuntu/ -http://mirrors.shlug.org/ubuntu/ +http://mirror.bjtu.edu.cn/ubuntu/ +http://mirror.lupaworld.com/ubuntu/ http://mirror.rootguide.org/ubuntu/ http://mirrors.163.com/ubuntu/ -http://ubuntu.srt.cn/ubuntu/ +http://mirrors.shlug.org/ubuntu/ +http://mirrors.sohu.com/ubuntu/ http://ubuntu.cn99.com/ubuntu/ http://ubuntu.dormforce.net/ubuntu/ -http://mirror.lupaworld.com/ubuntu/ +http://ubuntu.srt.cn/ubuntu/ #LOC:CO http://matematicas.unal.edu.co/ubuntu/ #LOC:CR @@ -71,86 +74,85 @@ http://mirrors.ucr.ac.cr/ubuntu/ #LOC:CY http://mirrors.cytanet.com.cy/linux/ubuntu/archive/ #LOC:CZ -http://ftp.sh.cvut.cz/MIRRORS/ubuntu/ http://archive.ubuntu.mirror.dkm.cz/ http://cz.archive.ubuntu.com/ubuntu/ -http://ucho.ignum.cz/ubuntu/ http://ftp.cvut.cz/ubuntu/ +http://ftp.sh.cvut.cz/MIRRORS/ubuntu/ http://ubuntu.sh.cvut.cz/ +http://ucho.ignum.cz/ubuntu/ #LOC:DE -ftp://ftp.rrzn.uni-hannover.de/pub/mirror/linux/ubuntu ftp://ftp.fu-berlin.de/linux/ubuntu/ -http://suse.uni-leipzig.de/pub/releases.ubuntu.com/ubuntu/ -http://ubuntu.mirror.tudos.de/ubuntu/ -http://mirror.netcologne.de/ubuntu/ -http://ftp5.gwdg.de/pub/linux/debian/ubuntu/ -http://ftp.uni-kl.de/pub/linux/ubuntu/ -http://debian.charite.de/ubuntu/ -http://ftp.tu-ilmenau.de/mirror/ubuntu/ -http://ubuntu.intergenia.de/ubuntu/ +ftp://ftp.rrzn.uni-hannover.de/pub/mirror/linux/ubuntu http://archive.ubuntu.uasw.edu/ -http://www.osnt.org/ubuntu/ -http://ftp.tu-chemnitz.de/pub/linux/ubuntu/ -http://mirror.bauhuette.fh-aachen.de/ubuntu/ -http://ftp.stw-bonn.de/ubuntu/ -http://ftp.uni-erlangen.de/mirrors/ubuntu/ -http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ -http://sunsite.informatik.rwth-aachen.de/ftp/pub/Linux/ubuntu/ubuntu/ +http://debian.charite.de/ubuntu/ http://ftp-stud.fht-esslingen.de/Mirrors/ubuntu/ +http://ftp-stud.hs-esslingen.de/ubuntu/ +http://ftp.hosteurope.de/mirror/archive.ubuntu.com/ +http://ftp.stw-bonn.de/ubuntu/ +http://ftp.tu-chemnitz.de/pub/linux/ubuntu/ +http://ftp.tu-ilmenau.de/mirror/ubuntu/ http://ftp.uni-bayreuth.de/linux/ubuntu/ubuntu/ +http://ftp.uni-erlangen.de/mirrors/ubuntu/ +http://ftp.uni-kl.de/pub/linux/ubuntu/ http://ftp.uni-muenster.de/pub/mirrors/ftp.ubuntu.com/ubuntu/ +http://ftp5.gwdg.de/pub/linux/debian/ubuntu/ +http://mirror.bauhuette.fh-aachen.de/ubuntu/ +http://mirror.netcologne.de/ubuntu/ +http://sunsite.informatik.rwth-aachen.de/ftp/pub/Linux/ubuntu/ubuntu/ +http://suse.uni-leipzig.de/pub/releases.ubuntu.com/ubuntu/ http://swtsrv.informatik.uni-mannheim.de/pub/linux/distributions/ubuntu/ +http://ubuntu.intergenia.de/ubuntu/ +http://ubuntu.mirror.tudos.de/ubuntu/ http://ubuntu.unitedcolo.de/ubuntu/ -http://ftp-stud.hs-esslingen.de/ubuntu/ +http://www.osnt.org/ubuntu/ #LOC:DK http://mirrors.dotsrc.org/ubuntu/ http://mirrors.telianet.dk/ubuntu/ -http://ftp.klid.dk/ftp/ubuntu/ #LOC:EE http://ftp.estpak.ee/ubuntu/ #LOC:ES +http://dafi.inf.um.es/ubuntu/ +http://ftp.caliu.cat/pub/distribucions/ubuntu/archive/ +http://ftp.dat.etsit.upm.es/ubuntu/ http://ftp.gui.uva.es/sites/ubuntu.com/ubuntu/ -http://sunsite.rediris.es/mirror/ubuntu-archive/ +http://ftp.udc.es/ubuntu/ +http://mirror.ousli.org/ubuntu/ http://peloto.pantuflo.es/ubuntu/ -http://ubuntu.cica.es/ubuntu/ http://softlibre.unizar.es/ubuntu/archive/ -http://mirror.ousli.org/ubuntu/ -http://ubuntu.uc3m.es/ubuntu/ +http://sunsite.rediris.es/mirror/ubuntu-archive/ +http://ubuntu.cica.es/ubuntu/ http://ubuntu.grn.cat/ubuntu/ -http://ftp.caliu.cat/pub/distribucions/ubuntu/archive/ -http://dafi.inf.um.es/ubuntu/ -http://ftp.udc.es/ubuntu/ -http://ftp.dat.etsit.upm.es/ubuntu/ +http://ubuntu.uc3m.es/ubuntu/ #LOC:FI -http://www.nic.funet.fi/pub/mirrors/archive.ubuntu.com/ http://mirrors.nic.funet.fi/ubuntu/ +http://www.nic.funet.fi/pub/mirrors/archive.ubuntu.com/ #LOC:FR -http://mirror.ovh.net/ubuntu/ -http://wwwftp.ciril.fr/pub/linux/ubuntu/archives/ -http://ubuntu.univ-nantes.fr/ubuntu/ +http://archive.monubuntu.fr/ http://distrib-coffee.ipsl.jussieu.fr/ubuntu/ +http://ftp.crihan.fr/ubuntu/ http://ftp.free.org/mirrors/archive.ubuntu.com/ubuntu/ -http://archive.monubuntu.fr/ -http://www-ftp.lip6.fr/pub/linux/distributions/Ubuntu/archive/ -http://ubuntu.univ-reims.fr/ubuntu/ http://ftp.oleane.net/ubuntu/ http://ftp.u-picardie.fr/mirror/ubuntu/ubuntu/ -http://ubuntu-archive.mirrors.proxad.net/ubuntu/ +http://mirror.ovh.net/ubuntu/ http://mirrors.ircam.fr/pub/ubuntu/archive/ -http://ftp.crihan.fr/ubuntu/ +http://ubuntu-archive.mirrors.proxad.net/ubuntu/ +http://ubuntu.univ-nantes.fr/ubuntu/ +http://ubuntu.univ-reims.fr/ubuntu/ +http://www-ftp.lip6.fr/pub/linux/distributions/Ubuntu/archive/ +http://wwwftp.ciril.fr/pub/linux/ubuntu/archives/ #LOC:GB -http://ubuntu.datahop.net/ubuntu/ +http://archive.ubuntu.com/ubuntu/ +http://ftp.ticklers.org/archive.ubuntu.org/ubuntu/ http://mirror.as29550.net/archive.ubuntu.com/ http://mirror.bytemark.co.uk/ubuntu/ -http://ftp.ticklers.org/archive.ubuntu.org/ubuntu/ -http://ubuntu.virginmedia.com/archive/ -http://www.mirrorservice.org/sites/archive.ubuntu.com/ubuntu/ +http://mirror.ox.ac.uk/sites/archive.ubuntu.com/ubuntu/ +http://mirror.sov.uk.goscomb.net/ubuntu/ http://mirrors.melbourne.co.uk/sites/archive.ubuntu.com/ubuntu/ +http://ubuntu.datahop.net/ubuntu/ http://ubuntu.positive-internet.com/ubuntu/ http://ubuntu.retrosnub.co.uk/ubuntu/ -http://mirror.sov.uk.goscomb.net/ubuntu/ -http://archive.ubuntu.com/ubuntu/ -http://mirror.ox.ac.uk/sites/archive.ubuntu.com/ubuntu/ +http://ubuntu.virginmedia.com/archive/ +http://www.mirrorservice.org/sites/archive.ubuntu.com/ubuntu/ #LOC:GE http://ubuntu.eriders.ge/ubuntu/ #LOC:GL @@ -164,62 +166,61 @@ http://ftp.hostrino.com/pub/ubuntu/archive/ #LOC:HR http://hr.archive.ubuntu.com/ubuntu/ #LOC:HU -http://ubuntu.sth.sze.hu/ubuntu/ http://ftp.freepark.org/ubuntu/ -http://ubuntu.mirrors.crysys.hu/ http://ftp.kfki.hu/linux/ubuntu/ +http://ubuntu.mirrors.crysys.hu/ +http://ubuntu.sth.sze.hu/ubuntu/ #LOC:ID -http://mirror.unej.ac.id/ubuntu/ +http://dl2.foss-id.web.id/ubuntu/ http://kambing.ui.ac.id/ubuntu/ http://kebo.vlsm.org/ubuntu/ -http://dl2.foss-id.web.id/ubuntu/ -http://ubuntu.indika.net.id/ubuntu/ +http://mirror.unej.ac.id/ubuntu/ http://repo.undip.ac.id/ubuntu/ +http://ubuntu.indika.net.id/ubuntu/ http://ubuntu.pesat.net.id/archive/ #LOC:IE -http://ftp.heanet.ie/pub/ubuntu/ http://ftp.esat.net/mirrors/archive.ubuntu.com/ +http://ftp.heanet.ie/pub/ubuntu/ #LOC:IL http://mirror.isoc.org.il/pub/ubuntu/ #LOC:IN ftp://ftp.iitb.ac.in/distributions/ubuntu/archives/ http://ftp.iitm.ac.in/ubuntu/ -http://ubuntuarchive.hnsdc.com/ http://mirror.cse.iitk.ac.in/ubuntu/ +http://ubuntuarchive.hnsdc.com/ #LOC:IS http://ubuntu.lhi.is/ubuntu/ #LOC:IT -http://giano.com.dist.unige.it/ubuntu/ -http://ubuntu.mirror.garr.it/mirrors/ubuntu-archive/ -http://ubuntu.ictvalleumbra.it/ubuntu/ http://ubuntu.fastbull.org/ubuntu/ +http://ubuntu.ictvalleumbra.it/ubuntu/ +http://ubuntu.mirror.garr.it/mirrors/ubuntu-archive/ #LOC:JP http://ftp.riken.jp/Linux/ubuntu/ -http://www.ftp.ne.jp/Linux/packages/ubuntu/archive/ -http://ubuntutym.u-toyama.ac.jp/ubuntu/ -http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ http://ftp.yz.yamagata-u.ac.jp/pub/linux/ubuntu/archives/ -http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ +http://ubuntu-ashisuto.ubuntulinux.jp/ubuntu/ http://ubuntu.mithril-linux.org/archives/ +http://ubuntutym.u-toyama.ac.jp/ubuntu/ +http://www.ftp.ne.jp/Linux/packages/ubuntu/archive/ #LOC:KG http://ubuntu.mega.kg/ubuntu/ #LOC:KR http://ftp.daum.net/ubuntu/ -http://mirror.khlug.org/ubuntu/ http://kr.archive.ubuntu.com/ubuntu/ +http://mirror.khlug.org/ubuntu/ http://mirror.korea.ac.kr/ubuntu/ #LOC:KW http://ubuntu.qualitynet.net/ubuntu/ #LOC:KZ -http://mirror.space.kz/ubuntu/ http://mirror.neolabs.kz/ubuntu/ +http://mirror.space.kz/ubuntu/ #LOC:LK http://archive.ubuntu.schoolnet.lk/ubuntu/ #LOC:LT -http://mirror.soften.ktu.lt/ubuntu/ http://ftp.litnet.lt/ubuntu/ +http://mirror.soften.ktu.lt/ubuntu/ #LOC:LV http://ubuntu-arch.linux.edu.lv/ubuntu/ +http://ubuntu.load.lv/ubuntu/ #LOC:MD http://mirrors.bsd.md/ubuntu/ #LOC:MN @@ -227,190 +228,189 @@ http://archive.ubuntu.mnosi.org/ubuntu/ #LOC:MT http://mirror.linux.org.mt/ubuntu/ #LOC:MX -http://ubuntu.ujed.mx/ubuntu/ http://tezcatl.fciencias.unam.mx/ubuntu/ #LOC:MY -http://ubuntu.bytecraft.com.my/ubuntu/ -http://mirror.upm.edu.my/ubuntu/ -http://www.mirror.upm.edu.my/ubuntu/ -http://mirror.oscc.org.my/ubuntu/ http://archive.mmu.edu.my/ubuntu/ +http://mirror.oscc.org.my/ubuntu/ +http://ubuntu.bytecraft.com.my/ubuntu/ http://ubuntu.mmu.edu.my/ubuntu/ #LOC:NA http://ubuntu-archive.polytechnic.edu.na/ubuntu/ +#LOC:NC +http://archive.ubuntu.nautile.nc/ubuntu/ #LOC:NL -http://ubuntu.tiscali.nl/ -http://ubuntu.mirror.cambrium.nl/ubuntu/ -http://mirrors.nl.eu.kernel.org/ubuntu/ -http://mirror.leaseweb.com/ubuntu/ -http://nl3.archive.ubuntu.com/ubuntu/ +ftp://ftpserv.tudelft.nl/pub/Linux/archive.ubuntu.com/ +http://ftp.snt.utwente.nl/pub/os/linux/ubuntu-archive/ http://ftp.telfort.nl/ubuntu/ http://ftp.tudelft.nl/archive.ubuntu.com/ +http://mirror.leaseweb.com/ubuntu/ http://mirror.liteserver.nl/pub/ubuntu/ -http://ftp.snt.utwente.nl/pub/os/linux/ubuntu-archive/ -ftp://ftpserv.tudelft.nl/pub/Linux/archive.ubuntu.com/ -http://ubuntuarchive.eweka.nl/ubuntu/ +http://mirrors.nl.eu.kernel.org/ubuntu/ http://nl.archive.ubuntu.com/ubuntu/ +http://nl3.archive.ubuntu.com/ubuntu/ http://osmirror.rug.nl/ubuntu/ +http://ubuntu.mirror.cambrium.nl/ubuntu/ +http://ubuntu.tiscali.nl/ +http://ubuntuarchive.eweka.nl/ubuntu/ #LOC:NO -http://no.archive.ubuntu.com/ubuntu/ http://ftp.uninett.no/ubuntu/ +http://no.archive.ubuntu.com/ubuntu/ http://ubuntu.uib.no/archive/ #LOC:NP http://archive.mitra.net.np/ubuntu/ #LOC:NZ -http://nz2.archive.ubuntu.com/ubuntu/ -http://mirror.ihug.co.nz/ubuntu/ http://ftp.citylink.co.nz/ubuntu/ +http://mirror.ihug.co.nz/ubuntu/ +http://nz2.archive.ubuntu.com/ubuntu/ #LOC:PF http://pf.archive.ubuntu.com/ubuntu/ +#LOC:PH +http://mirror.web.com.ph/ubuntu/ #LOC:PL ftp://ftp.man.szczecin.pl/pub/Linux/ubuntu/ -http://ftp.wcss.pl/ubuntu/ http://ftp.vectranet.pl/ubuntu/ -http://ubuntu.task.gda.pl/ubuntu/ +http://ftp.wcss.pl/ubuntu/ http://piotrkosoft.net/pub/mirrors/ubuntu/ +http://ubuntu.task.gda.pl/ubuntu/ #LOC:PT -http://mosel.estg.ipleiria.pt/mirror/distros/ubuntu/archive/ ftp://ftp.ua.pt/pub/ubuntu/ +http://archive.ubuntumirror.dei.uc.pt/ubuntu/ http://darkstar.ist.utl.pt/ubuntu/archive/ +http://deis-mirrors.isec.pt/ubuntu/ http://ftp.rnl.ist.utl.pt/pub/ubuntu/archive/ -http://archive.ubuntumirror.dei.uc.pt/ubuntu/ -http://pathfinder.ipcb.pt/ubuntu/ http://mirrors.fe.up.pt/ubuntu/ http://mirrors.nfsi.pt/ubuntu/ +http://mosel.estg.ipleiria.pt/mirror/distros/ubuntu/archive/ +http://pathfinder.ipcb.pt/ubuntu/ http://ubuntu.dcc.fc.up.pt/ -http://deis-mirrors.isec.pt/ubuntu/ #LOC:QA http://ubuntu.qatar.cmu.edu/ubuntu/ #LOC:RO -http://mirror.pub.ro/ubuntu/ -http://ftp.gts.lug.ro/ubuntu/ -http://mirror.arlug.ro/pub/ubuntu/ubuntu/ -http://ftp.roedu.net/mirrors/ubuntulinux.org/ubuntu/ http://ftp.astral.ro/mirrors/ubuntu.com/ubuntu/ +http://ftp.gts.lug.ro/ubuntu/ http://ftp.info.uvt.ro/ubuntu/ +http://ftp.roedu.net/mirrors/ubuntulinux.org/ubuntu/ +http://mirror.arlug.ro/pub/ubuntu/ubuntu/ +http://mirror.pub.ro/ubuntu/ #LOC:RS -http://ubuntu.etf.bg.ac.rs/ubuntu/ http://rpm.scl.rs/linux/ubuntu/archive/ +http://ubuntu.etf.bg.ac.rs/ubuntu/ #LOC:RU -ftp://ftp.mipt.ru/mirror/ubuntu/ -http://mirror.yandex.ru/ubuntu/ -http://ftp.chg.ru/pub/Linux/ubuntu/archive/ ftp://ftp.corbina.net/pub/Linux/ubuntu/ -http://linux.nsu.ru/ubuntu/ +ftp://ftp.mipt.ru/mirror/ubuntu/ http://89.148.222.236/ubuntu/ +http://ftp.chg.ru/pub/Linux/ubuntu/archive/ http://ftp.mtu.ru/pub/ubuntu/archive/ -http://mirror2.corbina.ru/ubuntu/ +http://linux.nsu.ru/ubuntu/ http://mirror.rol.ru/ubuntu/ +http://mirror.yandex.ru/ubuntu/ +http://mirror2.corbina.ru/ubuntu/ #LOC:SA -http://ubuntu.saudi.net.sa/ http://ubuntu.mirrors.isu.net.sa/ubuntu/ +http://ubuntu.saudi.net.sa/ #LOC:SE -http://ftp.port80.se/ubuntu/ -http://mirrors.se.eu.kernel.org/ubuntu/ -http://ftp.sunet.se/pub/os/Linux/distributions/ubuntu/ubuntu/ -http://ftp.ds.karen.hj.se/ubuntu/ http://ftp.acc.umu.se/ubuntu/ http://ftp.df.lth.se/ubuntu/ +http://ftp.ds.karen.hj.se/ubuntu/ +http://ftp.sunet.se/pub/os/Linux/distributions/ubuntu/ubuntu/ +http://mirrors.se.eu.kernel.org/ubuntu/ http://ubuntu.mirror.su.se/ubuntu/ #LOC:SG -http://ubuntu.oss.eznetsols.org/ubuntu/ -http://linux.ntuoss.org/ubuntu/ http://ftp.science.nus.edu.sg/ubuntu/ +http://linux.ntuoss.org/ubuntu/ +http://ubuntu.oss.eznetsols.org/ubuntu/ #LOC:SI http://ftp.arnes.si/pub/mirrors/ubuntu/ http://mirror.lihnidos.org/ubuntu/ubuntu/ #LOC:SK +http://ftp.antik.sk/ubuntu/ http://ftp.energotel.sk/pub/linux/ubuntu/ http://ubuntu.ynet.sk/ubuntu/ -http://ftp.antik.sk/ubuntu/ #LOC:TH http://mirror.in.th/osarchive/ubuntu/ -http://ubuntu-archive.sit.kmutt.ac.th/ http://mirror1.ku.ac.th/ubuntu/ +http://ubuntu-archive.sit.kmutt.ac.th/ #LOC:TR http://ftp.linux.org.tr/ubuntu/ -http://ftp.ankara.edu.tr/ubuntu/ -http://ubuntu.gnu.gen.tr/ubuntu/ -http://russell.cs.bilgi.edu.tr/ubuntu/ http://ftp.metu.edu.tr/ubuntu/ +http://russell.cs.bilgi.edu.tr/ubuntu/ +http://ubuntu.gnu.gen.tr/ubuntu/ #LOC:TW ftp://ftp.chu.edu.tw/Linux/Ubuntu/archives/ -http://ftp.nsysu.edu.tw/Linux/Ubuntu/ubuntu/ -http://ftp.ncnu.edu.tw/Linux/ubuntu/ubuntu/ -http://tw.archive.ubuntu.com/ubuntu/ -http://mirror.nttu.edu.tw/ubuntu/ -http://ftp.tcc.edu.tw/Linux/ubuntu/ -http://ubuntu.cs.nctu.edu.tw/ubuntu/ -http://ftp.nchu.edu.tw/Linux/Ubuntu/ http://debian.nctu.edu.tw/ubuntu/ -http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ -http://ftp.cse.yzu.edu.tw/pub/Linux/Ubuntu/ubuntu/ -http://ubuntu.stu.edu.tw/ubuntu/ http://free.nchc.org.tw/ubuntu/ http://ftp.cs.pu.edu.tw/Linux/Ubuntu/ubuntu/ +http://ftp.cse.yzu.edu.tw/pub/Linux/Ubuntu/ubuntu/ +http://ftp.nchu.edu.tw/Linux/Ubuntu/ +http://ftp.ncnu.edu.tw/Linux/ubuntu/ubuntu/ +http://ftp.nsysu.edu.tw/Linux/Ubuntu/ubuntu/ +http://ftp.tcc.edu.tw/Linux/ubuntu/ http://ftp.tku.edu.tw/ubuntu/ +http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ +http://mirror.nttu.edu.tw/ubuntu/ +http://tw.archive.ubuntu.com/ubuntu/ +http://ubuntu.cs.nctu.edu.tw/ubuntu/ +http://ubuntu.stu.edu.tw/ubuntu/ +http://www.mirror.tw/pub/ubuntu/ubuntu/ #LOC:UA http://mirror.mirohost.net/ubuntu/ -http://ubuntu.org.ua/ubuntu/ http://mirrors.dnepr.com/pub/mirrors/ubuntu/ +http://ubuntu.org.ua/ubuntu/ #LOC:US -http://ubuntu.wallawalla.edu/ubuntu/ -http://mirror.math.ucdavis.edu/ubuntu/ -http://mirror.umoss.org/ubuntu/ -http://ubuntu.securedservers.com/ -http://ubuntu.media.mit.edu/ubuntu/ -http://mirrors.cs.wmich.edu/ubuntu/ +ftp://ftp.egr.msu.edu/pub/ubuntu/archive/ +http://76.73.4.58/ubuntu/ +http://archive.linux.duke.edu/ubuntu/ +http://astromirror.uchicago.edu/ubuntu/ +http://cudlug.cudenver.edu/ubuntu/ +http://ftp.usf.edu/pub/ubuntu/ +http://ftp.ussg.iu.edu/linux/ubuntu/ +http://ftp.utexas.edu/ubuntu/ +http://lug.mtu.edu/ubuntu/ +http://mira.sunsite.utk.edu/ubuntu/ +http://mirror.anl.gov/pub/ubuntu/ http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/ +http://mirror.clarkson.edu/ubuntu/ +http://mirror.cs.umn.edu/ubuntu/ +http://mirror.hosef.org/ubuntu/ +http://mirror.its.uidaho.edu/pub/ubuntu/ +http://mirror.math.ucdavis.edu/ubuntu/ http://mirror.peer1.net/ubuntu/ -http://ubuntu.wikimedia.org/ubuntu/ -http://ubuntu.cs.utah.edu/ubuntu/ -http://mirrors.rit.edu/ubuntu/ +http://mirror.umoss.org/ubuntu/ +http://mirror.uoregon.edu/ubuntu/ +http://mirrors.acm.jhu.edu/ubuntu/ +http://mirrors.bloomu.edu/ubuntu/ http://mirrors.cat.pdx.edu/ubuntu/ -http://ubuntu.mirror.frontiernet.net/ubuntu/ -http://mirrors.jgi-psf.org/ubuntu/ -http://ftp.ussg.iu.edu/linux/ubuntu/ -http://lug.mtu.edu/ubuntu/ +http://mirrors.cavecreek.net/ubuntu/ http://mirrors.ccs.neu.edu/ubuntu/ -http://ftp.utexas.edu/ubuntu/ -http://mirrors.bloomu.edu/ubuntu/ -http://www.gtlib.gatech.edu/pub/ubuntu/ -http://mirror.its.uidaho.edu/pub/ubuntu/ -http://76.73.4.58/ubuntu/ -http://archive.linux.duke.edu/ubuntu/ -http://mirror.clarkson.edu/ubuntu/ -http://cudlug.cudenver.edu/ubuntu/ -http://ubuntu.secsup.org/ +http://mirrors.cs.wmich.edu/ubuntu/ http://mirrors.easynews.com/linux/ubuntu/ +http://mirrors.jgi-psf.org/ubuntu/ +http://mirrors.pavlovmedia.net/ubuntu/ +http://mirrors.rit.edu/ubuntu/ +http://mirrors.us.kernel.org/ubuntu/ +http://mirrors.xmission.com/ubuntu/ +http://samaritan.ucmerced.edu/ubuntu/ +http://ubuntu.cs.utah.edu/ubuntu/ http://ubuntu.eecs.wsu.edu/ +http://ubuntu.media.mit.edu/ubuntu/ +http://ubuntu.mirror.frontiernet.net/ubuntu/ +http://ubuntu.mirrors.tds.net/pub/ubuntu/ http://ubuntu.osuosl.org/ubuntu/ -ftp://ftp.egr.msu.edu/pub/ubuntu/archive/ -http://mirrors.us.kernel.org/ubuntu/ http://ubuntu.secs.oakland.edu/ -http://mirrors.pavlovmedia.net/ubuntu/ -http://mira.sunsite.utk.edu/ubuntu/ -http://astromirror.uchicago.edu/ubuntu/ +http://ubuntu.secsup.org/ +http://ubuntu.securedservers.com/ +http://ubuntu.wallawalla.edu/ubuntu/ http://ubuntu.washdc-linux.com/ubuntu/ +http://ubuntu.wikimedia.org/ubuntu/ http://www.club.cc.cmu.edu/pub/ubuntu/ -http://mirror.uoregon.edu/ubuntu/ +http://www.gtlib.gatech.edu/pub/ubuntu/ http://www.lug.bu.edu/mirror/ubuntu/ -http://mirror.anl.gov/pub/ubuntu/ -http://mirrors.cavecreek.net/ubuntu/ -http://mirror.hosef.org/ubuntu/ -http://mirrors.xmission.com/ubuntu/ -http://mirror.lcsee.wvu.edu/ubuntu/ -http://mirrors.acm.jhu.edu/ubuntu/ -http://samaritan.ucmerced.edu/ubuntu/ -http://ubuntu.mirrors.tds.net/pub/ubuntu/ -http://ftp.usf.edu/pub/ubuntu/ -http://mirror.cs.umn.edu/ubuntu/ #LOC:UZ http://ubuntu.uz/ubuntu/ #LOC:VN http://mirror-fpt-telecom.fpt.net/ubuntu/ #LOC:ZA -http://ubuntu.saix.net/ubuntu-archive/ -http://ftp.sun.ac.za/ftp/ubuntu/ http://ftp.leg.uct.ac.za/ubuntu/ +http://ftp.sun.ac.za/ftp/ubuntu/ http://ubuntu.mirror.ac.za/ubuntu-archive/ +http://ubuntu.saix.net/ubuntu-archive/ diff --git a/debian/changelog b/debian/changelog index 97c72763..090ee043 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,8 @@ python-apt (0.7.93.4) unstable; urgency=low - change one mirror which is not on the mirror list anymore. * utils/get_debian_mirrors.py: - Parse Mirrors.masterlist instead of the HTML web page. + * utils/get_ubuntu_mirrors_from_lp.py: + - Sort the mirror list of each country. -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py index 3c183b6d..341dba8a 100755 --- a/utils/get_ubuntu_mirrors_from_lp.py +++ b/utils/get_ubuntu_mirrors_from_lp.py @@ -44,4 +44,4 @@ keys = countries.keys() keys.sort() for country in keys: print "#LOC:%s" % country - print "\n".join(countries[country]) + print "\n".join(sorted(countries[country])) -- cgit v1.2.3 From ab48075a8c46d8006337754dea80bf8e8930a4b0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 15:01:18 +0100 Subject: * python/apt_pkgmodule.cc: - Treat '>>' and '>', '<<' and '<' as identical in check_dep (LP: #535667). * tests: - test_deps: Add tests for apt_pkg.CheckDep, apt_pkg.check_dep, apt_pkg.parse_depends and apt_pkg.parse_src_depends. --- debian/changelog | 5 ++ python/apt_pkgmodule.cc | 30 ++++++++++++ tests/test_deps.py | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 tests/test_deps.py (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 090ee043..5c6e6895 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.93.4) unstable; urgency=low * python/acquire-item.cc: - Add AcquireItem.partialsize member. + * python/apt_pkgmodule.cc: + - Treat '>>' and '>', '<<' and '<' as identical in check_dep (LP: #535667). * python/generic.cc: - Map UntranslatedDepType to dep_type_untranslated. * python/tag.cc: @@ -24,6 +26,9 @@ python-apt (0.7.93.4) unstable; urgency=low - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this for Debian mirrors) - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4) + * tests: + - test_deps: Add tests for apt_pkg.CheckDep, apt_pkg.check_dep, + apt_pkg.parse_depends and apt_pkg.parse_src_depends. * tests/data/aptsources/sources.list.testDistribution: - change one mirror which is not on the mirror list anymore. * utils/get_debian_mirrors.py: diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e3da1820..1885a84a 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -91,6 +91,35 @@ static PyObject *CheckDep(PyObject *Self,PyObject *Args) char *OpStr; unsigned int Op = 0; + if (PyArg_ParseTuple(Args,"sss",&A,&OpStr,&B) == 0) + return 0; + + if (strcmp(OpStr, ">") == 0) OpStr = ">>"; + if (strcmp(OpStr, "<") == 0) OpStr = "<<"; + 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 Py_BuildValue("i",_system->VS->CheckDep(A,Op,B)); +// return Py_BuildValue("i",pkgCheckDep(B,A,Op)); +} + +static char *doc_CheckDepOld = "CheckDep(PkgVer,DepOp,DepVer) -> int"; +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) @@ -473,6 +502,7 @@ static PyMethodDef methods[] = // 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}, diff --git a/tests/test_deps.py b/tests/test_deps.py new file mode 100644 index 00000000..674c9485 --- /dev/null +++ b/tests/test_deps.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# +# Copyright (C) 2010 Julian Andres Klode +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +"""Unit tests for verifying the correctness of check_dep, etc in apt_pkg.""" +import unittest + +import apt_pkg + + +class TestDependencies(unittest.TestCase): + + def setUp(self): + apt_pkg.init() + + def testCheckDep(self): + """dependencies: Test apt_pkg.CheckDep() for '<' and '>' + + The CheckDep function should treat '<' as '<=' and '>' as '>=', for + compatibility reasons.""" + if not hasattr(apt_pkg, 'CheckDep'): + return + self.assertFalse(apt_pkg.CheckDep("1", "<", "0")) + self.assertTrue(apt_pkg.CheckDep("1", "<", "1")) + self.assertTrue(apt_pkg.CheckDep("1", "<", "2")) + + self.assertFalse(apt_pkg.CheckDep("0", ">", "1")) + self.assertTrue(apt_pkg.CheckDep("1", ">", "1")) + self.assertTrue(apt_pkg.CheckDep("2", ">", "1")) + + def test_check_dep(self): + "dependencies: Test apt_pkg.check_dep()" + self.assertFalse(apt_pkg.check_dep("1", "<<", "0")) + self.assertFalse(apt_pkg.check_dep("1", "<<", "1")) + self.assertTrue(apt_pkg.check_dep("1", "<<", "2")) + + self.assertFalse(apt_pkg.check_dep("1", "<", "0")) + self.assertFalse(apt_pkg.check_dep("1", "<", "1")) + self.assertTrue(apt_pkg.check_dep("1", "<", "2")) + + self.assertFalse(apt_pkg.check_dep("1", "<=", "0")) + self.assertTrue(apt_pkg.check_dep("1", "<=", "1")) + self.assertTrue(apt_pkg.check_dep("1", "<=", "2")) + + self.assertFalse(apt_pkg.check_dep("0", "=", "1")) + self.assertTrue(apt_pkg.check_dep("1", "=", "1")) + self.assertFalse(apt_pkg.check_dep("2", "=", "1")) + + self.assertFalse(apt_pkg.check_dep("0", ">=", "1")) + self.assertTrue(apt_pkg.check_dep("1", ">=", "1")) + self.assertTrue(apt_pkg.check_dep("2", ">=", "1")) + + self.assertFalse(apt_pkg.check_dep("0", ">", "1")) + self.assertFalse(apt_pkg.check_dep("1", ">", "1")) + self.assertTrue(apt_pkg.check_dep("2", ">", "1")) + + self.assertFalse(apt_pkg.check_dep("0", ">>", "1")) + self.assertFalse(apt_pkg.check_dep("1", ">>", "1")) + self.assertTrue(apt_pkg.check_dep("2", ">>", "1")) + + def test_parse_depends(self): + """dependencies: Test apt_pkg.parse_depends()""" + deps = apt_pkg.parse_depends("p1a (<< 1a) | p1b (>> 1b)") + self.assertTrue(isinstance(deps, list)) + self.assertEqual(len(deps), 1) + self.assertTrue(isinstance(deps[0], list)) + self.assertEqual(len(deps[0]), 2) + self.assertEqual(len(deps[0][0]), 3) + self.assertEqual(len(deps[0][1]), 3) + self.assertEqual(deps[0][0][0], "p1a") + self.assertEqual(deps[0][0][1], "1a") + self.assertEqual(deps[0][0][2], "<") + self.assertEqual(deps[0][1][0], "p1b") + self.assertEqual(deps[0][1][1], "1b") + self.assertEqual(deps[0][1][2], ">") + + # Check that the type of comparison is parsed correctly. + self.assertEqual("<", apt_pkg.parse_depends("p1 (<< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.parse_depends("p1 (< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.parse_depends("p1 (<= 1)")[0][0][2]) + self.assertEqual("=", apt_pkg.parse_depends("p1 (= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.parse_depends("p1 (>= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.parse_depends("p1 (> 1)")[0][0][2]) + self.assertEqual(">", apt_pkg.parse_depends("p1 (>> 1)")[0][0][2]) + + def test_parse_src_depends(self): + """dependencies: Test apt_pkg.parse_src_depends().""" + # Check that architecture exclusion works + # depends_this: Current architecture is included + # depends_this_too: Another architecture is excluded + # depends_other: The current architecture is excluded + # depends_other: Another architecture is requested. + architecture = apt_pkg.config["APT::Architecture"] + depends_this = apt_pkg.parse_src_depends("p [%s]" % architecture) + depends_this_too = apt_pkg.parse_src_depends("p [!not-existing-arch]") + depends_other = apt_pkg.parse_src_depends("p [!%s]" % architecture) + depends_other_too = apt_pkg.parse_src_depends("p [not-existing-arch]") + + self.assertEqual(len(depends_this), len(depends_this_too), 1) + self.assertEqual(len(depends_other), len(depends_other_too), 0) + + def testParseDepends(self): + """dependencies: Test apt_pkg.ParseDepends().""" + if not hasattr(apt_pkg, 'ParseDepends'): + return + # Check that the type of comparison is parsed correctly. + self.assertEqual("<<", apt_pkg.ParseDepends("p1 (<< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.ParseDepends("p1 (< 1)")[0][0][2]) + self.assertEqual("<=", apt_pkg.ParseDepends("p1 (<= 1)")[0][0][2]) + self.assertEqual("=", apt_pkg.ParseDepends("p1 (= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.ParseDepends("p1 (>= 1)")[0][0][2]) + self.assertEqual(">=", apt_pkg.ParseDepends("p1 (> 1)")[0][0][2]) + self.assertEqual(">>", apt_pkg.ParseDepends("p1 (>> 1)")[0][0][2]) + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3 From 72e6ef284a460c497eec3964b0eeddbdf24a4b5a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 15:58:50 +0100 Subject: Move documentation into python-apt-doc (Closes: #572617) --- debian/changelog | 1 + debian/control | 16 ++++++++++++++-- debian/python-apt-doc.doc-base | 8 ++++++++ debian/python-apt-doc.docs | 1 + debian/python-apt.doc-base | 8 -------- debian/python-apt.docs | 1 - debian/rules | 2 +- 7 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 debian/python-apt-doc.doc-base create mode 100644 debian/python-apt-doc.docs delete mode 100644 debian/python-apt.doc-base (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 5c6e6895..b0e6657b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ python-apt (0.7.93.4) unstable; urgency=low + * Move documentation into python-apt-doc (Closes: #572617) * python/acquire-item.cc: - Add AcquireItem.partialsize member. * python/apt_pkgmodule.cc: diff --git a/debian/control b/debian/control index 4db6c164..8e7605e6 100644 --- a/debian/control +++ b/debian/control @@ -23,10 +23,10 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} -Recommends: lsb-release, iso-codes, libjs-jquery +Recommends: lsb-release, iso-codes Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4) Provides: ${python:Provides} -Suggests: python-apt-dbg, python-gtk2, python-vte +Suggests: python-apt-dbg, python-gtk2, python-vte, python-apt-doc XB-Python-Version: ${python:Versions} Description: Python interface to libapt-pkg The apt_pkg Python interface will provide full access to the internal @@ -41,6 +41,18 @@ Description: Python interface to libapt-pkg The included 'aptsources' Python interface provides an abstraction of the sources.list configuration on the repository and the distro level. +Package: python-apt-doc +Architecture: all +Section: doc +Depends: libjs-jquery, ${misc:Depends} +Enhances: python-apt +Description: Python interface to libapt-pkg (API documentation) + The apt_pkg Python interface will provide full access to the internal + libapt-pkg structures allowing Python programs to easily perform a + variety of functions. + . + This package contains the API documentation of python-apt. + Package: python-apt-dbg Priority: extra Architecture: any diff --git a/debian/python-apt-doc.doc-base b/debian/python-apt-doc.doc-base new file mode 100644 index 00000000..4f3c4d31 --- /dev/null +++ b/debian/python-apt-doc.doc-base @@ -0,0 +1,8 @@ +Document: python-apt-api-reference +Title: Python APT: API reference manual +Abstract: API reference manual for Python bindings to libapt-pkg +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/python-apt-doc/html/index.html +Files: /usr/share/doc/python-apt-doc/html/* diff --git a/debian/python-apt-doc.docs b/debian/python-apt-doc.docs new file mode 100644 index 00000000..f85adafd --- /dev/null +++ b/debian/python-apt-doc.docs @@ -0,0 +1 @@ +build/sphinx/html/ diff --git a/debian/python-apt.doc-base b/debian/python-apt.doc-base deleted file mode 100644 index e9b2040c..00000000 --- a/debian/python-apt.doc-base +++ /dev/null @@ -1,8 +0,0 @@ -Document: python-apt-api-reference -Title: Python APT: API reference manual -Abstract: API reference manual for Python bindings to libapt-pkg -Section: Programming/Python - -Format: HTML -Index: /usr/share/doc/python-apt/html/index.html -Files: /usr/share/doc/python-apt/html/* diff --git a/debian/python-apt.docs b/debian/python-apt.docs index 1bfc7c1c..a53a1ccc 100644 --- a/debian/python-apt.docs +++ b/debian/python-apt.docs @@ -3,4 +3,3 @@ AUTHORS TODO apt/README.apt data/templates/README.templates -build/sphinx/html/ diff --git a/debian/rules b/debian/rules index 24d0952e..3711080c 100755 --- a/debian/rules +++ b/debian/rules @@ -10,7 +10,7 @@ export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 override_dh_installdocs: dh_installdocs ln -sf ../../../../javascript/jquery/jquery.js \ - debian/python-apt/usr/share/doc/python-apt/html/_static/jquery.js + debian/python-apt-doc/usr/share/doc/python-apt-doc/html/_static/jquery.js rm -rf debian/python-apt-dbg/usr/share/doc/python-apt-dbg ln -s python-apt debian/python-apt-dbg/usr/share/doc/python-apt-dbg -- cgit v1.2.3 From 73906071bf00e83910b4aaf9050cd3f567dc7cb7 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 16:00:09 +0100 Subject: Build documentation only once on the default Python version. --- debian/changelog | 1 + debian/rules | 4 ++++ setup.py | 2 -- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index b0e6657b..b2c1a90e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ python-apt (0.7.93.4) unstable; urgency=low * Move documentation into python-apt-doc (Closes: #572617) + * Build documentation only once on the default Python version. * python/acquire-item.cc: - Add AcquireItem.partialsize member. * python/apt_pkgmodule.cc: diff --git a/debian/rules b/debian/rules index 3711080c..df775322 100755 --- a/debian/rules +++ b/debian/rules @@ -7,6 +7,10 @@ export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 %: dh --with python-central $@ +override_dh_auto_build: + dh_auto_build + python setup.py build_sphinx + override_dh_installdocs: dh_installdocs ln -sf ../../../../javascript/jquery/jquery.js \ diff --git a/setup.py b/setup.py index b285fcee..9c6eda60 100644 --- a/setup.py +++ b/setup.py @@ -14,8 +14,6 @@ try: cmdclass['build'] = build_extra.build_extra cmdclass['build_i18n'] = build_i18n.build_i18n cmdclass['clean'] = clean_build_tree - build_extra.build_extra.sub_commands.append(("build_sphinx", - lambda x: 'build_sphinx' in cmdclass)) except ImportError: print('W: [python%s] DistUtilsExtra import error.' % sys.version[:3]) -- cgit v1.2.3 From 0cfc2fb37e43dd71f21347e0d490ab89ecbdeaf0 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 16:19:27 +0100 Subject: python-apt-doc replaces files in older python-apt --- debian/control | 1 + 1 file changed, 1 insertion(+) (limited to 'debian') diff --git a/debian/control b/debian/control index 8e7605e6..af7aa055 100644 --- a/debian/control +++ b/debian/control @@ -46,6 +46,7 @@ Architecture: all Section: doc Depends: libjs-jquery, ${misc:Depends} Enhances: python-apt +Replaces: python-apt (<< 0.7.94) Description: Python interface to libapt-pkg (API documentation) The apt_pkg Python interface will provide full access to the internal libapt-pkg structures allowing Python programs to easily perform a -- cgit v1.2.3 From 030aa351e6f2dd2a85715a50323063b6139af4f9 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Mar 2010 16:20:24 +0100 Subject: Upload to unstable as 0.7.94. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index b2c1a90e..cb8a47ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.93.4) unstable; urgency=low +python-apt (0.7.94) unstable; urgency=low * Move documentation into python-apt-doc (Closes: #572617) * Build documentation only once on the default Python version. @@ -38,7 +38,7 @@ python-apt (0.7.93.4) unstable; urgency=low * utils/get_ubuntu_mirrors_from_lp.py: - Sort the mirror list of each country. - -- Julian Andres Klode Mon, 01 Mar 2010 16:13:22 +0100 + -- Julian Andres Klode Wed, 10 Mar 2010 16:10:27 +0100 python-apt (0.7.93.3) unstable; urgency=low -- cgit v1.2.3 From d19fac3e07bf43f106d062ea6be97e3959abf178 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 11 Mar 2010 19:57:19 +0100 Subject: Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend on python2.6. --- debian/changelog | 7 +++++++ debian/rules | 3 +++ 2 files changed, 10 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index cb8a47ee..50b8d3d7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.94.1) UNRELEASED; urgency=low + + * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend + on python2.6. + + -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 + python-apt (0.7.94) unstable; urgency=low * Move documentation into python-apt-doc (Closes: #572617) diff --git a/debian/rules b/debian/rules index df775322..be338540 100755 --- a/debian/rules +++ b/debian/rules @@ -28,3 +28,6 @@ override_dh_auto_test: set -e; for python in $(shell pyversions -r); do \ $$python tests/test_all.py -q; \ done; + +override_dh_pycentral: + dh_pycentral --exclude=migrate-0.8.py -- cgit v1.2.3 From c657b7a2a59e15a0c415ba94021c4de547a78e60 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 10:13:38 +0100 Subject: Use dh_link instead of ln for python-apt-doc (Closes: #573523). --- debian/changelog | 1 + debian/python-apt-doc.links | 1 + debian/rules | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 debian/python-apt-doc.links (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 50b8d3d7..d55c6246 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend on python2.6. + * Use dh_link instead of ln for python-apt-doc (Closes: #573523). -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 diff --git a/debian/python-apt-doc.links b/debian/python-apt-doc.links new file mode 100644 index 00000000..40f834f2 --- /dev/null +++ b/debian/python-apt-doc.links @@ -0,0 +1 @@ +usr/share/javascript/jquery/jquery.js usr/share/doc/python-apt-doc/html/_static/jquery.js diff --git a/debian/rules b/debian/rules index be338540..6d1f07bf 100755 --- a/debian/rules +++ b/debian/rules @@ -13,8 +13,6 @@ override_dh_auto_build: override_dh_installdocs: dh_installdocs - ln -sf ../../../../javascript/jquery/jquery.js \ - debian/python-apt-doc/usr/share/doc/python-apt-doc/html/_static/jquery.js rm -rf debian/python-apt-dbg/usr/share/doc/python-apt-dbg ln -s python-apt debian/python-apt-dbg/usr/share/doc/python-apt-dbg -- cgit v1.2.3 From e80e27ae1fba2e329eeb564f47d479cfa8b916d1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 12:40:52 +0100 Subject: Pass --link-doc=python-apt to dh_installdocs. --- debian/changelog | 1 + debian/rules | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index d55c6246..35d9039e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend on python2.6. * Use dh_link instead of ln for python-apt-doc (Closes: #573523). + * Pass --link-doc=python-apt to dh_installdocs. -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 diff --git a/debian/rules b/debian/rules index 6d1f07bf..a1ef5441 100755 --- a/debian/rules +++ b/debian/rules @@ -12,9 +12,9 @@ override_dh_auto_build: python setup.py build_sphinx override_dh_installdocs: - dh_installdocs - rm -rf debian/python-apt-dbg/usr/share/doc/python-apt-dbg - ln -s python-apt debian/python-apt-dbg/usr/share/doc/python-apt-dbg + dh_installdirs -ppython-apt-dev usr/share/doc/python-apt + dh_installdirs -ppython-apt-doc usr/share/doc/python-apt + dh_installdocs --link-doc=python-apt override_dh_strip: dh_strip --dbg-package=python-apt-dbg -- cgit v1.2.3 From 89246e2b657c7f160d5ebe2633ef64e3cdc23ee8 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 12:41:01 +0100 Subject: Install examples to python-apt-doc instead of python-apt. --- debian/changelog | 1 + debian/examples | 2 -- debian/python-apt-doc.examples | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 debian/examples create mode 100644 debian/python-apt-doc.examples (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 35d9039e..276e5cc3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low on python2.6. * Use dh_link instead of ln for python-apt-doc (Closes: #573523). * Pass --link-doc=python-apt to dh_installdocs. + * Install examples to python-apt-doc instead of python-apt. -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 diff --git a/debian/examples b/debian/examples deleted file mode 100644 index e4a93ea1..00000000 --- a/debian/examples +++ /dev/null @@ -1,2 +0,0 @@ -doc/examples/*.py -doc/source/examples/*.py diff --git a/debian/python-apt-doc.examples b/debian/python-apt-doc.examples new file mode 100644 index 00000000..e4a93ea1 --- /dev/null +++ b/debian/python-apt-doc.examples @@ -0,0 +1,2 @@ +doc/examples/*.py +doc/source/examples/*.py -- cgit v1.2.3 From 886cf9ab3e38a930f676d97d1e673be8d2ea7883 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 12:41:41 +0100 Subject: recommend python2.6. --- debian/changelog | 2 +- debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 276e5cc3..6970a7cc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend - on python2.6. + on python2.6; but recommend python2.6. * Use dh_link instead of ln for python-apt-doc (Closes: #573523). * Pass --link-doc=python-apt to dh_installdocs. * Install examples to python-apt-doc instead of python-apt. diff --git a/debian/control b/debian/control index af7aa055..3785e5d5 100644 --- a/debian/control +++ b/debian/control @@ -23,7 +23,7 @@ Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes Package: python-apt Architecture: any Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} -Recommends: lsb-release, iso-codes +Recommends: lsb-release, iso-codes, python2.6 Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4) Provides: ${python:Provides} Suggests: python-apt-dbg, python-gtk2, python-vte, python-apt-doc -- cgit v1.2.3 From 092deeee998dfa2695c586c8105120bd586e8fd1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 14:29:24 +0100 Subject: tests/test_all.py: Write information header to stderr, not stdout. --- debian/changelog | 1 + tests/test_all.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 6970a7cc..f33f4ed5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * Use dh_link instead of ln for python-apt-doc (Closes: #573523). * Pass --link-doc=python-apt to dh_installdocs. * Install examples to python-apt-doc instead of python-apt. + * tests/test_all.py: Write information header to stderr, not stdout. -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 diff --git a/tests/test_all.py b/tests/test_all.py index dc603dfd..d561a9ae 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -10,7 +10,7 @@ import unittest import sys if __name__ == '__main__': - print("[tests] Running on %s" % sys.version.replace("\n", "")) + sys.stderr.write("[tests] Running on %s\n" % sys.version.replace("\n", "")) os.chdir(os.path.dirname(__file__)) # Find the path to the built apt_pkg and apt_inst extensions if os.path.exists("../build"): -- cgit v1.2.3 From 5fc47b7e1c9ff27bdc850f9d2e4681ed8caa62ea Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 14:33:55 +0100 Subject: Build documentation only when needed (when building python-apt-doc). --- debian/changelog | 1 + debian/rules | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index f33f4ed5..462f60d1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * Pass --link-doc=python-apt to dh_installdocs. * Install examples to python-apt-doc instead of python-apt. * tests/test_all.py: Write information header to stderr, not stdout. + * Build documentation only when needed (when building python-apt-doc). -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 diff --git a/debian/rules b/debian/rules index a1ef5441..a65c5cfd 100755 --- a/debian/rules +++ b/debian/rules @@ -9,11 +9,13 @@ export CFLAGS=-Wno-write-strings -DCOMPAT_0_7 override_dh_auto_build: dh_auto_build - python setup.py build_sphinx override_dh_installdocs: + set -e; if [ -z $(filter -a,$(DH_INTERNAL_OPTIONS)) ]; then \ + python setup.py build_sphinx; \ + dh_installdirs -ppython-apt-doc usr/share/doc/python-apt; \ + fi dh_installdirs -ppython-apt-dev usr/share/doc/python-apt - dh_installdirs -ppython-apt-doc usr/share/doc/python-apt dh_installdocs --link-doc=python-apt override_dh_strip: -- cgit v1.2.3 From 7087b6bebc930dfee0f717d46329e3704cc871be Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 14:37:04 +0100 Subject: Upload to unstable. --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 462f60d1..be9888d3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.94.1) UNRELEASED; urgency=low +python-apt (0.7.94.1) unstable; urgency=low * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend on python2.6; but recommend python2.6. @@ -8,7 +8,7 @@ python-apt (0.7.94.1) UNRELEASED; urgency=low * tests/test_all.py: Write information header to stderr, not stdout. * Build documentation only when needed (when building python-apt-doc). - -- Julian Andres Klode Thu, 11 Mar 2010 19:33:26 +0100 + -- Julian Andres Klode Fri, 12 Mar 2010 14:36:48 +0100 python-apt (0.7.94) unstable; urgency=low -- cgit v1.2.3 From 4652428c6c964991ca1384c1a7f7d0e2a7028356 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 12 Mar 2010 19:26:11 +0100 Subject: Revert 0.7.93.3 and just set APT::Architecture to i386 for test_aptsources; fixes FTBFS on powerpc. --- data/templates/Ubuntu.info.in | 15 ++++++++++----- debian/changelog | 7 +++++++ tests/test_aptsources.py | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'debian') diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index a84cbc2b..1ca76927 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -8,7 +8,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 10.04 'Lucid Lynx' Component: main _CompDescription: Officially supported @@ -68,7 +69,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.10 'Karmic Koala' Component: main _CompDescription: Officially supported @@ -128,7 +130,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 9.04 'Jaunty Jackalope' Component: main _CompDescription: Officially supported @@ -188,7 +191,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.10 'Intrepid Ibex' Component: main _CompDescription: Officially supported @@ -249,7 +253,8 @@ BaseURI-powerpc: http://ports.ubuntu.com/ MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com BaseURI-lpia: http://ports.ubuntu.com/ MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com -MirrorsFile: Ubuntu.mirrors +MirrorsFile-amd64: Ubuntu.mirrors +MirrorsFile-i386: Ubuntu.mirrors _Description: Ubuntu 8.04 'Hardy Heron' Component: main _CompDescription: Officially supported diff --git a/debian/changelog b/debian/changelog index be9888d3..31bdf042 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.94.2) unstable; urgency=low + + * Revert 0.7.93.3 and just set APT::Architecture to i386 for + test_aptsources; fixes FTBFS on powerpc. + + -- Julian Andres Klode Fri, 12 Mar 2010 19:22:57 +0100 + python-apt (0.7.94.1) unstable; urgency=low * Pass --exclude=migrate-0.8.py to dh_pycentral; in order to not depend diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 0f7f078b..767f5244 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -14,6 +14,8 @@ class TestAptSources(unittest.TestCase): def setUp(self): apt_pkg.init_config() apt_pkg.init_system() + if apt_pkg.config["APT::Architecture"] not in ('i386', 'amd64'): + apt_pkg.config.set("APT::Architecture", "i386") apt_pkg.config.set("Dir::Etc", os.getcwd()) apt_pkg.config.set("Dir::Etc::sourceparts", "/xxx") if os.path.exists("../build/data/templates"): -- cgit v1.2.3 From dbfcddec5c85d306a97cdf73e539656c6d7225c5 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 15 Mar 2010 17:05:26 +0100 Subject: * python/generic.cc: - Fix a memory leak when using old attribute names. --- debian/changelog | 7 +++++++ python/generic.cc | 3 +++ 2 files changed, 10 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 31bdf042..84938005 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.94.3) UNRELEASED; urgency=low + + * python/generic.cc: + - Fix a memory leak when using old attribute names. + + -- Julian Andres Klode Mon, 15 Mar 2010 17:04:49 +0100 + python-apt (0.7.94.2) unstable; urgency=low * Revert 0.7.93.3 and just set APT::Architecture to i386 for diff --git a/python/generic.cc b/python/generic.cc index d3f6a6d6..84dda9aa 100644 --- a/python/generic.cc +++ b/python/generic.cc @@ -107,6 +107,9 @@ PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr) { PyErr_Restore(ptype, pvalue, ptraceback); } Py_DECREF(newattr); + Py_XDECREF(ptype); + Py_XDECREF(pvalue); + Py_XDECREF(ptraceback); } return value; } -- cgit v1.2.3 From 95112f12cea6ec54aaa8b5e372ee158a300f8967 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 20 Mar 2010 23:06:09 +0100 Subject: debian/control: Change priority to standard, keep -doc and -dev on optional. --- debian/changelog | 2 ++ debian/control | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 84938005..b7617f90 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low * python/generic.cc: - Fix a memory leak when using old attribute names. + * debian/control: + - Change priority to standard, keep -doc and -dev on optional. -- Julian Andres Klode Mon, 15 Mar 2010 17:04:49 +0100 diff --git a/debian/control b/debian/control index 3785e5d5..a3decb78 100644 --- a/debian/control +++ b/debian/control @@ -1,6 +1,6 @@ Source: python-apt Section: python -Priority: optional +Priority: standard Maintainer: APT Development Team Uploaders: Michael Vogt , Julian Andres Klode Standards-Version: 3.8.4 @@ -42,6 +42,7 @@ Description: Python interface to libapt-pkg the sources.list configuration on the repository and the distro level. Package: python-apt-doc +Priority: optional Architecture: all Section: doc Depends: libjs-jquery, ${misc:Depends} @@ -69,6 +70,7 @@ Description: Python interface to libapt-pkg (debug extension) This package contains the extension built for the Python debug interpreter. Package: python-apt-dev +Priority: optional Architecture: all Depends: python-apt (>= ${source:Version}), libapt-pkg-dev (>= 0.7.10), ${misc:Depends} -- cgit v1.2.3 From 3a08cfb10590d5cf5df1f45d94a424ef6a0f674b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Mar 2010 13:32:21 +0100 Subject: * apt/cache.py: - make cache open silent by default (use apt.progress.base.OpProgress) --- apt/cache.py | 2 +- debian/changelog | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'debian') diff --git a/apt/cache.py b/apt/cache.py index 2e6d24e5..cfe6bedc 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -117,7 +117,7 @@ class Cache(object): a dictionary """ if progress is None: - progress = apt.progress.text.OpProgress() + progress = apt.progress.base.OpProgress() self._run_callbacks("cache_pre_open") self._cache = apt_pkg.Cache(progress) diff --git a/debian/changelog b/debian/changelog index b7617f90..2137aa69 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,15 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low + [ Julian Andres Klode ] * python/generic.cc: - Fix a memory leak when using old attribute names. * debian/control: - Change priority to standard, keep -doc and -dev on optional. + [ Michael Vogt ] + * apt/cache.py: + - make cache open silent by default (use apt.progress.base.OpProgress) + -- Julian Andres Klode Mon, 15 Mar 2010 17:04:49 +0100 python-apt (0.7.94.2) unstable; urgency=low -- cgit v1.2.3