From d65882227dd3201c03c87922391d1ad8d21ee84e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 11:32:37 +0200 Subject: * python/pkgmanager.cc: - fix typo --- debian/changelog | 7 +++++++ python/pkgmanager.cc | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 783e510f..89fe3ccf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.20) unstable; urgency=low + + * python/pkgmanager.cc: + - fix typo (closes: #382853) + + -- + python-apt (0.6.19) unstable; urgency=low [ Michael Vogt ] diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc index bcd4c45b..9670f238 100644 --- a/python/pkgmanager.cc +++ b/python/pkgmanager.cc @@ -68,7 +68,7 @@ static PyObject *PkgManagerFixMissing(PyObject *Self,PyObject *Args) static PyMethodDef PkgManagerMethods[] = { - {"GetArchives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archvies into the fetcher"}, + {"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"}, {} -- cgit v1.2.3 From 8572d7a6dff1c3b5e8b27fcfbc36bd13232be598 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 12:28:50 +0200 Subject: * debian/control: - tightend dependency * apt/progress.py: - use os._exit() instead of sys.exit() (lp: 53298) --- apt/progress.py | 9 +++++++-- debian/changelog | 4 ++++ debian/control | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apt/progress.py b/apt/progress.py index 4119067c..d69ca6e6 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -19,7 +19,12 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import sys, apt_pkg, os, fcntl, string, re +import sys +import os +import re +import fcntl +import string +import apt_pkg class OpProgress(object): """ Abstract class to implement reporting on cache opening @@ -199,7 +204,7 @@ class InstallProgress(DumbInstallProgress): if pid == 0: # child res = pm.DoInstall(self.writefd) - sys.exit(res) + os._exit(res) self.child_pid = pid res = self.waitChild() return res diff --git a/debian/changelog b/debian/changelog index 89fe3ccf..5f8db68b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,10 @@ python-apt (0.6.20) unstable; urgency=low * python/pkgmanager.cc: - fix typo (closes: #382853) + * debian/control: + - tightend dependency (closes: #383478) + * apt/progress.py: + - use os._exit() in the child (lp: #53298) -- diff --git a/debian/control b/debian/control index 5fa1bc83..e2f97b78 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: APT Development Team Uploaders: Matt Zimmerman , Michael Vogt Standards-Version: 3.6.2.0 XS-Python-Version: all -Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.6.40), apt-utils, python-all-dev, python-central +Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.6.45), apt-utils, python-all-dev, python-central Package: python-apt Architecture: any -- cgit v1.2.3 From 7035132c76acf5fd72e62437e487f411bf726d5c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 15:16:33 +0200 Subject: * apt/progress.py: - use select() when waiting for child input --- apt/progress.py | 9 ++++++--- debian/changelog | 1 + doc/examples/inst.py | 5 +---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apt/progress.py b/apt/progress.py index d69ca6e6..8ac0e1dc 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -24,6 +24,8 @@ import os import re import fcntl import string +from errno import * +import select import apt_pkg class OpProgress(object): @@ -144,6 +146,7 @@ class InstallProgress(DumbInstallProgress): """ def __init__(self): DumbInstallProgress.__init__(self) + self.selectTimeout = 0.1 (read, write) = os.pipe() self.writefd=write self.statusfd = os.fdopen(read, "r") @@ -167,7 +170,7 @@ class InstallProgress(DumbInstallProgress): self.read += os.read(self.statusfd.fileno(),1) except OSError, (errno,errstr): # resource temporarly unavailable is ignored - if errno != 11: + if errno != EAGAIN and errnor != EWOULDBLOCK: print errstr if self.read.endswith("\n"): s = self.read @@ -189,15 +192,15 @@ class InstallProgress(DumbInstallProgress): self.percent = float(percent) self.status = string.strip(status_str) self.read = "" - def fork(self): return os.fork() def waitChild(self): while True: + select.select([self.statusfd],[],[], self.selectTimeout) + self.updateInterface() (pid, res) = os.waitpid(self.child_pid,os.WNOHANG) if pid == self.child_pid: break - self.updateInterface() return os.WEXITSTATUS(res) def run(self, pm): pid = self.fork() diff --git a/debian/changelog b/debian/changelog index 5f8db68b..02ec00a1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ python-apt (0.6.20) unstable; urgency=low - tightend dependency (closes: #383478) * apt/progress.py: - use os._exit() in the child (lp: #53298) + - use select() when checking for statusfd (lp: #53282) -- diff --git a/doc/examples/inst.py b/doc/examples/inst.py index 0e91c28f..ff9d452c 100644 --- a/doc/examples/inst.py +++ b/doc/examples/inst.py @@ -29,10 +29,7 @@ cache = apt.Cache(apt.progress.OpTextProgress()) fprogress = apt.progress.TextFetchProgress() iprogress = TextInstallProgress() -pkg = cache["test-package"] -pkg.markUpgrade() -cache.commit(fprogress,iprogress) -sys.exit(1) +pkg = cache["3dchess"] # install or remove, the importend thing is to keep us busy :) if pkg.isInstalled: -- cgit v1.2.3 From 8df7cb6c729a5451f231f2cd3e82fc495eaea289 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 15:35:55 +0200 Subject: * fix missing docstring --- debian/changelog | 4 ++++ python/apt_pkgmodule.cc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 02ec00a1..7029a040 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,10 @@ python-apt (0.6.20) unstable; urgency=low * apt/progress.py: - use os._exit() in the child (lp: #53298) - use select() when checking for statusfd (lp: #53282) + * acknoledge NMU (closes: #378048, #373512) + * python/apt_pkgmodule.cc: + - fix missing docstring (closes: #368907), + Thanks to Josh Triplett -- diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index b1c5c2a5..24d876af 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -440,7 +440,7 @@ static PyMethodDef methods[] = {"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS,"GetPkgAcquireFile() -> pkgAcquireFile"}, // PkgManager - {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager() -> PackageManager"}, + {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager(DepCache) -> PackageManager"}, {} }; -- cgit v1.2.3 From 0d7ffbdfcecfde690648da1ff9342d3bd736e71f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Sep 2006 18:40:30 +0200 Subject: * fix api changes for python2.5 --- debian/changelog | 1 + python/cache.cc | 8 ++++---- python/tag.cc | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7029a040..21cbd6a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ python-apt (0.6.20) unstable; urgency=low * python/apt_pkgmodule.cc: - fix missing docstring (closes: #368907), Thanks to Josh Triplett + * make it build against python2.5 -- diff --git a/python/cache.cc b/python/cache.cc index 174423c2..b6278de0 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -287,12 +287,12 @@ PyTypeObject PkgCacheFileType = /*}}}*/ // Package List Class /*{{{*/ // --------------------------------------------------------------------- -static int PkgListLen(PyObject *Self) +static Py_ssize_t PkgListLen(PyObject *Self) { return GetCpp(Self).Iter.Cache()->HeaderP->PackageCount; } -static PyObject *PkgListItem(PyObject *iSelf,int Index) +static PyObject *PkgListItem(PyObject *iSelf,Py_ssize_t Index) { PkgListStruct &Self = GetCpp(iSelf); if (Index < 0 || (unsigned)Index >= Self.Iter.Cache()->HeaderP->PackageCount) @@ -815,12 +815,12 @@ PyTypeObject DependencyType = /*}}}*/ // Reverse Dependency List Class /*{{{*/ // --------------------------------------------------------------------- -static int RDepListLen(PyObject *Self) +static Py_ssize_t RDepListLen(PyObject *Self) { return GetCpp(Self).Len; } -static PyObject *RDepListItem(PyObject *iSelf,int Index) +static PyObject *RDepListItem(PyObject *iSelf,Py_ssize_t Index) { RDepListStruct &Self = GetCpp(iSelf); if (Index < 0 || (unsigned)Index >= Self.Len) diff --git a/python/tag.cc b/python/tag.cc index 41db059c..883a8eab 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -132,7 +132,7 @@ static PyObject *TagSecMap(PyObject *Self,PyObject *Arg) } // len() operation -static int TagSecLength(PyObject *Self) +static Py_ssize_t TagSecLength(PyObject *Self) { pkgTagSection &Sec = GetCpp(Self); return Sec.Count(); -- cgit v1.2.3 From ddfb5f9abcc398843e48885bbc8b3e4439c14e7b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Sep 2006 19:26:55 +0200 Subject: * python/generic.h: - deal with the api change and stay backward compatible with 2.4 --- python/generic.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/generic.h b/python/generic.h index a808e28d..b47ed1a2 100644 --- a/python/generic.h +++ b/python/generic.h @@ -31,6 +31,10 @@ #include #include +#if PYTHON_API_VERSION < 1013 +typedef int Py_ssize_t; +#endif + template struct CppPyObject : public PyObject { // We are only using CppPyObject and friends as dumb structs only, ie the -- cgit v1.2.3 From c00b2271e6295c248c18d1bd62e14df372004e85 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 2 Oct 2006 18:20:49 +0200 Subject: * progress.cc: - fix memleak in progress.cc * tests/memleak.py: - uncomment the mem-leak code * doc/examples/sources.py: - improved the example --- debian/changelog | 4 +++- doc/examples/sources.py | 2 +- python/progress.cc | 10 +++++++--- tests/memleak.py | 14 +++++++++----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index 21cbd6a8..1979f75d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,8 +12,10 @@ python-apt (0.6.20) unstable; urgency=low - fix missing docstring (closes: #368907), Thanks to Josh Triplett * make it build against python2.5 + * python/progress.cc: + - fix memleak (lp: #43096) - -- + -- Michael Vogt Mon, 2 Oct 2006 17:29:49 +0200 python-apt (0.6.19) unstable; urgency=low diff --git a/doc/examples/sources.py b/doc/examples/sources.py index c12c6f15..b48c0ba5 100644 --- a/doc/examples/sources.py +++ b/doc/examples/sources.py @@ -12,4 +12,4 @@ sources.Restart() while sources.Lookup('hello'): print sources.Package, sources.Version, sources.Maintainer, sources.Section, `sources.Binaries` print sources.Files - print sources.Index.ArchiveURI("") + print sources.Index.ArchiveURI(sources.Files[0][2]) diff --git a/python/progress.cc b/python/progress.cc index f00058c9..df9c2ec1 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -18,8 +18,10 @@ bool PyCallbackObj::RunSimpleCallback(const char* method_name, PyObject *arglist, PyObject **res) { - if(callbackInst == 0) + if(callbackInst == 0) { + Py_XDECREF(arglist); return false; + } PyObject *method = PyObject_GetAttrString(callbackInst,(char*) method_name); if(method == NULL) { @@ -49,22 +51,24 @@ bool PyCallbackObj::RunSimpleCallback(const char* method_name, // OpProgress interface -// FIXME: add "string Op, string SubOp" as attribute to the callbackInst void PyOpProgress::Update() { - PyObject *o; o = Py_BuildValue("s", Op.c_str()); PyObject_SetAttrString(callbackInst, "op", o); + Py_XDECREF(o); o = Py_BuildValue("s", SubOp.c_str()); PyObject_SetAttrString(callbackInst, "subOp", o); + Py_XDECREF(o); o = Py_BuildValue("b", MajorChange); PyObject_SetAttrString(callbackInst, "majorChange", o); + Py_XDECREF(o); // Build up the argument list... PyObject *arglist = Py_BuildValue("(f)", Percent); if(CheckChange(0.05)) RunSimpleCallback("update", arglist); + Py_XDECREF(arglist); }; void PyOpProgress::Done() diff --git a/tests/memleak.py b/tests/memleak.py index 3e59cbb7..b5d05afc 100755 --- a/tests/memleak.py +++ b/tests/memleak.py @@ -10,11 +10,15 @@ import sys cache = apt.Cache() # memleak -#for i in range(100): -# cache.open(None) -# print cache["apt"].name -# time.sleep(1) -# gc.collect() +for i in range(100): + cache.open(None) + print cache["apt"].name + time.sleep(1) + gc.collect() + f = open("%s" % i,"w") + for obj in gc.get_objects(): + f.write("%s\n" % str(obj)) + f.close() # memleak #for i in range(100): -- cgit v1.2.3 From 722f0d8b1a276f2f069fc090db2365ae2659fac9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 Oct 2006 16:39:18 +0200 Subject: * python/generic.h: - use PyObject_DEL() instead of PyMem_DEL() --- debian/changelog | 9 +++++++++ python/generic.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1979f75d..3ab21a51 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +python-apt (0.6.21) unstable; urgency=low + + * python/generic.h: + - fix incorrect use of PyMem_DEL(), use pyObject_DEL() + instead. This fixes a nasty segfault with python2.5 + (lp: 63226) + + -- + python-apt (0.6.20) unstable; urgency=low * python/pkgmanager.cc: diff --git a/python/generic.h b/python/generic.h index b47ed1a2..a1b662bb 100644 --- a/python/generic.h +++ b/python/generic.h @@ -113,7 +113,7 @@ template void CppDealloc(PyObject *Obj) { GetCpp(Obj).~T(); - PyMem_DEL(Obj); + PyObject_DEL(Obj); } template @@ -123,7 +123,7 @@ void CppOwnedDealloc(PyObject *iObj) Obj->Object.~T(); if (Obj->Owner != 0) Py_DECREF(Obj->Owner); - PyMem_DEL(Obj); + PyObject_DEL(Obj); } inline PyObject *CppPyString(std::string Str) -- cgit v1.2.3 From 9e5bfd3bc00a88094e6d16dcce6f50a0f51a5ee6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 Oct 2006 16:54:00 +0200 Subject: * python/tag.cc: - fix another PyMem_DEL() -> PyObject_DEL() error --- python/tag.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tag.cc b/python/tag.cc index 883a8eab..d0d862c9 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -68,7 +68,7 @@ void TagFileFree(PyObject *Obj) Self->Object.~pkgTagFile(); Self->Fd.~FileFd(); Py_DECREF(Self->File); - PyMem_DEL(Obj); + PyObject_DEL(Obj); } /*}}}*/ -- cgit v1.2.3 From 053d66916010f0f4e2b234c6bbd93e0afe79631e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 Oct 2006 17:00:42 +0200 Subject: * python/configuration.cc: - and the final(!?!) incorrect PyMem_{DEL,Free} usage --- python/configuration.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/configuration.cc b/python/configuration.cc index 6cf33581..55eac1bf 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -490,7 +490,7 @@ PyTypeObject ConfigurationPtrType = sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - (destructor)PyMem_Free, // tp_dealloc + (destructor)PyObject_Free, // tp_dealloc 0, // tp_print CnfGetAttr, // tp_getattr 0, // tp_setattr -- cgit v1.2.3 From 2bd5e2dd14365d8d7e72b7671ed57c6b681b9072 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 12 Oct 2006 14:39:50 +0200 Subject: * remove dh_python --- debian/changelog | 1 + debian/rules | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3ab21a51..0dfa9381 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ python-apt (0.6.21) unstable; urgency=low - fix incorrect use of PyMem_DEL(), use pyObject_DEL() instead. This fixes a nasty segfault with python2.5 (lp: 63226) + * debian/rules: Remove dh_python call. -- diff --git a/debian/rules b/debian/rules index ee159b89..7299f554 100755 --- a/debian/rules +++ b/debian/rules @@ -49,12 +49,11 @@ binary-arch: build for PY in $(PYTHON); do \ /usr/bin/$$PY setup.py install --prefix=`pwd`/debian/python-apt/usr; \ done - + dh_installdocs dh_installchangelogs dh_installexamples dh_pycentral - dh_python dh_strip dh_compress dh_fixperms -- cgit v1.2.3 From 4ae6dbf9a654189b1f07e8056fff9a3b877a6e2d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Nov 2006 22:04:49 +0100 Subject: * apt/progress.py: - protect against unparsable strings send from dpkg --- apt/progress.py | 7 ++++++- debian/changelog | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apt/progress.py b/apt/progress.py index 8ac0e1dc..5169adf7 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -175,7 +175,12 @@ class InstallProgress(DumbInstallProgress): if self.read.endswith("\n"): s = self.read #print s - (status, pkg, percent, status_str) = string.split(s, ":") + try: + (status, pkg, percent, status_str) = string.split(s, ":",3) + except ValueError, e: + # silently ignore lines that can't be parsed + self.read = "" + return #print "percent: %s %s" % (pkg, float(percent)/100.0) if status == "pmerror": self.error(pkg,status_str) diff --git a/debian/changelog b/debian/changelog index 0dfa9381..9451428c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ python-apt (0.6.21) unstable; urgency=low instead. This fixes a nasty segfault with python2.5 (lp: 63226) * debian/rules: Remove dh_python call. + * protect against not-parsable strings send from dpkg (lp: 68553) -- -- cgit v1.2.3 From 3c393390f10b5ecfb3891fb89f199e2610d9246e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Dec 2006 11:46:28 +0100 Subject: * python/pkgrecords.cc: - export SHA1Sum() as well * debian/changelog: - updated --- debian/changelog | 9 ++++++--- python/pkgrecords.cc | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9451428c..6b52ff44 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,13 +1,16 @@ -python-apt (0.6.21) unstable; urgency=low +python-apt (0.6.21) UNRELEASED; urgency=low * python/generic.h: - fix incorrect use of PyMem_DEL(), use pyObject_DEL() instead. This fixes a nasty segfault with python2.5 (lp: 63226) + * python/pkgrecords.cc: + - export SHA1Hash() as well * debian/rules: Remove dh_python call. - * protect against not-parsable strings send from dpkg (lp: 68553) + * apt/progress.cc: + - protect against not-parsable strings send from dpkg (lp: 68553) - -- + -- Michael Vogt Tue, 19 Dec 2006 11:34:59 +0100 python-apt (0.6.20) unstable; urgency=low diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc index ec78f554..4a5556f2 100644 --- a/python/pkgrecords.cc +++ b/python/pkgrecords.cc @@ -63,6 +63,8 @@ static PyObject *PkgRecordsAttr(PyObject *Self,char *Name) return CppPyString(Struct.Last->FileName()); else if (strcmp("MD5Hash",Name) == 0) return CppPyString(Struct.Last->MD5Hash()); + else if (strcmp("SHA1Hash",Name) == 0) + return CppPyString(Struct.Last->SHA1Hash()); else if (strcmp("SourcePkg",Name) == 0) return CppPyString(Struct.Last->SourcePkg()); else if (strcmp("Maintainer",Name) == 0) -- cgit v1.2.3 From d27f389612249dcfb8b979d8487c39514dd6350b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Dec 2006 13:32:31 +0100 Subject: * debian/changelog: - updated changelog --- debian/changelog | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6b52ff44..8104a4fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.6.21) UNRELEASED; urgency=low +python-apt (0.6.20) UNRELEASED; urgency=low * python/generic.h: - fix incorrect use of PyMem_DEL(), use pyObject_DEL() @@ -9,11 +9,6 @@ python-apt (0.6.21) UNRELEASED; urgency=low * debian/rules: Remove dh_python call. * apt/progress.cc: - protect against not-parsable strings send from dpkg (lp: 68553) - - -- Michael Vogt Tue, 19 Dec 2006 11:34:59 +0100 - -python-apt (0.6.20) unstable; urgency=low - * python/pkgmanager.cc: - fix typo (closes: #382853) * debian/control: @@ -29,7 +24,7 @@ python-apt (0.6.20) unstable; urgency=low * python/progress.cc: - fix memleak (lp: #43096) - -- Michael Vogt Mon, 2 Oct 2006 17:29:49 +0200 + -- Michael Vogt Tue, 19 Dec 2006 13:32:11 +0100 python-apt (0.6.19) unstable; urgency=low -- cgit v1.2.3 From a775bc53771d2c0665205fbec407014eea239682 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Dec 2006 13:32:53 +0100 Subject: * debian/changelog: - and upload --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 8104a4fb..79e6d078 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.6.20) UNRELEASED; urgency=low +python-apt (0.6.20) unstable; urgency=low * python/generic.h: - fix incorrect use of PyMem_DEL(), use pyObject_DEL() -- cgit v1.2.3 From e2b1181b6600d5dfb1f5e1ebd31d89ee9229db8c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 6 Feb 2007 14:40:45 +0100 Subject: * better cdrom support merged --- apt/__init__.py | 1 + apt/cdrom.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ apt/progress.py | 2 ++ debian/changelog | 7 +++++++ 4 files changed, 58 insertions(+) create mode 100644 apt/cdrom.py diff --git a/apt/__init__.py b/apt/__init__.py index 15df6990..c6a2ff39 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -7,6 +7,7 @@ import os 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 # init the package system diff --git a/apt/cdrom.py b/apt/cdrom.py new file mode 100644 index 00000000..d499b30a --- /dev/null +++ b/apt/cdrom.py @@ -0,0 +1,48 @@ + +import apt_pkg +from apt.progress import CdromProgress + +class Cdrom(object): + def __init__(self, progress=None, mountpoint=None, nomount=True): + """ Support for apt-cdrom like features. + Options: + - progress: optional progress.CdromProgress() subclass + - mountpoint: optional alternative mountpoint + - nomount: do not mess with mount/umount the CD + """ + self._cdrom = apt_pkg.GetCdrom() + if progress is None: + self._progress = apt.progress.CdromProgress() + else: + self._progress = progress + # see if we have a alternative mountpoint + if mountpoint is not None: + apt_pkg.Config.Set("Acquire::cdrom::mount",mountpoint) + # do not mess with mount points by default + if nomount is True: + apt_pkg.Config.Set("APT::CDROM::NoMount", "true") + else: + apt_pkg.Config.Set("APT::CDROM::NoMount", "false") + def add(self): + " add cdrom to the sources.list " + return self._cdrom.Add(self._progress) + def ident(self): + " identify the cdrom " + (res, ident) = self._cdrom.Ident(self._progress) + if res: + return ident + return None + @property + def inSourcesList(self): + " check if the cdrom is already in the current sources.list " + cdid = self.ident() + if cdid is None: + # FIXME: throw exception instead + return False + # FIXME: check sources.list.d/ as well + for line in open(apt_pkg.Config.FindFile("Dir::Etc::sourcelist")): + line = line.strip() + if not line.startswith("#") and cdid in line: + return True + return False + diff --git a/apt/progress.py b/apt/progress.py index 5169adf7..bb1bce35 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -28,6 +28,8 @@ from errno import * import select import apt_pkg +import apt + class OpProgress(object): """ Abstract class to implement reporting on cache opening Subclass this class to implement simple Operation progress reporting diff --git a/debian/changelog b/debian/changelog index 79e6d078..da487377 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.21) unstable; urgency=low + + * apt/cdrom.py: + - better cdrom handling support + + -- + python-apt (0.6.20) unstable; urgency=low * python/generic.h: -- cgit v1.2.3 From fb94875bd4e108c6d22e05d5312de7ed9f86b057 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 22 Feb 2007 15:31:00 +0100 Subject: * python/string.cc: - SizeToString supports PyLong too --- debian/changelog | 2 ++ python/string.cc | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index da487377..7833dc00 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.6.21) unstable; urgency=low * apt/cdrom.py: - better cdrom handling support + * python/string.cc: + - SizeToString supports PyLong too -- diff --git a/python/string.cc b/python/string.cc index 16adc8cd..d0926da5 100644 --- a/python/string.cc +++ b/python/string.cc @@ -53,9 +53,11 @@ PyObject *StrSizeToStr(PyObject *Self,PyObject *Args) if (PyArg_ParseTuple(Args,"O",&Obj) == 0) return 0; if (PyInt_Check(Obj)) - return CppPyString(SizeToStr(PyInt_AS_LONG(Obj))); + return CppPyString(SizeToStr(PyInt_AsLong(Obj))); + if (PyLong_Check(Obj)) + return CppPyString(SizeToStr(PyLong_AsLong(Obj))); if (PyFloat_Check(Obj)) - return CppPyString(SizeToStr(PyFloat_AS_DOUBLE(Obj))); + return CppPyString(SizeToStr(PyFloat_AsDouble(Obj))); PyErr_SetString(PyExc_TypeError,"Only understand integers and floats"); return 0; -- cgit v1.2.3 From 9f0a976e63fe1f429036d9d6492fbfb06d26eae8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Mar 2007 14:41:14 +0100 Subject: - SizeToString supports PyLong too * apt/cache.py: - fix rootdir --- apt/cache.py | 3 +-- debian/changelog | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index 690510e3..9e682bd8 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -33,11 +33,10 @@ class Cache(object): def __init__(self, progress=None, rootdir=None): self._callbacks = {} - self.open(progress) - if rootdir: apt_pkg.Config.Set("Dir", rootdir) apt_pkg.Config.Set("Dir::State::status", rootdir + "/var/lib/dpkg/status") + self.open(progress) def _runCallbacks(self, name): """ internal helper to run a callback """ diff --git a/debian/changelog b/debian/changelog index 7833dc00..e8d06ebf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,7 +3,9 @@ python-apt (0.6.21) unstable; urgency=low * apt/cdrom.py: - better cdrom handling support * python/string.cc: - - SizeToString supports PyLong too + - SizeToString supports PyLong too + * apt/cache.py: + - fix rootdir -- -- cgit v1.2.3 From 29acfcee494341dca6ab27ea646d99955dd78d14 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 6 Mar 2007 12:28:05 +0100 Subject: * apt/package.py: - added candidateDependencies, installedDependencies --- apt/package.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- debian/changelog | 3 ++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/apt/package.py b/apt/package.py index 0d1145ea..99dbdd9e 100644 --- a/apt/package.py +++ b/apt/package.py @@ -24,6 +24,17 @@ import sys import random import string +class BaseDependency(object): + " a single dependency " + def __init__(self, name, rel, ver, pre): + self.name = name + self.relation = rel + self.version = ver + self.preDepend = pre + +class Dependency(object): + def __init__(self, alternatives): + self.or_dependencies = alternatives class Package(object): """ This class represents a package in the cache @@ -94,6 +105,35 @@ class Package(object): return None candidateVersion = property(candidateVersion) + def _getDependencies(self, ver): + depends_list = [] + depends = ver.DependsList + for t in ["PreDepends", "Depends"]: + if not depends.has_key(t): + continue + for depVerList in depends[t]: + base_deps = [] + for depOr in depVerList: + base_deps.append(BaseDependency(depOr.TargetPkg.Name, depOr.TargetVer, depOr.CompType, (t == "PreDepends"))) + depends_list.append(Dependency(base_deps)) + return depends_list + + @property + def candidateDependencies(self): + """ return a list of candidate dependencies """ + candver = self._depcache.GetCandidateVer(self._pkg) + if candver == None: + return [] + return self._getDependencies(candver) + + @property + def installedDependencies(self): + """ return a list of installed dependencies """ + ver = self._pkg.CurrentVer + if ver == None: + return [] + return self._getDependencies(ver) + def _downloadable(self, useCandidate=True): """ helper, return if the version is downloadable """ if useCandidate: @@ -159,7 +199,11 @@ class Package(object): if not self._lookupRecord(): return "" desc = "" - for line in string.split(self._records.LongDesc, "\n"): + try: + tmp = unicode(self._records.LongDesc) + except UnicodeDecodeError: + tmp = "Invalid unicode in description" + for line in string.split(tmp, "\n"): tmp = string.strip(line) if tmp == ".": desc += "\n" @@ -238,6 +282,8 @@ class Package(object): def installedSize(self): """ The size of the currently installed package """ ver = self._pkg.CurrentVer + if ver is None: + return 0 return ver.InstalledSize installedSize = property(installedSize) @@ -344,6 +390,11 @@ if __name__ == "__main__": print "Description (unformated):\n%s" % pkg.rawDescription print "InstalledSize: %s " % pkg.installedSize print "PackageSize: %s " % pkg.packageSize + print "Dependencies: %s" % pkg.installedDependencies + for dep in pkg.candidateDependencies: + print ",".join(["%s (%s) (%s) (%s)" % (o.name,o.version,o.relation, o.preDepend) for o in dep.or_dependencies]) + + # now test install/remove import apt diff --git a/debian/changelog b/debian/changelog index e8d06ebf..f55793df 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,8 @@ python-apt (0.6.21) unstable; urgency=low * apt/cdrom.py: - better cdrom handling support - * python/string.cc: + * apt/package.py: + - added candidateDependencies, installedDependencies - SizeToString supports PyLong too * apt/cache.py: - fix rootdir -- cgit v1.2.3 From ada1e076e5fb2b022dddb535777493b0db562970 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 6 Mar 2007 16:14:59 +0100 Subject: - support pkg.architecture --- apt/package.py | 17 +++++++++++++---- debian/changelog | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apt/package.py b/apt/package.py index 99dbdd9e..6d54cb22 100644 --- a/apt/package.py +++ b/apt/package.py @@ -118,21 +118,30 @@ class Package(object): depends_list.append(Dependency(base_deps)) return depends_list - @property def candidateDependencies(self): """ return a list of candidate dependencies """ candver = self._depcache.GetCandidateVer(self._pkg) if candver == None: return [] return self._getDependencies(candver) + candidateDependencies = property(candidateDependencies) - @property def installedDependencies(self): """ return a list of installed dependencies """ ver = self._pkg.CurrentVer if ver == None: return [] return self._getDependencies(ver) + installedDependencies = property(installedDependencies) + + def architecture(self): + if not self._lookupRecord(): + return None + sec = apt_pkg.ParseSection(self._records.Record) + if sec.has_key("Architecture"): + return sec["Architecture"] + return None + architecture = property(architecture) def _downloadable(self, useCandidate=True): """ helper, return if the version is downloadable """ @@ -393,8 +402,8 @@ if __name__ == "__main__": print "Dependencies: %s" % pkg.installedDependencies for dep in pkg.candidateDependencies: print ",".join(["%s (%s) (%s) (%s)" % (o.name,o.version,o.relation, o.preDepend) for o in dep.or_dependencies]) - - + print "arch: %s" % pkg.architecture + # now test install/remove import apt diff --git a/debian/changelog b/debian/changelog index f55793df..9e76a9e8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ python-apt (0.6.21) unstable; urgency=low * apt/package.py: - added candidateDependencies, installedDependencies - SizeToString supports PyLong too + - support pkg.architecture * apt/cache.py: - fix rootdir -- cgit v1.2.3 From 8205cc8ecaae7c60d688498d5d2d1d415879c58c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 6 Mar 2007 16:22:13 +0100 Subject: - support candidateRecord, installedRecord --- apt/package.py | 15 ++++++++++++++- debian/changelog | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apt/package.py b/apt/package.py index 6d54cb22..13481be3 100644 --- a/apt/package.py +++ b/apt/package.py @@ -228,6 +228,19 @@ class Package(object): return self._records.LongDesc rawDescription = property(rawDescription) + def candidateRecord(self): + " return the full pkgrecord as string of the candidate version " + if not self._lookupRecord(True): + return None + return self._records.Record + candidateRecord = property(candidateRecord) + + def installedRecord(self): + " return the full pkgrecord as string of the installed version " + if not self._lookupRecord(False): + return None + return self._records.Record + installedRecord = property(installedRecord) # depcache states def markedInstall(self): @@ -403,7 +416,7 @@ if __name__ == "__main__": for dep in pkg.candidateDependencies: print ",".join(["%s (%s) (%s) (%s)" % (o.name,o.version,o.relation, o.preDepend) for o in dep.or_dependencies]) print "arch: %s" % pkg.architecture - + print "rec: ",pkg.candidateRecord # now test install/remove import apt diff --git a/debian/changelog b/debian/changelog index 9e76a9e8..3ac73a8e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ python-apt (0.6.21) unstable; urgency=low - added candidateDependencies, installedDependencies - SizeToString supports PyLong too - support pkg.architecture + - support candidateRecord, installedRecord * apt/cache.py: - fix rootdir -- cgit v1.2.3 From 6b02ff1915b3dcd098474e1b9ccd5f89d6b777da Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 7 Mar 2007 11:07:56 +0100 Subject: * apt/cdrom.py: - fix bug in cdrom mountpoint handling --- apt/cdrom.py | 4 ++-- debian/changelog | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apt/cdrom.py b/apt/cdrom.py index d499b30a..8d73339c 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -1,6 +1,6 @@ import apt_pkg -from apt.progress import CdromProgress +from progress import CdromProgress class Cdrom(object): def __init__(self, progress=None, mountpoint=None, nomount=True): @@ -12,7 +12,7 @@ class Cdrom(object): """ self._cdrom = apt_pkg.GetCdrom() if progress is None: - self._progress = apt.progress.CdromProgress() + self._progress = CdromProgress() else: self._progress = progress # see if we have a alternative mountpoint diff --git a/debian/changelog b/debian/changelog index 3ac73a8e..cab337f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ python-apt (0.6.21) unstable; urgency=low - support candidateRecord, installedRecord * apt/cache.py: - fix rootdir + * apt/cdrom.py: + - fix bug in cdrom mountpoint handling -- -- cgit v1.2.3 From b9128440279784a5f6d9bd8a4b67c497f5696823 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 24 Apr 2007 21:38:29 +0200 Subject: * debian/changelog: sync with debian upload --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index cab337f6..eabbc931 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,7 +12,7 @@ python-apt (0.6.21) unstable; urgency=low * apt/cdrom.py: - fix bug in cdrom mountpoint handling - -- + -- Michael Vogt Tue, 24 Apr 2007 21:24:28 +0200 python-apt (0.6.20) unstable; urgency=low -- cgit v1.2.3 From cccfb88edd8dd82348ff89f96a0b26ac815b483c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 25 Apr 2007 16:17:01 +0200 Subject: * python/apt_pkgmodule.cc: - added pkgCache::State::PkgCurrentState enums --- debian/changelog | 7 +++++++ python/apt_pkgmodule.cc | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/debian/changelog b/debian/changelog index eabbc931..75725676 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.22) unstable; urgency=low + + * python/apt_pkgmodule.cc: + - added pkgCache::State::PkgCurrentState enums + + -- + python-apt (0.6.21) unstable; urgency=low * apt/cdrom.py: diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 24d876af..627eaced 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -502,6 +502,12 @@ extern "C" void initapt_pkg() AddInt(Dict,"PriOptional",pkgCache::State::Optional); AddInt(Dict,"PriExtra",pkgCache::State::Extra); + AddInt(Dict,"CurStateNotInstalled",pkgCache::State::NotInstalled); + AddInt(Dict,"CurStateUnPacked",pkgCache::State::UnPacked); + AddInt(Dict,"CurStateHalfConfigured",pkgCache::State::HalfConfigured); + AddInt(Dict,"CurStateHalfInstalled",pkgCache::State::HalfInstalled); + AddInt(Dict,"CurStateConfigFiles",pkgCache::State::ConfigFiles); + AddInt(Dict,"CurStateInstalled",pkgCache::State::Installed); } /*}}}*/ -- cgit v1.2.3