summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-07-27 15:00:12 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-07-27 15:00:12 +0200
commitaf398fcce8671bc864e4300c1b0bbeb07ab95aaf (patch)
treee89efbe87083941ab7a220c3a9a93f0e9f6df05c
parent0b081c5451d6394618290cd9a5767d767d98b819 (diff)
parent8d79b99c1a3338e31e8def858cee3209824ae8bf (diff)
downloadpython-apt-af398fcce8671bc864e4300c1b0bbeb07ab95aaf.tar.gz
* merged with mainline
-rw-r--r--apt/cache.py8
-rw-r--r--apt/package.py8
-rw-r--r--debian/changelog70
-rw-r--r--debian/control24
-rw-r--r--debian/examples1
-rwxr-xr-xdebian/rules25
-rw-r--r--doc/examples/all_deps.py34
-rw-r--r--doc/examples/indexfile.py1
-rwxr-xr-xdoc/examples/print_uris.py22
-rw-r--r--doc/examples/sources.py4
-rw-r--r--python/apt_pkgmodule.cc39
-rw-r--r--python/indexfile.cc20
-rw-r--r--python/pkgsrcrecords.cc4
13 files changed, 215 insertions, 45 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 01034cf9..690510e3 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -31,10 +31,14 @@ class Cache(object):
dictionary
"""
- def __init__(self, progress=None):
+ 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")
+
def _runCallbacks(self, name):
""" internal helper to run a callback """
if self._callbacks.has_key(name):
@@ -218,7 +222,7 @@ class Cache(object):
def connect(self, name, callback):
""" connect to a signal, currently only used for
- cache_{post,pre}_changed """
+ cache_{post,pre}_{changed,open} """
if not self._callbacks.has_key(name):
self._callbacks[name] = []
self._callbacks[name].append(callback)
diff --git a/apt/package.py b/apt/package.py
index dfb74789..c870c325 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -293,10 +293,12 @@ class Package(object):
Fix.InstallProtect()
Fix.Resolve()
self._pcache.cachePostChange()
- def markInstall(self, autoFix=True):
- """ mark a package for install. Run the resolver if autoFix is set """
+ def markInstall(self, autoFix=True, autoInst=True):
+ """ mark a package for install. Run the resolver if autoFix is set,
+ automatically install required dependencies if autoInst is set
+ """
self._pcache.cachePreChange()
- self._depcache.MarkInstall(self._pkg)
+ self._depcache.MarkInstall(self._pkg, autoInst)
# try to fix broken stuff
if autoFix and self._depcache.BrokenCount > 0:
fixer = apt_pkg.GetPkgProblemResolver(self._depcache)
diff --git a/debian/changelog b/debian/changelog
index ad6bc8d8..467341a2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,64 @@
+=======
+python-apt (0.6.19) unstable; urgency=low
+
+ [ Michael Vogt ]
+ * doc/examples/print_uris.py:
+ - added a example to show how the indexfile.ArchiveURI() can be used
+ with binary packages
+ * python/apt_pkgmodule.cc:
+ - export sha256 generation
+
+ [ Otavio Salvador ]
+ * apt/cache.py:
+ - fix commit doc string to also cite the open related callbacks
+ - allow change of rootdir for APT database loading
+ - add dh_installexamples in package building Closes: #376014
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Wed, 26 Jul 2006 18:51:56 +0200
+
+python-apt (0.6.18-0.2) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * Add ${shlibs:Depends} and ${misc:Depends} (Closes: #377615).
+
+ -- Christoph Berg <myon@debian.org> Tue, 18 Jul 2006 11:39:52 +0200
+
+python-apt (0.6.18-0.1) unstable; urgency=high
+
+ * Non-maintainer upload.
+ * Call dh_pycentral and dh_python before dh_installdeb, to make sure
+ the dh_pycentral snippets are put into the maintainer scripts; patch from
+ Sam Morris. (Closes: #376416)
+
+ -- Steinar H. Gunderson <sesse@debian.org> Wed, 12 Jul 2006 23:26:50 +0200
+
+python-apt (0.6.18) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * Update for the new Python policy. Closes: #373512
+
+ -- Raphael Hertzog <hertzog@debian.org> Sat, 17 Jun 2006 15:09:28 +0200
+
+python-apt (0.6.17) unstable; urgency=low
+
+ * apt/cache.py:
+ - return useful values on Cache.update()
+ - Release locks on failure (thanks to Colin Watson)
+ - fix various pychecker warnings
+ * apt/package.py:
+ - fix various pychecker warnings
+ - check if looupRecords succeeded
+ - fix bug in the return statement of _downloadable()
+ * python/srcrecords.cc:
+ - add "Restart" method
+ - don't run auto "Restart" before performing a Lookup
+ - fix the initalization (no need to pass a PkgCacheType to the records)
+ - added "Index" attribute
+ * python/indexfile.cc:
+ - added ArchiveURI() method
+
+ -- Michael Vogt <mvo@debian.org> Mon, 8 May 2006 22:34:58 +0200
+
python-apt (0.6.16.2ubuntu9) edgy; urgency=low
* rebuild against the latest apt (with auto-mark support)
@@ -75,6 +136,15 @@ python-apt (0.6.16.2ubuntu1) dapper; urgency=low
-- Michael Vogt <michael.vogt@ubuntu.com> Tue, 28 Feb 2006 12:04:37 +0100
+python-apt (0.6.16.2) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * debian/control:
+ + Replaces: python-apt (<< 0.6.11), instead of Conflicts which is not
+ correct here. (closes: #308586).
+
+ -- Pierre Habouzit <madcoder@debian.org> Fri, 14 Apr 2006 19:30:51 +0200
+
python-apt (0.6.16.1) unstable; urgency=low
* typos fixed (thanks to Gustavo Franco)
diff --git a/debian/control b/debian/control
index 4f5f3019..c057feed 100644
--- a/debian/control
+++ b/debian/control
@@ -4,27 +4,17 @@ Priority: optional
Maintainer: APT Development Team <deity@lists.debian.org>
Uploaders: Matt Zimmerman <mdz@debian.org>, Michael Vogt <mvo@debian.org>
Standards-Version: 3.6.2.0
-Build-Depends: debhelper (>= 5.0), libapt-pkg-dev (>= 0.6.44.2), apt-utils, python-dev, python2.4-dev
+XS-Python-Version: all
+Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.6.44.2), apt-utils, python-all-dev, python-central
Package: python-apt
-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
- 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}
-Replaces: python-apt (<< 0.6.11)
+Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}
Priority: optional
+Replaces: python2.3-apt (<< 0.6.18), python2.4-apt (<< 0.6.18)
+Conflicts: python2.3-apt (<< 0.6.18), python2.4-apt (<< 0.6.18)
+Provides: ${python:Provides}
+XB-Python-Version: ${python:Versions}
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
diff --git a/debian/examples b/debian/examples
new file mode 100644
index 00000000..80a386c8
--- /dev/null
+++ b/debian/examples
@@ -0,0 +1 @@
+doc/examples/*.py
diff --git a/debian/rules b/debian/rules
index c71baf08..ee159b89 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,8 +12,7 @@ DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-PYTHON=python2.3 python2.4
-PYTHON=python2.4
+PYTHON=$(shell pyversions -r debian/control)
build: build-stamp
build-stamp:
@@ -39,18 +38,6 @@ clean:
# Build architecture-independent files here.
binary-indep: DH_OPTIONS=-i
binary-indep: build
- 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
@@ -58,19 +45,21 @@ binary-arch: build
dh_testdir
dh_testroot
dh_clean -k
-
+
for PY in $(PYTHON); do \
- /usr/bin/$$PY setup.py install --prefix=`pwd`/debian/$${PY}-apt/usr; \
+ /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
dh_installdeb
dh_shlibdeps
- dh_python
dh_gencontrol
dh_md5sums
dh_builddeb
diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py
new file mode 100644
index 00000000..f4f1741c
--- /dev/null
+++ b/doc/examples/all_deps.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import sys
+import apt
+
+
+def dependencies(cache, pkg, deps, key="Depends"):
+ #print "pkg: %s (%s)" % (pkg.name, deps)
+ candver = cache._depcache.GetCandidateVer(pkg._pkg)
+ if candver == None:
+ return deps
+ dependslist = candver.DependsList
+ if dependslist.has_key(key):
+ for depVerList in dependslist[key]:
+ for dep in depVerList:
+ if cache.has_key(dep.TargetPkg.Name):
+ if pkg.name != dep.TargetPkg.Name and not dep.TargetPkg.Name in deps:
+ deps.add(dep.TargetPkg.Name)
+ dependencies(cache, cache[dep.TargetPkg.Name], deps, key)
+ return deps
+
+
+pkgname = sys.argv[1]
+c = apt.Cache()
+pkg = c[pkgname]
+
+deps = set()
+
+deps = dependencies(c,pkg, deps, "Depends")
+print " ".join(deps)
+
+preDeps = set()
+preDeps = dependencies(c,pkg, preDeps, "PreDepends")
+print " ".join(preDeps)
diff --git a/doc/examples/indexfile.py b/doc/examples/indexfile.py
index 5eaab517..d383fd61 100644
--- a/doc/examples/indexfile.py
+++ b/doc/examples/indexfile.py
@@ -18,3 +18,4 @@ for (f,i) in cand.FileList:
print index.IsTrusted
print index.Exists
print index.HasPackages
+ print index.ArchiveURI("some/path")
diff --git a/doc/examples/print_uris.py b/doc/examples/print_uris.py
new file mode 100755
index 00000000..c8a64223
--- /dev/null
+++ b/doc/examples/print_uris.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+#
+# a example that prints the URIs of all upgradable packages
+#
+
+import apt
+import apt_pkg
+
+
+cache = apt.Cache()
+upgradable = filter(lambda p: p.isUpgradable, cache)
+
+
+for pkg in upgradable:
+ pkg._lookupRecord(True)
+ path = apt_pkg.ParseSection(pkg._records.Record)["Filename"]
+ cand = pkg._depcache.GetCandidateVer(pkg._pkg)
+ for (packagefile,i) in cand.FileList:
+ indexfile = cache._list.FindIndex(packagefile)
+ if indexfile:
+ uri = indexfile.ArchiveURI(path)
+ print uri
diff --git a/doc/examples/sources.py b/doc/examples/sources.py
index 0a90bae9..c12c6f15 100644
--- a/doc/examples/sources.py
+++ b/doc/examples/sources.py
@@ -11,5 +11,5 @@ sources = apt_pkg.GetPkgSrcRecords()
sources.Restart()
while sources.Lookup('hello'):
print sources.Package, sources.Version, sources.Maintainer, sources.Section, `sources.Binaries`
- #print sources.Files
-
+ print sources.Files
+ print sources.Index.ArchiveURI("")
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index e73628c3..b1c5c2a5 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -19,6 +19,7 @@
#include <apt-pkg/tagfile.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha256.h>
#include <apt-pkg/init.h>
#include <apt-pkg/pkgsystem.h>
@@ -236,6 +237,43 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args)
return 0;
}
/*}}}*/
+// sha256sum - Compute the sha1sum of a file or string /*{{{*/
+// ---------------------------------------------------------------------
+static char *doc_sha256sum = "sha256sum(String) -> String or sha256sum(File) -> String";
+static PyObject *sha256sum(PyObject *Self,PyObject *Args)
+{
+ PyObject *Obj;
+ if (PyArg_ParseTuple(Args,"O",&Obj) == 0)
+ return 0;
+
+ // Digest of a string.
+ if (PyString_Check(Obj) != 0)
+ {
+ SHA256Summation Sum;
+ Sum.Add(PyString_AsString(Obj));
+ return CppPyString(Sum.Result().Value());
+ }
+
+ // Digest of a file
+ if (PyFile_Check(Obj) != 0)
+ {
+ SHA256Summation Sum;
+ int Fd = fileno(PyFile_AsFile(Obj));
+ struct stat St;
+ if (fstat(Fd,&St) != 0 ||
+ Sum.AddFD(Fd,St.st_size) == false)
+ {
+ PyErr_SetFromErrno(PyExc_SystemError);
+ return 0;
+ }
+
+ return CppPyString(Sum.Result().Value());
+ }
+
+ PyErr_SetString(PyExc_TypeError,"Only understand strings and files");
+ return 0;
+}
+ /*}}}*/
// init - 3 init functions /*{{{*/
// ---------------------------------------------------------------------
static char *doc_Init =
@@ -370,6 +408,7 @@ static PyMethodDef methods[] =
// Stuff
{"md5sum",md5sum,METH_VARARGS,doc_md5sum},
{"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum},
+ {"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum},
// Strings
{"CheckDomainList",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"},
diff --git a/python/indexfile.cc b/python/indexfile.cc
index 4e106e25..ef6ffc8a 100644
--- a/python/indexfile.cc
+++ b/python/indexfile.cc
@@ -15,6 +15,22 @@
#include <Python.h>
+static PyObject *PackageIndexFileArchiveURI(PyObject *Self,PyObject *Args)
+{
+ pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self);
+ char *path;
+
+ if (PyArg_ParseTuple(Args, "s",&path) == 0)
+ return 0;
+
+ return HandleErrors(Safe_FromString(File->ArchiveURI(path).c_str()));
+}
+
+static PyMethodDef PackageIndexFileMethods[] =
+{
+ {"ArchiveURI",PackageIndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"},
+ {}
+};
static PyObject *PackageIndexFileAttr(PyObject *Self,char *Name)
@@ -33,8 +49,7 @@ static PyObject *PackageIndexFileAttr(PyObject *Self,char *Name)
else if (strcmp("IsTrusted",Name) == 0)
return Py_BuildValue("i",(File->IsTrusted()));
- PyErr_SetString(PyExc_AttributeError,Name);
- return 0;
+ return Py_FindMethod(PackageIndexFileMethods,Self,Name);
}
static PyObject *PackageIndexFileRepr(PyObject *Self)
@@ -51,6 +66,7 @@ static PyObject *PackageIndexFileRepr(PyObject *Self)
File->IsTrusted(), File->ArchiveURI("").c_str());
return PyString_FromString(S);
}
+
PyTypeObject PackageIndexFileType =
{
PyObject_HEAD_INIT(&PyType_Type)
diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc
index abb29c74..5e04f5fc 100644
--- a/python/pkgsrcrecords.cc
+++ b/python/pkgsrcrecords.cc
@@ -96,8 +96,10 @@ static PyObject *PkgSrcRecordsAttr(PyObject *Self,char *Name)
*b != 0;
++b)
PyList_Append(List, CppPyString(*b));
-
return List; // todo
+ } else if (strcmp("Index",Name) == 0) {
+ const pkgIndexFile &tmp = Struct.Last->Index();
+ return CppOwnedPyObject_NEW<pkgIndexFile*>(Self,&PackageIndexFileType, (pkgIndexFile*)&tmp);
} else if (strcmp("Files",Name) == 0) {
PyObject *List = PyList_New(0);