summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-08-14 14:58:25 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-08-14 14:58:25 +0200
commitc1ad8a0fbc0adfebdb847f28da92b3d5a1f90582 (patch)
tree80225148a1c1d0d4283fb76e827c6ccc9ca206bf /doc
parentc736d5c9290a2ffdb8802a4ac62e521cf1218b54 (diff)
parentdfd6bacface878eecf3fec4876bdae2f0491a646 (diff)
downloadpython-apt-c1ad8a0fbc0adfebdb847f28da92b3d5a1f90582.tar.gz
merged from the debian-sid tree
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/examples/build-deps-old.py73
-rwxr-xr-xdoc/examples/build-deps.py55
-rw-r--r--doc/source/library/apt_inst.rst6
-rw-r--r--doc/source/library/apt_pkg.rst8
4 files changed, 101 insertions, 41 deletions
diff --git a/doc/examples/build-deps-old.py b/doc/examples/build-deps-old.py
new file mode 100755
index 00000000..656f1361
--- /dev/null
+++ b/doc/examples/build-deps-old.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+# this is a example how to access the build dependencies of a package
+
+import apt_pkg
+import sys
+
+
+def get_source_pkg(pkg, records, depcache):
+ """ get the source package name of a given package """
+ version = depcache.GetCandidateVer(pkg)
+ if not version:
+ return None
+ file, index = version.FileList.pop(0)
+ records.Lookup((file, index))
+ if records.SourcePkg != "":
+ srcpkg = records.SourcePkg
+ else:
+ srcpkg = pkg.Name
+ return srcpkg
+
+
+# main
+apt_pkg.init()
+cache = apt_pkg.Cache()
+depcache = apt_pkg.DepCache(cache)
+depcache.Init()
+records = apt_pkg.PackageRecords(cache)
+srcrecords = apt_pkg.SourceRecords()
+
+# base package that we use for build-depends calculation
+if len(sys.argv) < 2:
+ print "need a package name as argument"
+ sys.exit(1)
+try:
+ pkg = base = cache[sys.argv[1]]
+except KeyError:
+ print "No package %s found" % sys.argv[1]
+ sys.exit(1)
+all_build_depends = set()
+
+# get the build depdends for the package itself
+srcpkg_name = get_source_pkg(base, records, depcache)
+print "srcpkg_name: %s " % srcpkg_name
+if not srcpkg_name:
+ print "Can't find source package for '%s'" % pkg.Name
+srcrec = srcrecords.Lookup(srcpkg_name)
+if srcrec:
+ print "Files:"
+ print srcrecords.Files
+ bd = srcrecords.BuildDepends
+ print "build-depends of the package: %s " % bd
+ for b in bd:
+ all_build_depends.add(b[0])
+
+# calculate the build depends for all dependencies
+depends = depcache.GetCandidateVer(base).DependsList
+for dep in depends["Depends"]: # FIXME: do we need to consider PreDepends?
+ pkg = dep[0].TargetPkg
+ srcpkg_name = get_source_pkg(pkg, records, depcache)
+ if not srcpkg_name:
+ print "Can't find source package for '%s'" % pkg.Name
+ continue
+ srcrec = srcrecords.Lookup(srcpkg_name)
+ if srcrec:
+ #print srcrecords.Package
+ #print srcrecords.Binaries
+ bd = srcrecords.BuildDepends
+ #print "%s: %s " % (srcpkg_name, bd)
+ for b in bd:
+ all_build_depends.add(b[0])
+
+
+print "\n".join(all_build_depends)
diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py
index 656f1361..5d243943 100755
--- a/doc/examples/build-deps.py
+++ b/doc/examples/build-deps.py
@@ -1,30 +1,12 @@
#!/usr/bin/python
# this is a example how to access the build dependencies of a package
+import apt
import apt_pkg
import sys
-
-def get_source_pkg(pkg, records, depcache):
- """ get the source package name of a given package """
- version = depcache.GetCandidateVer(pkg)
- if not version:
- return None
- file, index = version.FileList.pop(0)
- records.Lookup((file, index))
- if records.SourcePkg != "":
- srcpkg = records.SourcePkg
- else:
- srcpkg = pkg.Name
- return srcpkg
-
-
# main
-apt_pkg.init()
-cache = apt_pkg.Cache()
-depcache = apt_pkg.DepCache(cache)
-depcache.Init()
-records = apt_pkg.PackageRecords(cache)
+cache = apt.Cache()
srcrecords = apt_pkg.SourceRecords()
# base package that we use for build-depends calculation
@@ -39,7 +21,7 @@ except KeyError:
all_build_depends = set()
# get the build depdends for the package itself
-srcpkg_name = get_source_pkg(base, records, depcache)
+srcpkg_name = base.candidate.source_name
print "srcpkg_name: %s " % srcpkg_name
if not srcpkg_name:
print "Can't find source package for '%s'" % pkg.Name
@@ -53,21 +35,22 @@ if srcrec:
all_build_depends.add(b[0])
# calculate the build depends for all dependencies
-depends = depcache.GetCandidateVer(base).DependsList
-for dep in depends["Depends"]: # FIXME: do we need to consider PreDepends?
- pkg = dep[0].TargetPkg
- srcpkg_name = get_source_pkg(pkg, records, depcache)
- if not srcpkg_name:
- print "Can't find source package for '%s'" % pkg.Name
- continue
- srcrec = srcrecords.Lookup(srcpkg_name)
- if srcrec:
- #print srcrecords.Package
- #print srcrecords.Binaries
- bd = srcrecords.BuildDepends
- #print "%s: %s " % (srcpkg_name, bd)
- for b in bd:
- all_build_depends.add(b[0])
+depends = base.candidate.dependencies
+for or_dep in depends:
+ for dep in or_dep.or_dependencies:
+ pkg = cache[dep.name]
+ srcpkg_name = pkg.candidate.source_name
+ if not srcpkg_name:
+ print "Can't find source package for '%s'" % pkg.Name
+ continue
+ srcrec = srcrecords.Lookup(srcpkg_name)
+ if srcrec:
+ #print srcrecords.Package
+ #print srcrecords.Binaries
+ bd = srcrecords.BuildDepends
+ #print "%s: %s " % (srcpkg_name, bd)
+ for b in bd:
+ all_build_depends.add(b[0])
print "\n".join(all_build_depends)
diff --git a/doc/source/library/apt_inst.rst b/doc/source/library/apt_inst.rst
index d9403a9e..9e6772f5 100644
--- a/doc/source/library/apt_inst.rst
+++ b/doc/source/library/apt_inst.rst
@@ -134,8 +134,8 @@ Debian Packages
.. attribute:: data
- The :class:`TarFile` object associated with the data.tar.{gz,bz2,lzma}
- member.
+ The :class:`TarFile` object associated with the
+ data.tar.{gz,bz2,lzma,xz} member.
.. attribute:: debian_binary
@@ -307,7 +307,7 @@ function can be replaced.
Call the function *func* for each member of the tar file *file*.
The parameter *comp* is a string determining the compressor used. Possible
- options are "lzma", "bzip2" and "gzip". The parameter *file* may be
+ options are "xz", "lzma", "bzip2" and "gzip". The parameter *file* may be
a :class:`file()` object, a file descriptor, or anything implementing
a :meth:`fileno` method.
diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst
index ffef9c50..b5ee1a53 100644
--- a/doc/source/library/apt_pkg.rst
+++ b/doc/source/library/apt_pkg.rst
@@ -1904,7 +1904,7 @@ thereof and provides a function :func:`RewriteSection` which takes a
:class:`TagSection()` object and sorting information and outputs a sorted
section as a string.
-.. class:: TagFile(file)
+.. class:: TagFile(file, bytes: bool = False)
An object which represents a typical debian control file. Can be used for
Packages, Sources, control, Release, etc. Such an object provides two
@@ -1921,6 +1921,10 @@ section as a string.
.. versionchanged:: 0.7.100
Added support for using gzip files, via :class:`gzip.GzipFile` or any
file containing a compressed gzip stream.
+
+ .. versionadded:: 0.8.5
+
+ Added support for using bytes instead of str in Python 3
.. method:: next()
@@ -2392,7 +2396,7 @@ following three functions:
.. function:: pkgsystem_unlock()
Unlock the global pkgsystem. This reverts the effect of
- :func:`pkgsystem_unlock`.
+ :func:`pkgsystem_lock`.
Other classes