From 52ecc81517a1fa9748d04f0c0d05ce8396233b71 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 3 May 2005 16:25:44 +0000 Subject: * merged with Greek0@gmx.net--2005-main, native apt interface added, fixed a refcount problem, added tests/ directory * apt/package.py, apt/__init__.py: - started a native python interface that will wrap the uglier bits of python-apt in the future * tests/pkgsrcrecords.py: - started a test directory * python/pkgsrcrecords.cc: - fixed a refcount problem - merged with Greek0s tree Patches applied: * Greek0@gmx.net--2005-main/python-apt--debian--0.6--base-0 tag of apt@packages.debian.org/python-apt--main--0--patch-8 * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-1 Minor typo fix in debian/rules * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-2 Typo fix in depcache.cc which caused wrong function to be called * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-3 Improved CppPyObject, leading to a better PkgDepCacheStruct * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-4 Improved build system * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-5 Restored the old tar.cc to work with the older apt in debian again * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-6 Fix for Debian #304296 (Segfault in CppOwnedDealloc) * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-7 Fix for Debian #304903 (FD leak) * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-8 Fixed the compilation error introduced in patch-6 * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-9 New debian/changelog from Debians python-apt 0.6.10 * Greek0@gmx.net--2005-main/python-apt--debian--0.6--patch-10 Minor changes to make the packages lintian/linda clean * apt@packages.debian.org/python-apt--main--0--patch-8 Merge michael.vogt@ubuntu.com--2005/python-apt--pkgDepCache--0 --- debian/changelog | 7 ++++++- debian/control | 24 ++++++++++++++++----- debian/rules | 56 ++++++++++++++++++++++++++++--------------------- python/depcache.cc | 6 +----- python/generic.h | 11 ++++++++++ python/pkgsrcrecords.cc | 13 ++++++++++-- python/sourcelist.cc | 4 ++-- setup.py | 11 +++++----- tests/pkgsrcrecords.py | 25 ++++++++++++++++++++++ 9 files changed, 113 insertions(+), 44 deletions(-) create mode 100644 tests/pkgsrcrecords.py diff --git a/debian/changelog b/debian/changelog index f8593cda..efaf9405 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,12 @@ -python-apt (0.5.36ubuntu3) hoary; urgency=low +python-apt (0.5.37) hoary; urgency=low * fixed some reference count problems in the depcache code * DepCache.Init() is never called implicit now + * merged with Greek0@gmx.net--2005-main/python-apt--debian--0.6 + that fixes a segfault in the pkgsrcrecords code + * added a tests/ directory + * added tests/pkgsrcrecords.py that will check if the pkgsrcrecords + interface does not segfault -- Michael Vogt Thu, 7 Apr 2005 10:20:30 +0200 diff --git a/debian/control b/debian/control index 1d3e1314..99e15296 100644 --- a/debian/control +++ b/debian/control @@ -3,12 +3,12 @@ Section: python Priority: optional Maintainer: APT Development Team Uploaders: Matt Zimmerman -Standards-Version: 3.1.1 -Build-Depends: debhelper (>= 4.2.28), libapt-pkg-dev (>= 0.5.32), apt-utils, python, python-dev (>= 2.4), python2.3-dev +Standards-Version: 3.6.1.1 +Build-Depends: debhelper (>= 4.2.28), libapt-pkg-dev (>= 0.6.35), apt-utils, python-dev (>= 2.4), python2.4-dev, python2.3-dev Package: python-apt -Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends} +Architecture: all +Depends: ${python:Depends} Priority: optional Description: Python interface to libapt-pkg The apt-pkg Python interface will provide full access to the internal @@ -22,7 +22,21 @@ Description: Python interface to libapt-pkg Package: python2.3-apt Architecture: any -Depends: ${python:Depends}, ${shlibs:Depends} +Depends: python2.3, ${shlibs:Depends} +Priority: optional +Description: Python interface to libapt-pkg + 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, such as: + . + - Access to the APT configuration system + - Access to the APT package information database + - Parsing of Debian package control files, and other files with a + similar structure + +Package: python2.4-apt +Architecture: any +Depends: python2.4, ${shlibs:Depends} Priority: optional Description: Python interface to libapt-pkg The apt-pkg Python interface will provide full access to the internal diff --git a/debian/rules b/debian/rules index 8180834a..16d26380 100755 --- a/debian/rules +++ b/debian/rules @@ -1,59 +1,68 @@ #!/usr/bin/make -f -# MAde with the aid of dh_make, by Craig Small +# Made with the aid of dh_make, by Craig Small # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Cristoph Lameter. +# This has to be exported to make some magic below work. +export DH_OPTIONS + +# This is the debhelper compatibility version to use. +export DH_COMPAT=3 + # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -PYTHON=/usr/bin/python2.4 - -DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p') -DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS) +PYTHON=python2.3 python2.4 build: build-stamp build-stamp: dh_testdir - $(PYTHON) setup.py build + for PY in $(PYTHON); do \ + /usr/bin/$$PY setup.py build; \ + done touch build-stamp clean: dh_testdir dh_testroot - rm -rf build-stamp debian/arch-build + rm -f build-stamp - $(PYTHON) setup.py clean --all - /usr/bin/python2.3 setup.py clean --all + for PY in $(PYTHON); do \ + /usr/bin/$$PY setup.py clean --all; \ + done dh_clean # Build architecture-independent files here. +binary-indep: DH_OPTIONS=-i binary-indep: build -# We have nothing to do by default. + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples doc/examples/*.py + dh_installchangelogs + dh_compress + dh_fixperms + dh_installdeb + dh_python + dh_gencontrol + dh_md5sums + dh_builddeb # Build architecture-dependent files here. +binary-arch: DH_OPTIONS=-a binary-arch: build -# dh_testversion dh_testdir dh_testroot dh_clean -k - $(PYTHON) setup.py install --prefix=`pwd`/debian/tmp/usr - /usr/bin/python2.3 setup.py install --prefix=`pwd`/debian/python2.3-apt/usr + for PY in $(PYTHON); do \ + /usr/bin/$$PY setup.py install --prefix=`pwd`/debian/$${PY}-apt/usr; \ + done dh_installdocs - # Hooks for doc-base. doc-base doesn't support `pdf' yet, - # therefore this is still disabled. - ##XX install -d `pwd`/debian/tmp/usr/share/doc-base - ##XX cp debian/doc-base `pwd`/debian/tmp/usr/share/doc-base/python-ldap - dh_installexamples doc/examples/*.py - dh_installmenu -# dh_installinit - dh_installcron - dh_installmanpages -# dh_undocumented dh_installchangelogs dh_strip dh_compress @@ -62,7 +71,6 @@ binary-arch: build dh_shlibdeps dh_python dh_gencontrol -# dh_makeshlibs dh_md5sums dh_builddeb diff --git a/python/depcache.cc b/python/depcache.cc index ae6da3b9..d2ec4a8d 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -43,9 +43,6 @@ struct PkgDepCacheStruct delete depcache; delete policy; }; - - - PkgDepCacheStruct() {abort();}; }; @@ -439,11 +436,10 @@ static PyMethodDef PkgDepCacheMethods[] = {"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",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for keep"}, + {"MarkedKeep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"}, // Action {"Commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"}, - {} }; diff --git a/python/generic.h b/python/generic.h index bcdf5806..a808e28d 100644 --- a/python/generic.h +++ b/python/generic.h @@ -33,6 +33,17 @@ template struct CppPyObject : public PyObject { + // We are only using CppPyObject and friends as dumb structs only, ie the + // c'tor is never called. + // 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 + // 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() { }; T Object; }; diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc index fb66284a..8eb9e5f3 100644 --- a/python/pkgsrcrecords.cc +++ b/python/pkgsrcrecords.cc @@ -26,6 +26,9 @@ struct PkgSrcRecordsStruct List.ReadMainList(); Records = new pkgSrcRecords(List); }; + ~PkgSrcRecordsStruct() { + delete Records; + }; }; // PkgSrcRecords Class /*{{{*/ @@ -43,7 +46,8 @@ static PyObject *PkgSrcRecordsLookup(PyObject *Self,PyObject *Args) Struct.Last = Struct.Records->Find(Name, false); if (Struct.Last == 0) { Struct.Records->Restart(); - return Py_None; + Py_INCREF(Py_None); + return HandleErrors(Py_None); } return Py_BuildValue("i", 1); @@ -124,6 +128,11 @@ PyTypeObject PkgSrcRecordsType = PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args) { - return CppPyObject_NEW(&PkgSrcRecordsType); + PyObject *Owner; + if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0) + return 0; + + return HandleErrors(CppOwnedPyObject_NEW(Owner, + &PkgSrcRecordsType)); } diff --git a/python/sourcelist.cc b/python/sourcelist.cc index 6f039244..e2343e1c 100644 --- a/python/sourcelist.cc +++ b/python/sourcelist.cc @@ -56,10 +56,10 @@ PyTypeObject PkgSourceListType = PyObject_HEAD_INIT(&PyType_Type) 0, // ob_size "pkgSourceList", // tp_name - sizeof(CppOwnedPyObject), // tp_basicsize + sizeof(CppPyObject), // tp_basicsize 0, // tp_itemsize // Methods - CppOwnedDealloc, // tp_dealloc + CppDealloc, // tp_dealloc 0, // tp_print PkgSourceListAttr, // tp_getattr 0, // tp_setattr diff --git a/setup.py b/setup.py index 64b5db34..fe970825 100644 --- a/setup.py +++ b/setup.py @@ -3,8 +3,7 @@ from distutils.core import setup, Extension from distutils.sysconfig import parse_makefile -import string; - +import string, glob # The apt_pkg module files = string.split(parse_makefile("python/makefile")["APT_PKG_SRC"]); @@ -19,11 +18,13 @@ for i in range(0,len(files)): files[i] = "python/"+ files[i]; apt_inst = Extension("apt_inst", files, libraries=["apt-pkg","apt-inst"]); - + setup(name="python-apt", - version="0.5.4", + version="0.5.37", description="Python bindings for APT", author="APT Development Team", author_email="deity@lists.debian.org", - ext_modules=[apt_pkg,apt_inst]) + ext_modules=[apt_pkg,apt_inst], + packages=['apt'] + ) diff --git a/tests/pkgsrcrecords.py b/tests/pkgsrcrecords.py new file mode 100644 index 00000000..dc4881dd --- /dev/null +++ b/tests/pkgsrcrecords.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python2.4 +# +# Test for the PkgSrcRecords code +# it segfaults for python-apt < 0.5.37 +# + +import apt_pkg +import sys + +def main(): + apt_pkg.init() + cache = apt_pkg.GetCache() + i=0 + print "Running PkgSrcRecords test on all packages:" + for x in cache.Packages: + i += 1 + src = apt_pkg.GetPkgSrcRecords(cache) + if src.Lookup(x.Name): + #print src.Package + pass + print "\r%i/%i=%.3f%% " % (i,cache.PackageCount, (float(i)/float(cache.PackageCount)*100)), + +if __name__ == "__main__": + main() + sys.exit(0) -- cgit v1.2.3