summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-05 22:06:22 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-05 22:06:22 +0300
commit622812485150fa7864910ee2f710d5aab2fa9e6d (patch)
treeb3bc4fd72bb80e74ba5a60d8b3d47e610dff012e
parent798846ab8337471998b0a4d796d6d409453faa7d (diff)
parentfdd173dd444098ed533cbcd541a7f10f228bc47e (diff)
downloadpython-apt-622812485150fa7864910ee2f710d5aab2fa9e6d.tar.gz
Merge git://anonscm.debian.org/apt/python-apt
Conflicts: debian/changelog python/apt_pkgmodule.cc
-rw-r--r--.travis.yml19
-rw-r--r--apt/__init__.py16
-rw-r--r--apt/auth.py56
-rw-r--r--apt/cache.py327
-rw-r--r--apt/cdrom.py6
-rw-r--r--apt/debfile.py247
-rw-r--r--apt/deprecation.py106
-rw-r--r--apt/package.py505
-rw-r--r--apt/progress/__init__.py14
-rw-r--r--apt/progress/base.py7
-rw-r--r--apt/progress/gtk2.py519
-rw-r--r--apt/progress/old.py259
-rw-r--r--apt/progress/text.py26
-rw-r--r--apt/utils.py13
-rw-r--r--aptsources/__init__.py9
-rw-r--r--aptsources/distinfo.py15
-rw-r--r--aptsources/distro.py107
-rw-r--r--aptsources/sourceslist.py120
-rw-r--r--data/templates/Blankon.info.in370
-rw-r--r--data/templates/Blankon.mirrors17
-rw-r--r--data/templates/Debian.info.in32
-rw-r--r--data/templates/Tanglu.info.in42
-rw-r--r--data/templates/Tanglu.mirrors3
-rw-r--r--data/templates/Ubuntu.info.in692
-rw-r--r--debian/README.source3
-rw-r--r--debian/changelog366
-rw-r--r--debian/compat2
-rw-r--r--debian/control39
-rw-r--r--debian/gbp.conf1
-rw-r--r--debian/pycompat1
-rw-r--r--debian/python-apt-common.install2
-rw-r--r--debian/python-apt-common.lintian-overrides2
-rw-r--r--debian/python-apt-dev.maintscript1
-rw-r--r--debian/python-apt-doc.links1
-rw-r--r--debian/python-apt-doc.maintscript1
-rwxr-xr-xdebian/python-apt-doc.preinst16
-rw-r--r--debian/python3-apt-dbg.files2
-rwxr-xr-xdebian/rules20
-rw-r--r--debian/tests/control2
-rw-r--r--debian/tests/run-tests2
-rw-r--r--doc/examples/acquire.py53
-rw-r--r--doc/examples/action.py176
-rw-r--r--doc/examples/all_deps.py14
-rw-r--r--doc/examples/architecture.py2
-rwxr-xr-xdoc/examples/build-deps-old.py38
-rwxr-xr-xdoc/examples/build-deps.py18
-rw-r--r--doc/examples/cdrom.py6
-rwxr-xr-xdoc/examples/checkstate.py18
-rwxr-xr-xdoc/examples/config.py22
-rwxr-xr-xdoc/examples/configisc.py22
-rwxr-xr-xdoc/examples/deb_inspect.py16
-rw-r--r--doc/examples/depcache.py122
-rwxr-xr-xdoc/examples/dependant-pkgs.py12
-rw-r--r--doc/examples/desc.py12
-rwxr-xr-xdoc/examples/gui-inst.py27
-rw-r--r--doc/examples/indexfile.py18
-rw-r--r--doc/examples/inst.py8
-rw-r--r--doc/examples/metaindex.py10
-rwxr-xr-xdoc/examples/print_uris.py18
-rw-r--r--doc/examples/progress.py89
-rwxr-xr-xdoc/examples/recommends.py12
-rw-r--r--doc/examples/sources.py12
-rwxr-xr-xdoc/examples/tagfile.py6
-rwxr-xr-xdoc/examples/update.py4
-rwxr-xr-xdoc/examples/versiontest.py18
-rw-r--r--doc/source/c++/api.rst436
-rw-r--r--doc/source/c++/embedding.rst2
-rw-r--r--doc/source/conf.py18
-rw-r--r--doc/source/contents.rst1
-rw-r--r--doc/source/examples/apt-gtk.py29
-rw-r--r--doc/source/examples/cache-pkgfile.py2
-rw-r--r--doc/source/examples/dpkg-info.py4
-rw-r--r--doc/source/examples/missing-deps.py2
-rw-r--r--doc/source/library/apt.package.rst22
-rw-r--r--doc/source/library/apt.progress.gtk2.rst131
-rw-r--r--doc/source/library/apt_pkg.rst93
-rw-r--r--doc/source/library/index.rst5
-rw-r--r--doc/source/templates/indexcontent.html2
-rw-r--r--doc/source/templates/layout.html6
-rw-r--r--doc/source/tutorials/apt-get.rst2
-rw-r--r--doc/source/whatsnew/0.9.4.rst17
-rw-r--r--doc/source/whatsnew/1.0.rst53
-rw-r--r--po/POTFILES.in1
-rw-r--r--po/ar.po2
-rw-r--r--po/be.po4
-rw-r--r--po/bg.po2
-rw-r--r--po/bn.po2
-rw-r--r--po/ca.po2
-rw-r--r--po/cs.po2
-rw-r--r--po/csb.po2
-rw-r--r--po/da.po4
-rw-r--r--po/de.po4
-rw-r--r--po/el.po4
-rw-r--r--po/en_AU.po2
-rw-r--r--po/en_CA.po2
-rw-r--r--po/eo.po4
-rw-r--r--po/es.po4
-rw-r--r--po/fi.po4
-rw-r--r--po/fr.po4
-rw-r--r--po/gl.po2
-rw-r--r--po/he.po2
-rw-r--r--po/hr.po2
-rw-r--r--po/hu.po4
-rw-r--r--po/id.po4
-rw-r--r--po/it.po2
-rw-r--r--po/ja.po4
-rw-r--r--po/ka.po2
-rw-r--r--po/ko.po2
-rw-r--r--po/ku.po2
-rw-r--r--po/lt.po2
-rw-r--r--po/lv.po2
-rw-r--r--po/mk.po2
-rw-r--r--po/nb.po2
-rw-r--r--po/ne.po2
-rw-r--r--po/nl.po4
-rw-r--r--po/oc.po2
-rw-r--r--po/pl.po4
-rw-r--r--po/pt.po2
-rw-r--r--po/pt_BR.po4
-rw-r--r--po/python-apt.pot310
-rw-r--r--po/ro.po2
-rw-r--r--po/ru.po4
-rw-r--r--po/sk.po4
-rw-r--r--po/sl.po4
-rw-r--r--po/sq.po2
-rw-r--r--po/sr.po4
-rw-r--r--po/sv.po2
-rw-r--r--po/th.po2
-rw-r--r--po/tl.po4
-rw-r--r--po/tr.po2
-rw-r--r--po/uk.po2
-rw-r--r--po/vi.po2
-rw-r--r--po/zh_CN.po2
-rw-r--r--po/zh_HK.po2
-rw-r--r--po/zh_TW.po2
-rwxr-xr-xpre-build.sh2
-rw-r--r--python/acquire-item.cc76
-rw-r--r--python/acquire.cc17
-rw-r--r--python/apt_instmodule.cc143
-rw-r--r--python/apt_instmodule.h6
-rw-r--r--python/apt_pkgmodule.cc281
-rw-r--r--python/arfile.cc136
-rw-r--r--python/cache.cc102
-rw-r--r--python/cdrom.cc36
-rw-r--r--python/configuration.cc12
-rw-r--r--python/depcache.cc33
-rw-r--r--python/generic.cc92
-rw-r--r--python/generic.h53
-rw-r--r--python/indexfile.cc4
-rw-r--r--python/indexrecords.cc8
-rw-r--r--python/lock.cc5
-rw-r--r--python/pkgmanager.cc15
-rw-r--r--python/pkgrecords.cc9
-rw-r--r--python/pkgsrcrecords.cc62
-rw-r--r--python/policy.cc14
-rw-r--r--python/progress.cc135
-rw-r--r--python/sourcelist.cc9
-rw-r--r--python/string.cc2
-rw-r--r--python/tag.cc95
-rw-r--r--python/tar.cc197
-rw-r--r--python/tarfile.cc71
-rw-r--r--setup.py51
-rw-r--r--tests/data/aptsources/sources.list1
-rw-r--r--tests/data/aptsources/sources.list.testDistribution1
-rw-r--r--tests/data/hashsums/hashsum_test.data (renamed from tests/old/hashsum_test.data)0
-rw-r--r--tests/data/hashsums/hashsum_test_with_zero.data (renamed from tests/old/hashsum_test_with_zero.data)bin7 -> 7 bytes
-rw-r--r--tests/data/test_debs/data-tar-xz.debbin626 -> 680 bytes
-rw-r--r--tests/data/test_debs/data-tar.debbin0 -> 20672 bytes
-rw-r--r--tests/data/test_debs/gdebi-test13.debbin0 -> 720 bytes
-rw-r--r--tests/data/test_debs/hello_2.5-1.dsc3
-rw-r--r--tests/data/test_debs/large-package-content_1.0_all.debbin0 -> 781546 bytes
-rw-r--r--tests/data/test_debs/testdep-allowed-any_1.0-1_i386.debbin0 -> 1128 bytes
-rw-r--r--tests/data/test_debs/testdep-same-arch_1.0-1_i386.debbin0 -> 1236 bytes
-rw-r--r--tests/data/test_debs/var/lib/dpkg/status39
-rw-r--r--tests/old/__init__.py1
-rw-r--r--tests/old/apt-test.py18
-rw-r--r--tests/old/cache.py34
-rw-r--r--tests/old/depcache.py48
-rw-r--r--tests/old/lock.py12
-rw-r--r--tests/old/memleak.py8
-rw-r--r--tests/old/pkgproblemresolver.py60
-rw-r--r--tests/old/pkgrecords.py24
-rw-r--r--tests/old/pkgsrcrecords.py12
-rwxr-xr-xtests/old/refcount.py11
-rwxr-xr-xtests/old/test_debextract.py4
-rw-r--r--tests/old/test_enhances.py4
-rw-r--r--tests/old/test_hashsums.py67
-rw-r--r--tests/test_all.py27
-rw-r--r--tests/test_apt_cache.py52
-rw-r--r--tests/test_aptsources.py67
-rw-r--r--tests/test_aptsources_ports.py1
-rw-r--r--tests/test_auth.py33
-rw-r--r--tests/test_cache_invocation.py1
-rw-r--r--tests/test_configuration.py5
-rw-r--r--tests/test_debfile.py88
-rw-r--r--tests/test_debfile_multiarch.py11
-rw-r--r--tests/test_deps.py18
-rw-r--r--tests/test_group.py1
-rw-r--r--tests/test_hashes.py2
-rw-r--r--tests/test_hashsums.py95
-rw-r--r--tests/test_large_file.py23
-rw-r--r--tests/test_lp659438.py4
-rw-r--r--tests/test_paths.py160
-rwxr-xr-xtests/test_pep8.py30
-rw-r--r--tests/test_policy.py4
-rw-r--r--tests/test_progress.py10
-rw-r--r--tests/test_pyflakes.py41
-rw-r--r--tests/test_size_to_str.py143
-rw-r--r--tests/test_tagfile.py24
-rw-r--r--tests/test_utils.py26
-rw-r--r--utils/doclint.py77
-rwxr-xr-xutils/get_debian_mirrors.py12
-rwxr-xr-xutils/get_ubuntu_mirrors.py59
-rwxr-xr-xutils/get_ubuntu_mirrors_from_lp.py12
-rwxr-xr-xutils/migrate-0.8.py254
-rwxr-xr-xutils/mirrortest29
216 files changed, 4677 insertions, 4662 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..832b69e2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,19 @@
+# This provides integration into the travis-ci.org CI system. For a overview
+# check http://about.travis-ci.org/docs/user/getting-started/
+#
+# Some notes:
+# - language is "C" because the travis chroot for python installs a non-repo
+# python3.3 from a PPA
+# - we need to add the current stable ubuntu (or even the current development
+# ubuntu because we need a recent version of apt to build the python-apt
+# - we use ubuntu instead of debian because the travis chroot is ubuntu based
+# - ./debian/rules build-arch will build the package and run the tests
+language: c
+before_install:
+ - sudo apt-get update -q
+ - sudo apt-get install distro-info
+ - echo "deb http://archive.ubuntu.com/ubuntu $(distro-info --stable) main"|sudo tee -a /etc/apt/sources.list.d/added.list
+ - sudo apt-get update -q
+ - sudo apt-get install -q --no-install-recommends gdebi-core
+ - sudo apt-get install -q build-essential $(gdebi -q --apt-line ./debian/control)
+script: ./debian/rules build-arch
diff --git a/apt/__init__.py b/apt/__init__.py
index 677a625b..b8d291e3 100644
--- a/apt/__init__.py
+++ b/apt/__init__.py
@@ -18,20 +18,20 @@
# USA
# import the core of apt_pkg
"""High-Level Interface for working with apt."""
+from __future__ import print_function
+
import apt_pkg
# import some fancy classes
from apt.package import Package
from apt.cache import Cache, ProblemResolver
+Cache # pyflakes
+ProblemResolver # pyflakes
from apt.cdrom import Cdrom
-if apt_pkg._COMPAT_0_7:
- from apt.progress.old import (OpProgress, FetchProgress, InstallProgress,
- CdromProgress)
- from apt_pkg import (size_to_str as SizeToStr, time_to_str as TimeToStr,
- version_compare as VersionCompare)
-
-# init the package system
-apt_pkg.init()
+# init the package system, but do not re-initialize config
+if "APT" not in apt_pkg.config:
+ apt_pkg.init_config()
+apt_pkg.init_system()
__all__ = ['Cache', 'Cdrom', 'Package']
diff --git a/apt/auth.py b/apt/auth.py
index c1b8da2a..74fea10b 100644
--- a/apt/auth.py
+++ b/apt/auth.py
@@ -24,7 +24,8 @@
# USA
"""Handle GnuPG keys used to trust signed repositories."""
-import atexit
+from __future__ import print_function
+
import os
import os.path
import shutil
@@ -68,7 +69,8 @@ def _call_apt_key_script(*args, **kwargs):
# configuration from the chroot to the apt-key script by using
# a temporary APT_CONFIG file. The apt-key script uses apt-config
# shell internally
- conf = tempfile.NamedTemporaryFile(prefix="apt-key", suffix=".conf")
+ conf = tempfile.NamedTemporaryFile(
+ prefix="apt-key", suffix=".conf")
conf.write(apt_pkg.config.dump().encode("UTF-8"))
conf.flush()
env["APT_CONFIG"] = conf.name
@@ -79,17 +81,18 @@ def _call_apt_key_script(*args, **kwargs):
content = kwargs.get("stdin", None)
# py2 needs this encoded, py3.3 will crash if it is
- if isinstance(content, unicode) and sys.version_info[:2] < (3, 3):
+ if sys.version_info.major < 3 and isinstance(content, unicode):
content = content.encode("utf-8")
output, stderr = proc.communicate(content)
if proc.returncode:
- raise AptKeyError("The apt-key script failed with return code %s:\n"
- "%s\n"
- "stdout: %s\n"
- "stderr: %s" % (proc.returncode, " ".join(cmd),
- output,stderr))
+ raise AptKeyError(
+ "The apt-key script failed with return code %s:\n"
+ "%s\n"
+ "stdout: %s\n"
+ "stderr: %s" % (
+ proc.returncode, " ".join(cmd), output, stderr))
elif stderr:
sys.stderr.write(stderr) # Forward stderr
@@ -98,6 +101,7 @@ def _call_apt_key_script(*args, **kwargs):
if conf is not None:
conf.close()
+
def add_key_from_file(filename):
"""Import a GnuPG key file to trust repositores signed by it.
@@ -110,6 +114,7 @@ def add_key_from_file(filename):
raise AptKeyError("Key file cannot be accessed: %s" % filename)
_call_apt_key_script("add", filename)
+
def add_key_from_keyserver(keyid, keyserver):
"""Import a GnuPG key file to trust repositores signed by it.
@@ -126,8 +131,9 @@ def add_key_from_keyserver(keyid, keyserver):
finally:
shutil.rmtree(tmp_keyring_dir)
+
def _add_key_from_keyserver(keyid, keyserver, tmp_keyring_dir):
- if len(keyid) < 160/8:
+ if len(keyid) < (160 / 8):
raise AptKeyError("Only long keyids (v4, 160bit) are supported")
# create a temp keyring dir
tmp_secret_keyring = os.path.join(tmp_keyring_dir, "secring.gpg")
@@ -137,17 +143,23 @@ def _add_key_from_keyserver(keyid, keyserver, tmp_keyring_dir):
"gpg",
"--no-default-keyring", "--no-options",
"--homedir", tmp_keyring_dir,
- ]
+ ]
# download the key to a temp keyring first
res = subprocess.call(gpg_default_options + [
"--secret-keyring", tmp_secret_keyring,
"--keyring", tmp_keyring,
"--keyserver", keyserver,
"--recv", keyid,
- ])
+ ])
if res != 0:
raise AptKeyError("recv from '%s' failed for '%s'" % (
keyserver, keyid))
+ # FIXME:
+ # - with gnupg 1.4.18 the downloaded key is actually checked(!),
+ # i.e. gnupg will not import anything that the server sends
+ # into the keyring, so the below checks are now redundant *if*
+ # gnupg 1.4.18 is used
+
# now export again using the long key id (to ensure that there is
# really only this one key in our keyring) and not someone MITM us
tmp_export_keyring = os.path.join(tmp_keyring_dir, "export-keyring.gpg")
@@ -155,7 +167,7 @@ def _add_key_from_keyserver(keyid, keyserver, tmp_keyring_dir):
"--keyring", tmp_keyring,
"--output", tmp_export_keyring,
"--export", keyid,
- ])
+ ])
if res != 0:
raise AptKeyError("export of '%s' failed", keyid)
# now verify the fingerprint, this is probably redundant as we
@@ -167,10 +179,10 @@ def _add_key_from_keyserver(keyid, keyserver, tmp_keyring_dir):
"--fingerprint",
"--batch",
"--with-colons",
- ],
- stdout=subprocess.PIPE,
- universal_newlines=True).communicate()[0]
- got_fingerprint=None
+ ],
+ stdout=subprocess.PIPE,
+ universal_newlines=True).communicate()[0]
+ got_fingerprint = None
for line in output.splitlines():
if line.startswith("fpr:"):
got_fingerprint = line.split(":")[9]
@@ -180,12 +192,15 @@ def _add_key_from_keyserver(keyid, keyserver, tmp_keyring_dir):
# what gnupg is using)
signing_key_fingerprint = keyid.replace("0x", "").upper()
if got_fingerprint != signing_key_fingerprint:
+ # make the error match what gnupg >= 1.4.18 will output when
+ # it checks the key itself before importing it
raise AptKeyError(
- "Fingerprints do not match, not importing: '%s' != '%s'" % (
- signing_key_fingerprint, got_fingerprint))
+ "recv from '%s' failed for '%s'" % (
+ keyserver, signing_key_fingerprint))
# finally add it
add_key_from_file(tmp_export_keyring)
+
def add_key(content):
"""Import a GnuPG key to trust repositores signed by it.
@@ -195,6 +210,7 @@ def add_key(content):
_call_apt_key_script("adv", "--quiet", "--batch",
"--import", "-", stdin=content)
+
def remove_key(fingerprint):
"""Remove a GnuPG key to no longer trust repositores signed by it.
@@ -203,6 +219,7 @@ def remove_key(fingerprint):
"""
_call_apt_key_script("rm", fingerprint)
+
def export_key(fingerprint):
"""Return the GnuPG key in text format.
@@ -211,6 +228,7 @@ def export_key(fingerprint):
"""
return _call_apt_key_script("export", fingerprint)
+
def update():
"""Update the local keyring with the archive keyring and remove from
the local keyring the archive keys which are no longer valid. The
@@ -219,6 +237,7 @@ def update():
"""
return _call_apt_key_script("update")
+
def net_update():
"""Work similar to the update command above, but get the archive
keyring from an URI instead and validate it against a master key.
@@ -229,6 +248,7 @@ def net_update():
"""
return _call_apt_key_script("net-update")
+
def list_keys():
"""Returns a list of TrustedKey instances for each key which is
used to trust repositories.
diff --git a/apt/cache.py b/apt/cache.py
index 9842cb2a..74bbe71f 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -19,15 +19,15 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
+from __future__ import print_function
+
import fnmatch
import os
+import warnings
import weakref
import apt_pkg
from apt import Package
-from apt_pkg import gettext as _
-from apt.deprecation import (AttributeDeprecatedBy, function_deprecated_by,
- deprecated_args)
import apt.progress.text
@@ -42,6 +42,7 @@ class FetchFailedException(IOError):
class LockFailedException(IOError):
"""Exception that is thrown when locking fails."""
+
class CacheClosedException(Exception):
"""Exception that is thrown when the cache is used after close()."""
@@ -55,14 +56,21 @@ class Cache(object):
list of available packages.
The cache can be used like a mapping from package names to Package
- objects (although only getting items is supported).
+ objects (although only getting items is supported).
Keyword arguments:
- progress -- a OpProgress object
- rootdir -- a alternative root directory. if that is given
- the system sources.list and system lists/ files are
- not read, only files relative to the given rootdir
- memonly -- build the cache in memory only
+ progress -- a OpProgress object,
+ rootdir -- an alternative root directory. if that is given the system
+ sources.list and system lists/files are not read, only file relative
+ to the given rootdir,
+ memonly -- build the cache in memory only.
+
+
+ .. versionchanged:: 1.0
+
+ The cache now supports package names with special architecture
+ qualifiers such as :all and :native. It does not export them
+ in :meth:`keys()`, though, to keep :meth:`keys()` a unique set.
"""
def __init__(self, progress=None, rootdir=None, memonly=False):
@@ -71,30 +79,30 @@ class Cache(object):
self._records = None
self._list = None
self._callbacks = {}
+ self._callbacks2 = {}
self._weakref = weakref.WeakValueDictionary()
- self._set = set()
- self._fullnameset = set()
self._changes_count = -1
self._sorted_set = None
-
- self.connect("cache_post_open", self._inc_changes_count)
- self.connect("cache_post_change", self._inc_changes_count)
+
+ self.connect("cache_post_open", "_inc_changes_count")
+ self.connect("cache_post_change", "_inc_changes_count")
if memonly:
# force apt to build its caches in memory
apt_pkg.config.set("Dir::Cache::pkgcache", "")
if rootdir:
- if os.path.exists(rootdir+"/etc/apt/apt.conf"):
+ rootdir = os.path.abspath(rootdir)
+ if os.path.exists(rootdir + "/etc/apt/apt.conf"):
apt_pkg.read_config_file(apt_pkg.config,
- rootdir + "/etc/apt/apt.conf")
- if os.path.isdir(rootdir+"/etc/apt/apt.conf.d"):
+ rootdir + "/etc/apt/apt.conf")
+ if os.path.isdir(rootdir + "/etc/apt/apt.conf.d"):
apt_pkg.read_config_dir(apt_pkg.config,
- rootdir + "/etc/apt/apt.conf.d")
+ rootdir + "/etc/apt/apt.conf.d")
apt_pkg.config.set("Dir", rootdir)
apt_pkg.config.set("Dir::State::status",
rootdir + "/var/lib/dpkg/status")
# also set dpkg to the rootdir path so that its called for the
# --print-foreign-architectures call
- apt_pkg.config.set("Dir::bin::dpkg",
+ apt_pkg.config.set("Dir::bin::dpkg",
os.path.join(rootdir, "usr", "bin", "dpkg"))
# create required dirs/files when run with special rootdir
# automatically
@@ -103,7 +111,6 @@ class Cache(object):
# recognized (LP: #320665)
apt_pkg.init_system()
self.open(progress)
-
def _inc_changes_count(self):
"""Increase the number of changes"""
@@ -116,12 +123,12 @@ class Cache(object):
"""
files = ["/var/lib/dpkg/status",
"/etc/apt/sources.list",
- ]
+ ]
dirs = ["/var/lib/dpkg",
"/etc/apt/",
"/var/cache/apt/archives/partial",
"/var/lib/apt/lists/partial",
- ]
+ ]
for d in dirs:
if not os.path.exists(rootdir + d):
#print "creating: ", rootdir + d
@@ -134,7 +141,14 @@ class Cache(object):
""" internal helper to run a callback """
if name in self._callbacks:
for callback in self._callbacks[name]:
- callback()
+ if callback == '_inc_changes_count':
+ self._inc_changes_count()
+ else:
+ callback()
+
+ if name in self._callbacks2:
+ for callback, args, kwds in self._callbacks2[name]:
+ callback(self, *args, **kwds)
def open(self, progress=None):
""" Open the package cache, after that it can be used like
@@ -152,28 +166,11 @@ class Cache(object):
self._records = apt_pkg.PackageRecords(self._cache)
self._list = apt_pkg.SourceList()
self._list.read_main_list()
- self._set.clear()
- self._fullnameset.clear()
self._sorted_set = None
self._weakref.clear()
self._have_multi_arch = len(apt_pkg.get_architectures()) > 1
- progress.op = _("Building data structures")
- i = last = 0
- size = len(self._cache.packages)
- for pkg in self._cache.packages:
- if progress is not None and last+100 < i:
- progress.update(i/float(size)*100)
- last = i
- # drop stuff with no versions (cruft)
- if pkg.has_versions:
- self._set.add(pkg.get_fullname(pretty=True))
- if self._have_multi_arch:
- self._fullnameset.add(pkg.get_fullname(pretty=False))
-
- i += 1
-
progress.done()
self._run_callbacks("cache_post_open")
@@ -196,37 +193,58 @@ class Cache(object):
try:
return self._weakref[key]
except KeyError:
- if key in self._set or key in self._fullnameset:
- key = str(key)
- pkg = self._weakref[key] = Package(self, self._cache[key])
- return pkg
- else:
+ key = str(key)
+ try:
+ rawpkg = self._cache[key]
+ except KeyError:
+ raise KeyError('The cache has no package named %r' % key)
+
+ # It might be excluded due to not having a version or something
+ if not self.__is_real_pkg(rawpkg):
raise KeyError('The cache has no package named %r' % key)
+ # Check if we already know the package using the normalized name
+ name = rawpkg.get_fullname(pretty=False)
+ try:
+ return self._weakref[name]
+ except KeyError:
+ pkg = Package(self, rawpkg)
+ self._weakref[key] = self._weakref[name] = pkg
+
+ return pkg
+
def __iter__(self):
# We iterate sorted over package names here. With this we read the
# package lists linearly if we need to access the package records,
# instead of having to do thousands of random seeks; the latter
# is disastrous if we use compressed package indexes, and slower than
# necessary for uncompressed indexes.
- if self._sorted_set is None:
- self._sorted_set = sorted(self._set)
-
- for pkgname in self._sorted_set:
+ for pkgname in self.keys():
yield self[pkgname]
raise StopIteration
+ def __is_real_pkg(self, rawpkg):
+ """Check if the apt_pkg.Package provided is a real package."""
+ return rawpkg.has_versions
+
def has_key(self, key):
- return (key in self._set or key in self._fullnameset)
+ return key in self
def __contains__(self, key):
- return (key in self._set or key in self._fullnameset)
+ try:
+ return self.__is_real_pkg(self._cache[key])
+ except KeyError:
+ return False
def __len__(self):
- return len(self._set)
+ return len(self.keys())
def keys(self):
- return list(self._set)
+ if self._sorted_set is None:
+ self._sorted_set = sorted(p.get_fullname(pretty=True)
+ for p in self._cache.packages
+ if self.__is_real_pkg(p))
+ return list(self._sorted_set) # We need a copy here, caller may modify
def get_changes(self):
""" Get the marked changes """
@@ -242,7 +260,6 @@ class Cache(object):
changes.append(package)
return changes
- @deprecated_args
def upgrade(self, dist_upgrade=False):
"""Upgrade all packages.
@@ -258,7 +275,8 @@ class Cache(object):
def required_download(self):
"""Get the size of the packages that are required to download."""
if self._records is None:
- raise CacheClosedException("Cache object used after close() called")
+ raise CacheClosedException(
+ "Cache object used after close() called")
pm = apt_pkg.PackageManager(self._depcache)
fetcher = apt_pkg.Acquire()
pm.get_archives(fetcher, self._list, self._records)
@@ -288,16 +306,14 @@ class Cache(object):
# now check the result (this is the code from apt-get.cc)
failed = False
- transient = False
err_msg = ""
for item in fetcher.items:
if item.status == item.STAT_DONE:
continue
if item.STAT_IDLE:
- transient = True
continue
err_msg += "Failed to fetch %s %s\n" % (item.desc_uri,
- item.error_text)
+ item.error_text)
failed = True
# we raise a exception if the download failed or it was cancelt
@@ -310,7 +326,8 @@ class Cache(object):
def _fetch_archives(self, fetcher, pm):
""" fetch the needed archives """
if self._records is None:
- raise CacheClosedException("Cache object used after close() called")
+ raise CacheClosedException(
+ "Cache object used after close() called")
# get lock
lockfile = apt_pkg.config.find_dir("Dir::Cache::Archives") + "lock"
@@ -348,7 +365,6 @@ class Cache(object):
if fetcher is None:
fetcher = apt_pkg.Acquire(progress)
-
return self._fetch_archives(fetcher,
apt_pkg.PackageManager(self._depcache))
@@ -361,12 +377,12 @@ class Cache(object):
else:
return bool(pkg.has_provides and not pkg.has_versions)
- def get_providing_packages(self, pkgname, candidate_only=True,
+ def get_providing_packages(self, pkgname, candidate_only=True,
include_nonvirtual=False):
"""Return a list of all packages providing a package.
-
+
Return a list of packages which provide the virtual package of the
- specified name.
+ specified name.
If 'candidate_only' is False, return all packages with at
least one version providing the virtual package. Otherwise,
@@ -377,7 +393,7 @@ class Cache(object):
packages providing pkgname, even if pkgname is not itself
a virtual pkg.
"""
-
+
providers = set()
get_candidate_ver = self._depcache.get_candidate_ver
try:
@@ -398,7 +414,6 @@ class Cache(object):
providers.add(package)
return list(providers)
- @deprecated_args
def update(self, fetch_progress=None, pulse_interval=0,
raise_on_error=True, sources_list=None):
"""Run the equivalent of apt-get update.
@@ -411,7 +426,7 @@ class Cache(object):
apt.progress.FetchProgress, the default is apt.progress.FetchProgress()
.
sources_list -- Update a alternative sources.list than the default.
- Note that the sources.list.d directory is ignored in this case
+ Note that the sources.list.d directory is ignored in this case
"""
lockfile = apt_pkg.config.find_dir("Dir::State::Lists") + "lock"
lock = apt_pkg.get_lock(lockfile)
@@ -423,7 +438,8 @@ class Cache(object):
old_sources_list = apt_pkg.config.find("Dir::Etc::sourcelist")
old_sources_list_d = apt_pkg.config.find("Dir::Etc::sourceparts")
old_cleanup = apt_pkg.config.find("APT::List-Cleanup")
- apt_pkg.config.set("Dir::Etc::sourcelist", os.path.abspath(sources_list))
+ apt_pkg.config.set("Dir::Etc::sourcelist",
+ os.path.abspath(sources_list))
apt_pkg.config.set("Dir::Etc::sourceparts", "xxx")
apt_pkg.config.set("APT::List-Cleanup", "0")
slist = apt_pkg.SourceList()
@@ -450,7 +466,6 @@ class Cache(object):
apt_pkg.config.set("Dir::Etc::sourceparts", old_sources_list_d)
apt_pkg.config.set("APT::List-Cleanup", old_cleanup)
- @deprecated_args
def install_archives(self, pm, install_progress):
"""
The first parameter *pm* refers to an object returned by
@@ -471,7 +486,6 @@ class Cache(object):
install_progress.finish_update()
return res
- @deprecated_args
def commit(self, fetch_progress=None, install_progress=None):
"""Apply the marked changes to the cache.
@@ -531,12 +545,40 @@ class Cache(object):
self._run_callbacks("cache_pre_change")
def connect(self, name, callback):
- """ connect to a signal, currently only used for
- cache_{post,pre}_{changed,open} """
- if not name in self._callbacks:
+ """Connect to a signal.
+
+ .. deprecated:: 1.0
+
+ Please use connect2() instead, as this function is very
+ likely to cause a memory leak.
+ """
+ if callback != '_inc_changes_count':
+ warnings.warn("connect() likely causes a reference"
+ " cycle, use connect2() instead", RuntimeWarning, 2)
+ if name not in self._callbacks:
self._callbacks[name] = []
self._callbacks[name].append(callback)
+ def connect2(self, name, callback, *args, **kwds):
+ """Connect to a signal.
+
+ The callback will be passed the cache as an argument, and
+ any arguments passed to this function. Make sure that, if you
+ pass a method of a class as your callback, your class does not
+ contain a reference to the cache.
+
+ Cyclic references to the cache can cause issues if the Cache object
+ is replaced by a new one, because the cache keeps a lot of objects and
+ tens of open file descriptors.
+
+ currently only used for cache_{post,pre}_{changed,open}.
+
+ .. versionadded:: 1.0
+ """
+ if name not in self._callbacks2:
+ self._callbacks2[name] = []
+ self._callbacks2[name].append((callback, args, kwds))
+
def actiongroup(self):
"""Return an `ActionGroup` object for the current cache.
@@ -561,9 +603,9 @@ class Cache(object):
@property
def dpkg_journal_dirty(self):
"""Return True if the dpkg was interrupted
-
+
All dpkg operations will fail until this is fixed, the action to
- fix the system if dpkg got interrupted is to run
+ fix the system if dpkg got interrupted is to run
'dpkg --configure -a' as root.
"""
dpkg_status_dir = os.path.dirname(
@@ -593,20 +635,6 @@ class Cache(object):
"""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)
- 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)
-
class ProblemResolver(object):
"""Resolve problems due to dependencies and conflicts.
@@ -670,6 +698,38 @@ class MarkedChangesFilter(Filter):
return False
+class _FilteredCacheHelper(object):
+ """Helper class for FilteredCache to break a reference cycle."""
+
+ def __init__(self, cache):
+ # Do not keep a reference to the cache, or you have a cycle!
+
+ self._filtered = {}
+ self._filters = {}
+ cache.connect2("cache_post_change", self.filter_cache_post_change)
+ cache.connect2("cache_post_open", self.filter_cache_post_change)
+
+ def _reapply_filter(self, cache):
+ " internal helper to refilter "
+ # Do not keep a reference to the cache, or you have a cycle!
+ self._filtered = {}
+ for pkg in cache:
+ for f in self._filters:
+ if f.apply(pkg):
+ self._filtered[pkg.name] = 1
+ break
+
+ def set_filter(self, filter):
+ """Set the current active filter."""
+ self._filters = []
+ self._filters.append(filter)
+
+ def filter_cache_post_change(self, cache):
+ """Called internally if the cache changes, emit a signal then."""
+ # Do not keep a reference to the cache, or you have a cycle!
+ self._reapply_filter(cache)
+
+
class FilteredCache(object):
""" A package cache that is filtered.
@@ -681,99 +741,74 @@ class FilteredCache(object):
self.cache = Cache(progress)
else:
self.cache = cache
- 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 = []
+ self._helper = _FilteredCacheHelper(self.cache)
def __len__(self):
- return len(self._filtered)
+ return len(self._helper._filtered)
def __getitem__(self, key):
return self.cache[key]
def __iter__(self):
- for pkgname in self._filtered:
+ for pkgname in self._helper._filtered:
yield self.cache[pkgname]
def keys(self):
- return self._filtered.keys()
+ return self._helper._filtered.keys()
def has_key(self, key):
- return (key in self._filtered)
+ return key in self
def __contains__(self, key):
- return (key in self._filtered)
-
- def _reapply_filter(self):
- " internal helper to refilter "
- self._filtered = {}
- for pkg in self.cache:
- for f in self._filters:
- if f.apply(pkg):
- self._filtered[pkg.name] = 1
- break
+ try:
+ # Normalize package name for multi arch
+ return self.cache[key].name in self._helper._filtered
+ except KeyError:
+ return False
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._helper.set_filter(filter)
self.cache.cache_post_change()
def filter_cache_post_change(self):
"""Called internally if the cache changes, emit a signal then."""
- #print "filterCachePostChange()"
- self._reapply_filter()
-
-
-# def connect(self, name, callback):
-# self.cache.connect(name, callback)
+ self._helper.filter_cache_post_change(self.cache)
def __getattr__(self, key):
"""we try to look exactly like a real cache."""
- #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"
+def cache_pre_changed(cache):
+ print("cache pre changed")
-def cache_post_changed():
- print "cache post changed"
+def cache_post_changed(cache):
+ print("cache post changed")
def _test():
"""Internal test code."""
- print "Cache self test"
+ print("Cache self test")
apt_pkg.init()
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)
+ cache.connect2("cache_pre_change", cache_pre_changed)
+ cache.connect2("cache_post_change", cache_post_changed)
+ print(("aptitude" in cache))
pkg = cache["aptitude"]
- print pkg.name
- print len(cache)
+ print(pkg.name)
+ print(len(cache))
for pkgname in cache.keys():
assert cache[pkgname].name == pkgname
cache.upgrade()
changes = cache.get_changes()
- print len(changes)
+ print(len(changes))
for pkg in changes:
assert pkg.name
-
-
# see if fetching works
for dirname in ["/tmp/pytest", "/tmp/pytest/partial"]:
if not os.path.exists(dirname):
@@ -784,28 +819,28 @@ def _test():
cache._fetch_archives(fetcher, pm)
#sys.exit(1)
- print "Testing filtered cache (argument is old cache)"
+ print("Testing filtered cache (argument is old cache)")
filtered = FilteredCache(cache)
- filtered.cache.connect("cache_pre_change", cache_pre_changed)
- filtered.cache.connect("cache_post_change", cache_post_changed)
+ filtered.cache.connect2("cache_pre_change", cache_pre_changed)
+ filtered.cache.connect2("cache_post_change", cache_post_changed)
filtered.cache.upgrade()
filtered.set_filter(MarkedChangesFilter())
- print len(filtered)
+ print(len(filtered))
for pkgname in filtered.keys():
assert pkgname == filtered[pkg].name
- print len(filtered)
+ print(len(filtered))
- print "Testing filtered cache (no argument)"
+ print("Testing filtered cache (no argument)")
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.connect2("cache_pre_change", cache_pre_changed)
+ filtered.cache.connect2("cache_post_change", cache_post_changed)
filtered.cache.upgrade()
filtered.set_filter(MarkedChangesFilter())
- print len(filtered)
+ print(len(filtered))
for pkgname in filtered.keys():
assert pkgname == filtered[pkgname].name
- print len(filtered)
+ print(len(filtered))
if __name__ == '__main__':
_test()
diff --git a/apt/cdrom.py b/apt/cdrom.py
index 9688de9e..35a0b180 100644
--- a/apt/cdrom.py
+++ b/apt/cdrom.py
@@ -20,10 +20,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
"""Classes related to cdrom handling."""
+from __future__ import print_function
+
import glob
import apt_pkg
-from apt.deprecation import AttributeDeprecatedBy
from apt.progress.base import CdromProgress
@@ -84,6 +85,3 @@ class Cdrom(apt_pkg.Cdrom):
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 adf9b348..3f4bca4b 100644
--- a/apt/debfile.py
+++ b/apt/debfile.py
@@ -17,6 +17,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
"""Classes for working with locally available Debian packages."""
+from __future__ import print_function
+
import apt
import apt_inst
import apt_pkg
@@ -25,19 +27,21 @@ import os
import sys
from apt_pkg import gettext as _
-from StringIO import StringIO
+from io import BytesIO
+
class NoDebArchiveException(IOError):
"""Exception which is raised if a file is no Debian archive."""
+
class DebPackage(object):
"""A Debian Package (.deb file)."""
# Constants for comparing the local package file with the version
# in the cache
- (VERSION_NONE,
- VERSION_OUTDATED,
- VERSION_SAME,
+ (VERSION_NONE,
+ VERSION_OUTDATED,
+ VERSION_SAME,
VERSION_NEWER) = range(4)
debug = 0
@@ -68,7 +72,7 @@ class DebPackage(object):
self._sections = apt_pkg.TagSection(control)
self.pkgname = self._sections["Package"]
self._check_was_run = False
-
+
def __getitem__(self, key):
return self._sections[key]
@@ -91,29 +95,31 @@ class DebPackage(object):
""" return the list of files in control.tar.gt """
control = []
try:
- self._debfile.control.go(lambda item, data: control.append(item.name))
+ self._debfile.control.go(
+ lambda item, data: control.append(item.name))
except SystemError:
return [_("List of control files for '%s' could not be read") %
self.filename]
return sorted(control)
-
# helper that will return a pkgname with a multiarch suffix if needed
- def _maybe_append_multiarch_suffix(self, pkgname,
+ def _maybe_append_multiarch_suffix(self, pkgname,
in_conflict_checking=False):
# trivial cases
+ if ":" in pkgname:
+ return pkgname
if not self._multiarch:
return pkgname
elif self._cache.is_virtual_package(pkgname):
return pkgname
- elif (pkgname in self._cache and
+ elif (pkgname in self._cache and
self._cache[pkgname].candidate and
self._cache[pkgname].candidate.architecture == "all"):
return pkgname
# now do the real multiarch checking
multiarch_pkgname = "%s:%s" % (pkgname, self._multiarch)
# the upper layers will handle this
- if not multiarch_pkgname in self._cache:
+ if multiarch_pkgname not in self._cache:
return multiarch_pkgname
# now check the multiarch state
cand = self._cache[multiarch_pkgname].candidate._cand
@@ -124,8 +130,8 @@ class DebPackage(object):
return pkgname
# for conflicts we need a special case here, any not multiarch enabled
# package has a implicit conflict
- if (in_conflict_checking and
- not (cand.multi_arch & cand.MULTI_ARCH_SAME)):
+ if (in_conflict_checking and
+ not (cand.multi_arch & cand.MULTI_ARCH_SAME)):
return pkgname
return multiarch_pkgname
@@ -146,9 +152,11 @@ class DebPackage(object):
depname = self._maybe_append_multiarch_suffix(depname)
# check for virtual pkgs
- if not depname in self._cache:
+ if depname not in self._cache:
if self._cache.is_virtual_package(depname):
- self._dbg(3, "_is_or_group_satisfied(): %s is virtual dep" % depname)
+ self._dbg(
+ 3, "_is_or_group_satisfied(): %s is virtual dep" %
+ depname)
for pkg in self._cache.get_providing_packages(depname):
if pkg.is_installed:
return True
@@ -161,13 +169,15 @@ class DebPackage(object):
# if no real dependency is installed, check if there is
# a package installed that provides this dependency
# (e.g. scrollkeeper dependecies are provided by rarian-compat)
- # but only do that if there is no version required in the
+ # but only do that if there is no version required in the
# dependency (we do not supprot versionized dependencies)
if not oper:
for ppkg in self._cache.get_providing_packages(
depname, include_nonvirtual=True):
if ppkg.is_installed:
- self._dbg(3, "found installed '%s' that provides '%s'" % (ppkg.name, depname))
+ self._dbg(
+ 3, "found installed '%s' that provides '%s'" % (
+ ppkg.name, depname))
return True
return False
@@ -180,7 +190,7 @@ class DebPackage(object):
depname = self._maybe_append_multiarch_suffix(depname)
# if we don't have it in the cache, it may be virtual
- if not depname in self._cache:
+ if depname not in self._cache:
if not self._cache.is_virtual_package(depname):
continue
providers = self._cache.get_providing_packages(depname)
@@ -210,16 +220,19 @@ class DebPackage(object):
or_str += dep[0]
if ver and oper:
or_str += " (%s %s)" % (dep[2], dep[1])
- if dep != or_group[len(or_group)-1]:
+ if dep != or_group[len(or_group) - 1]:
or_str += "|"
- self._failure_string += _("Dependency is not satisfiable: %s\n") % or_str
+ self._failure_string += _(
+ "Dependency is not satisfiable: %s\n") % or_str
return False
def _check_single_pkg_conflict(self, pkgname, ver, oper):
"""Return True if a pkg conflicts with a real installed/marked pkg."""
# FIXME: deal with conflicts against its own provides
# (e.g. Provides: ftp-server, Conflicts: ftp-server)
- self._dbg(3, "_check_single_pkg_conflict() pkg='%s' ver='%s' oper='%s'" % (pkgname, ver, oper))
+ self._dbg(
+ 3, "_check_single_pkg_conflict() pkg='%s' ver='%s' oper='%s'" % (
+ pkgname, ver, oper))
pkg = self._cache[pkgname]
if pkg.is_installed:
pkgver = pkg.installed.version
@@ -232,7 +245,7 @@ class DebPackage(object):
#print "pkgver: %s " % pkgver
#print "oper: %s " % oper
if (apt_pkg.check_dep(pkgver, oper, ver) and not
- self.replaces_real_pkg(pkgname, oper, ver)):
+ self.replaces_real_pkg(pkgname, oper, ver)):
self._failure_string += _("Conflicts with the installed package "
"'%s'") % pkg.name
self._dbg(3, "conflicts with installed pkg '%s'" % pkg.name)
@@ -253,7 +266,7 @@ class DebPackage(object):
depname, in_conflict_checking=True)
# check conflicts with virtual pkgs
- if not depname in self._cache:
+ if depname not in self._cache:
# FIXME: we have to check for virtual replaces here as
# well (to pass tests/gdebi-test8.deb)
if self._cache.is_virtual_package(depname):
@@ -263,8 +276,8 @@ class DebPackage(object):
if self.pkgname == pkg.name:
self._dbg(3, "conflict on self, ignoring")
continue
- if self._check_single_pkg_conflict(pkg.name, ver,
- oper):
+ if self._check_single_pkg_conflict(
+ pkg.name, ver, oper):
self._installed_conflicts.add(pkg.name)
continue
if self._check_single_pkg_conflict(depname, ver, oper):
@@ -276,7 +289,7 @@ class DebPackage(object):
"""List of package names conflicting with this package."""
key = "Conflicts"
try:
- return apt_pkg.parse_depends(self._sections[key])
+ return apt_pkg.parse_depends(self._sections[key], False)
except KeyError:
return []
@@ -287,7 +300,8 @@ class DebPackage(object):
# find depends
for key in "Depends", "Pre-Depends":
try:
- depends.extend(apt_pkg.parse_depends(self._sections[key]))
+ depends.extend(
+ apt_pkg.parse_depends(self._sections[key], False))
except KeyError:
pass
return depends
@@ -297,7 +311,7 @@ class DebPackage(object):
"""List of virtual packages which are provided by this package."""
key = "Provides"
try:
- return apt_pkg.parse_depends(self._sections[key])
+ return apt_pkg.parse_depends(self._sections[key], False)
except KeyError:
return []
@@ -306,7 +320,7 @@ class DebPackage(object):
"""List of packages which are replaced by this package."""
key = "Replaces"
try:
- return apt_pkg.parse_depends(self._sections[key])
+ return apt_pkg.parse_depends(self._sections[key], False)
except KeyError:
return []
@@ -347,22 +361,22 @@ class DebPackage(object):
return res
def check_breaks_existing_packages(self):
- """
- check if installing the package would break exsisting
+ """
+ check if installing the package would break exsisting
package on the system, e.g. system has:
smc depends on smc-data (= 1.4)
and user tries to installs smc-data 1.6
"""
# show progress information as this step may take some time
size = float(len(self._cache))
- steps = max(int(size/50), 1)
+ steps = max(int(size / 50), 1)
debver = self._sections["Version"]
debarch = self._sections["Architecture"]
# store what we provide so that we can later check against that
- provides = [ x[0][0] for x in self.provides]
+ provides = [x[0][0] for x in self.provides]
for (i, pkg) in enumerate(self._cache):
- if i%steps == 0:
- self._cache.op_progress.update(float(i)/size*100.0)
+ if i % steps == 0:
+ self._cache.op_progress.update(float(i) / size * 100.0)
if not pkg.is_installed:
continue
# check if the exising dependencies are still satisfied
@@ -371,14 +385,21 @@ class DebPackage(object):
for dep_or in pkg.installed.dependencies:
for dep in dep_or.or_dependencies:
if dep.name == self.pkgname:
- if not apt_pkg.check_dep(debver, dep.relation, dep.version):
+ if not apt_pkg.check_dep(
+ debver, dep.relation, dep.version):
self._dbg(2, "would break (depends) %s" % pkg.name)
- # TRANSLATORS: the first '%s' is the package that breaks, the second the dependency that makes it break, the third the relation (e.g. >=) and the latest the version for the releation
- self._failure_string += _("Breaks existing package '%(pkgname)s' dependency %(depname)s (%(deprelation)s %(depversion)s)") % {
- 'pkgname' : pkg.name,
- 'depname' : dep.name,
- 'deprelation' : dep.relation,
- 'depversion' : dep.version}
+ # TRANSLATORS: the first '%s' is the package that
+ # breaks, the second the dependency that makes it
+ # break, the third the relation (e.g. >=) and the
+ # latest the version for the releation
+ self._failure_string += _(
+ "Breaks existing package '%(pkgname)s' "
+ "dependency %(depname)s "
+ "(%(deprelation)s %(depversion)s)") % {
+ 'pkgname': pkg.name,
+ 'depname': dep.name,
+ 'deprelation': dep.relation,
+ 'depversion': dep.version}
self._cache.op_progress.done()
return False
# now check if there are conflicts against this package on
@@ -386,25 +407,41 @@ class DebPackage(object):
if "Conflicts" in ver.depends_list:
for conflicts_ver_list in ver.depends_list["Conflicts"]:
for c_or in conflicts_ver_list:
- if c_or.target_pkg.name == self.pkgname and c_or.target_pkg.architecture == debarch:
- if apt_pkg.check_dep(debver, c_or.comp_type, c_or.target_ver):
- self._dbg(2, "would break (conflicts) %s" % pkg.name)
- # TRANSLATORS: the first '%s' is the package that conflicts, the second the packagename that it conflicts with (so the name of the deb the user tries to install), the third is the relation (e.g. >=) and the last is the version for the relation
- self._failure_string += _("Breaks existing package '%(pkgname)s' conflict: %(targetpkg)s (%(comptype)s %(targetver)s)") % {
- 'pkgname' : pkg.name,
- 'targetpkg' : c_or.target_pkg.name,
- 'comptype' : c_or.comp_type,
- 'targetver' : c_or.target_ver }
+ if (c_or.target_pkg.name == self.pkgname and
+ c_or.target_pkg.architecture == debarch):
+ if apt_pkg.check_dep(
+ debver, c_or.comp_type, c_or.target_ver):
+ self._dbg(
+ 2, "would break (conflicts) %s" % pkg.name)
+ # TRANSLATORS: the first '%s' is the package
+ # that conflicts, the second the packagename
+ # that it conflicts with (so the name of the
+ # deb the user tries to install), the third is
+ # the relation (e.g. >=) and the last is the
+ # version for the relation
+ self._failure_string += _(
+ "Breaks existing package '%(pkgname)s' "
+ "conflict: %(targetpkg)s "
+ "(%(comptype)s %(targetver)s)") % {
+ 'pkgname': pkg.name,
+ 'targetpkg': c_or.target_pkg.name,
+ 'comptype': c_or.comp_type,
+ 'targetver': c_or.target_ver}
self._cache.op_progress.done()
return False
if (c_or.target_pkg.name in provides and
- self.pkgname != pkg.name):
- self._dbg(2, "would break (conflicts) %s" % provides)
- self._failure_string += _("Breaks existing package '%(pkgname)s' that conflict: '%(targetpkg)s'. But the '%(debfile)s' provides it via: '%(provides)s'") % {
- 'provides' : ",".join(provides),
- 'debfile' : self.filename,
- 'targetpkg' : c_or.target_pkg.name,
- 'pkgname' : pkg.name }
+ self.pkgname != pkg.name):
+ self._dbg(
+ 2, "would break (conflicts) %s" % provides)
+ self._failure_string += _(
+ "Breaks existing package '%(pkgname)s' "
+ "that conflict: '%(targetpkg)s'. But the "
+ "'%(debfile)s' provides it via: "
+ "'%(provides)s'") % {
+ 'provides': ",".join(provides),
+ 'debfile': self.filename,
+ 'targetpkg': c_or.target_pkg.name,
+ 'pkgname': pkg.name}
self._cache.op_progress.done()
return False
self._cache.op_progress.done()
@@ -419,6 +456,11 @@ class DebPackage(object):
"""
self._dbg(3, "compare_to_version_in_cache")
pkgname = self._sections["Package"]
+ architecture = self._sections["Architecture"]
+
+ # Arch qualify the package name
+ pkgname = ":".join([pkgname, architecture])
+
debver = self._sections["Version"]
self._dbg(1, "debver: %s" % debver)
if pkgname in self._cache:
@@ -439,19 +481,19 @@ class DebPackage(object):
return self.VERSION_OUTDATED
return self.VERSION_NONE
- def check(self):
+ def check(self, allow_downgrade=False):
"""Check if the package is installable."""
self._dbg(3, "check")
self._check_was_run = True
# check arch
- if not "Architecture" in self._sections:
+ if "Architecture" not in self._sections:
self._dbg(1, "ERROR: no architecture field")
self._failure_string = _("No Architecture field in the package")
return False
arch = self._sections["Architecture"]
- if arch != "all" and arch != apt_pkg.config.find("APT::Architecture"):
+ if arch != "all" and arch != apt_pkg.config.find("APT::Architecture"):
if arch in apt_pkg.get_architectures():
self._multiarch = arch
self.pkgname = "%s:%s" % (self.pkgname, self._multiarch)
@@ -462,10 +504,12 @@ class DebPackage(object):
return False
# check version
- if self.compare_to_version_in_cache() == self.VERSION_OUTDATED:
+ if (not allow_downgrade and
+ self.compare_to_version_in_cache() == self.VERSION_OUTDATED):
if self._cache[self.pkgname].installed:
# the deb is older than the installed
- self._failure_string = _("A later version is already installed")
+ self._failure_string = _(
+ "A later version is already installed")
return False
# FIXME: this sort of error handling sux
@@ -475,7 +519,7 @@ class DebPackage(object):
if not self.check_conflicts():
return False
- # check if installing it would break anything on the
+ # check if installing it would break anything on the
# current system
if not self.check_breaks_existing_packages():
return False
@@ -499,19 +543,18 @@ class DebPackage(object):
def satisfy_depends_str(self, dependsstr):
"""Satisfy the dependencies in the given string."""
- return self._satisfy_depends(apt_pkg.parse_depends(dependsstr))
+ return self._satisfy_depends(apt_pkg.parse_depends(dependsstr, False))
def _satisfy_depends(self, depends):
"""Satisfy the dependencies."""
# turn off MarkAndSweep via a action group (if available)
try:
_actiongroup = apt_pkg.ActionGroup(self._cache._depcache)
+ _actiongroup # pyflakes
except AttributeError:
pass
# check depends
for or_group in depends:
- #print "or_group: %s" % or_group
- #print "or_group satified: %s" % self._is_or_group_satisfied(or_group)
if not self._is_or_group_satisfied(or_group):
if not self._satisfy_or_group(or_group):
return False
@@ -530,7 +573,8 @@ class DebPackage(object):
"""Return missing dependencies."""
self._dbg(1, "Installing: %s" % self._need_pkgs)
if not self._check_was_run:
- raise AttributeError("property only available after check() was run")
+ raise AttributeError(
+ "property only available after check() was run")
return self._need_pkgs
@property
@@ -543,7 +587,8 @@ class DebPackage(object):
remove = []
unauthenticated = []
if not self._check_was_run:
- raise AttributeError("property only available after check() was run")
+ raise AttributeError(
+ "property only available after check() was run")
for pkg in self._cache:
if pkg.marked_install or pkg.marked_upgrade:
install.append(pkg.name)
@@ -562,7 +607,7 @@ class DebPackage(object):
def to_hex(in_data):
hex = ""
for (i, c) in enumerate(in_data):
- if i%80 == 0:
+ if i % 80 == 0:
hex += "\n"
hex += "%2.2x " % ord(c)
return hex
@@ -585,20 +630,20 @@ class DebPackage(object):
else:
s += chr(b)
return s
-
+
def _get_content(self, part, name, auto_decompress=True, auto_hex=True):
if name.startswith("./"):
name = name[2:]
data = part.extractdata(name)
# check for zip content
if name.endswith(".gz") and auto_decompress:
- io = StringIO(data)
+ io = BytesIO(data)
gz = gzip.GzipFile(fileobj=io)
- data = _("Automatically decompressed:\n\n")
+ data = _("Automatically decompressed:\n\n").encode("utf-8")
data += gz.read()
# auto-convert to hex
try:
- data = unicode(data, "utf-8")
+ data = data.decode("utf-8")
except Exception:
new_data = _("Automatically converted to printable ascii:\n")
new_data += self.to_strish(data)
@@ -622,7 +667,7 @@ class DebPackage(object):
def _dbg(self, level, msg):
"""Write debugging output to sys.stderr."""
if level <= self.debug:
- print >> sys.stderr, msg
+ print(msg, file=sys.stderr)
def install(self, install_progress=None):
"""Install the package."""
@@ -640,6 +685,7 @@ class DebPackage(object):
install_progress.finishUpdate()
return res
+
class DscSrcPackage(DebPackage):
"""A locally available source package."""
@@ -664,28 +710,42 @@ class DscSrcPackage(DebPackage):
"""Return the dependencies of the package"""
return self._conflicts
+ @property
+ def filelist(self):
+ """Return the list of files associated with this dsc file"""
+ # Files stanza looks like (hash, size, filename, ...)
+ return self._sections['Files'].split()[2::3]
+
def open(self, file):
"""Open the package."""
depends_tags = ["Build-Depends", "Build-Depends-Indep"]
conflicts_tags = ["Build-Conflicts", "Build-Conflicts-Indep"]
- fobj = open(file)
+ fd = apt_pkg.open_maybe_clear_signed_file(file)
+ fobj = os.fdopen(fd)
tagfile = apt_pkg.TagFile(fobj)
try:
for sec in tagfile:
+ # we only care about the stanza with the "Format:" tag, the
+ # rest is gpg signature noise. we should probably have
+ # bindings for apts OpenMaybeClearsignedFile()
+ if "Format" not in sec:
+ continue
for tag in depends_tags:
- if not tag in sec:
+ if tag not in sec:
continue
self._depends.extend(apt_pkg.parse_src_depends(sec[tag]))
for tag in conflicts_tags:
- if not tag in sec:
+ if tag not in sec:
continue
self._conflicts.extend(apt_pkg.parse_src_depends(sec[tag]))
if 'Source' in sec:
self.pkgname = sec['Source']
if 'Binary' in sec:
- self.binaries = sec['Binary'].split(', ')
- if 'Version' in sec:
- self._sections['Version'] = sec['Version']
+ self.binaries = [b.strip() for b in
+ sec['Binary'].split(',')]
+ for tag in sec.keys():
+ if tag in sec:
+ self._sections[tag] = sec[tag]
finally:
del tagfile
fobj.close()
@@ -695,7 +755,7 @@ class DscSrcPackage(DebPackage):
" ".join(self.binaries))
self._sections["Description"] = s
self._check_was_run = False
-
+
def check(self):
"""Check if the package is installable.."""
if not self.check_conflicts():
@@ -709,6 +769,7 @@ class DscSrcPackage(DebPackage):
# after _satisfy_depends() should probably be done
return self._satisfy_depends(self.depends)
+
def _test():
"""Test function"""
from apt.cache import Cache
@@ -717,25 +778,25 @@ def _test():
cache = Cache()
vp = "www-browser"
- print "%s virtual: %s" % (vp, cache.is_virtual_package(vp))
+ print("%s virtual: %s" % (vp, cache.is_virtual_package(vp)))
providers = cache.get_providing_packages(vp)
- print "Providers for %s :" % vp
+ print("Providers for %s :" % vp)
for pkg in providers:
- print " %s" % pkg.name
+ print(" %s" % pkg.name)
d = DebPackage(sys.argv[1], cache)
- print "Deb: %s" % d.pkgname
+ print("Deb: %s" % d.pkgname)
if not d.check():
- print "can't be satified"
- print d._failure_string
- print "missing deps: %s" % d.missing_deps
- print d.required_changes
+ print("can't be satified")
+ print(d._failure_string)
+ print("missing deps: %s" % d.missing_deps)
+ print(d.required_changes)
- print d.filelist
+ print(d.filelist)
- print "Installing ..."
+ print("Installing ...")
ret = d.install(InstallProgress())
- print ret
+ print(ret)
#s = DscSrcPackage(cache, "../tests/3ddesktop_0.2.9-6.dsc")
#s.check_dep()
@@ -744,7 +805,7 @@ def _test():
s = DscSrcPackage(cache=cache)
d = "libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)"
- print s._satisfy_depends(apt_pkg.parse_depends(d))
+ print(s._satisfy_depends(apt_pkg.parse_depends(d, False)))
if __name__ == "__main__":
_test()
diff --git a/apt/deprecation.py b/apt/deprecation.py
deleted file mode 100644
index 0f39ad63..00000000
--- a/apt/deprecation.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# deprecation.py - Module providing classes and functions for deprecation.
-#
-# Copyright (c) 2009 Julian Andres Klode <jak@debian.org>
-# Copyright (c) 2009 Ben Finney <ben+debian@benfinney.id.au>
-#
-# 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
-
-import apt_pkg
-
-__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.__name__
-
- def deprecated_function(*args, **kwds):
- """Wrapper around a deprecated function."""
- 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
-
-
-def deprecated_args(func):
- """A function with deprecated arguments.
-
- Similar to function_deprecated_by() but warns on every deprecated argument
- instead of function calls.
- """
- if not apt_pkg._COMPAT_0_7:
- return func
-
- def deprecated_function(*args, **kwds):
- """Wrapper around a function with deprecated arguments."""
- for key in kwds.keys():
- new_key = re.sub('([A-Z])', '_\\1', key).lower()
- if new_key != key:
- warnings.warn("Deprecated parameter %r" % key)
- kwds[new_key] = kwds.pop(key)
- return func(*args, **kwds)
-
- # Wrap the function completely (same as functools.wraps)
- # pylint: disable-msg=W0622
- deprecated_function.__name__ = func.__name__
- deprecated_function.__doc__ = func.__doc__
- deprecated_function.__module__ = func.__module__
- deprecated_function.__dict__.update(func.__dict__)
- return deprecated_function
diff --git a/apt/package.py b/apt/package.py
index dbaab320..57c89b35 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -19,34 +19,35 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
"""Functionality related to packages."""
-import httplib
+from __future__ import print_function
+
+
import os
import sys
import re
import socket
import subprocess
-import urllib2
-import warnings
-try:
- from collections import Mapping, Sequence
-except ImportError:
- # (for Python < 2.6) pylint: disable-msg=C0103
- Sequence = Mapping = object
try:
- from collections import Sequence
+ from http.client import BadStatusLine
+ from urllib.error import HTTPError
+ from urllib.request import urlopen
except ImportError:
- Sequence = object
+ from httplib import BadStatusLine
+ from urllib2 import HTTPError, urlopen
+
+from collections import Mapping, Sequence
import apt_pkg
import apt.progress.text
from apt_pkg import gettext as _
-from apt.deprecation import (function_deprecated_by, AttributeDeprecatedBy,
- deprecated_args)
__all__ = ('BaseDependency', 'Dependency', 'Origin', 'Package', 'Record',
'Version', 'VersionList')
+if sys.version_info.major >= 3:
+ unicode = str
+
def _file_is_same(path, size, md5):
"""Return ``True`` if the file is the same."""
@@ -60,38 +61,77 @@ class FetchError(Exception):
class BaseDependency(object):
- """A single dependency.
-
- Attributes defined here:
- name - The name of the dependency
- relation - The relation (>,>=,==,<,<=,)
- version - The version depended on
- rawtype - The type of the dependendy (e.g. 'Recommends')
- pre_depend - Boolean value whether this is a pre-dependency.
- """
+ """A single dependency."""
class __dstr(str):
- """Helper to make > match >> and < match <<"""
+ """Compare helper for compatibility with old third-party code.
+
+ Old third-party code might still compare the relation with the
+ previously used relations (<<,<=,==,!=,>=,>>,) instead of the curently
+ used ones (<,<=,=,!=,>=,>,). This compare helper lets < match to <<,
+ > match to >> and = match to ==.
+ """
def __eq__(self, other):
- return str.__eq__(self, other) or str.__eq__(2 * self, other)
+ if str.__eq__(self, other):
+ return True
+ elif str.__eq__(self, '<'):
+ return str.__eq__('<<', other)
+ elif str.__eq__(self, '>'):
+ return str.__eq__('>>', other)
+ elif str.__eq__(self, '='):
+ return str.__eq__('==', other)
+ else:
+ return False
def __ne__(self, other):
- return str.__eq__(self, other) and str.__ne__(2 * self, other)
+ return not self.__eq__(other)
- def __init__(self, name, rel, ver, pre, rawtype=None):
- self.name = name
- self.relation = len(rel) == 1 and self.__dstr(rel) or rel
- self.version = ver
- self.pre_depend = pre
- self.rawtype = rawtype
+ def __init__(self, dep):
+ self._dep = dep # apt_pkg.Dependency
- def __repr__(self):
- return ('<BaseDependency: name:%r relation:%r version:%r preDepend:%r>'
- % (self.name, self.relation, self.version, self.pre_depend))
+ @property
+ def name(self):
+ """The name of the target package."""
+ return self._dep.target_pkg.name
+
+ @property
+ def relation(self):
+ """The relation (<, <=, !=, =, >=, >, ).
+
+ Note that the empty string is a valid string as well, if no version
+ is specified.
+ """
+ return self.__dstr(self._dep.comp_type)
- if apt_pkg._COMPAT_0_7:
- preDepend = AttributeDeprecatedBy('pre_depend')
+ @property
+ def version(self):
+ """The target version or an empty string.
+
+ Note that the version is only an empty string in case of an unversioned
+ dependency. In this case the relation is also an empty string.
+ """
+ return self._dep.target_ver
+
+ @property
+ def rawtype(self):
+ """Type of the dependency.
+
+ This should be one of 'Breaks', 'Conflicts', 'Depends', 'Enhances',
+ 'PreDepends', 'Recommends', 'Replaces', 'Suggests'.
+
+ Additional types might be added in the future.
+ """
+ return self._dep.dep_type_untranslated
+
+ @property
+ def pre_depend(self):
+ """Whether this is a PreDepends."""
+ return self._dep.dep_type_untranslated == 'PreDepends'
+
+ def __repr__(self):
+ return ('<BaseDependency: name:%r relation:%r version:%r rawtype:%r>'
+ % (self.name, self.relation, self.version, self.rawtype))
class Dependency(list):
@@ -99,34 +139,29 @@ class Dependency(list):
Attributes defined here:
or_dependencies - The possible choices
+ rawtype - The type of the dependencies in the Or-group
"""
- def __init__(self, alternatives):
- super(Dependency, self).__init__()
- self.extend(alternatives)
+ def __init__(self, base_deps, rawtype):
+ super(Dependency, self).__init__(base_deps)
+ self._rawtype = rawtype
@property
def or_dependencies(self):
return self
-class DeprecatedProperty(property):
- """A property which gives DeprecationWarning on access.
+ @property
+ def rawtype(self):
+ """Type of the Or-group of dependency.
- This is only used for providing the properties in Package, which have been
- replaced by the ones in Version.
- """
+ This should be one of 'Breaks', 'Conflicts', 'Depends', 'Enhances',
+ 'PreDepends', 'Recommends', 'Replaces', 'Suggests'.
- def __init__(self, fget=None, fset=None, fdel=None, doc=None):
- property.__init__(self, fget, fset, fdel, doc)
- self.__doc__ = (doc or fget.__doc__ or '')
+ Additional types might be added in the future.
- def __get__(self, obj, type_=None):
- if obj is not None:
- warnings.warn("Accessed deprecated property %s.%s, please see the "
- "Version class for alternatives." %
- ((obj.__class__.__name__ or type_.__name__),
- self.fget.__name__), DeprecationWarning, 2)
- return property.__get__(self, obj, type_)
+ .. versionadded:: 1.0.0
+ """
+ return self._rawtype
class Origin(object):
@@ -356,14 +391,14 @@ class Version(object):
try:
if not isinstance(dsc, unicode):
# Only convert where needed (i.e. Python 2.X)
- dsc = unicode(dsc, "utf-8")
+ dsc = dsc.decode("utf-8")
except UnicodeDecodeError as err:
return _("Invalid unicode in description for '%s' (%s). "
- "Please report.") % (self.package.name, err)
+ "Please report.") % (self.package.name, err)
lines = iter(dsc.split("\n"))
# Skip the first line, since its a duplication of the summary
- lines.next()
+ next(lines)
for raw_line in lines:
if raw_line.strip() == ".":
# The line is just line break
@@ -417,7 +452,7 @@ class Version(object):
"""
priority = 0
policy = self.package._pcache._depcache.policy
- for (packagefile, _) in self._cand.file_list:
+ for (packagefile, _unused) in self._cand.file_list:
priority = max(priority, policy.get_priority(packagefile))
return priority
@@ -431,7 +466,14 @@ class Version(object):
return Record(self._records.record)
def get_dependencies(self, *types):
- """Return a list of Dependency objects for the given types."""
+ """Return a list of Dependency objects for the given types.
+
+ Multiple types can be specified. Possible types are:
+ 'Breaks', 'Conflicts', 'Depends', 'Enhances', 'PreDepends',
+ 'Recommends', 'Replaces', 'Suggests'
+
+ Additional types might be added in the future.
+ """
depends_list = []
depends = self._cand.depends_list
for type_ in types:
@@ -439,11 +481,8 @@ class Version(object):
for dep_ver_list in depends[type_]:
base_deps = []
for dep_or in dep_ver_list:
- base_deps.append(BaseDependency(dep_or.target_pkg.name,
- dep_or.comp_type, dep_or.target_ver,
- (type_ == "PreDepends"),
- rawtype=type_))
- depends_list.append(Dependency(base_deps))
+ base_deps.append(BaseDependency(dep_or))
+ depends_list.append(Dependency(base_deps, type_))
except KeyError:
pass
return depends_list
@@ -452,7 +491,7 @@ class Version(object):
def provides(self):
""" Return a list of names that this version provides."""
return [p[0] for p in self._cand.provides_list]
-
+
@property
def enhances(self):
"""Return the list of enhances for the package version."""
@@ -477,7 +516,7 @@ class Version(object):
def origins(self):
"""Return a list of origins for the package version."""
origins = []
- for (packagefile, _) in self._cand.file_list:
+ for (packagefile, _unused) in self._cand.file_list:
origins.append(Origin(self.package, packagefile))
return origins
@@ -528,7 +567,7 @@ class Version(object):
.. versionadded:: 0.7.10
"""
- for (packagefile, _) in self._cand.file_list:
+ for (packagefile, _unused) in self._cand.file_list:
indexfile = self.package._pcache._list.find_index(packagefile)
if indexfile:
yield indexfile.archive_uri(self._records.filename)
@@ -548,7 +587,7 @@ class Version(object):
.. versionadded:: 0.7.10
"""
try:
- return iter(self._uris()).next()
+ return next(iter(self._uris()))
except StopIteration:
return None
@@ -567,7 +606,7 @@ class Version(object):
base = os.path.basename(self._records.filename)
destfile = os.path.join(destdir, base)
if _file_is_same(destfile, self.size, self._records.md5_hash):
- print('Ignoring already existing file: %s' % destfile)
+ print(('Ignoring already existing file: %s' % destfile))
return os.path.abspath(destfile)
acq = apt_pkg.Acquire(progress or apt.progress.text.AcquireProgress())
acqfile = apt_pkg.AcquireFile(acq, self.uri, self._records.md5_hash,
@@ -616,7 +655,7 @@ class Version(object):
if type_ == 'dsc':
dsc = destfile
if _file_is_same(destfile, size, md5):
- print('Ignoring already existing file: %s' % destfile)
+ print(('Ignoring already existing file: %s' % destfile))
continue
files.append(apt_pkg.AcquireFile(acq, src.index.archive_uri(path),
md5, size, base, destfile=destfile))
@@ -625,7 +664,7 @@ class Version(object):
for item in acq.items:
if item.status != item.STAT_DONE:
raise FetchError("The item %r could not be fetched: %s" %
- (item.destfile, item.error_text))
+ (item.destfile, item.error_text))
if unpack:
outdir = src.package + '-' + apt_pkg.upstream_version(src.version)
@@ -657,8 +696,8 @@ class VersionList(Sequence):
"""
def __init__(self, package, slice_=None):
- self._package = package # apt.package.Package()
- self._versions = package._pkg.version_list # [apt_pkg.Version(), ...]
+ self._package = package # apt.package.Package()
+ self._versions = package._pkg.version_list # [apt_pkg.Version(), ...]
if slice_:
self._versions = self._versions[slice_]
@@ -683,7 +722,7 @@ class VersionList(Sequence):
return (Version(self._package, ver) for ver in self._versions)
def __contains__(self, item):
- if isinstance(item, Version): # Sequence interface
+ if isinstance(item, Version): # Sequence interface
item = item.version
# Dictionary interface.
for ver in self._versions:
@@ -726,8 +765,8 @@ class Package(object):
self._changelog = "" # Cached changelog
def __repr__(self):
- return '<Package: name:%r architecture=%r id:%r>' % (self._pkg.name,
- self._pkg.architecture, self._pkg.id)
+ return '<Package: name:%r architecture=%r id:%r>' % (
+ self._pkg.name, self._pkg.architecture, self._pkg.id)
def __lt__(self, other):
return self.name < other.name
@@ -769,6 +808,7 @@ class Package(object):
as :attr:`shortname`
.. versionchanged:: 0.7.100.3
+
As part of multi-arch, this field now may include architecture
information.
"""
@@ -806,36 +846,6 @@ class Package(object):
"""Return True if the package is an essential part of the system."""
return self._pkg.essential
- @DeprecatedProperty
- def installedVersion(self): #pylint: disable-msg=C0103
- """Return the installed version as string.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.installed, 'version', None)
-
- @DeprecatedProperty
- def candidateVersion(self): #pylint: disable-msg=C0103
- """Return the candidate version as string.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.candidate, "version", None)
-
- @DeprecatedProperty
- def candidateDependencies(self): #pylint: disable-msg=C0103
- """Return a list of candidate dependencies.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "dependencies", None)
-
- @DeprecatedProperty
- def installedDependencies(self): #pylint: disable-msg=C0103
- """Return a list of installed dependencies.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'dependencies', [])
-
def architecture(self):
"""Return the Architecture of the package.
@@ -846,107 +856,11 @@ class Package(object):
"""
return self._pkg.architecture
- @DeprecatedProperty
- def candidateDownloadable(self): #pylint: disable-msg=C0103
- """Return ``True`` if the candidate is downloadable.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "downloadable", None)
-
- @DeprecatedProperty
- def installedDownloadable(self): #pylint: disable-msg=C0103
- """Return ``True`` if the installed version is downloadable.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'downloadable', False)
-
- @DeprecatedProperty
- def sourcePackageName(self): #pylint: disable-msg=C0103
- """Return the source package name as string.
-
- .. deprecated:: 0.7.9
- """
- try:
- return self.candidate._records.source_pkg or self._pkg.name
- except AttributeError:
- try:
- return self.installed._records.source_pkg or self._pkg.name
- except AttributeError:
- return self._pkg.name
-
- @DeprecatedProperty
- def homepage(self):
- """Return the homepage field as string.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "homepage", None)
-
@property
def section(self):
"""Return the section of the package."""
return self._pkg.section
- @DeprecatedProperty
- def priority(self):
- """Return the priority (of the candidate version).
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "priority", None)
-
- @DeprecatedProperty
- def installedPriority(self): #pylint: disable-msg=C0103
- """Return the priority (of the installed version).
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'priority', None)
-
- @DeprecatedProperty
- def summary(self):
- """Return the short description (one line summary).
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "summary", None)
-
- @DeprecatedProperty
- def description(self):
- """Return the formatted long description.
-
- Return the formatted long description according to the Debian policy
- (Chapter 5.6.13).
- See http://www.debian.org/doc/debian-policy/ch-controlfields.html
- for more information.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "description", None)
-
- @DeprecatedProperty
- def rawDescription(self): #pylint: disable-msg=C0103
- """return the long description (raw).
-
- .. deprecated:: 0.7.9"""
- return getattr(self.candidate, "raw_description", None)
-
- @DeprecatedProperty
- def candidateRecord(self): #pylint: disable-msg=C0103
- """Return the Record of the candidate version of the package.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.candidate, "record", None)
-
- @DeprecatedProperty
- def installedRecord(self): #pylint: disable-msg=C0103
- """Return the Record of the candidate version of the package.
-
- .. deprecated:: 0.7.9"""
- return getattr(self.installed, 'record', '')
-
# depcache states
@property
@@ -1007,39 +921,6 @@ class Package(object):
return self._pcache._depcache.is_auto_installed(self._pkg)
# sizes
- @DeprecatedProperty
- def packageSize(self): #pylint: disable-msg=C0103
- """Return the size of the candidate deb package.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "size", None)
-
- @DeprecatedProperty
- def installedPackageSize(self): #pylint: disable-msg=C0103
- """Return the size of the installed deb package.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'size', 0)
-
- @DeprecatedProperty
- def candidateInstalledSize(self): #pylint: disable-msg=C0103
- """Return the size of the candidate installed package.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "installed_size", None)
-
- @DeprecatedProperty
- def installedSize(self): #pylint: disable-msg=C0103
- """Return the size of the currently installed package.
-
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.installed, 'installed_size', 0)
-
@property
def installed_files(self):
"""Return a list of files installed by the package.
@@ -1047,7 +928,7 @@ class Package(object):
Return a list of unicode names of the files which have
been installed by this package
"""
- for name in self.shortname, self.fullname:
+ for name in self.name, self.fullname:
path = "/var/lib/dpkg/info/%s.list" % name
try:
with open(path, "rb") as file_list:
@@ -1100,10 +981,10 @@ class Package(object):
src_section = "main"
# use the section of the candidate as a starting point
section = self.candidate.section
-
+
# get the source version
src_ver = self.candidate.source_version
-
+
try:
# try to get the source version of the pkg, this differs
# for some (e.g. libnspr4 on ubuntu)
@@ -1160,7 +1041,7 @@ class Package(object):
if cancel_lock and cancel_lock.isSet():
return u""
# FIXME: python3.2: Should be closed manually
- changelog_file = urllib2.urlopen(uri)
+ changelog_file = urlopen(uri)
# do only get the lines that are new
changelog = u""
regexp = "^%s \((.*)\)(.*)$" % (re.escape(src_pkg))
@@ -1189,7 +1070,7 @@ class Package(object):
changelog_ver = changelog_ver.split(":", 1)[1]
if (installed and apt_pkg.version_compare(
- changelog_ver, installed) <= 0):
+ changelog_ver, installed) <= 0):
break
# EOF (shouldn't really happen)
changelog += line
@@ -1201,29 +1082,25 @@ class Package(object):
changelog = changelog.decode("utf-8")
self._changelog = changelog
- except urllib2.HTTPError:
- 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)
+ except HTTPError:
+ if self.candidate.origins[0].origin == "Ubuntu":
+ 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)
+ else:
+ res = _("The list of changes is not available")
return res if isinstance(res, unicode) else res.decode("utf-8")
- except (IOError, httplib.BadStatusLine):
+ except (IOError, BadStatusLine):
res = _("Failed to download the list of changes. \nPlease "
- "check your Internet connection.")
+ "check your Internet connection.")
return res if isinstance(res, unicode) else res.decode("utf-8")
finally:
socket.setdefaulttimeout(timeout)
return self._changelog
- @DeprecatedProperty
- def candidateOrigin(self): #pylint: disable-msg=C0103
- """Return a list of `Origin()` objects for the candidate version.
-
- .. deprecated:: 0.7.9
- """
- return getattr(self.candidate, "origins", None)
-
@property
def versions(self):
"""Return a VersionList() object for all available versions.
@@ -1242,6 +1119,11 @@ class Package(object):
"""Return True if the installed package is broken."""
return self._pcache._depcache.is_now_broken(self._pkg)
+ @property
+ def has_config_files(self):
+ """Checks whether the package is is the config-files state."""
+ return self. _pkg.current_state == apt_pkg.CURSTATE_CONFIG_FILES
+
# depcache actions
def mark_keep(self):
@@ -1250,7 +1132,6 @@ class Package(object):
self._pcache._depcache.mark_keep(self._pkg)
self._pcache.cache_post_change()
- @deprecated_args
def mark_delete(self, auto_fix=True, purge=False):
"""Mark a package for deletion.
@@ -1272,7 +1153,6 @@ class Package(object):
fix.resolve()
self._pcache.cache_post_change()
- @deprecated_args
def mark_install(self, auto_fix=True, auto_inst=True, from_user=True):
"""Mark a package for install.
@@ -1297,11 +1177,12 @@ class Package(object):
fixer.resolve(True)
self._pcache.cache_post_change()
- def mark_upgrade(self):
+ def mark_upgrade(self, from_user=True):
"""Mark a package for upgrade."""
if self.is_upgradable:
- from_user = not self._pcache._depcache.is_auto_installed(self._pkg)
+ auto = self.is_auto_installed
self.mark_install(from_user=from_user)
+ self.mark_auto(auto)
else:
# FIXME: we may want to throw a exception here
sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: "
@@ -1328,103 +1209,61 @@ 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')
- markedInstall = AttributeDeprecatedBy('marked_install')
- 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"
+ print("Self-test for the Package modul")
import random
apt_pkg.init()
progress = apt.progress.text.OpProgress()
cache = apt.Cache(progress)
pkg = cache["apt-utils"]
- print "Name: %s " % pkg.name
- print "ID: %s " % pkg.id
- print "Priority (Candidate): %s " % pkg.candidate.priority
- print "Priority (Installed): %s " % pkg.installed.priority
- print "Installed: %s " % pkg.installed.version
- print "Candidate: %s " % pkg.candidate.version
- print "CandidateDownloadable: %s" % pkg.candidate.downloadable
- print "CandidateOrigins: %s" % pkg.candidate.origins
- print "SourcePkg: %s " % pkg.candidate.source_name
- print "Section: %s " % pkg.section
- print "Summary: %s" % pkg.candidate.summary
- print "Description (formatted) :\n%s" % pkg.candidate.description
- print "Description (unformatted):\n%s" % pkg.candidate.raw_description
- print "InstalledSize: %s " % pkg.candidate.installed_size
- print "PackageSize: %s " % pkg.candidate.size
- print "Dependencies: %s" % pkg.installed.dependencies
- print "Recommends: %s" % pkg.installed.recommends
+ print("Name: %s " % pkg.name)
+ print("ID: %s " % pkg.id)
+ print("Priority (Candidate): %s " % pkg.candidate.priority)
+ print("Priority (Installed): %s " % pkg.installed.priority)
+ print("Installed: %s " % pkg.installed.version)
+ print("Candidate: %s " % pkg.candidate.version)
+ print("CandidateDownloadable: %s" % pkg.candidate.downloadable)
+ print("CandidateOrigins: %s" % pkg.candidate.origins)
+ print("SourcePkg: %s " % pkg.candidate.source_name)
+ print("Section: %s " % pkg.section)
+ print("Summary: %s" % pkg.candidate.summary)
+ print("Description (formatted) :\n%s" % pkg.candidate.description)
+ print("Description (unformatted):\n%s" % pkg.candidate.raw_description)
+ print("InstalledSize: %s " % pkg.candidate.installed_size)
+ print("PackageSize: %s " % pkg.candidate.size)
+ print("Dependencies: %s" % pkg.installed.dependencies)
+ print("Recommends: %s" % pkg.installed.recommends)
for dep in pkg.candidate.dependencies:
- print ",".join("%s (%s) (%s) (%s)" % (o.name, o.version, o.relation,
- 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(",".join("%s (%s) (%s) (%s)" % (o.name, o.version, o.relation,
+ 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"].get_changelog()
+ print(cache["2vcard"].get_changelog())
for i in True, False:
- print "Running install on random upgradable pkgs with AutoFix: %s " % i
+ print("Running install on random upgradable pkgs with AutoFix: ", i)
for pkg in cache:
if pkg.is_upgradable:
if random.randint(0, 1) == 1:
pkg.mark_install(i)
- print "Broken: %s " % cache._depcache.broken_count
- print "InstCount: %s " % cache._depcache.inst_count
+ print("Broken: %s " % cache._depcache.broken_count)
+ print("InstCount: %s " % cache._depcache.inst_count)
- print
+ print()
# get a new cache
for i in True, False:
- print "Randomly remove some packages with AutoFix: %s" % i
+ print("Randomly remove some packages with AutoFix: %s" % i)
cache = apt.Cache(progress)
for name in cache.keys():
if random.randint(0, 1) == 1:
try:
cache[name].mark_delete(i)
except SystemError:
- print "Error trying to remove: %s " % name
- print "Broken: %s " % cache._depcache.broken_count
- print "DelCount: %s " % cache._depcache.del_count
+ print("Error trying to remove: %s " % name)
+ print("Broken: %s " % cache._depcache.broken_count)
+ print("DelCount: %s " % cache._depcache.del_count)
# self-test
if __name__ == "__main__":
diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py
index 10c11021..1ae94d06 100644
--- a/apt/progress/__init__.py
+++ b/apt/progress/__init__.py
@@ -19,17 +19,11 @@
"""Progress reporting.
This package provides progress reporting for the python-apt package. The module
-'base' provides classes with no output, the module 'gtk2' provides classes for
-GTK+ applications, and the module 'text' provides classes for terminals, etc.
+'base' provides classes with no output, and the module 'text' provides classes
+for terminals, etc.
"""
-import apt_pkg
-
-__all__ = []
+from __future__ import print_function
-if apt_pkg._COMPAT_0_7:
- from apt.progress.old import (CdromProgress, DpkgInstallProgress,
- DumbInstallProgress, FetchProgress,
- InstallProgress, OpProgress,
- OpTextProgress, TextFetchProgress)
+__all__ = []
diff --git a/apt/progress/base.py b/apt/progress/base.py
index 2c80ae29..95eca9ec 100644
--- a/apt/progress/base.py
+++ b/apt/progress/base.py
@@ -22,6 +22,8 @@
Custom progress classes should inherit from these classes. They can also be
used as dummy progress classes which simply do nothing.
"""
+from __future__ import print_function
+
import errno
import fcntl
import os
@@ -217,7 +219,7 @@ class InstallProgress(object):
except IOError as err:
# resource temporarly unavailable is ignored
if err.errno != errno.EAGAIN and err.errno != errno.EWOULDBLOCK:
- print err.strerror
+ print(err.strerror)
return
pkgname = status = status_str = percent = base = ""
@@ -269,7 +271,8 @@ class InstallProgress(object):
try:
select.select([self.status_stream], [], [],
self.select_timeout)
- except select.error as (errno_, _errstr):
+ except select.error as error:
+ (errno_, _errstr) = error.args
if errno_ != errno.EINTR:
raise
diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py
deleted file mode 100644
index c2635ca0..00000000
--- a/apt/progress/gtk2.py
+++ /dev/null
@@ -1,519 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (c) 2004-2009 Canonical
-#
-# Authors: Michael Vogt <michael.vogt@ubuntu.com>
-# Sebastian Heinlein <glatzor@ubuntu.com>
-# Julian Andres Klode <jak@debian.org>
-#
-# 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
-"""GObject-powered progress classes and a GTK+ status widget."""
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-try:
- import glib
-except ImportError:
- import gobject as glib
-import gobject
-import pango
-import time
-import vte
-
-import apt_pkg
-from apt_pkg import gettext as _
-from apt.deprecation import function_deprecated_by, AttributeDeprecatedBy
-from apt.progress import base
-
-if apt_pkg._COMPAT_0_7:
- from apt.progress import old
-
-
-__all__ = ['GAcquireProgress', 'GInstallProgress', 'GOpProgress',
- 'GtkAptProgress']
-
-
-def mksig(params=(), run=gobject.SIGNAL_RUN_FIRST, rettype=gobject.TYPE_NONE):
- """Simplified Create a gobject signal.
-
- This allows us to write signals easier, because we just need to define the
- type of the parameters (in most cases).
-
- ``params`` is a tuple which defines the types of the arguments.
- """
- return (run, rettype, params)
-
-
-class GOpProgress(gobject.GObject, base.OpProgress):
- """Operation progress with GObject signals.
-
- Signals:
-
- * status-changed(str: operation, int: percent)
- * status-started() - Not Implemented yet
- * status-finished()
-
- """
-
- __gsignals__ = {"status-changed": mksig((str, int)),
- "status-started": mksig(),
- "status-finished": mksig()}
-
- def __init__(self):
- base.OpProgress.__init__(self)
- gobject.GObject.__init__(self)
- self._context = glib.main_context_default()
-
- def update(self, percent=None):
- """Called to update the percentage done"""
- base.OpProgress.update(self, percent)
- self.emit("status-changed", self.op, self.percent)
- while self._context.pending():
- self._context.iteration()
-
- def done(self):
- """Called when all operation have finished."""
- base.OpProgress.done(self)
- self.emit("status-finished")
-
- if apt_pkg._COMPAT_0_7:
- subOp = AttributeDeprecatedBy('subop')
- Op = AttributeDeprecatedBy('op')
-
-
-class GInstallProgress(gobject.GObject, base.InstallProgress):
- """Installation progress with GObject signals.
-
- Signals:
-
- * status-changed(str: status, int: percent)
- * status-started()
- * status-finished()
- * status-timeout()
- * status-error()
- * status-conffile()
-
- """
- # Seconds until a maintainer script will be regarded as hanging
- INSTALL_TIMEOUT = 5 * 60
-
- __gsignals__ = {"status-changed": mksig((str, int)),
- "status-started": mksig(),
- "status-timeout": mksig(),
- "status-error": mksig(),
- "status-conffile": mksig(),
- "status-finished": mksig()}
-
- def __init__(self, term):
- base.InstallProgress.__init__(self)
- gobject.GObject.__init__(self)
- self.finished = False
- self.apt_status = -1
- self.time_last_update = time.time()
- self.term = term
- self.term.connect("child-exited", self.child_exited)
- self.env = ["VTE_PTY_KEEP_FD=%s" % self.writefd,
- "DEBIAN_FRONTEND=gnome",
- "APT_LISTCHANGES_FRONTEND=gtk"]
- self._context = glib.main_context_default()
-
- def child_exited(self, term):
- """Called when a child process exits"""
- self.apt_status = term.get_child_exit_status()
- self.finished = True
-
- def error(self, pkg, errormsg):
- """Called when an error happens.
-
- Emits: status-error()
- """
- self.emit("status-error")
-
- def conffile(self, current, new):
- """Called during conffile.
-
- Emits: status-conffile()
- """
- self.emit("status-conffile")
-
- def start_update(self):
- """Called when the update starts.
-
- Emits: status-started()
- """
- self.emit("status-started")
-
- def run(self, obj):
- """Run."""
- self.finished = False
- return base.InstallProgress.run(self, obj)
-
- def finish_update(self):
- """Called when the update finished.
-
- Emits: status-finished()
- """
- self.emit("status-finished")
-
- def processing(self, pkg, stage):
- """Called when entering a new stage in dpkg."""
- # We have no percentage or alike, send -1 to let the bar pulse.
- self.emit("status-changed", ("Installing %s...") % pkg, -1)
-
- def status_change(self, pkg, percent, status):
- """Called when the status changed.
-
- Emits: status-changed(status, percent)
- """
- self.time_last_update = time.time()
- self.emit("status-changed", status, percent)
-
- def update_interface(self):
- """Called periodically to update the interface.
-
- Emits: status-timeout() [When a timeout happens]
- """
- base.InstallProgress.update_interface(self)
- while self._context.pending():
- self._context.iteration()
- if self.time_last_update + self.INSTALL_TIMEOUT < time.time():
- self.emit("status-timeout")
-
- def fork(self):
- """Fork the process."""
- return self.term.forkpty(envv=self.env)
-
- def wait_child(self):
- """Wait for the child process to exit."""
- while not self.finished:
- self.update_interface()
- time.sleep(0.02)
- return self.apt_status
-
- if apt_pkg._COMPAT_0_7:
- updateInterface = function_deprecated_by(update_interface)
- startUpdate = function_deprecated_by(start_update)
- finishUpdate = function_deprecated_by(finish_update)
- statusChange = function_deprecated_by(status_change)
- waitChild = function_deprecated_by(wait_child)
- childExited = function_deprecated_by(child_exited)
-
-
-GDpkgInstallProgress = GInstallProgress
-
-
-class GAcquireProgress(gobject.GObject, base.AcquireProgress):
- """A Fetch Progress with GObject signals.
-
- Signals:
-
- * status-changed(str: description, int: percent)
- * status-started()
- * status-finished()
-
- DEPRECATED.
- """
-
- __gsignals__ = {"status-changed": mksig((str, int)),
- "status-started": mksig(),
- "status-finished": mksig()}
-
- def __init__(self):
- base.AcquireProgress.__init__(self)
- gobject.GObject.__init__(self)
- self._continue = True
- self._context = glib.main_context_default()
-
- def start(self):
- base.AcquireProgress.start(self)
- self.emit("status-started")
-
- def stop(self):
- base.AcquireProgress.stop(self)
- self.emit("status-finished")
-
- def cancel(self):
- self._continue = False
-
- def pulse(self, owner):
- base.AcquireProgress.pulse(self, owner)
- current_item = self.current_items + 1
- if current_item > self.total_items:
- current_item = self.total_items
- if self.current_cps > 0:
- text = (_("Downloading file %(current)li of %(total)li with "
- "%(speed)s/s") % \
- {"current": current_item,
- "total": self.total_items,
- "speed": apt_pkg.size_to_str(self.current_cps)})
- else:
- text = (_("Downloading file %(current)li of %(total)li") % \
- {"current": current_item,
- "total": self.total_items})
-
- percent = (((self.current_bytes + self.current_items) * 100.0) /
- float(self.total_bytes + self.total_items))
- self.emit("status-changed", text, percent)
- while self._context.pending():
- self._context.iteration()
- return self._continue
-
-if apt_pkg._COMPAT_0_7:
-
- class GFetchProgress(gobject.GObject, old.FetchProgress):
- """A Fetch Progress with GObject signals.
-
- Signals:
-
- * status-changed(str: description, int: percent)
- * status-started()
- * status-finished()
-
- DEPRECATED.
- """
-
- __gsignals__ = {"status-changed": mksig((str, int)),
- "status-started": mksig(),
- "status-finished": mksig()}
-
- def __init__(self):
- old.FetchProgress.__init__(self)
- gobject.GObject.__init__(self)
- self._continue = True
- self._context = glib.main_context_default()
-
- def start(self):
- self.emit("status-started")
-
- def stop(self):
- self.emit("status-finished")
-
- def cancel(self):
- self._continue = False
-
- def pulse(self):
- old.FetchProgress.pulse(self)
- current_item = self.currentItems + 1
- if current_item > self.totalItems:
- current_item = self.totalItems
- if self.current_cps > 0:
- text = (_("Downloading file %(current)li of %(total)li with "
- "%(speed)s/s") % \
- {"current": current_item,
- "total": self.totalItems,
- "speed": apt_pkg.size_to_str(self.currentCPS)})
- else:
- text = (_("Downloading file %(current)li of %(total)li") % \
- {"current": current_item,
- "total": self.totalItems})
- self.emit("status-changed", text, self.percent)
- while self._context.pending():
- self._context.iteration()
- return self._continue
-
-
-class GtkAptProgress(gtk.VBox):
- """Graphical progress for installation/fetch/operations.
-
- This widget provides a progress bar, a terminal and a status bar for
- showing the progress of package manipulation tasks.
- """
-
- def __init__(self):
- gtk.VBox.__init__(self)
- self.set_spacing(6)
- # Setup some child widgets
- self._expander = gtk.Expander(_("Details"))
- self._terminal = vte.Terminal()
- #self._terminal.set_font_from_string("monospace 10")
- self._expander.add(self._terminal)
- self._progressbar = gtk.ProgressBar()
- # Setup the always italic status label
- self._label = gtk.Label()
- attr_list = pango.AttrList()
- attr_list.insert(pango.AttrStyle(pango.STYLE_ITALIC, 0, -1))
- self._label.set_attributes(attr_list)
- self._label.set_ellipsize(pango.ELLIPSIZE_END)
- self._label.set_alignment(0, 0)
- # add child widgets
- self.pack_start(self._progressbar, False)
- self.pack_start(self._label, False)
- self.pack_start(self._expander, False)
- # Setup the internal progress handlers
- self._progress_open = GOpProgress()
- self._progress_open.connect("status-changed", self._on_status_changed)
- self._progress_open.connect("status-started", self._on_status_started)
- self._progress_open.connect("status-finished",
- self._on_status_finished)
- self._progress_acquire = GAcquireProgress()
- self._progress_acquire.connect("status-changed",
- self._on_status_changed)
- self._progress_acquire.connect("status-started",
- self._on_status_started)
- self._progress_acquire.connect("status-finished",
- self._on_status_finished)
-
- self._progress_fetch = None
- self._progress_install = GInstallProgress(self._terminal)
- self._progress_install.connect("status-changed",
- self._on_status_changed)
- self._progress_install.connect("status-started",
- self._on_status_started)
- self._progress_install.connect("status-finished",
- self._on_status_finished)
- self._progress_install.connect("status-timeout",
- self._on_status_timeout)
- self._progress_install.connect("status-error",
- self._on_status_timeout)
- self._progress_install.connect("status-conffile",
- self._on_status_timeout)
-
- def clear(self):
- """Reset all status information."""
- self._label.set_label("")
- self._progressbar.set_fraction(0)
- self._expander.set_expanded(False)
-
- @property
- def open(self):
- """Return the cache opening progress handler."""
- return self._progress_open
-
- @property
- def install(self):
- """Return the install progress handler."""
- return self._progress_install
-
- @property
- def dpkg_install(self):
- """Return the install progress handler for dpkg."""
- return self._progress_install
-
- if apt_pkg._COMPAT_0_7:
-
- @property
- def fetch(self):
- """Return the fetch progress handler."""
- if self._progress_fetch is None:
- self._progress_fetch = GFetchProgress()
- self._progress_fetch.connect("status-changed",
- self._on_status_changed)
- self._progress_fetch.connect("status-started",
- self._on_status_started)
- self._progress_fetch.connect("status-finished",
- self._on_status_finished)
- return self._progress_fetch
-
- @property
- def acquire(self):
- """Return the acquire progress handler."""
- return self._progress_acquire
-
- def _on_status_started(self, progress):
- """Called when something starts."""
- self._on_status_changed(progress, _("Starting..."), 0)
- while gtk.events_pending():
- gtk.main_iteration()
-
- def _on_status_finished(self, progress):
- """Called when something finished."""
- self._on_status_changed(progress, _("Complete"), 100)
- while gtk.events_pending():
- gtk.main_iteration()
-
- def _on_status_changed(self, progress, status, percent):
- """Called when the status changed."""
- self._label.set_text(status)
- if percent is None or percent == -1:
- self._progressbar.pulse()
- else:
- self._progressbar.set_fraction(percent/100.0)
- while gtk.events_pending():
- gtk.main_iteration()
-
- def _on_status_timeout(self, progress):
- """Called when timeout happens."""
- self._expander.set_expanded(True)
- while gtk.events_pending():
- gtk.main_iteration()
-
- def cancel_download(self):
- """Cancel a currently running download."""
- self._progress_fetch.cancel()
-
- def show_terminal(self, expanded=False):
- """Show the expander for the terminal.
-
- Show an expander with a terminal widget which provides a way
- to interact with dpkg
- """
- self._expander.show()
- self._terminal.show()
- self._expander.set_expanded(expanded)
- while gtk.events_pending():
- gtk.main_iteration()
-
- def hide_terminal(self):
- """Hide the expander with the terminal widget."""
- self._expander.hide()
- while gtk.events_pending():
- gtk.main_iteration()
-
- def show(self):
- """Show the Box"""
- gtk.HBox.show(self)
- self._label.show()
- self._progressbar.show()
- while gtk.events_pending():
- gtk.main_iteration()
-
-
-def _test():
- """Test function"""
- import sys
-
- import apt
- from apt.debfile import DebPackage
-
- win = gtk.Window()
- apt_progress = GtkAptProgress()
- win.set_title("GtkAptProgress Demo")
- win.add(apt_progress)
- apt_progress.show()
- win.show()
- cache = apt.cache.Cache(apt_progress.open)
- pkg = cache["xterm"]
- if pkg.is_installed:
- pkg.mark_delete()
- else:
- pkg.mark_install()
- apt_progress.show_terminal(True)
- try:
- cache.commit(apt_progress.acquire, apt_progress.install)
- except Exception as exc:
- print >> sys.stderr, "Exception happened:", exc
- if len(sys.argv) > 1:
- deb = DebPackage(sys.argv[1], cache)
- deb.install(apt_progress.dpkg_install)
- win.connect("destroy", gtk.main_quit)
- gtk.main()
-
-
-if __name__ == "__main__":
- _test()
-
-# vim: ts=4 et sts=4
diff --git a/apt/progress/old.py b/apt/progress/old.py
deleted file mode 100644
index 364cd2ce..00000000
--- a/apt/progress/old.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# progress.py - progress reporting classes
-#
-# Copyright (c) 2005-2009 Canonical
-#
-# Author: Michael Vogt <michael.vogt@ubuntu.com>
-#
-# 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
-# pylint: disable-msg = C0103
-"""Deprecated progress reporting classes.
-
-This module provides classes for compatibility with python-apt 0.7. They are
-completely deprecated and should not be used anymore.
-"""
-
-
-import os
-import sys
-
-import apt_pkg
-from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by
-import warnings
-from apt.progress import base, text
-
-__all__ = []
-
-
-class OpProgress(base.OpProgress):
- """Abstract class to implement reporting on cache opening."""
-
- def __init__(self):
- base.OpProgress.__init__(self)
- warnings.warn("apt.progress.OpProgress is deprecated.",
- DeprecationWarning, stacklevel=2)
-
- subOp = AttributeDeprecatedBy('subop')
- Op = AttributeDeprecatedBy('op')
-
-
-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."""
-
- # download status constants
- (dlDone, dlQueued, dlFailed, dlHit, dlIgnored) = range(5)
- dlStatusStr = {dlDone: "Done", dlQueued: "Queued", dlFailed: "Failed",
- dlHit: "Hit", dlIgnored: "Ignored"}
-
- def __init__(self):
- self.eta = 0.0
- self.percent = 0.0
- # Make checking easier
- self.currentBytes = 0
- self.currentItems = 0
- self.totalBytes = 0
- self.totalItems = 0
- self.currentCPS = 0
- warnings.warn("apt.progress.FetchProgress is deprecated.",
- DeprecationWarning, stacklevel=2)
-
- def start(self):
- """Called when the fetching starts."""
-
- def stop(self):
- """Called when all files have been fetched."""
-
- def updateStatus(self, uri, descr, short_descr, status):
- """Called when the status of an item changes.
-
- 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.
-
- This happens eg. when the downloads fails or is completed. This
- version include information on current filesize and partial size
- """
-
- def pulse(self):
- """Called periodically to update the user interface.
-
- Return True to continue or False to cancel.
- """
- self.percent = (((self.currentBytes + self.currentItems) * 100.0) /
- float(self.totalBytes + self.totalItems))
- if self.currentCPS > 0:
- self.eta = ((self.totalBytes - self.currentBytes) /
- float(self.currentCPS))
- return True
-
- def pulse_items(self, items):
- """Called periodically to update the user interface.
- This function includes details about the items being fetched
- Return True to continue or False to cancel.
-
- """
- self.percent = (((self.currentBytes + self.currentItems) * 100.0) /
- float(self.totalBytes + self.totalItems))
- if self.currentCPS > 0:
- self.eta = ((self.totalBytes - self.currentBytes) /
- float(self.currentCPS))
- return True
-
- def mediaChange(self, medium, drive):
- """react to media change events."""
-
-
-class TextFetchProgress(FetchProgress):
- """ Ready to use progress object for terminal windows """
-
- def __init__(self):
- FetchProgress.__init__(self)
- self.items = {}
-
- def updateStatus(self, uri, descr, short_descr, status):
- """Called when the status of an item changes.
-
- This happens eg. when the downloads fails or is completed.
- """
- if status != self.dlQueued:
- print "\r%s %s" % (self.dlStatusStr[status], descr)
- self.items[uri] = status
-
- def pulse(self):
- """Called periodically to update the user interface.
-
- Return True to continue or False to cancel.
- """
- FetchProgress.pulse(self)
-
- if self.currentCPS > 0:
- s = "[%2.f%%] %sB/s %s" % (self.percent,
- apt_pkg.size_to_str(self.currentCPS),
- apt_pkg.time_to_str(long(self.eta)))
- else:
- s = "%2.f%% [Working]" % (self.percent)
- print "\r%s" % (s),
- sys.stdout.flush()
- return True
-
- def stop(self):
- """Called when all files have been fetched."""
- print "\rDone downloading "
-
- def mediaChange(self, medium, drive):
- """react to media change events."""
- print ("Media change: please insert the disc labeled "
- "'%s' in the drive '%s' and press enter") % (medium, drive)
-
- return raw_input() not in ('c', 'C')
-
-
-class CdromProgress(object):
- """Report the cdrom add progress."""
-
- 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."""
-
- def __init__(self):
- base.InstallProgress.__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")
- return base.InstallProgress.update_interface(self)
-
- def update_interface(self):
- return self.updateInterface()
-
- def startUpdate(self):
- return base.InstallProgress.start_update(self)
-
- def start_update(self):
- return self.startUpdate()
-
- def finishUpdate(self):
- return base.InstallProgress.finish_update(self)
-
- def finish_update(self):
- return self.finishUpdate()
-
-
-class InstallProgress(DumbInstallProgress, base.InstallProgress):
- """An InstallProgress that is pretty useful.
-
- It supports the attributes 'percent' 'status' and callbacks for the dpkg
- errors and conffiles and status changes.
- """
-
- selectTimeout = AttributeDeprecatedBy('select_timeout')
-
- def statusChange(self, pkg, percent, status):
- return base.InstallProgress.status_change(self, pkg, percent, status)
-
- def status_change(self, pkg, percent, status):
- return self.statusChange(pkg, percent, status)
-
- def waitChild(self):
- return base.InstallProgress.wait_child(self)
-
- def wait_child(self):
- return self.waitChild()
-
-
-class DpkgInstallProgress(InstallProgress):
- """Progress handler for a local Debian package installation."""
-
- debfile = ""
- debname = ""
-
- def run(self, debfile):
- """Start installing the given Debian package."""
- # Deprecated stuff
- self.debfile = debfile
- self.debname = os.path.basename(debfile).split("_")[0]
- return base.InstallProgress.run(self, debfile)
diff --git a/apt/progress/text.py b/apt/progress/text.py
index c5eec092..d1f87539 100644
--- a/apt/progress/text.py
+++ b/apt/progress/text.py
@@ -15,6 +15,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
"""Progress reporting for text interfaces."""
+from __future__ import print_function
+
import os
import sys
@@ -23,6 +25,11 @@ from apt.progress import base
__all__ = ['AcquireProgress', 'CdromProgress', 'OpProgress']
+if sys.version_info.major < 3:
+ input = raw_input
+else:
+ long = int
+
def _(msg):
"""Translate the message, also try apt if translation is missing."""
@@ -47,7 +54,7 @@ class TextProgress(object):
# Fill remaining stuff with whitespace
if self._width > len(msg):
self._file.write((self._width - len(msg)) * ' ')
- elif maximize: # Needed for OpProgress.
+ elif maximize: # Needed for OpProgress.
self._width = max(self._width, len(msg))
if newline:
self._file.write("\n")
@@ -91,7 +98,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
base.AcquireProgress.__init__(self)
self._signal = None
self._width = 80
- self._id = 1
+ self._id = long(1)
def start(self):
"""Start an Acquire progress.
@@ -104,7 +111,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
self._signal = signal.signal(signal.SIGWINCH, self._winch)
# Get the window size.
self._winch()
- self._id = 1L
+ self._id = long(1)
def _winch(self, *dummy):
"""Signal handler for window resize signals."""
@@ -114,7 +121,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
import struct
buf = fcntl.ioctl(self._file, termios.TIOCGWINSZ, 8 * ' ')
dummy, col, dummy, dummy = struct.unpack('hhhh', buf)
- self._width = col - 1 # 1 for the cursor
+ self._width = col - 1 # 1 for the cursor
def ims_hit(self, item):
"""Called when an item is update (e.g. not modified on the server)."""
@@ -188,8 +195,9 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
# Add the total size and percent
if worker.total_size and not worker.current_item.owner.complete:
- val += "/%sB %i%%" % (apt_pkg.size_to_str(worker.total_size),
- worker.current_size*100.0/worker.total_size)
+ val += "/%sB %i%%" % (
+ apt_pkg.size_to_str(worker.total_size),
+ worker.current_size * 100.0 / worker.total_size)
val += ']'
@@ -214,7 +222,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
self._write(_("Media change: please insert the disc labeled\n"
" '%s'\n"
"in the drive '%s' and press enter\n") % (medium, drive))
- return raw_input() not in ('c', 'C')
+ return input() not in ('c', 'C')
def stop(self):
"""Invoked when the Acquire process stops running."""
@@ -239,7 +247,7 @@ class CdromProgress(base.CdromProgress, TextProgress):
self._write(_("Please provide a name for this Disc, such as "
"'Debian 2.1r1 Disk 1'"), False)
try:
- return raw_input(":")
+ return input(":")
except KeyboardInterrupt:
return
@@ -255,6 +263,6 @@ class CdromProgress(base.CdromProgress, TextProgress):
self._write(_("Please insert a Disc in the drive and press enter"),
False)
try:
- return (raw_input() == '')
+ return (input() == '')
except KeyboardInterrupt:
return False
diff --git a/apt/utils.py b/apt/utils.py
index 08140258..948aac92 100644
--- a/apt/utils.py
+++ b/apt/utils.py
@@ -16,6 +16,7 @@
# 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
+from __future__ import print_function
import os.path
@@ -32,7 +33,7 @@ def get_maintenance_end_date(release_date, m_months):
years = m_months // 12
months = m_months % 12
support_end_year = (release_date.year + years +
- (release_date.month + months)//12)
+ (release_date.month + months) // 12)
support_end_month = (release_date.month + months) % 12
# special case: this happens when e.g. doing 2010-06 + 18 months
if support_end_month == 0:
@@ -49,7 +50,7 @@ def get_release_date_from_release_file(path):
return None
tag = apt_pkg.TagFile(open(path))
section = next(tag)
- if not "Date" in section:
+ if "Date" not in section:
return None
date = section["Date"]
return apt_pkg.str_to_time(date)
@@ -69,8 +70,8 @@ def get_release_filename_for_pkg(cache, pkgname, label, release):
for ver_file, _index in aver.file_list:
#print verFile
if (ver_file.origin == label and
- ver_file.label == label and
- ver_file.archive == release):
+ ver_file.label == label and
+ ver_file.archive == release):
ver = aver
if not ver:
return None
@@ -78,8 +79,8 @@ def get_release_filename_for_pkg(cache, pkgname, label, release):
for metaindex in cache._list.list:
for m in metaindex.index_files:
if (indexfile and
- indexfile.describe == m.describe and
- indexfile.is_trusted):
+ indexfile.describe == m.describe and
+ indexfile.is_trusted):
dirname = apt_pkg.config.find_dir("Dir::State::lists")
name = (apt_pkg.uri_to_filename(metaindex.uri) +
"dists_%s_Release" % metaindex.dist)
diff --git a/aptsources/__init__.py b/aptsources/__init__.py
index c02341c2..d711b4f3 100644
--- a/aptsources/__init__.py
+++ b/aptsources/__init__.py
@@ -1,4 +1,9 @@
+from __future__ import print_function
+
import apt_pkg
-# init the package system
-apt_pkg.init()
+
+# init the package system, but do not re-initialize config
+if "APT" not in apt_pkg.config:
+ apt_pkg.init_config()
+apt_pkg.init_system()
diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py
index d80721e5..8fcbac96 100644
--- a/aptsources/distinfo.py
+++ b/aptsources/distinfo.py
@@ -33,6 +33,7 @@ import apt_pkg
from apt_pkg import gettext as _
+
class Template(object):
def __init__(self):
@@ -152,9 +153,7 @@ def split_url(url):
class DistInfo(object):
- def __init__(self,
- dist = None,
- base_dir = "/usr/share/python-apt/templates"):
+ def __init__(self, dist=None, base_dir="/usr/share/python-apt/templates"):
self.metarelease_uri = ''
self.templates = []
self.arch = apt_pkg.config.find("APT::Architecture")
@@ -196,7 +195,7 @@ class DistInfo(object):
self.metarelease_uri = value
elif field == 'Suite':
self.finish_template(template, component)
- component=None
+ component = None
template = Template()
template.name = value
template.distribution = dist
@@ -255,8 +254,8 @@ class DistInfo(object):
template.description = _(value)
elif field == 'Component':
if (component and not
- template.has_component(component.name)):
- template.components.append(component)
+ template.has_component(component.name)):
+ template.components.append(component)
component = Component(value)
elif field == 'CompDescription':
component.set_description(_(value))
@@ -265,8 +264,8 @@ class DistInfo(object):
elif field == 'ParentComponent':
component.set_parent_component(value)
self.finish_template(template, component)
- template=None
- component=None
+ template = None
+ component = None
def finish_template(self, template, component):
" finish the current tempalte "
diff --git a/aptsources/distro.py b/aptsources/distro.py
index e9facbfb..e11f113c 100644
--- a/aptsources/distro.py
+++ b/aptsources/distro.py
@@ -77,7 +77,7 @@ class Distribution(object):
# find the distro template
for template in self.sourceslist.matcher.templates:
if (self.is_codename(template.name) and
- template.distribution == self.id):
+ template.distribution == self.id):
#print "yeah! found a template for %s" % self.description
#print template.description, template.base_uri, \
# template.components
@@ -85,7 +85,7 @@ class Distribution(object):
break
if self.source_template is None:
raise NoDistroTemplateException(
- "Error: could not find a distribution template for %s/%s" %
+ "Error: could not find a distribution template for %s/%s" %
(self.id, self.codename))
# find main and child sources
@@ -95,41 +95,41 @@ class Distribution(object):
enabled_comps = []
#source_code = []
for source in self.sourceslist.list:
- if (source.invalid == False and
- self.is_codename(source.dist) and
- source.template and
- source.template.official == True and
- self.is_codename(source.template.name)):
+ if (not source.invalid and
+ self.is_codename(source.dist) and
+ source.template and
+ source.template.official and
+ self.is_codename(source.template.name)):
#print "yeah! found a distro repo: %s" % source.line
# cdroms need do be handled differently
if (source.uri.startswith("cdrom:") and
- source.disabled == False):
- self.cdrom_sources.append(source)
- cdrom_comps.extend(source.comps)
+ not source.disabled):
+ self.cdrom_sources.append(source)
+ cdrom_comps.extend(source.comps)
elif (source.uri.startswith("cdrom:") and
- source.disabled == True):
+ source.disabled):
self.cdrom_sources.append(source)
elif (source.type == self.binary_type and
- source.disabled == False):
+ not source.disabled):
self.main_sources.append(source)
comps.extend(source.comps)
media.append(source.uri)
elif (source.type == self.binary_type and
- source.disabled == True):
+ source.disabled):
self.disabled_sources.append(source)
- elif (source.type == self.source_type
- and source.disabled == False):
+ elif (source.type == self.source_type and
+ not source.disabled):
self.source_code_sources.append(source)
elif (source.type == self.source_type and
- source.disabled == True):
+ source.disabled):
self.disabled_sources.append(source)
- if (source.invalid == False and
- source.template in self.source_template.children):
- if (source.disabled == False
- and source.type == self.binary_type):
- self.child_sources.append(source)
- elif (source.disabled == False
- and source.type == self.source_type):
+ if (not source.invalid and
+ source.template in self.source_template.children):
+ if (not source.disabled
+ and source.type == self.binary_type):
+ self.child_sources.append(source)
+ elif (not source.disabled
+ and source.type == self.source_type):
self.source_code_sources.append(source)
else:
self.disabled_sources.append(source)
@@ -189,7 +189,7 @@ class Distribution(object):
z = locale.find(".")
if z == -1:
z = len(locale)
- country_code = locale[a+1:z].lower()
+ country_code = locale[a + 1:z].lower()
if mirror_template:
self.nearest_server = mirror_template % country_code
@@ -205,7 +205,7 @@ class Distribution(object):
i = server.find("://")
l = server.find(".archive.ubuntu.com")
if i != -1 and l != -1:
- country = server[i+len("://"):l]
+ country = server[i + len("://"):l]
if country in self.countries:
# TRANSLATORS: %s is a country
return _("Server for %s") % self.countries[country]
@@ -256,9 +256,9 @@ class Distribution(object):
for server in self.used_servers:
mirror_entry = [self._get_mirror_name(server), server, False]
if (compare_mirrors(server, self.nearest_server) or
- compare_mirrors(server, self.main_server)):
+ compare_mirrors(server, self.main_server)):
continue
- elif not mirror_entry in mirrors:
+ elif mirror_entry not in mirrors:
mirrors.append(mirror_entry)
return mirrors
@@ -280,10 +280,11 @@ class Distribution(object):
new_source = self.sourceslist.add(type, uri, dist, comps, comment)
# if source code is enabled add a deb-src line after the new
# source
- if self.get_source_code == True and type == self.binary_type:
- self.sourceslist.add(self.source_type, uri, dist, comps, comment,
- file=new_source.file,
- pos=self.sourceslist.list.index(new_source)+1)
+ if self.get_source_code and type == self.binary_type:
+ self.sourceslist.add(
+ self.source_type, uri, dist, comps, comment,
+ file=new_source.file,
+ pos=self.sourceslist.list.index(new_source) + 1)
def enable_component(self, comp):
"""
@@ -344,7 +345,7 @@ class Distribution(object):
# check if there is a main source at all
if len(self.main_sources) < 1:
# create a new main source
- self.add_source(comps=["%s"%comp])
+ self.add_source(comps=["%s" % comp])
else:
# add the comp to all main, child and source code sources
for source in sources:
@@ -354,10 +355,10 @@ class Distribution(object):
add_component_only_once(source, comps_per_sdist)
# check if there is a main source code source at all
- if self.get_source_code == True:
+ if self.get_source_code:
if len(self.source_code_sources) < 1:
# create a new main source
- self.add_source(type=self.source_type, comps=["%s"%comp])
+ self.add_source(type=self.source_type, comps=["%s" % comp])
else:
# add the comp to all main, child and source code sources
for source in self.source_code_sources:
@@ -404,7 +405,7 @@ class Distribution(object):
for source in self.child_sources:
# Do not change the forces server of a child source
if (source.template.base_uri is None or
- source.template.base_uri != source.uri):
+ source.template.base_uri != source.uri):
change_server_of_source(source, uri, seen_binary)
for source in self.source_code_sources:
change_server_of_source(source, uri, seen_source)
@@ -435,7 +436,7 @@ class DebianDistribution(Distribution):
i = server.find("://ftp.")
l = server.find(".debian.org")
if i != -1 and l != -1:
- country = server[i+len("://ftp."):l]
+ country = server[i + len("://ftp."):l]
if country in self.countries:
# TRANSLATORS: %s is a country
return _("Server for %s") % gettext.dgettext(
@@ -456,6 +457,13 @@ class UbuntuDistribution(Distribution):
self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/")
+class UbuntuRTMDistribution(UbuntuDistribution):
+ ''' Class to support specific Ubuntu RTM features '''
+
+ def get_mirrors(self):
+ self.main_server = self.source_template.base_uri
+
+
def _lsb_release():
"""Call lsb_release --idrc and return a mapping."""
from subprocess import Popen, PIPE
@@ -474,6 +482,24 @@ def _lsb_release():
return result
+def _system_image_channel():
+ """Get the current channel from system-image-cli -i if possible."""
+ from subprocess import Popen, PIPE
+ import errno
+ try:
+ out = Popen(
+ ['system-image-cli', '-i'], stdout=PIPE,
+ universal_newlines=True).communicate()[0]
+ for l in out.splitlines():
+ if l.startswith('channel: '):
+ return l.split(': ', 1)[1]
+ except OSError as exc:
+ if exc.errno != errno.ENOENT:
+ logging.warning(
+ 'system-image-cli failed, using defaults: %s' % exc)
+ return None
+
+
def get_distro(id=None, codename=None, description=None, release=None):
"""
Check the currently used distribution and return the corresponding
@@ -489,8 +515,17 @@ def get_distro(id=None, codename=None, description=None, release=None):
codename = result['Codename']
description = result['Description']
release = result['Release']
+ if id == "Ubuntu":
+ channel = _system_image_channel()
+ if channel is not None and "ubuntu-rtm/" in channel:
+ id = "Ubuntu-RTM"
+ codename = channel.rsplit("/", 1)[1].split("-", 1)[0]
+ description = codename
+ release = codename
if id == "Ubuntu":
return UbuntuDistribution(id, codename, description, release)
+ if id == "Ubuntu-RTM":
+ return UbuntuRTMDistribution(id, codename, description, release)
elif id == "Debian":
return DebianDistribution(id, codename, description, release)
else:
diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py
index f5a86ecb..f4903523 100644
--- a/aptsources/sourceslist.py
+++ b/aptsources/sourceslist.py
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
import glob
import logging
@@ -34,18 +34,20 @@ import time
import apt_pkg
from .distinfo import DistInfo
-from apt.deprecation import function_deprecated_by
#from apt_pkg import gettext as _
# some global helpers
+__all__ = ['is_mirror', 'SourceEntry', 'NullMatcher', 'SourcesList',
+ 'SourceEntryMatcher']
+
def is_mirror(master_uri, compare_uri):
- """ check if the given add_url is idential or a mirror of orig_uri
- e.g. master_uri = archive.ubuntu.com
- compare_uri = de.archive.ubuntu.com
- -> True
+ """ check if the given add_url is idential or a mirror of orig_uri e.g.:
+ master_uri = archive.ubuntu.com
+ compare_uri = de.archive.ubuntu.com
+ -> True
"""
# remove traling spaces and "/"
compare_uri = compare_uri.rstrip("/ ")
@@ -60,19 +62,24 @@ def is_mirror(master_uri, compare_uri):
compare_srv = compare_uri.split("//")[1]
master_srv = master_uri.split("//")[1]
#print "%s == %s " % (add_srv, orig_srv)
- except IndexError: # ok, somethings wrong here
+ except IndexError: # ok, somethings wrong here
#print "IndexError"
return False
# remove the leading "<country>." (if any) and see if that helps
if "." in compare_srv and \
- compare_srv[compare_srv.index(".")+1:] == master_srv:
+ compare_srv[compare_srv.index(".") + 1:] == master_srv:
#print "Mirror"
return True
return False
def uniq(s):
- """ simple and efficient way to return uniq list """
+ """ simple and efficient way to return uniq collection
+
+ This is not intended for use with a SourceList. It is provided
+ for internal use only. It does not have a leading underscore to
+ not break any old code that uses it; but it should not be used
+ in new code (and is not listed in __all__)."""
return list(set(s))
@@ -80,22 +87,22 @@ class SourceEntry(object):
""" single sources.list entry """
def __init__(self, line, file=None):
- self.invalid = False # is the source entry valid
- self.disabled = False # is it disabled ('#' in front)
- self.type = "" # what type (deb, deb-src)
- self.architectures = [] # architectures
- self.uri = "" # base-uri
- self.dist = "" # distribution (dapper, edgy, etc)
- self.comps = [] # list of available componetns
- # (may empty)
- self.comment = "" # (optional) comment
- self.line = line # the original sources.list line
+ self.invalid = False # is the source entry valid
+ self.disabled = False # is it disabled ('#' in front)
+ self.type = "" # what type (deb, deb-src)
+ self.architectures = [] # architectures
+ self.trusted = None # Trusted
+ self.uri = "" # base-uri
+ self.dist = "" # distribution (dapper, edgy, etc)
+ self.comps = [] # list of available componetns (may empty)
+ self.comment = "" # (optional) comment
+ self.line = line # the original sources.list line
if file is None:
file = apt_pkg.config.find_dir(
- "Dir::Etc")+apt_pkg.config.find("Dir::Etc::sourcelist")
- self.file = file # the file that the entry is located in
+ "Dir::Etc") + apt_pkg.config.find("Dir::Etc::sourcelist")
+ self.file = file # the file that the entry is located in
self.parse(line)
- self.template = None # type DistInfo.Suite
+ self.template = None # type DistInfo.Suite
self.children = []
def __eq__(self, other):
@@ -116,11 +123,17 @@ class SourceEntry(object):
p_found = False
space_found = False
for i in range(len(line)):
- if line[i] == "[" and not space_found:
- p_found=True
- tmp += line[i]
+ if line[i] == "[":
+ if space_found:
+ space_found = False
+ p_found = True
+ pieces.append(tmp)
+ tmp = line[i]
+ else:
+ p_found = True
+ tmp += line[i]
elif line[i] == "]":
- p_found=False
+ p_found = False
tmp += line[i]
elif space_found and not line[i].isspace():
# we skip one or more space
@@ -143,7 +156,7 @@ class SourceEntry(object):
line = self.line.strip()
#print line
# check if the source is enabled/disabled
- if line == "" or line == "#": # empty line
+ if line == "" or line == "#": # empty line
self.invalid = True
return
if line[0] == "#":
@@ -158,7 +171,7 @@ class SourceEntry(object):
# check for another "#" in the line (this is treated as a comment)
i = line.find("#")
if i > 0:
- self.comment = line[i+1:]
+ self.comment = line[i + 1:]
line = line[:i]
# source is ok, split it and see what we have
pieces = self.mysplit(line)
@@ -174,7 +187,7 @@ class SourceEntry(object):
return
if pieces[1].strip()[0] == "[":
- options = pieces.pop(1).strip("[]").split(";")
+ options = pieces.pop(1).strip("[]").split()
for option in options:
try:
key, value = option.split("=", 1)
@@ -183,9 +196,11 @@ class SourceEntry(object):
else:
if key == "arch":
self.architectures = value.split(",")
+ elif key == "trusted":
+ self.trusted = apt_pkg.string_to_bool(value)
else:
self.invalid = True
-
+
# URI
self.uri = pieces[1].strip()
if len(self.uri) < 1:
@@ -224,13 +239,18 @@ class SourceEntry(object):
line += self.type
- if self.architectures:
+ if self.architectures and self.trusted is not None:
+ line += " [arch=%s trusted=%s]" % (
+ ",".join(self.architectures), "yes" if self.trusted else "no")
+ elif self.trusted is not None:
+ line += " [trusted=%s]" % ("yes" if self.trusted else "no")
+ elif self.architectures:
line += " [arch=%s]" % ",".join(self.architectures)
line += " %s %s" % (self.uri, self.dist)
if len(self.comps) > 0:
line += " " + " ".join(self.comps)
if self.comment != "":
- line += " #"+self.comment
+ line += " #" + self.comment
line += "\n"
return line
@@ -280,10 +300,11 @@ class SourcesList(object):
def __find(self, *predicates, **attrs):
for source in self.list:
if (all(getattr(source, key) == attrs[key] for key in attrs) and
- all(predicate(source) for predicate in predicates)):
+ all(predicate(source) for predicate in predicates)):
yield source
- def add(self, type, uri, dist, orig_comps, comment="", pos=-1, file=None, architectures=[]):
+ def add(self, type, uri, dist, orig_comps, comment="", pos=-1, file=None,
+ architectures=[]):
"""
Add a new source to the sources.list.
The method will search for existing matching repos and will try to
@@ -295,8 +316,8 @@ class SourcesList(object):
# we can modify it later
comps = orig_comps[:]
sources = self.__find(lambda s: set(s.architectures) == architectures,
- disabled=False, invalid=False, type=type, uri=uri,
- dist=dist)
+ disabled=False, invalid=False, type=type,
+ uri=uri, dist=dist)
# check if we have this source already in the sources.list
for source in sources:
for new_comp in comps:
@@ -309,7 +330,6 @@ class SourcesList(object):
sources = self.__find(lambda s: set(s.architectures) == architectures,
invalid=False, type=type, uri=uri, dist=dist)
-
for source in sources:
# if there is a repo with the same (type, uri, dist) just add the
# components
@@ -343,17 +363,13 @@ class SourcesList(object):
def restore_backup(self, backup_ext):
" restore sources.list files based on the backup extension "
file = apt_pkg.config.find_file("Dir::Etc::sourcelist")
- if os.path.exists(file+backup_ext) and \
- os.path.exists(file):
- shutil.copy(file+backup_ext, file)
+ if os.path.exists(file + backup_ext) and os.path.exists(file):
+ shutil.copy(file + backup_ext, file)
# now sources.list.d
partsdir = apt_pkg.config.find_dir("Dir::Etc::sourceparts")
for file in glob.glob("%s/*.list" % partsdir):
- 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)
+ if os.path.exists(file + backup_ext):
+ shutil.copy(file + backup_ext, file)
def backup(self, backup_ext=None):
""" make a backup of the current source files, if no backup extension
@@ -362,8 +378,8 @@ class SourcesList(object):
if backup_ext is None:
backup_ext = time.strftime("%y%m%d.%H%M")
for source in self.list:
- if not source.file in already_backuped \
- and os.path.exists(source.file):
+ if (source.file not in already_backuped
+ and os.path.exists(source.file)):
shutil.copy(source.file, "%s%s" % (source.file, backup_ext))
return backup_ext
@@ -450,15 +466,15 @@ class SourceEntryMatcher(object):
found = False
for template in self.templates:
if (re.search(template.match_uri, source.uri) and
- re.match(template.match_name, source.dist) and
- # deb is a valid fallback for deb-src (if that is not
- # definied, see #760035
- (source.type == template.type or template.type == "deb")):
+ re.match(template.match_name, source.dist) and
+ # deb is a valid fallback for deb-src (if that is not
+ # definied, see #760035
+ (source.type == template.type or template.type == "deb")):
found = True
source.template = template
break
elif (template.is_mirror(source.uri) and
- re.match(template.match_name, source.dist)):
+ re.match(template.match_name, source.dist)):
found = True
source.template = template
break
diff --git a/data/templates/Blankon.info.in b/data/templates/Blankon.info.in
new file mode 100644
index 00000000..960ff223
--- /dev/null
+++ b/data/templates/Blankon.info.in
@@ -0,0 +1,370 @@
+ChangelogURI: http://arsip.blankonlinux.or.id/blankon/changelogs/pool/%s/%s/%s/%s_%s/changelog
+
+Suite: tambora
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon/
+MatchURI: arsip.blankonlinux.or.id/blankon
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 10.0 'Tambora'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Blankon-supported Free/Open Source software
+Component: extras
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained Free/Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: extras-restricted
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: tambora
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*10.0
+MatchURI: cdrom:\[Blankon.*10.0
+_Description: CDROM with Blankon 10.0 'Tambora'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: tambora-security
+ParentSuite: tambora
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon/
+MatchURI: arsip.blankonlinux.or.id/blankon
+_Description: Important security updates
+
+Suite: tambora-updates
+ParentSuite: tambora
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: suroboyo
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon/
+MatchURI: arsip.blankonlinux.or.id/blankon
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 9.0 'Suroboyo'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Blankon-supported Free/Open Source software
+Component: extras
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained Free/Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: extras-restricted
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: suroboyo
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*9.0
+MatchURI: cdrom:\[Blankon.*9.0
+_Description: CDROM with Blankon 9.0 'Suroboyo'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: suroboyo-security
+ParentSuite: suroboyo
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon/
+MatchURI: arsip.blankonlinux.or.id/blankon
+_Description: Important security updates
+
+Suite: suroboyo-updates
+ParentSuite: suroboyo
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: rote
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon/
+MatchURI: arsip.blankonlinux.or.id/blankon
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 8.0 'Rote'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Blankon-supported Free/Open Source software
+Component: extras
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained Free/Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: extras-restricted
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: rote
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*8.0
+MatchURI: cdrom:\[Blankon.*8.0
+_Description: CDROM with Blankon 8.0 'Rote'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: rote-security
+ParentSuite: rote
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon/
+MatchURI: arsip.blankonlinux.or.id/blankon
+_Description: Important security updates
+
+Suite: rote-updates
+ParentSuite: rote
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: pattimura
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 7.0 'Pattimura'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Blankon-supported Free/Open Source software
+Component: extras
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained Free/Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: extras-restricted
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: pattimura
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*7.0
+MatchURI: cdrom:\[Blankon.*7.0
+_Description: CDROM with Blankon 7.0 'Pattimura'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: pattimura-security
+ParentSuite: pattimura
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+_Description: Important security updates
+
+Suite: pattimura-updates
+ParentSuite: pattimura
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: ombilin
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 6.0 'Ombilin'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Blankon-supported Free/Open Source software
+Component: extras
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained Free/Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: extras-restricted
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: ombilin
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*6.0
+MatchURI: cdrom:\[Blankon.*6.0
+_Description: CDROM with Blankon 6.0 'Ombilin'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: ombilin-security
+ParentSuite: ombilin
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+_Description: Important security updates
+
+Suite: ombilin-updates
+ParentSuite: ombilin
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: nanggar
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 5.0 'Nanggar'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: BlankOn-supported Open Source software
+Component: universe
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: multiverse
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: nanggar
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*5.0
+MatchURI: cdrom:\[Blankon.*5.0
+_Description: Cdrom with Blankon 5.0 'Nanggar'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: nanggar-security
+ParentSuite: nanggar
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+_Description: Important security updates
+
+Suite: nanggar-updates
+ParentSuite: nanggar
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: meuligoe
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 4.1 'Meuligoe'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: BlankOn-supported Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+
+Suite: meuligoe
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*4.1
+MatchURI: cdrom:\[Blankon.*4.1
+_Description: Cdrom with Blankon 4.1 'Meuligoe'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: meuligoe-security
+ParentSuite: meuligoe
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+_Description: Important security updates
+
+Suite: meuligoe-updates
+ParentSuite: meuligoe
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: lontara
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: BlankOn 3.0 'Lontara'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: BlankOn-supported Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+
+Suite: lontara
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*3.0
+MatchURI: cdrom:\[Blankon.*3.0
+_Description: Cdrom with Blankon 3.0 'Lontara'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: lontara-security
+ParentSuite: lontara
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+_Description: Important security updates
+
+Suite: lontara-updates
+ParentSuite: lontara
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: konde
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+MirrorsFile-amd64: /usr/share/python-apt/templates/Blankon.mirrors
+MirrorsFile-i386: /usr/share/python-apt/templates/Blankon.mirrors
+_Description: Blankon 2.0 'Konde'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: BlankOn-supported Open Source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+
+Suite: konde
+MatchName: .*
+BaseURI: cdrom:\[Blankon.*2.0
+MatchURI: cdrom:\[Blankon.*2.0
+_Description: Cdrom with Blankon 2.0 'Konde'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: konde-security
+ParentSuite: konde
+RepositoryType: deb
+BaseURI: http://arsip.blankonlinux.or.id/blankon-legacy/
+MatchURI: arsip.blankonlinux.or.id/blankon-legacy
+_Description: Important security updates
+
+Suite: konde-updates
+ParentSuite: konde
+RepositoryType: deb
+_Description: Recommended updates
diff --git a/data/templates/Blankon.mirrors b/data/templates/Blankon.mirrors
new file mode 100644
index 00000000..f277c033
--- /dev/null
+++ b/data/templates/Blankon.mirrors
@@ -0,0 +1,17 @@
+#LOC:ID
+http://kambing.ui.ac.id/blankon/
+http://mirror.omadata.com/blankon/
+http://repo.ugm.ac.id/repo/blankon/
+http://buaya.klas.or.id/blankon/
+http://bos.fkip.uns.ac.id/blankon
+http://pandawa.ipb.ac.id/blankon/
+http://dl2.foss-id.web.id/blankon/
+http://shol.vlsm.org/blankon/
+http://openstorage.gunadarma.ac.id/blankon/
+http://debian.rab.co.id/blankon/
+http://singo.ub.ac.id/blankon/
+http://ftp.paudni.kemdiknas.go.id/blankon/
+http://blankon.idrepo.or.id/blankon/
+http://mirror.kioss.undip.ac.id/blankon/
+http://repo.unnes.ac.id/repo/blankon/
+http://kartolo.sby.datautama.net.id/blankon/
diff --git a/data/templates/Debian.info.in b/data/templates/Debian.info.in
index 3ffe174d..9c3f2fa6 100644
--- a/data/templates/Debian.info.in
+++ b/data/templates/Debian.info.in
@@ -1,11 +1,41 @@
_ChangelogURI: http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog
+Suite: jessie
+RepositoryType: deb
+BaseURI: http://http.us.debian.org/debian/
+MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org
+MirrorsFile: Debian.mirrors
+_Description: Debian 8 'jessie'
+Component: main
+_CompDescription: Officially supported
+Component: contrib
+_CompDescription: DFSG-compatible Software with Non-Free Dependencies
+Component: non-free
+_CompDescription: Non-DFSG-compatible Software
+
+Suite: jessie/updates
+RepositoryType: deb
+BaseURI: http://security.debian.org/
+MatchURI: security\.debian\.org
+ParentSuite: jessie
+_Description: Security updates
+
+Suite: jessie-updates
+RepositoryType: deb
+ParentSuite: jessie
+_Description: Recommended updates
+
+Suite: jessie-proposed-updates
+RepositoryType: deb
+ParentSuite: jessie
+_Description: Proposed updates
+
Suite: wheezy
RepositoryType: deb
BaseURI: http://http.us.debian.org/debian/
MatchURI: ftp[0-9]*\.([a-z]*\.){0,1}debian\.org
MirrorsFile: Debian.mirrors
-_Description: Debian 7.0 'Wheezy'
+_Description: Debian 7 'Wheezy'
Component: main
_CompDescription: Officially supported
Component: contrib
diff --git a/data/templates/Tanglu.info.in b/data/templates/Tanglu.info.in
new file mode 100644
index 00000000..df370832
--- /dev/null
+++ b/data/templates/Tanglu.info.in
@@ -0,0 +1,42 @@
+_ChangelogURI: http://changelogs.tanglu.org/changelogs/%s/%s/%s/%s_%s/changelog
+
+Suite: aequorea
+RepositoryType: deb
+BaseURI: http://archive.tanglu.org/tanglu/
+MatchURI: archive.tanglu.org/tanglu
+MirrorsFile: Tanglu.mirrors
+_Description: Tanglu 1.0 'Aequorea'
+Component: main
+_CompDescription: Officially supported
+Component: contrib
+_CompDescription: DFSG-compatible Software with Non-Free Dependencies
+Component: non-free
+_CompDescription: Non-DFSG-compatible Software
+
+Suite: aequorea-updates
+RepositoryType: deb
+ParentSuite: aequorea
+_Description: Recommended updates
+
+Suite: bartholomea
+RepositoryType: deb
+BaseURI: http://archive.tanglu.org/tanglu/
+MatchURI: archive.tanglu.org/tanglu
+MirrorsFile: Tanglu.mirrors
+_Description: Tanglu 2.0 'Bartholomea'
+Component: main
+_CompDescription: Officially supported
+Component: contrib
+_CompDescription: DFSG-compatible Software with Non-Free Dependencies
+Component: non-free
+_CompDescription: Non-DFSG-compatible Software
+
+Suite: bartholomea-security
+RepositoryType: deb
+ParentSuite: bartholomea
+_Description: Security updates
+
+Suite: bartholomea-updates
+RepositoryType: deb
+ParentSuite: bartholomea
+_Description: Recommended updates
diff --git a/data/templates/Tanglu.mirrors b/data/templates/Tanglu.mirrors
new file mode 100644
index 00000000..dd8ab425
--- /dev/null
+++ b/data/templates/Tanglu.mirrors
@@ -0,0 +1,3 @@
+#LOC:DE
+http://de.archive.tanglu.org/tanglu/
+http://mirror1.hs-esslingen.de/pub/Mirrors/archive.tanglu.org/tanglu/
diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in
index 567456b3..41ae5c82 100644
--- a/data/templates/Ubuntu.info.in
+++ b/data/templates/Ubuntu.info.in
@@ -1,5 +1,697 @@
_ChangelogURI: http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog
+Suite: devel
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://archive.ubuntu.com/ubuntu
+MatchURI-amd64: archive.ubuntu.com/ubuntu
+BaseURI-i386: http://archive.ubuntu.com/ubuntu
+MatchURI-i386: archive.ubuntu.com/ubuntu
+MirrorsFile-amd64: Ubuntu.mirrors
+MirrorsFile-i386: Ubuntu.mirrors
+_Description: Ubuntu development series
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Canonical-supported free and open-source software
+Component: universe
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained free and open-source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: multiverse
+ParentComponent: universe
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: devel
+ParentSuite: devel
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Ubuntu development series
+
+Suite: devel
+Official: false
+RepositoryType: deb
+BaseURI: http://archive.canonical.com
+MatchURI: archive.canonical.com
+_Description: Canonical Partners
+Component: partner
+_CompDescription: Software packaged by Canonical for their partners
+_CompDescriptionLong: This software is not part of Ubuntu.
+
+Suite: devel
+Official: false
+RepositoryType: deb
+BaseURI: http://extras.ubuntu.com
+MatchURI: extras.ubuntu.com
+_Description: Independent
+Component: main
+_CompDescription: Provided by third-party software developers
+_CompDescriptionLong: Software offered by third party developers.
+
+Suite: devel-security
+ParentSuite: devel
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://security.ubuntu.com/ubuntu/
+MatchURI-amd64: archive.ubuntu.com/ubuntu|security.ubuntu.com
+BaseURI-i386: http://security.ubuntu.com/ubuntu/
+MatchURI-i386: archive.ubuntu.com/ubuntu|security.ubuntu.com
+_Description: Important security updates
+
+Suite: devel-security
+ParentSuite: devel
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports|security.ubuntu.com
+_Description: Important security updates
+
+Suite: devel-updates
+ParentSuite: devel
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: devel-updates
+ParentSuite: devel
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Recommended updates
+
+Suite: devel-proposed
+ParentSuite: devel
+RepositoryType: deb
+_Description: Pre-released updates
+
+Suite: devel-proposed
+ParentSuite: devel
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Pre-released updates
+
+Suite: devel-backports
+ParentSuite: devel
+RepositoryType: deb
+_Description: Unsupported updates
+
+Suite: devel-backports
+ParentSuite: devel
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Unsupported updates
+
+
+Suite: wily
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://archive.ubuntu.com/ubuntu
+MatchURI-amd64: archive.ubuntu.com/ubuntu
+BaseURI-i386: http://archive.ubuntu.com/ubuntu
+MatchURI-i386: archive.ubuntu.com/ubuntu
+MirrorsFile-amd64: Ubuntu.mirrors
+MirrorsFile-i386: Ubuntu.mirrors
+_Description: Ubuntu 15.10 'Wily Werewolf'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Canonical-supported free and open-source software
+Component: universe
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained free and open-source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: multiverse
+ParentComponent: universe
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: wily
+ParentSuite: wily
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Ubuntu 15.10 'Wily Werewolf'
+
+Suite: wily
+RepositoryType: deb
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*15.10
+MatchURI: cdrom:\[Ubuntu.*15.10
+_Description: Cdrom with Ubuntu 15.10 'Wily Werewolf'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: wily
+Official: false
+RepositoryType: deb
+BaseURI: http://archive.canonical.com
+MatchURI: archive.canonical.com
+_Description: Canonical Partners
+Component: partner
+_CompDescription: Software packaged by Canonical for their partners
+_CompDescriptionLong: This software is not part of Ubuntu.
+
+Suite: wily-security
+ParentSuite: wily
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://security.ubuntu.com/ubuntu/
+MatchURI-amd64: archive.ubuntu.com/ubuntu|security.ubuntu.com
+BaseURI-i386: http://security.ubuntu.com/ubuntu/
+MatchURI-i386: archive.ubuntu.com/ubuntu|security.ubuntu.com
+_Description: Important security updates
+
+Suite: wily-security
+ParentSuite: wily
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports|security.ubuntu.com
+_Description: Important security updates
+
+Suite: wily-updates
+ParentSuite: wily
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: wily-updates
+ParentSuite: wily
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Recommended updates
+
+Suite: wily-proposed
+ParentSuite: wily
+RepositoryType: deb
+_Description: Pre-released updates
+
+Suite: wily-proposed
+ParentSuite: wily
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Pre-released updates
+
+Suite: wily-backports
+ParentSuite: wily
+RepositoryType: deb
+_Description: Unsupported updates
+
+Suite: wily-backports
+ParentSuite: wily
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Unsupported updates
+
+
+Suite: vivid
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://archive.ubuntu.com/ubuntu
+MatchURI-amd64: archive.ubuntu.com/ubuntu
+BaseURI-i386: http://archive.ubuntu.com/ubuntu
+MatchURI-i386: archive.ubuntu.com/ubuntu
+MirrorsFile-amd64: Ubuntu.mirrors
+MirrorsFile-i386: Ubuntu.mirrors
+_Description: Ubuntu 15.04 'Vivid Vervet'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Canonical-supported free and open-source software
+Component: universe
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained free and open-source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: multiverse
+ParentComponent: universe
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: vivid
+ParentSuite: vivid
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Ubuntu 15.04 'Vivid Vervet'
+
+Suite: vivid
+RepositoryType: deb
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*15.04
+MatchURI: cdrom:\[Ubuntu.*15.04
+_Description: Cdrom with Ubuntu 15.04 'Vivid Vervet'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: vivid
+Official: false
+RepositoryType: deb
+BaseURI: http://archive.canonical.com
+MatchURI: archive.canonical.com
+_Description: Canonical Partners
+Component: partner
+_CompDescription: Software packaged by Canonical for their partners
+_CompDescriptionLong: This software is not part of Ubuntu.
+
+Suite: vivid
+Official: false
+RepositoryType: deb
+BaseURI: http://extras.ubuntu.com
+MatchURI: extras.ubuntu.com
+_Description: Independent
+Component: main
+_CompDescription: Provided by third-party software developers
+_CompDescriptionLong: Software offered by third party developers.
+
+Suite: vivid-security
+ParentSuite: vivid
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://security.ubuntu.com/ubuntu/
+MatchURI-amd64: archive.ubuntu.com/ubuntu|security.ubuntu.com
+BaseURI-i386: http://security.ubuntu.com/ubuntu/
+MatchURI-i386: archive.ubuntu.com/ubuntu|security.ubuntu.com
+_Description: Important security updates
+
+Suite: vivid-security
+ParentSuite: vivid
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports|security.ubuntu.com
+_Description: Important security updates
+
+Suite: vivid-updates
+ParentSuite: vivid
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: vivid-updates
+ParentSuite: vivid
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Recommended updates
+
+Suite: vivid-proposed
+ParentSuite: vivid
+RepositoryType: deb
+_Description: Pre-released updates
+
+Suite: vivid-proposed
+ParentSuite: vivid
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Pre-released updates
+
+Suite: vivid-backports
+ParentSuite: vivid
+RepositoryType: deb
+_Description: Unsupported updates
+
+Suite: vivid-backports
+ParentSuite: vivid
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Unsupported updates
+
+
+Suite: utopic
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://archive.ubuntu.com/ubuntu
+MatchURI-amd64: archive.ubuntu.com/ubuntu
+BaseURI-i386: http://archive.ubuntu.com/ubuntu
+MatchURI-i386: archive.ubuntu.com/ubuntu
+MirrorsFile-amd64: Ubuntu.mirrors
+MirrorsFile-i386: Ubuntu.mirrors
+_Description: Ubuntu 14.10 'Utopic Unicorn'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Canonical-supported free and open-source software
+Component: universe
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained free and open-source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: multiverse
+ParentComponent: universe
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: utopic
+ParentSuite: utopic
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Ubuntu 14.10 'Utopic Unicorn'
+
+Suite: utopic
+RepositoryType: deb
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*14.10
+MatchURI: cdrom:\[Ubuntu.*14.10
+_Description: Cdrom with Ubuntu 14.10 'Utopic Unicorn'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: utopic
+Official: false
+RepositoryType: deb
+BaseURI: http://archive.canonical.com
+MatchURI: archive.canonical.com
+_Description: Canonical Partners
+Component: partner
+_CompDescription: Software packaged by Canonical for their partners
+_CompDescriptionLong: This software is not part of Ubuntu.
+
+Suite: utopic
+Official: false
+RepositoryType: deb
+BaseURI: http://extras.ubuntu.com
+MatchURI: extras.ubuntu.com
+_Description: Independent
+Component: main
+_CompDescription: Provided by third-party software developers
+_CompDescriptionLong: Software offered by third party developers.
+
+Suite: utopic-security
+ParentSuite: utopic
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://security.ubuntu.com/ubuntu/
+MatchURI-amd64: archive.ubuntu.com/ubuntu|security.ubuntu.com
+BaseURI-i386: http://security.ubuntu.com/ubuntu/
+MatchURI-i386: archive.ubuntu.com/ubuntu|security.ubuntu.com
+_Description: Important security updates
+
+Suite: utopic-security
+ParentSuite: utopic
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports|security.ubuntu.com
+_Description: Important security updates
+
+Suite: utopic-updates
+ParentSuite: utopic
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: utopic-updates
+ParentSuite: utopic
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Recommended updates
+
+Suite: utopic-proposed
+ParentSuite: utopic
+RepositoryType: deb
+_Description: Pre-released updates
+
+Suite: utopic-proposed
+ParentSuite: utopic
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Pre-released updates
+
+Suite: utopic-backports
+ParentSuite: utopic
+RepositoryType: deb
+_Description: Unsupported updates
+
+Suite: utopic-backports
+ParentSuite: utopic
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Unsupported updates
+
+
+Suite: trusty
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://archive.ubuntu.com/ubuntu
+MatchURI-amd64: archive.ubuntu.com/ubuntu
+BaseURI-i386: http://archive.ubuntu.com/ubuntu
+MatchURI-i386: archive.ubuntu.com/ubuntu
+MirrorsFile-amd64: Ubuntu.mirrors
+MirrorsFile-i386: Ubuntu.mirrors
+_Description: Ubuntu 14.04 'Trusty Tahr'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Canonical-supported free and open-source software
+Component: universe
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained free and open-source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: multiverse
+ParentComponent: universe
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: trusty
+ParentSuite: trusty
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Ubuntu 14.04 'Trusty Tahr'
+
+Suite: trusty
+RepositoryType: deb
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*14.04
+MatchURI: cdrom:\[Ubuntu.*14.04
+_Description: Cdrom with Ubuntu 14.04 'Trusty Tahr'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: trusty
+Official: false
+RepositoryType: deb
+BaseURI: http://archive.canonical.com
+MatchURI: archive.canonical.com
+_Description: Canonical Partners
+Component: partner
+_CompDescription: Software packaged by Canonical for their partners
+_CompDescriptionLong: This software is not part of Ubuntu.
+
+Suite: trusty
+Official: false
+RepositoryType: deb
+BaseURI: http://extras.ubuntu.com
+MatchURI: extras.ubuntu.com
+_Description: Independent
+Component: main
+_CompDescription: Provided by third-party software developers
+_CompDescriptionLong: Software offered by third party developers.
+
+Suite: trusty-security
+ParentSuite: trusty
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://security.ubuntu.com/ubuntu/
+MatchURI-amd64: archive.ubuntu.com/ubuntu|security.ubuntu.com
+BaseURI-i386: http://security.ubuntu.com/ubuntu/
+MatchURI-i386: archive.ubuntu.com/ubuntu|security.ubuntu.com
+_Description: Important security updates
+
+Suite: trusty-security
+ParentSuite: trusty
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports|security.ubuntu.com
+_Description: Important security updates
+
+Suite: trusty-updates
+ParentSuite: trusty
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: trusty-updates
+ParentSuite: trusty
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Recommended updates
+
+Suite: trusty-proposed
+ParentSuite: trusty
+RepositoryType: deb
+_Description: Pre-released updates
+
+Suite: trusty-proposed
+ParentSuite: trusty
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Pre-released updates
+
+Suite: trusty-backports
+ParentSuite: trusty
+RepositoryType: deb
+_Description: Unsupported updates
+
+Suite: trusty-backports
+ParentSuite: trusty
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Unsupported updates
+
+
+Suite: saucy
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://archive.ubuntu.com/ubuntu
+MatchURI-amd64: archive.ubuntu.com/ubuntu
+BaseURI-i386: http://archive.ubuntu.com/ubuntu
+MatchURI-i386: archive.ubuntu.com/ubuntu
+MirrorsFile-amd64: Ubuntu.mirrors
+MirrorsFile-i386: Ubuntu.mirrors
+_Description: Ubuntu 13.10 'Saucy Salamander'
+Component: main
+_CompDescription: Officially supported
+_CompDescriptionLong: Canonical-supported free and open-source software
+Component: universe
+_CompDescription: Community-maintained
+_CompDescriptionLong: Community-maintained free and open-source software
+Component: restricted
+_CompDescription: Non-free drivers
+_CompDescriptionLong: Proprietary drivers for devices
+Component: multiverse
+ParentComponent: universe
+_CompDescription: Restricted software
+_CompDescriptionLong: Software restricted by copyright or legal issues
+
+Suite: saucy
+ParentSuite: saucy
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Ubuntu 13.10 'Saucy Salamander'
+
+Suite: saucy
+RepositoryType: deb
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*13.10
+MatchURI: cdrom:\[Ubuntu.*13.10
+_Description: Cdrom with Ubuntu 13.10 'Saucy Salamander'
+Available: False
+Component: main
+_CompDescription: Officially supported
+Component: restricted
+_CompDescription: Restricted copyright
+
+Suite: saucy
+Official: false
+RepositoryType: deb
+BaseURI: http://archive.canonical.com
+MatchURI: archive.canonical.com
+_Description: Canonical Partners
+Component: partner
+_CompDescription: Software packaged by Canonical for their partners
+_CompDescriptionLong: This software is not part of Ubuntu.
+
+Suite: saucy
+Official: false
+RepositoryType: deb
+BaseURI: http://extras.ubuntu.com
+MatchURI: extras.ubuntu.com
+_Description: Independent
+Component: main
+_CompDescription: Provided by third-party software developers
+_CompDescriptionLong: Software offered by third party developers.
+
+Suite: saucy-security
+ParentSuite: saucy
+RepositoryType: deb
+BaseURI: http://ports.ubuntu.com/ubuntu-ports/
+MatchURI: ports.ubuntu.com/ubuntu-ports
+BaseURI-amd64: http://security.ubuntu.com/ubuntu/
+MatchURI-amd64: archive.ubuntu.com/ubuntu|security.ubuntu.com
+BaseURI-i386: http://security.ubuntu.com/ubuntu/
+MatchURI-i386: archive.ubuntu.com/ubuntu|security.ubuntu.com
+_Description: Important security updates
+
+Suite: saucy-security
+ParentSuite: saucy
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports|security.ubuntu.com
+_Description: Important security updates
+
+Suite: saucy-updates
+ParentSuite: saucy
+RepositoryType: deb
+_Description: Recommended updates
+
+Suite: saucy-updates
+ParentSuite: saucy
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Recommended updates
+
+Suite: saucy-proposed
+ParentSuite: saucy
+RepositoryType: deb
+_Description: Pre-released updates
+
+Suite: saucy-proposed
+ParentSuite: saucy
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Pre-released updates
+
+Suite: saucy-backports
+ParentSuite: saucy
+RepositoryType: deb
+_Description: Unsupported updates
+
+Suite: saucy-backports
+ParentSuite: saucy
+RepositoryType: deb-src
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu|ports.ubuntu.com/ubuntu-ports
+_Description: Unsupported updates
+
+
Suite: raring
RepositoryType: deb
BaseURI: http://ports.ubuntu.com/ubuntu-ports/
diff --git a/debian/README.source b/debian/README.source
deleted file mode 100644
index ecd31364..00000000
--- a/debian/README.source
+++ /dev/null
@@ -1,3 +0,0 @@
-This package is maintained in bzr and it should be build
-with:
-$ bzr-buildpackage --native
diff --git a/debian/changelog b/debian/changelog
index 5ac830b0..31b12488 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,361 @@
+python-apt (1.0.0~beta3) unstable; urgency=medium
+
+ * tests/test_paths.py: Catch and assert the DeprecationWarning
+ * setup.py: If no version is in the environment, return None
+ * doc/source/library/apt_pkg.rst: Fix an example from old API to new API
+ * apt.cache.FilteredCache: Fix multi-arch package lookups
+ * apt.Cache: Introduce a connect2() callback connector
+ * Break the FilteredCache <-> Cache reference cycle
+ * apt.Cache: Issue a RuntimeWarning in connect()
+ * doc: whatsnew: Document what's new in beta3
+
+ -- Julian Andres Klode <jak@debian.org> Wed, 17 Jun 2015 18:28:44 +0200
+
+python-apt (1.0.0~beta2) unstable; urgency=low
+
+ * debian/control: Build-Depend on apt (>= 1.0.9.4) for Files2()
+ * Handle the symlink to directory transition correctly (Closes: #788571)
+
+ -- Julian Andres Klode <jak@debian.org> Sat, 13 Jun 2015 00:41:30 +0200
+
+python-apt (1.0.0~beta1) unstable; urgency=low
+
+ [ Julian Andres Klode ]
+ * tests/test_tagfile.py: Close files we opened to prevent leakage
+ (Closes: #785337)
+ * doc/source/c++/api.rst: Upgrade syntax to use the new domain stuff
+ * doc/source/library/apt_pkg.rst: Fix indentation (Closes: #736119)
+ * sphinx docs: Fix remaining instances of old C syntax to use domains
+ * python/cache.cc: Handle deprecation of pkgCache::PkgIterator::Section()
+ * doc: Prepare for 1.0 release
+ * TagFile: Provide close() and context manager (Closes: #748922)
+ * doc: Document apt_pkg.TagFile additions
+ * doc: templates: layout: Remove invalid icon links
+ * debian/control: Build-Depend on dh-python
+ * Do not link documentation from Architecture: all to Architecture: any
+ * Use ${python:Depends} and friends for the debug packages
+ * apt.debfile: Fix splitting of multi-lines Binary fields in dsc files
+ (Closes: #751770)
+ * Remove apt.progress.gtk2
+ * apt_pkg.Package: Drop the unset 'auto' attribute (Closes: #565364)
+ * Update POTFILES.in and the pot
+ * apt/cache.py: Work around a cyclic reference from Cache to its methods
+ (Closes: #745487)
+ * apt/debfile.py: Arch-qualify in compare_to_version_in_cache()
+ (Closes: #750189)
+ * apt.package: Only reference Launchpad for missing changelogs on Ubuntu
+ (Closes: #781270)
+ * apt/cache.py: Support :all and other special architecture specifies
+ * apt/debfile: Stop special-casing all when looking for a package in the cache
+ * apt/debfile.py: Allow downgrading packages in check() with a parameter
+ (Closes: #613974)
+ * Acquire: Document that items may have transient errors on run() success
+ (Closes: #680997)
+ * Large file support (Closes: #742885)
+ - python/arfile.cc: Do not allow files larger than SIZE_MAX to be mapped
+ - python/arfile.cc: LFS: Use long long instead of long for file sizes
+ - python/tarfile.cc: LFS: Handle too large file
+ * setup.py: Translate version number from Debian to PEP0440 (LP: #1445949)
+
+ [ Michael Vogt ]
+ * apt_pkg.rst: improve documentation for AcquireFile() hash and add
+ sha512 to the documentation
+ * rename "md5" keyword argument in AcquireFile() to "hash" and add
+ backward compatiblity
+ * Fix apt.Package.installed_files for multi-arch packages (LP: #1313699)
+
+ [ von ]
+ * Remove the "-Wstrict-prototypes" compiler option (Closes: #785261)
+ * Set Standards-Version to 3.9.6 (Closes: #785431)
+ * Fix indentation and docstring problems (Closes: #784910)
+
+ [ Michael Schaller ]
+ * Fixed docstring of BaseDependency.version property.
+ * Improved docstring of the Version.get_dependencies method.
+
+ -- Julian Andres Klode <jak@debian.org> Thu, 11 Jun 2015 22:38:31 +0200
+
+python-apt (0.9.4) unstable; urgency=medium
+
+ [ Michael Vogt ]
+ * add apt_pkg.sha512sum()
+ * Add binding for apt_pkg.maybe_open_clear_signed_file()
+ * apt/debfile.py: use apt_pkg.open_maybe_clear_signed_file() when opening a .dsc file
+ * Update doc/example/action.py for py3 and latest API (closes: #782335)
+ * Add MULTI_ARCH_NO constant and deprecate MULTI_ARCH_NONE (closes: #782802)
+ * Fix dead links in python-apt documentation (Closes: #779426)
+
+ [ Martin Pitt ]
+ * ./data/templates/Ubuntu.info.in: Add Wily template. Don't copy extras.u.c.
+ stanza as that's gone since 15.04.
+
+ [ von ]
+ * Update the print_uris.py example to use the new API (Closes: #779217)
+
+ -- Michael Vogt <mvo@debian.org> Thu, 07 May 2015 18:18:29 +0200
+
+python-apt (0.9.3.11) unstable; urgency=low
+
+ [ Colin Watson ]
+ * Add template for the "Ubuntu-RTM" derived distribution.
+ * Detect whether a system is running Ubuntu-RTM by way of
+ "system-image-cli -i". Not perfect but close enough.
+
+ [ Julian Andres Klode ]
+ * Embed changelog entry date and time instead of build date and time
+ (Closes: #762674)
+
+ [ Michael Vogt ]
+ * python/tarfile.cc: use long long in Process() for APT >= 4.14
+ * Merged UbuntuRTMDistribution detection from ubuntu
+ * Add Ubuntu 15.04 (Vivid Vervet) to the template
+
+ -- Michael Vogt <mvo@debian.org> Fri, 24 Oct 2014 10:16:01 -0400
+
+python-apt (0.9.3.10) unstable; urgency=medium
+
+ * python/tag.cc: ensure that the final \n is there when
+ duplicating section data
+ * apt/debfile.py:
+ - Stop reading after the "Format" stanza in a .dsc file
+ - Add support for apt.debfile.DscSrcPackage.filelist
+ - Read all tags from a dsc file and improve tests
+ * fix tests when gnupg is < 1.4.18
+ * update python-apt.pot
+
+ -- Michael Vogt <mvo@debian.org> Thu, 04 Sep 2014 18:07:41 +0200
+
+python-apt (0.9.3.9) unstable; urgency=medium
+
+ [ Michael Vogt ]
+ * fix another pep8 failure
+
+ [ Julian Andres Klode ]
+ * doc/source/tutorials/apt-get.rst: Remove -s from --print-uris invocation
+ (LP: #1308670)
+
+ [ Mauricio Faria de Oliveira ]
+ * tests/test_pep8.py: --ignore E129 too (fix FTBFS with pep8 >= 1.5)
+ * tests/test_auth.py: update for gnupg 1.4.18 (Closes: #755342)
+
+ -- Michael Vogt <mvo@debian.org> Thu, 28 Aug 2014 14:46:57 -0700
+
+python-apt (0.9.3.8) unstable; urgency=medium
+
+ * pep8 fixes to fix autopkgtest failure with the most recent
+ pep8 package
+
+ -- Michael Vogt <mvo@debian.org> Mon, 30 Jun 2014 13:31:29 +0200
+
+python-apt (0.9.3.7) unstable; urgency=medium
+
+ * Include "Blankon" template (Closes: #747498)
+ * Add apt_pkg.SourceRecords.step() to step through all SrcRecords
+ * debian/control:
+ - update build-dependency for libapt-pkg-dev to 1.0.4 for
+ pkgSourceRecords::Step()
+
+ -- Michael Vogt <mvo@debian.org> Tue, 10 Jun 2014 18:23:33 +0200
+
+python-apt (0.9.3.6) unstable; urgency=medium
+
+ [ Johannes Schauer ]
+ * Add support for build profiles (Closes: 744243)
+
+ [ Michael Vogt ]
+ * debian/control:
+ - update build-depends on libapt-pkg-dev for build-profile support
+ * data/templates/Ubuntu.info.in:
+ - add ubuntu utopic
+
+ -- Michael Vogt <mvo@debian.org> Fri, 25 Apr 2014 13:00:08 +0200
+
+python-apt (0.9.3.5) unstable; urgency=medium
+
+ * utils/get_ubuntu_mirrors.py: Drop, its unused and broken
+ * doc/source/conf.py: Do not use 'u' and 'r' prefixes together
+ * tests: Drop some more Python 2.6 cruft
+ * debian/control: Drop X{B,S}-Python-Version and use X-Python-Version
+ * debian/pycompat: Drop, it's not used anymore
+ * python/tag.cc: Ignore missing 'encoding' attribute in file objects
+ * apt/package.py: Do not shadow _
+
+ -- Julian Andres Klode <jak@debian.org> Wed, 02 Apr 2014 00:37:27 +0200
+
+python-apt (0.9.3.4) unstable; urgency=medium
+
+ * python/progress.cc: Fix InstallProgress to set child_pid (LP: #1177720)
+ * python/progress.cc: Remove invalid checks for mixedCase methods
+ * utils/get_*_mirrors*.py: Ensure failure if no mirrors were read
+ * utils/get_*_mirrors*.py: Use sys.stderr.write instead of print
+ * Support all compressors for data.tar/control.tar (Closes: #718330)
+ * Revert "aptsources/sourceslist.py: ensure that our sources are opened with UTF-8"
+ (Closes: #742118)
+
+ -- Julian Andres Klode <jak@debian.org> Thu, 20 Mar 2014 16:48:12 +0100
+
+python-apt (0.9.3.3) unstable; urgency=medium
+
+ [ Steve Langasek ]
+ * aptsources/sourceslist.py: ensure that our sources are opened with UTF-8
+ encoding, regardless of the current locale, and handle the sources lines
+ as Unicode internally for consistency between python2 and python3.
+ LP: #1069019.
+
+ [ Brian Murray ]
+ * Fix pep8 error.
+
+ -- Julian Andres Klode <jak@debian.org> Sat, 15 Mar 2014 18:53:58 +0100
+
+python-apt (0.9.3.2) unstable; urgency=high
+
+ * Revert "* apt/cache.py:" (rootdir change) (Closes: #741251) (LP: #1288171)
+
+ We cannot reset the configuration when rootdir is specified in
+ apt.Cache(). This reopens: #728274.
+
+ -- Julian Andres Klode <jak@debian.org> Mon, 10 Mar 2014 14:32:53 +0100
+
+python-apt (0.9.3.1) unstable; urgency=medium
+
+ * debian/rules: Do not run dh_sphinxdoc -a
+
+ -- Julian Andres Klode <jak@debian.org> Sat, 22 Feb 2014 20:33:06 +0100
+
+python-apt (0.9.3) unstable; urgency=medium
+
+ * doc/source/conf.py: Python 3 support
+ * debian/rules: Use dh_sphinxdoc integration
+ * utils/doclint.py: Drop, not working anymore.
+ * python/generic.h: Fix MkPyNumber to work if char is unsigned.
+ * data: Add Tanglu distribution information
+ * debian/python3-apt-dbg.files: Fix pattern for kFreeBSD
+ * tests/test_policy.py: Disable, uses system state (FTBFS on ppc64)
+ * tests/data/aptsources/sources.list.testDistribution: Add tanglu
+ * tests/test_policy.py: Fix comment to conform to PEP8
+
+ -- Julian Andres Klode <jak@debian.org> Sat, 22 Feb 2014 19:05:48 +0100
+
+python-apt (0.9.2) unstable; urgency=medium
+
+ [ Michael Vogt ]
+ * apt/cache.py:
+ - when using apt.Cache(rootdir=/some/dir) only read the APT
+ configuration from this rootdir instead of /etc (closes: #728274)
+ * make pep8 test part of the unittests
+ * add pyflakes test
+ * add .travis.yml & update python3 dependency to 3.3
+
+ [ Barry Warsaw ]
+ * debian/tests/control: Add python-all and python3-all as Depends for the
+ autopkgtests so all the supported Python versions are pulled in.
+ (closes: #734500)
+
+ [ Michael Schaller]
+ * apt/cache.py:
+ - Fixed PEP8 issues
+ - Fixed pyflakes issue: Removed unused local variable 'transient'
+ * apt/package.py:
+ - Fixed PEP8 issues
+ - Fixed pyflakes issue: Removed unused import 'warnings'
+ - Improved readability and documentation of BaseDependency.__dstr().
+
+ [ Julian Andres Klode ]
+ * apt/cache.py: Call os.path.abspath() on a supplied rootdir (LP: #792295)
+ * apt/package.py: Fix BaseDependency.__dstr.__ne__()
+ * apt/package.py: Pass an apt_pkg.Dependency to BaseDependency
+ * tests: Add back test_hashsums from old and update
+ * Style fixes:
+ - Style fix: Do not use "is True" / "is False"
+ - debian/control: Replace a tab with spaces
+ - tests/test_deps.py: Remove an invalid blank line
+ * Use a single code base for Python 2 and 3
+ - Use print_function everywhere
+ - Drop support for Python 2.6
+ - tests: Remove checks for Python older than 2.7
+ * Documentation fixes:
+ - apt, doc: Fix the list of comp_type values
+ - Unify list of comparison type values everywhere
+ * Static analysis fixes:
+ - (cppcheck) python/pkgmanager.cc: Do not create temporary CppPyRef
+ * Packaging changes:
+ - debian/README.source: Drop it, it's useless bzr
+ - debian/gbp.conf: Set sign-tags = True
+ - debian/control: Set Standards-Version to 3.9.5
+ - debian/control: Drop python-{unittest2,debian} build deps
+
+ -- Julian Andres Klode <jak@debian.org> Sat, 25 Jan 2014 18:18:38 +0100
+
+python-apt (0.9.1) unstable; urgency=low
+
+ * data/templates/Ubuntu.info.in: It's 'Tahr', not 'Thar'
+ * data/templates/Debian.info.in: Add jessie
+ * data/templates/Debian.info.in: Change wheezy version from 7.0 to 7
+ * python/*.cc: Get rid of the easy-to-replace deprecated APT functions
+ * python/{depcache.cc,string.cc}: Ignore deprecation warnings for some calls
+ * python/depcache.cc: Add more error handling to PkgDepCacheCommit
+ * python/cache.cc: Remove a check for an unsigned long value < 0
+ * python/arfile.cc: (C++11) Explicitly cast unsigned long to time_t in {}
+ * python/apt_instmodule.cc: Make RETURN(x) be return on Python 2
+ * python/policy.cc: (scan-build): Fix a dead assignment
+ * python/progress.cc: (scan-build): Fix some uninitialized values
+ * debian: Upgrade to debhelper 9 (and dpkg-buildflags)
+ * debian/python-apt-doc.links: Replace bundled underscore.js by symlink
+ * po: Update the template
+
+ -- Julian Andres Klode <jak@debian.org> Wed, 23 Oct 2013 20:32:40 +0200
+
+python-apt (0.9.0) unstable; urgency=low
+
+ [ Michael Vogt ]
+ * some fixes from the "coverity" scan
+ * merge from Ubuntu:
+ - data/templates/Ubuntu.info.in: add "Saucy Salamander" to
+ - debian/control: add "Multi-Arch: allowed"
+
+ [ Julian Andres Klode ]
+ * Completely remove all old-API support code
+ * Accept bytes object for file names (Closes: #680971)
+ * aptsources/sourceslist.py
+ - Document correct use of uniq and hide it using __all__ (Closes: #723815)
+ - Correctly parse multiple options (LP: #1103200)
+ * python/apt_pkgmodule.cc:
+ - Fix documentation of version_compare (Closes: #680891)
+ * python/cache.cc:
+ - Set NoDelete=true when creating Policy, fixes segfault in destructor
+ * apt/package.py:
+ - Add a Package.has_config_files property (Closes: #712749)
+ * tests:
+ - Do not set dir::etc::sourceparts to /tmp
+ * apt, aptsources:
+ - Only call init_config() if not already initialized (Closes: #686403)
+ * apt/debfile.py:
+ - Pass strip_multi_arch=False to parse_depends. Patch by Michael, tests
+ derived from the ones provided by the reporter.
+ Closes: #717859. Closes: #717861.
+ * doc/source/examples/dpkg-info.py:
+ - Use apt_inst.DebFile (Closes: #671784)
+ * doc/examples/*.py:
+ - Update examples to the new API (Closes: #639022)
+ * tests/old/*.py:
+ - Update to new API as well
+ * data/templates/Ubuntu.info.in:
+ - Add "Trusty Thar"
+ * debian/control:
+ - Set Standards-Version to 3.9.4
+
+ [ Jeremy Bicha ]
+ * data/templates/Ubuntu.info.in: add 'devel' series (Closes: #722961)
+
+ [ Jakub Wilk ]
+ * python-apt: formatting error in library/index.rst (Closes: #692484)
+
+ [ Daniel Hartwig ]
+ * apt/package.py:
+ - mark_upgrade misuses FromUser to set auto-installed (Closes: #686726)
+
+ -- Julian Andres Klode <jak@debian.org> Mon, 21 Oct 2013 20:53:17 +0200
+
python-apt (0.8.9.2+dyson1) unstable; urgency=low
[ Michael Vogt ]
@@ -96,14 +454,6 @@ python-apt (0.8.9~exp1) experimental; urgency=low
-- Michael Vogt <mvo@debian.org> Wed, 13 Mar 2013 18:36:37 +0100
-python-apt (0.8.8.3) UNRELEASED; urgency=low
-
- * aptsources/distro.py:
- - include the missing ID in the NoDistroTemplateException() error,
- thanks to Brian Murray
-
- -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 30 Apr 2013 18:37:24 +0200
-
python-apt (0.8.8.2) unstable; urgency=low
[ David Prévot ]
diff --git a/debian/compat b/debian/compat
index 7f8f011e..ec635144 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-7
+9
diff --git a/debian/control b/debian/control
index 945d49d5..64f9d7d9 100644
--- a/debian/control
+++ b/debian/control
@@ -3,28 +3,30 @@ Section: python
Priority: standard
Maintainer: APT Development Team <deity@lists.debian.org>
Uploaders: Michael Vogt <mvo@debian.org>, Julian Andres Klode <jak@debian.org>
-Standards-Version: 3.9.3
-XS-Python-Version: >= 2.6
-X-Python3-Version: >= 3.1
-Build-Depends: apt (>= 0.9.6),
+Standards-Version: 3.9.6
+X-Python-Version: >= 2.7
+X-Python3-Version: >= 3.3
+Build-Depends: apt (>= 1.0.9.4),
apt-utils,
- debhelper (>= 7.3.5),
+ debhelper (>= 9),
+ dh-python,
fakeroot,
- libapt-pkg-dev (>= 0.8.11),
- python-all-dev (>= 2.6.6-3~),
+ libapt-pkg-dev (>= 1.0.4~),
+ python-all-dev (>= 2.7),
python-all-dbg,
- python3-all-dev (>= 3.1.2-10~),
- python3-all-dbg (>= 3.1.2-6~),
+ python3-all-dev (>= 3.3),
+ python3-all-dbg (>= 3.3),
python-distutils-extra (>= 2.0),
python-sphinx (>= 0.5),
- python-debian,
- python-unittest2
+ pep8,
+ pyflakes
Vcs-Git: git://anonscm.debian.org/apt/python-apt.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=apt/python-apt.git
XS-Testsuite: autopkgtest
Package: python-apt
Architecture: any
+Multi-Arch: allowed
Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, python-apt-common
Recommends: lsb-release, iso-codes, xz-utils
Breaks: packagekit-backend-apt (<= 0.4.8-0ubuntu4),
@@ -56,8 +58,7 @@ Breaks: packagekit-backend-apt (<= 0.4.8-0ubuntu4),
update-notifier (<< 0.99.3debian9),
wajig (<< 2.0.46)
Provides: ${python:Provides}
-Suggests: python-apt-dbg, python-gtk2, python-vte, python-apt-doc
-XB-Python-Version: ${python:Versions}
+Suggests: python-apt-dbg, python-apt-doc
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
@@ -75,7 +76,7 @@ Package: python-apt-doc
Priority: optional
Architecture: all
Section: doc
-Depends: libjs-jquery, ${misc:Depends}
+Depends: libjs-jquery, libjs-underscore, ${misc:Depends}, ${sphinxdoc:Depends}
Enhances: python-apt
Replaces: python-apt (<< 0.7.94)
Description: Python interface to libapt-pkg (API documentation)
@@ -88,10 +89,11 @@ Description: Python interface to libapt-pkg (API documentation)
Package: python-apt-dbg
Priority: extra
Architecture: any
+Multi-Arch: allowed
Section: debug
-Depends: python-dbg, python-apt (= ${binary:Version}), ${shlibs:Depends},
+Depends: ${python:Depends}, python-apt (= ${binary:Version}), ${shlibs:Depends},
${misc:Depends}
-XB-Python-Version: ${python:Versions}
+Provides: ${python:Provides}
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
@@ -130,6 +132,7 @@ Description: Python interface to libapt-pkg (locales)
Package: python3-apt
Priority: optional
Architecture: any
+Multi-Arch: allowed
Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends}, python-apt-common
Recommends: lsb-release, iso-codes
Provides: ${python3:Provides}
@@ -152,11 +155,13 @@ Description: Python 3 interface to libapt-pkg
Package: python3-apt-dbg
Priority: extra
Architecture: any
+Multi-Arch: allowed
Section: debug
Breaks: python-apt (<< 0.7.98+nmu1)
Replaces: python-apt (<< 0.7.98+nmu1)
-Depends: python3-dbg, python3-apt (= ${binary:Version}), ${shlibs:Depends},
+Depends: ${python3:Depends}, python3-apt (= ${binary:Version}), ${shlibs:Depends},
${misc:Depends}
+Provides: ${python3:Provides}
Description: Python 3 interface to libapt-pkg (debug extension)
The apt_pkg Python 3 interface will provide full access to the internal
libapt-pkg structures allowing Python 3 programs to easily perform a
diff --git a/debian/gbp.conf b/debian/gbp.conf
index 9a5cb4f8..e9f2f7c0 100644
--- a/debian/gbp.conf
+++ b/debian/gbp.conf
@@ -3,3 +3,4 @@ prebuild = ./pre-build.sh
export-dir = ../build-area
debian-branch = debian/sid
debian-tag = %(version)s
+sign-tags = True
diff --git a/debian/pycompat b/debian/pycompat
deleted file mode 100644
index 0cfbf088..00000000
--- a/debian/pycompat
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/debian/python-apt-common.install b/debian/python-apt-common.install
index bea48037..d21f9b8e 100644
--- a/debian/python-apt-common.install
+++ b/debian/python-apt-common.install
@@ -1,4 +1,2 @@
usr/share/locale
usr/share/python-apt
-# Install the migration helper
-utils/migrate-0.8.py usr/share/python-apt
diff --git a/debian/python-apt-common.lintian-overrides b/debian/python-apt-common.lintian-overrides
deleted file mode 100644
index f0eddf6b..00000000
--- a/debian/python-apt-common.lintian-overrides
+++ /dev/null
@@ -1,2 +0,0 @@
-# package depends on python | python3
-python-script-but-no-python-dep usr/share/python-apt/migrate-0.8.py
diff --git a/debian/python-apt-dev.maintscript b/debian/python-apt-dev.maintscript
new file mode 100644
index 00000000..95afb26e
--- /dev/null
+++ b/debian/python-apt-dev.maintscript
@@ -0,0 +1 @@
+symlink_to_dir /usr/share/doc/python-apt-dev python-apt 1.0.0~beta2~
diff --git a/debian/python-apt-doc.links b/debian/python-apt-doc.links
index 40f834f2..d43d0018 100644
--- a/debian/python-apt-doc.links
+++ b/debian/python-apt-doc.links
@@ -1 +1,2 @@
usr/share/javascript/jquery/jquery.js usr/share/doc/python-apt-doc/html/_static/jquery.js
+usr/share/javascript/underscore/underscore.js usr/share/doc/python-apt-doc/html/_static/underscore.js
diff --git a/debian/python-apt-doc.maintscript b/debian/python-apt-doc.maintscript
new file mode 100644
index 00000000..5deb7bd1
--- /dev/null
+++ b/debian/python-apt-doc.maintscript
@@ -0,0 +1 @@
+symlink_to_dir /usr/share/doc/python-apt-doc python-apt 1.0.0~beta2~
diff --git a/debian/python-apt-doc.preinst b/debian/python-apt-doc.preinst
new file mode 100755
index 00000000..2c467dd2
--- /dev/null
+++ b/debian/python-apt-doc.preinst
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+# Remove files that remained
+if [ "$1" = "upgrade" ]; then
+ if test -d /usr/share/doc/python-apt/html; then
+ rm -r /usr/share/doc/python-apt/html
+ fi
+
+ if test -d /usr/share/doc/python-apt/examples; then
+ rm -r /usr/share/doc/python-apt/examples
+ fi
+fi
+
+#DEBHELPER#
diff --git a/debian/python3-apt-dbg.files b/debian/python3-apt-dbg.files
index 88cbfcb0..90856651 100644
--- a/debian/python3-apt-dbg.files
+++ b/debian/python3-apt-dbg.files
@@ -1 +1 @@
-usr/lib/python3*/*/*d*.so
+usr/lib/python3*/*/*dm-*.so
diff --git a/debian/rules b/debian/rules
index c6c3e053..abf92519 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,13 +1,18 @@
#!/usr/bin/make -f
# Should be include-links, but that somehow fails.
export DEBVER=$(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
-# For compatibility, add -DCOMPAT_0_7
-export CFLAGS=-Wno-write-strings
+export DATETIME:=$(shell dpkg-parsechangelog | sed -n -e 's/^Date: //p')
+export DATE_CMD:=env TZ=UTC LC_ALL=C.UTF-8 date
+export DATE:=$(shell $(DATE_CMD) --date="$(DATETIME)" "+%b %_d %Y")
+export TIME:=$(shell $(DATE_CMD) --date="$(DATETIME)" "+%H:%M:%S")
+export DEB_CFLAGS_MAINT_APPEND=-Wno-write-strings \
+ -DDATE=\""$(DATE)"\" \
+ -DTIME=\""$(TIME)"\"
export PATH := $(CURDIR)/utils:$(PATH)
export pyversions := $(CURDIR)/utils/pyversions
%:
- dh --with python2,python3 $@
+ dh $@ --with python2,python3,sphinxdoc
override_dh_auto_build:
dh_auto_build
@@ -16,15 +21,20 @@ override_dh_install:
dh_movefiles
dh_install
+override_dh_sphinxdoc:
+ set -e; if [ -z $(filter -a,$(DH_INTERNAL_OPTIONS)) ]; then \
+ dh_sphinxdoc; \
+ fi
+
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_installdocs -Npython-apt-common -Npython3-apt -Npython3-apt-dbg --link-doc=python-apt
+ dh_installdocs -p python-apt -p python-apt-dbg --link-doc=python-apt
dh_installdocs -p python3-apt -p python3-apt-dbg --link-doc=python3-apt
- dh_installdocs -p python-apt-common
+ dh_installdocs --remaining-packages
override_dh_strip:
dh_strip -p python-apt --dbg-package=python-apt-dbg
diff --git a/debian/tests/control b/debian/tests/control
index 2ca0a401..9c92c35d 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,2 +1,2 @@
Tests: run-tests
-Depends: @, apt-utils, python-debian, fakeroot, intltool
+Depends: @, apt-utils, python-debian, python-all, python3-all, fakeroot, intltool, pep8, pyflakes
diff --git a/debian/tests/run-tests b/debian/tests/run-tests
index bb980c6b..7d7a4bf3 100644
--- a/debian/tests/run-tests
+++ b/debian/tests/run-tests
@@ -3,6 +3,6 @@
set -e
# from debian/rules
-for python in $(utils/pyversions -r); do
+for python in $(utils/pyversions -r); do
$python tests/test_all.py -q
done
diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py
index 96426a32..942d0686 100644
--- a/doc/examples/acquire.py
+++ b/doc/examples/acquire.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
import apt
+import apt.progress.text
import apt_pkg
import os
@@ -8,46 +9,48 @@ def get_file(fetcher, uri, destfile):
# get the file
af = apt_pkg.AcquireFile(fetcher, uri=uri, descr="sample descr",
destfile=destfile)
- res = fetcher.Run()
- if res != fetcher.ResultContinue:
+ print "desc_uri: %s -> %s" % (af.desc_uri, af.destfile)
+ res = fetcher.run()
+ if res != fetcher.RESULT_CONTINUE:
return False
return True
apt_pkg.init()
-#apt_pkg.Config.Set("Debug::pkgDPkgPM","1");
-#apt_pkg.Config.Set("Debug::pkgPackageManager","1");
-#apt_pkg.Config.Set("Debug::pkgDPkgProgressReporting","1");
+#apt_pkg.config.set("Debug::pkgDPkgPM","1");
+#apt_pkg.config.set("Debug::pkgPackageManager","1");
+#apt_pkg.config.set("Debug::pkgDPkgProgressReporting","1");
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
recs = apt_pkg.PackageRecords(cache)
list = apt_pkg.SourceList()
-list.ReadMainList()
+list.read_main_list()
# show the amount fetch needed for a dist-upgrade
-depcache.Upgrade(True)
-progress = apt.progress.TextFetchProgress()
+depcache.upgrade(True)
+progress = apt.progress.text.AcquireProgress()
fetcher = apt_pkg.Acquire(progress)
pm = apt_pkg.PackageManager(depcache)
-pm.GetArchives(fetcher, list, recs)
-print "%s (%s)" % (apt_pkg.SizeToStr(fetcher.FetchNeeded), fetcher.FetchNeeded)
+pm.get_archives(fetcher, list, recs)
+print "%s (%s)" % (
+ apt_pkg.size_to_str(fetcher.fetch_needed), fetcher.fetch_needed)
actiongroup = apt_pkg.ActionGroup(depcache)
-for pkg in cache.Packages:
- depcache.MarkKeep(pkg)
+for pkg in cache.packages:
+ depcache.mark_keep(pkg)
try:
os.mkdir("/tmp/pyapt-test")
os.mkdir("/tmp/pyapt-test/partial")
except OSError:
pass
-apt_pkg.Config.Set("Dir::Cache::archives", "/tmp/pyapt-test")
+apt_pkg.config.set("Dir::Cache::archives", "/tmp/pyapt-test")
-pkg = cache["3ddesktop"]
-depcache.MarkInstall(pkg)
+pkg = cache["2vcard"]
+depcache.mark_install(pkg)
-progress = apt.progress.TextFetchProgress()
+progress = apt.progress.text.AcquireProgress()
fetcher = apt_pkg.Acquire(progress)
#fetcher = apt_pkg.Acquire()
pm = apt_pkg.PackageManager(depcache)
@@ -57,20 +60,20 @@ print fetcher
get_file(fetcher, "ftp://ftp.debian.org/debian/dists/README", "/tmp/lala")
-pm.GetArchives(fetcher, list, recs)
+pm.get_archives(fetcher, list, recs)
-for item in fetcher.Items:
+for item in fetcher.items:
print item
- if item.Status == item.StatError:
- print "Some error ocured: '%s'" % item.ErrorText
- if item.Complete == False:
- print "No error, still nothing downloaded (%s)" % item.ErrorText
+ if item.status == item.STAT_ERROR:
+ print "Some error ocured: '%s'" % item.error_text
+ if not item.complete:
+ print "No error, still nothing downloaded (%s)" % item.error_text
print
-res = fetcher.Run()
+res = fetcher.run()
print "fetcher.Run() returned: %s" % res
print "now runing pm.DoInstall()"
-res = pm.DoInstall(1)
-print "pm.DoInstall() returned: %s"% res
+res = pm.do_install(1)
+print "pm.DoInstall() returned: %s" % res
diff --git a/doc/examples/action.py b/doc/examples/action.py
index 512945df..b395adc6 100644
--- a/doc/examples/action.py
+++ b/doc/examples/action.py
@@ -1,110 +1,112 @@
#!/usr/bin/python
-# example how to deal with the depcache
+#
+# LOW LEVEL example how to deal with the depcache
+#
+# you probably do not want to use this low level code and use
+# the high level "apt" interface instead that can do all this
+# but with a nicer API
import apt_pkg
-import sys
-from apt.progress import OpTextProgress
+from apt.progress.text import OpProgress
from progress import TextFetchProgress
# init
apt_pkg.init()
-progress = OpTextProgress()
+progress = OpProgress()
cache = apt_pkg.Cache(progress)
-print "Available packages: %s " % cache.PackageCount
+print("Available packages: %s " % cache.package_count)
-print "Fetching"
+print("Fetching")
progress = TextFetchProgress()
-cache.Update(progress)
-
-print "Exiting"
-sys.exit(0)
+source = apt_pkg.SourceList()
+cache.update(progress, source)
iter = cache["base-config"]
-print "example package iter: %s" % iter
+print("example package iter: %s" % iter)
# get depcache
-print "\n\n depcache"
-depcache = apt_pkg.DepCache(cache, progress)
-depcache.ReadPinFile()
-print "got a depcache: %s " % depcache
-print "Marked for install: %s " % depcache.InstCount
+print("\n\n depcache")
+depcache = apt_pkg.DepCache(cache)
+depcache.read_pinfile()
+print("got a depcache: %s " % depcache)
+print("Marked for install: %s " % depcache.inst_count)
-print "\n\n Reinit"
-depcache.Init(progress)
+print("\n\n Reinit")
+depcache.init(progress)
#sys.exit()
# get a canidate version
-ver= depcache.GetCandidateVer(iter)
-print "Candidate version: %s " % ver
-
-print "\n\nQuerry interface"
-print "%s.IsUpgradable(): %s" % (iter.Name, depcache.IsUpgradable(iter))
-
-print "\nMarking interface"
-print "Marking '%s' for install" % iter.Name
-depcache.MarkInstall(iter)
-print "Install count: %s " % depcache.InstCount
-print "%s.MarkedInstall(): %s" % (iter.Name, depcache.MarkedInstall(iter))
-print "%s.MarkedUpgrade(): %s" % (iter.Name, depcache.MarkedUpgrade(iter))
-print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter))
-
-print "Marking %s for delete" % iter.Name
-depcache.MarkDelete(iter)
-print "DelCount: %s " % depcache.DelCount
-print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter))
-
-iter = cache["3dchess"]
-print "\nMarking '%s' for install" % iter.Name
-depcache.MarkInstall(iter)
-print "Install count: %s " % depcache.InstCount
-print "%s.MarkedInstall(): %s" % (iter.Name, depcache.MarkedInstall(iter))
-print "%s.MarkedUpgrade(): %s" % (iter.Name, depcache.MarkedUpgrade(iter))
-print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter))
-
-print "Marking %s for keep" % iter.Name
-depcache.MarkKeep(iter)
-print "Install: %s " % depcache.InstCount
-
-iter = cache["3dwm-server"]
-print "\nMarking '%s' for install" % iter.Name
-depcache.MarkInstall(iter)
-print "Install: %s " % depcache.InstCount
-print "Broken count: %s" % depcache.BrokenCount
-print "FixBroken() "
-depcache.FixBroken()
-print "Broken count: %s" % depcache.BrokenCount
-
-print "\nPerforming Upgrade"
-depcache.Upgrade()
-print "Keep: %s " % depcache.KeepCount
-print "Install: %s " % depcache.InstCount
-print "Delete: %s " % depcache.DelCount
-print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize)
-print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
-
-for pkg in cache.Packages:
- if pkg.CurrentVer is not None and not depcache.MarkedInstall(pkg) \
- and depcache.IsUpgradable(pkg):
- print "Upgrade didn't upgrade (kept): %s" % pkg.Name
-
-print "\nPerforming DistUpgrade"
-depcache.Upgrade(True)
-print "Keep: %s " % depcache.KeepCount
-print "Install: %s " % depcache.InstCount
-print "Delete: %s " % depcache.DelCount
-print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize)
-print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
+ver = depcache.get_candidate_ver(iter)
+print("Candidate version: %s " % ver)
+
+print("\n\nQuerry interface")
+print("%s.is_upgradable(): %s" % (iter.name, depcache.is_upgradable(iter)))
+
+print("\nMarking interface")
+print("Marking '%s' for install" % iter.name)
+depcache.mark_install(iter)
+print("Install count: %s " % depcache.inst_count)
+print("%s.marked_install(): %s" % (iter.name, depcache.marked_install(iter)))
+print("%s.marked_upgrade(): %s" % (iter.name, depcache.marked_upgrade(iter)))
+print("%s.marked_delete(): %s" % (iter.name, depcache.marked_delete(iter)))
+
+print("Marking %s for delete" % iter.name)
+depcache.mark_delete(iter)
+print("del_count: %s " % depcache.del_count)
+print("%s.marked_delete(): %s" % (iter.name, depcache.marked_delete(iter)))
+
+iter = cache["apt"]
+print("\nMarking '%s' for install" % iter.name)
+depcache.mark_install(iter)
+print("Install count: %s " % depcache.inst_count)
+print("%s.marked_install(): %s" % (iter.name, depcache.marked_install(iter)))
+print("%s.marked_upgrade(): %s" % (iter.name, depcache.marked_upgrade(iter)))
+print("%s.marked_delete(): %s" % (iter.name, depcache.marked_delete(iter)))
+
+print("Marking %s for keep" % iter.name)
+depcache.mark_keep(iter)
+print("Install: %s " % depcache.inst_count)
+
+iter = cache["python-apt"]
+print("\nMarking '%s' for install" % iter.name)
+depcache.mark_install(iter)
+print("Install: %s " % depcache.inst_count)
+print("Broken count: %s" % depcache.broken_count)
+print("fix_broken() ")
+depcache.fix_broken()
+print("Broken count: %s" % depcache.broken_count)
+
+print("\nPerforming upgrade")
+depcache.upgrade()
+print("Keep: %s " % depcache.keep_count)
+print("Install: %s " % depcache.inst_count)
+print("Delete: %s " % depcache.del_count)
+print("usr_size: %s " % apt_pkg.size_to_str(depcache.usr_size))
+print("deb_size: %s " % apt_pkg.size_to_str(depcache.deb_size))
+
+for pkg in cache.packages:
+ if pkg.current_ver is not None and not depcache.marked_install(pkg) \
+ and depcache.is_upgradable(pkg):
+ print("upgrade didn't upgrade (kept): %s" % pkg.name)
+
+print("\nPerforming Distupgrade")
+depcache.upgrade(True)
+print("Keep: %s " % depcache.keep_count)
+print("Install: %s " % depcache.inst_count)
+print("Delete: %s " % depcache.del_count)
+print("usr_size: %s " % apt_pkg.size_to_str(depcache.usr_size))
+print("deb_size: %s " % apt_pkg.size_to_str(depcache.deb_size))
# overview about what would happen
-for pkg in cache.Packages:
- if depcache.MarkedInstall(pkg):
- if pkg.CurrentVer is not None:
- print "Marked upgrade: %s " % pkg.Name
+for pkg in cache.packages:
+ if depcache.marked_install(pkg):
+ if pkg.current_ver is not None:
+ print("Marked upgrade: %s " % pkg.name)
else:
- print "Marked install: %s" % pkg.Name
- elif depcache.MarkedDelete(pkg):
- print "Marked delete: %s" % pkg.Name
- elif depcache.MarkedKeep(pkg):
- print "Marked keep: %s" % pkg.Name
+ print("Marked install: %s" % pkg.name)
+ elif depcache.marked_delete(pkg):
+ print("Marked delete: %s" % pkg.name)
+ elif depcache.marked_keep(pkg):
+ print("Marked keep: %s" % pkg.name)
diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py
index 992e98d8..6ce264bb 100644
--- a/doc/examples/all_deps.py
+++ b/doc/examples/all_deps.py
@@ -6,19 +6,19 @@ import apt
def dependencies(cache, pkg, deps, key="Depends"):
#print "pkg: %s (%s)" % (pkg.name, deps)
- candver = cache._depcache.GetCandidateVer(pkg._pkg)
+ candver = cache._depcache.get_candidate_ver(pkg._pkg)
if candver is None:
return deps
- dependslist = candver.DependsList
+ dependslist = candver.depends_list
if key in dependslist:
for depVerList in dependslist[key]:
for dep in depVerList:
- if dep.TargetPkg.Name in cache:
- if pkg.name != dep.TargetPkg.Name and \
- not dep.TargetPkg.Name in deps:
- deps.add(dep.TargetPkg.Name)
+ if dep.target_pkg.name in cache:
+ if (pkg.name != dep.target_pkg.name and
+ dep.target_pkg.name not in deps):
+ deps.add(dep.target_pkg.name)
dependencies(
- cache, cache[dep.TargetPkg.Name], deps, key)
+ cache, cache[dep.target_pkg.name], deps, key)
return deps
diff --git a/doc/examples/architecture.py b/doc/examples/architecture.py
index 75afb2d1..421c79a7 100644
--- a/doc/examples/architecture.py
+++ b/doc/examples/architecture.py
@@ -6,7 +6,7 @@ def main():
print "Native architecture:", apt_pkg.config["APT::Architecture"]
print "All architectures:", apt_pkg.config.value_list("APT::Architectures")
-
+
if __name__ == '__main__':
main()
diff --git a/doc/examples/build-deps-old.py b/doc/examples/build-deps-old.py
index 656f1361..4e7e4350 100755
--- a/doc/examples/build-deps-old.py
+++ b/doc/examples/build-deps-old.py
@@ -7,15 +7,15 @@ import sys
def get_source_pkg(pkg, records, depcache):
""" get the source package name of a given package """
- version = depcache.GetCandidateVer(pkg)
+ version = depcache.get_candidate_ver(pkg)
if not version:
return None
- file, index = version.FileList.pop(0)
- records.Lookup((file, index))
- if records.SourcePkg != "":
- srcpkg = records.SourcePkg
+ file, index = version.file_list.pop(0)
+ records.lookup((file, index))
+ if records.source_pkg != "":
+ srcpkg = records.source_pkg
else:
- srcpkg = pkg.Name
+ srcpkg = pkg.name
return srcpkg
@@ -23,7 +23,7 @@ def get_source_pkg(pkg, records, depcache):
apt_pkg.init()
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
-depcache.Init()
+depcache.init()
records = apt_pkg.PackageRecords(cache)
srcrecords = apt_pkg.SourceRecords()
@@ -42,29 +42,29 @@ all_build_depends = set()
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)
+ print "Can't find source package for '%s'" % pkg.mame
+srcrec = srcrecords.lookup(srcpkg_name)
if srcrec:
print "Files:"
- print srcrecords.Files
- bd = srcrecords.BuildDepends
+ print srcrecords.files
+ bd = srcrecords.build_depends
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
+depends = depcache.get_candidate_ver(base).depends_list
+for dep in depends["Depends"]: # FIXME: do we need to consider PreDepends?
+ pkg = dep[0].target_pkg
srcpkg_name = get_source_pkg(pkg, records, depcache)
if not srcpkg_name:
- print "Can't find source package for '%s'" % pkg.Name
+ print "Can't find source package for '%s'" % pkg.name
continue
- srcrec = srcrecords.Lookup(srcpkg_name)
+ srcrec = srcrecords.lookup(srcpkg_name)
if srcrec:
- #print srcrecords.Package
- #print srcrecords.Binaries
- bd = srcrecords.BuildDepends
+ #print srcrecords.package
+ #print srcrecords.binaries
+ bd = srcrecords.build_depends
#print "%s: %s " % (srcpkg_name, bd)
for b in bd:
all_build_depends.add(b[0])
diff --git a/doc/examples/build-deps.py b/doc/examples/build-deps.py
index 5d243943..e618e414 100755
--- a/doc/examples/build-deps.py
+++ b/doc/examples/build-deps.py
@@ -24,12 +24,12 @@ all_build_depends = set()
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
-srcrec = srcrecords.Lookup(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 srcrecords.files
+ bd = srcrecords.build_depends
print "build-depends of the package: %s " % bd
for b in bd:
all_build_depends.add(b[0])
@@ -41,13 +41,13 @@ for or_dep in depends:
pkg = cache[dep.name]
srcpkg_name = pkg.candidate.source_name
if not srcpkg_name:
- print "Can't find source package for '%s'" % pkg.Name
+ print "Can't find source package for '%s'" % pkg.name
continue
- srcrec = srcrecords.Lookup(srcpkg_name)
+ srcrec = srcrecords.lookup(srcpkg_name)
if srcrec:
- #print srcrecords.Package
- #print srcrecords.Binaries
- bd = srcrecords.BuildDepends
+ #print srcrecords.package
+ #print srcrecords.binaries
+ bd = srcrecords.build_depends
#print "%s: %s " % (srcpkg_name, bd)
for b in bd:
all_build_depends.add(b[0])
diff --git a/doc/examples/cdrom.py b/doc/examples/cdrom.py
index 78f2a8af..2fbc8f34 100644
--- a/doc/examples/cdrom.py
+++ b/doc/examples/cdrom.py
@@ -15,11 +15,11 @@ print cdrom
progress = TextCdromProgress()
-(res, ident) = cdrom.Ident(progress)
+(res, ident) = cdrom.ident(progress)
print "ident result is: %s (%s) " % (res, ident)
-apt_pkg.Config.Set("APT::CDROM::Rename", "True")
-cdrom.Add(progress)
+apt_pkg.config["APT::CDROM::Rename"] = "True"
+cdrom.add(progress)
print "Exiting"
sys.exit(0)
diff --git a/doc/examples/checkstate.py b/doc/examples/checkstate.py
index 41040b6c..084fdb87 100755
--- a/doc/examples/checkstate.py
+++ b/doc/examples/checkstate.py
@@ -9,27 +9,27 @@ import apt_pkg
apt_pkg.init()
cache = apt_pkg.Cache()
-packages = cache.Packages
+packages = cache.packages
uninstalled, updated, upgradable = {}, {}, {}
for package in packages:
- versions = package.VersionList
+ versions = package.version_list
if not versions:
continue
version = versions[0]
for other_version in versions:
- if apt_pkg.VersionCompare(version.VerStr, other_version.VerStr)<0:
+ if apt_pkg.version_compare(version.ver_str, other_version.ver_str) < 0:
version = other_version
- if package.CurrentVer:
- current = package.CurrentVer
- if apt_pkg.VersionCompare(current.VerStr, version.VerStr)<0:
- upgradable[package.Name] = version
+ if package.current_ver:
+ current = package.current_ver
+ if apt_pkg.version_compare(current.ver_str, version.ver_str) < 0:
+ upgradable[package.name] = version
break
else:
- updated[package.Name] = current
+ updated[package.name] = current
else:
- uninstalled[package.Name] = version
+ uninstalled[package.name] = version
for l in (uninstalled, updated, upgradable):
diff --git a/doc/examples/config.py b/doc/examples/config.py
index 0dff4cac..c3330a5b 100755
--- a/doc/examples/config.py
+++ b/doc/examples/config.py
@@ -18,17 +18,17 @@ import sys
import posixpath
# Create a new empty Configuration object - there is also the system global
-# configuration object apt_pkg.Config which is used interally by apt-pkg
+# configuration object apt_pkg.config which is used interally by apt-pkg
# routines to control unusual situations. I recommend using the sytem global
# whenever possible..
Cnf = apt_pkg.Configuration()
print "Command line is", sys.argv
-# Load the default configuration file, InitConfig() does this better..
-Cnf.Set("config-file", "/etc/apt/apt.conf") # or Cnf["config-file"] = ".."
-if posixpath.exists(Cnf.FindFile("config-file")):
- apt_pkg.ReadConfigFile(Cnf, "/etc/apt/apt.conf")
+# Load the default configuration file, init_config() does this better..
+Cnf.set("config-file", "/etc/apt/apt.conf") # or Cnf["config-file"] = ".."
+if posixpath.exists(Cnf.find_file("config-file")):
+ apt_pkg.read_config_file(Cnf, "/etc/apt/apt.conf")
# Merge the command line arguments into the configuration space
Arguments = [('h', "help", "help"),
@@ -36,17 +36,17 @@ Arguments = [('h', "help", "help"),
('q', "quiet", "quiet", "IntLevel"),
('c', "config-file", "", "ConfigFile"),
('o', "option", "", "ArbItem")]
-print "FileNames", apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv)
+print "FileNames", apt_pkg.parse_commandline(Cnf, Arguments, sys.argv)
-print "Quiet level selected is", Cnf.FindI("quiet", 0)
+print "Quiet level selected is", Cnf.find_i("quiet", 0)
# Do some stuff with it
-if Cnf.FindB("version", 0) == 1:
+if Cnf.find_b("version", 0) == 1:
print "Version selected - 1.1"
-if Cnf.FindB("help", 0) == 1:
- print "python-apt", apt_pkg.Version, \
- "compiled on", apt_pkg.Date, apt_pkg.Time
+if Cnf.find_b("help", 0) == 1:
+ print "python-apt", apt_pkg.VERSION, \
+ "compiled on", apt_pkg.DATE, apt_pkg.TIME
print "Hi, I am the help text for this program"
sys.exit(0)
diff --git a/doc/examples/configisc.py b/doc/examples/configisc.py
index fe3d161b..d9355d49 100755
--- a/doc/examples/configisc.py
+++ b/doc/examples/configisc.py
@@ -11,14 +11,14 @@
import apt_pkg
import sys
-ConfigFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv)
+ConfigFile = apt_pkg.parse_commandline(apt_pkg.config, [], sys.argv)
if len(ConfigFile) != 1:
print "Must have exactly 1 file name"
sys.exit(0)
Cnf = apt_pkg.Configuration()
-apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0])
+apt_pkg.read_config_file_isc(Cnf, ConfigFile[0])
# Print the configuration space
#print "The Configuration space looks like:"
@@ -26,18 +26,18 @@ apt_pkg.ReadConfigFileISC(Cnf, ConfigFile[0])
# print "%s \"%s\";" % (I, Cnf[I])
# bind8 config file..
-if Cnf.Exists("Zone"):
- print "Zones: ", Cnf.SubTree("zone").List()
- for I in Cnf.List("zone"):
- SubCnf = Cnf.SubTree(I)
- if SubCnf.Find("type") == "slave":
+if "Zone" in Cnf:
+ print "Zones: ", Cnf.sub_tree("zone").list()
+ for I in Cnf.list("zone"):
+ SubCnf = Cnf.sub_tree(I)
+ if SubCnf.find("type") == "slave":
print "Masters for %s: %s" % (
- SubCnf.MyTag(), SubCnf.ValueList("masters"))
+ SubCnf.my_tag(), SubCnf.value_list("masters"))
else:
print "Tree definitions:"
- for I in Cnf.List("tree"):
- SubCnf = Cnf.SubTree(I)
+ for I in Cnf.list("tree"):
+ SubCnf = Cnf.sub_tree(I)
# This could use Find which would eliminate the possibility of
# exceptions.
print "Subtree %s with sections '%s' and architectures '%s'" % (
- SubCnf.MyTag(), SubCnf["Sections"], SubCnf["Architectures"])
+ SubCnf.my_tag(), SubCnf["Sections"], SubCnf["Architectures"])
diff --git a/doc/examples/deb_inspect.py b/doc/examples/deb_inspect.py
index 54c52b7b..f6e090a1 100755
--- a/doc/examples/deb_inspect.py
+++ b/doc/examples/deb_inspect.py
@@ -7,10 +7,11 @@ import sys
import os.path
-def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor):
+def Callback(member, data):
""" callback for debExtract """
- print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" \
- % (What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor)
+ print "'%s','%s',%u,%u,%u,%u,%u,%u,%u" \
+ % (member.name, member.linkname, member.mode, member.uid,
+ member.gid, member.size, member.mtime, member.major, member.minor)
if __name__ == "__main__":
@@ -21,10 +22,10 @@ if __name__ == "__main__":
print "Working on: %s" % file
print "Displaying data.tar.gz:"
- apt_inst.debExtract(open(file), Callback, "data.tar.gz")
+ apt_inst.DebFile(open(file)).data.go(Callback)
print "Now extracting the control file:"
- control = apt_inst.debExtractControl(open(file))
+ control = apt_inst.DebFile(open(file)).control.extractdata("control")
sections = apt_pkg.TagSection(control)
print "Maintainer is: "
@@ -33,13 +34,12 @@ if __name__ == "__main__":
print
print "DependsOn: "
depends = sections["Depends"]
- print apt_pkg.ParseDepends(depends)
-
+ print apt_pkg.parse_depends(depends)
print "extracting archive"
dir = "/tmp/deb"
os.mkdir(dir)
- apt_inst.debExtractArchive(open(file), dir)
+ apt_inst.DebFile(open(file)).data.extractall(dir)
def visit(arg, dirname, names):
print "%s/" % dirname
diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py
index 858e45a4..8e33e98b 100644
--- a/doc/examples/depcache.py
+++ b/doc/examples/depcache.py
@@ -10,7 +10,7 @@ apt_pkg.init()
progress = TextProgress()
cache = apt_pkg.Cache(progress)
-print "Available packages: %s " % cache.PackageCount
+print "Available packages: %s " % cache.package_count
iter = cache["base-config"]
print "example package iter: %s" % iter
@@ -18,90 +18,90 @@ print "example package iter: %s" % iter
# get depcache
print "\n\n depcache"
depcache = apt_pkg.DepCache(cache)
-depcache.ReadPinFile()
+depcache.read_pinfile()
# init is needed after the creation/pin file reading
-depcache.Init(progress)
+depcache.init(progress)
print "got a depcache: %s " % depcache
-print "Marked for install: %s " % depcache.InstCount
+print "Marked for install: %s " % depcache.inst_count
print "\n\n Reinit"
-depcache.Init(progress)
+depcache.init(progress)
#sys.exit()
# get a canidate version
-ver= depcache.GetCandidateVer(iter)
+ver = depcache.get_candidate_ver(iter)
print "Candidate version: %s " % ver
print "\n\nQuerry interface"
-print "%s.IsUpgradable(): %s" % (iter.Name, depcache.IsUpgradable(iter))
+print "%s.is_upgradable(): %s" % (iter.name, depcache.is_upgradable(iter))
print "\nMarking interface"
-print "Marking '%s' for install" % iter.Name
-depcache.MarkInstall(iter)
-print "Install count: %s " % depcache.InstCount
-print "%s.MarkedInstall(): %s" % (iter.Name, depcache.MarkedInstall(iter))
-print "%s.MarkedUpgrade(): %s" % (iter.Name, depcache.MarkedUpgrade(iter))
-print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter))
+print "Marking '%s' for install" % iter.name
+depcache.mark_install(iter)
+print "Install count: %s " % depcache.inst_count
+print "%s.marked_install(): %s" % (iter.name, depcache.marked_install(iter))
+print "%s.marked_upgrade(): %s" % (iter.name, depcache.marked_upgrade(iter))
+print "%s.marked_delete(): %s" % (iter.name, depcache.marked_delete(iter))
-print "Marking %s for delete" % iter.Name
-depcache.MarkDelete(iter)
-print "DelCount: %s " % depcache.DelCount
-print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter))
+print "Marking %s for delete" % iter.name
+depcache.mark_delete(iter)
+print "del_count: %s " % depcache.del_count
+print "%s.marked_delete(): %s" % (iter.name, depcache.marked_delete(iter))
iter = cache["3dchess"]
-print "\nMarking '%s' for install" % iter.Name
-depcache.MarkInstall(iter)
-print "Install count: %s " % depcache.InstCount
-print "%s.MarkedInstall(): %s" % (iter.Name, depcache.MarkedInstall(iter))
-print "%s.MarkedUpgrade(): %s" % (iter.Name, depcache.MarkedUpgrade(iter))
-print "%s.MarkedDelete(): %s" % (iter.Name, depcache.MarkedDelete(iter))
+print "\nMarking '%s' for install" % iter.name
+depcache.mark_install(iter)
+print "Install count: %s " % depcache.inst_count
+print "%s.marked_install(): %s" % (iter.name, depcache.marked_install(iter))
+print "%s.marked_upgrade(): %s" % (iter.name, depcache.marked_upgrade(iter))
+print "%s.marked_delete(): %s" % (iter.name, depcache.marked_delete(iter))
-print "Marking %s for keep" % iter.Name
-depcache.MarkKeep(iter)
-print "Install: %s " % depcache.InstCount
+print "Marking %s for keep" % iter.name
+depcache.mark_keep(iter)
+print "Install: %s " % depcache.inst_count
iter = cache["synaptic"]
-print "\nMarking '%s' for install" % iter.Name
-depcache.MarkInstall(iter)
-print "Install: %s " % depcache.InstCount
-print "Broken count: %s" % depcache.BrokenCount
-print "FixBroken() "
-depcache.FixBroken()
-print "Broken count: %s" % depcache.BrokenCount
-
-print "\nPerforming Upgrade"
-depcache.Upgrade()
-print "Keep: %s " % depcache.KeepCount
-print "Install: %s " % depcache.InstCount
-print "Delete: %s " % depcache.DelCount
-print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize)
-print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
-
-for pkg in cache.Packages:
- if pkg.CurrentVer is not None and not depcache.MarkedInstall(pkg) \
- and depcache.IsUpgradable(pkg):
- print "Upgrade didn't upgrade (kept): %s" % pkg.Name
+print "\nMarking '%s' for install" % iter.name
+depcache.mark_install(iter)
+print "Install: %s " % depcache.inst_count
+print "Broken count: %s" % depcache.broken_count
+print "fix_broken() "
+depcache.fix_broken()
+print "Broken count: %s" % depcache.broken_count
+
+print "\nPerforming upgrade"
+depcache.upgrade()
+print "Keep: %s " % depcache.keep_count
+print "Install: %s " % depcache.inst_count
+print "Delete: %s " % depcache.del_count
+print "usr_size: %s " % apt_pkg.size_to_str(depcache.usr_size)
+print "deb_size: %s " % apt_pkg.size_to_str(depcache.deb_size)
+
+for pkg in cache.packages:
+ if pkg.current_ver is not None and not depcache.marked_install(pkg) \
+ and depcache.is_upgradable(pkg):
+ print "upgrade didn't upgrade (kept): %s" % pkg.name
print "\nPerforming DistUpgrade"
-depcache.Upgrade(True)
-print "Keep: %s " % depcache.KeepCount
-print "Install: %s " % depcache.InstCount
-print "Delete: %s " % depcache.DelCount
-print "UsrSize: %s " % apt_pkg.SizeToStr(depcache.UsrSize)
-print "DebSize: %s " % apt_pkg.SizeToStr(depcache.DebSize)
+depcache.upgrade(True)
+print "Keep: %s " % depcache.keep_count
+print "Install: %s " % depcache.inst_count
+print "Delete: %s " % depcache.del_count
+print "usr_size: %s " % apt_pkg.size_to_str(depcache.usr_size)
+print "deb_size: %s " % apt_pkg.size_to_str(depcache.deb_size)
# overview about what would happen
-for pkg in cache.Packages:
- if depcache.MarkedInstall(pkg):
- if pkg.CurrentVer is not None:
- print "Marked upgrade: %s " % pkg.Name
+for pkg in cache.packages:
+ if depcache.marked_install(pkg):
+ if pkg.current_ver is not None:
+ print "Marked upgrade: %s " % pkg.name
else:
- print "Marked install: %s" % pkg.Name
- elif depcache.MarkedDelete(pkg):
- print "Marked delete: %s" % pkg.Name
- elif depcache.MarkedKeep(pkg):
- print "Marked keep: %s" % pkg.Name
+ print "Marked install: %s" % pkg.name
+ elif depcache.marked_delete(pkg):
+ print "Marked delete: %s" % pkg.name
+ elif depcache.marked_keep(pkg):
+ print "Marked keep: %s" % pkg.name
diff --git a/doc/examples/dependant-pkgs.py b/doc/examples/dependant-pkgs.py
index 5fbbc76d..a02547ac 100755
--- a/doc/examples/dependant-pkgs.py
+++ b/doc/examples/dependant-pkgs.py
@@ -6,27 +6,27 @@ import sys
pkgs = set()
cache = apt.Cache()
for pkg in cache:
- candver = cache._depcache.GetCandidateVer(pkg._pkg)
+ candver = cache._depcache.get_candidate_ver(pkg._pkg)
if candver is None:
continue
- dependslist = candver.DependsList
+ dependslist = candver.depends_list
for dep in dependslist.keys():
# get the list of each dependency object
for depVerList in dependslist[dep]:
for z in depVerList:
# get all TargetVersions of
# the dependency object
- for tpkg in z.AllTargets():
- if sys.argv[1] == tpkg.ParentPkg.Name:
+ for tpkg in z.all_targets():
+ if sys.argv[1] == tpkg.parent_pkg.name:
pkgs.add(pkg.name)
main = set()
universe = set()
for pkg in pkgs:
if "universe" in cache[pkg].section:
- universe.add(cache[pkg].sourcePackageName)
+ universe.add(cache[pkg].source_name)
else:
- main.add(cache[pkg].sourcePackageName)
+ main.add(cache[pkg].source_name)
print "main:"
print "\n".join(main)
diff --git a/doc/examples/desc.py b/doc/examples/desc.py
index d50aa0ce..797459aa 100644
--- a/doc/examples/desc.py
+++ b/doc/examples/desc.py
@@ -4,22 +4,22 @@ import apt_pkg
apt_pkg.init()
-apt_pkg.Config.Set("APT::Acquire::Translation", "de")
+apt_pkg.config.set("APT::Acquire::Translation", "de")
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
pkg = cache["gcc"]
-cand = depcache.GetCandidateVer(pkg)
+cand = depcache.get_candidate_ver(pkg)
print cand
desc = cand.TranslatedDescription
print desc
-print desc.FileList
-(f, index) = desc.FileList.pop(0)
+print desc.file_list
+(f, index) = desc.file_list.pop(0)
records = apt_pkg.PackageRecords(cache)
-records.Lookup((f, index))
-desc = records.LongDesc
+records.lookup((f, index))
+desc = records.long_desc
print len(desc)
print desc
diff --git a/doc/examples/gui-inst.py b/doc/examples/gui-inst.py
deleted file mode 100755
index 68f06fc0..00000000
--- a/doc/examples/gui-inst.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-# example how to install in a custom terminal widget
-# see also gnome bug: #169201
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-import apt.progress.gtk2
-
-
-if __name__ == "__main__":
-
- win = gtk.Window()
- progress = apt.progress.gtk2.GtkAptProgress()
- win.set_title("GtkAptProgress Demo")
- win.add(progress)
- progress.show()
- win.show()
-
- cache = apt.cache.Cache(progress.open)
- if cache["2vcard"].isInstalled:
- cache["2vcard"].markDelete()
- else:
- cache["2vcard"].markInstall()
- progress.show_terminal(expanded=True)
- cache.commit(progress.fetch, progress.install)
- gtk.main()
diff --git a/doc/examples/indexfile.py b/doc/examples/indexfile.py
index cc5070aa..a9282bf5 100644
--- a/doc/examples/indexfile.py
+++ b/doc/examples/indexfile.py
@@ -5,18 +5,18 @@ import apt_pkg
apt_pkg.init()
sources = apt_pkg.SourceList()
-sources.ReadMainList()
+sources.read_main_list()
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
pkg = cache["libimlib2"]
-cand = depcache.GetCandidateVer(pkg)
-for (f, i) in cand.FileList:
- index = sources.FindIndex(f)
+cand = depcache.get_candidate_ver(pkg)
+for (f, i) in cand.file_list:
+ index = sources.find_index(f)
print index
if index:
- print index.Size
- print index.IsTrusted
- print index.Exists
- print index.HasPackages
- print index.ArchiveURI("some/path")
+ print index.size
+ print index.is_trusted
+ print index.exists
+ print index.Haspackages
+ print index.archive_uri("some/path")
diff --git a/doc/examples/inst.py b/doc/examples/inst.py
index 5a7fc993..25658435 100644
--- a/doc/examples/inst.py
+++ b/doc/examples/inst.py
@@ -17,7 +17,7 @@ class TextInstallProgress(InstallProgress):
InstallProgress.updateInterface(self)
if self.last >= self.percent:
return
- sys.stdout.write("\r[%s] %s\n" %(self.percent, self.status))
+ sys.stdout.write("\r[%s] %s\n" % (self.percent, self.status))
sys.stdout.flush()
self.last = self.percent
@@ -36,12 +36,12 @@ iprogress = TextInstallProgress()
pkg = cache["3dchess"]
# install or remove, the importend thing is to keep us busy :)
-if pkg.isInstalled:
+if pkg.is_installed:
print "Going to delete %s" % pkg.name
- pkg.markDelete()
+ pkg.mark_delete()
else:
print "Going to install %s" % pkg.name
- pkg.markInstall()
+ pkg.mark_install()
res = cache.commit(fprogress, iprogress)
print res
diff --git a/doc/examples/metaindex.py b/doc/examples/metaindex.py
index bbb4ac47..a04a83dd 100644
--- a/doc/examples/metaindex.py
+++ b/doc/examples/metaindex.py
@@ -5,12 +5,12 @@ import apt_pkg
apt_pkg.init()
sources = apt_pkg.SourceList()
-sources.ReadMainList()
+sources.read_main_list()
-for metaindex in sources.List:
+for metaindex in sources.list:
print metaindex
- print "URI: ", metaindex.URI
- print "Dist: ", metaindex.Dist
- print "IndexFiles: ", "\n".join([str(i) for i in metaindex.IndexFiles])
+ print "uri: ", metaindex.uri
+ print "dist: ", metaindex.dist
+ print "index_files: ", "\n".join([str(i) for i in metaindex.index_files])
print
diff --git a/doc/examples/print_uris.py b/doc/examples/print_uris.py
index c64a4b54..e5f69ff3 100755
--- a/doc/examples/print_uris.py
+++ b/doc/examples/print_uris.py
@@ -4,19 +4,7 @@
#
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.TagSection(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
+for pkg in apt.Cache():
+ if pkg.is_upgradable:
+ print pkg.candidate.uri
diff --git a/doc/examples/progress.py b/doc/examples/progress.py
index c007681f..a273eb24 100644
--- a/doc/examples/progress.py
+++ b/doc/examples/progress.py
@@ -3,13 +3,15 @@
import sys
import time
+import apt_pkg
import apt
+import apt.progress.base
-class TextProgress(apt.OpProgress):
+class TextProgress(apt.progress.base.OpProgress):
def __init__(self):
- self.last=0.0
+ self.last = 0.0
def update(self, percent):
if (self.last + 1.0) <= percent:
@@ -20,10 +22,10 @@ class TextProgress(apt.OpProgress):
def done(self):
self.last = 0.0
- print "\rDone "
+ print("\rDone ")
-class TextFetchProgress(apt.FetchProgress):
+class TextFetchProgress(apt.progress.base.AcquireProgress):
def __init__(self):
pass
@@ -34,60 +36,52 @@ class TextFetchProgress(apt.FetchProgress):
def stop(self):
pass
- def updateStatus(self, uri, descr, shortDescr, status):
- print "UpdateStatus: '%s' '%s' '%s' '%i' " % (
- uri, descr, shortDescr, status)
+ def fail(self, item):
+ print('fail', item)
- def update_status_full(self, uri, descr, shortDescr, status, fileSize,
- partialSize):
- print "update_status_full: '%s' '%s' '%s' '%i' '%d/%d'" % (
- uri, descr, shortDescr, status, partialSize, fileSize)
+ def fetch(self, item):
+ print('fetch', item)
- def pulse(self):
- print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (
- apt.SizeToStr(self.currentCPS), apt.SizeToStr(self.currentBytes),
- apt.SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
- return True
+ def ims_hit(self, item):
+ print('ims_hit', item)
- def pulse_items(self, items):
- print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (
- apt.SizeToStr(self.currentCPS), apt.SizeToStr(self.currentBytes),
- apt.SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
- print "Pulse-Items: "
- for itm in items:
- uri, descr, shortDescr, fileSize, partialSize = itm
- print " - '%s' '%s' '%s' '%d/%d'" % (
- uri, descr, shortDescr, partialSize, fileSize)
+ def pulse(self, owner):
+ print("pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (
+ apt_pkg.size_to_str(self.current_cps),
+ apt_pkg.size_to_str(self.current_bytes),
+ apt_pkg.size_to_str(self.total_bytes),
+ self.current_items,
+ self.total_items))
return True
- def mediaChange(self, medium, drive):
- print "Please insert medium %s in drive %s" % (medium, drive)
+ def media_change(self, medium, drive):
+ print("Please insert medium %s in drive %s" % (medium, drive))
sys.stdin.readline()
#return False
-class TextInstallProgress(apt.InstallProgress):
+class TextInstallProgress(apt.progress.base.InstallProgress):
def __init__(self):
- apt.InstallProgress.__init__(self)
+ apt.progress.base.InstallProgress.__init__(self)
pass
- def startUpdate(self):
- print "StartUpdate"
+ def start_update(self):
+ print("start_update")
- def finishUpdate(self):
- print "FinishUpdate"
+ def finish_update(self):
+ print("finish_update")
- def statusChange(self, pkg, percent, status):
- print "[%s] %s: %s" % (percent, pkg, status)
+ def status_change(self, pkg, percent, status):
+ print("[%s] %s: %s" % (percent, pkg, status))
- def updateInterface(self):
- apt.InstallProgress.updateInterface(self)
+ def update_interface(self):
+ apt.progress.base.InstallProgress.update_interface(self)
# usefull to e.g. redraw a GUI
time.sleep(0.1)
-class TextCdromProgress(apt.CdromProgress):
+class TextCdromProgress(apt.progress.base.CdromProgress):
def __init__(self):
pass
@@ -97,27 +91,28 @@ class TextCdromProgress(apt.CdromProgress):
def update(self, text, step):
# check if we actually have some text to display
if text != "":
- print "Update: %s %s" % (text.strip(), step)
+ print("Update: %s %s" % (text.strip(), step))
- def askCdromName(self):
- print "Please enter cd-name: ",
+ def ask_cdrom_name(self):
+ sys.stdout.write("Please enter cd-name: ")
cd_name = sys.stdin.readline()
return (True, cd_name.strip())
- def changeCdrom(self):
- print "Please insert cdrom and press <ENTER>"
+ def change_cdrom(self):
+ print("Please insert cdrom and press <ENTER>")
answer = sys.stdin.readline()
+ print(answer)
return True
if __name__ == "__main__":
c = apt.Cache()
pkg = c["3dchess"]
- if pkg.isInstalled:
- pkg.markDelete()
+ if pkg.is_installed:
+ pkg.mark_delete()
else:
- pkg.markInstall()
+ pkg.mark_install()
res = c.commit(TextFetchProgress(), TextInstallProgress())
- print res
+ print(res)
diff --git a/doc/examples/recommends.py b/doc/examples/recommends.py
index 0ecd5882..01727820 100755
--- a/doc/examples/recommends.py
+++ b/doc/examples/recommends.py
@@ -16,21 +16,21 @@ class Wanted:
wanted = {}
-for package in cache.Packages:
- current = package.CurrentVer
+for package in cache.packages:
+ current = package.current_ver
if not current:
continue
- depends = current.DependsList
+ depends = current.depends_list
for (key, attr) in (('Suggests', 'suggested'),
('Recommends', 'recommended')):
list = depends.get(key, [])
for dependency in list:
- name = dependency[0].TargetPkg.Name
+ name = dependency[0].target_pkg.name
dep = cache[name]
- if dep.CurrentVer:
+ if dep.current_ver:
continue
getattr(wanted.setdefault(name, Wanted(name)),
- attr).append(package.Name)
+ attr).append(package.name)
ks = wanted.keys()
ks.sort()
diff --git a/doc/examples/sources.py b/doc/examples/sources.py
index bc08ad69..aa783758 100644
--- a/doc/examples/sources.py
+++ b/doc/examples/sources.py
@@ -8,9 +8,9 @@ apt_pkg.init()
#sources = apt_pkg.SourceRecords(cache)
sources = apt_pkg.SourceRecords()
-sources.Restart()
-while sources.Lookup('hello'):
- print sources.Package, sources.Version, sources.Maintainer, \
- sources.Section, `sources.Binaries`
- print sources.Files
- print sources.Index.ArchiveURI(sources.Files[0][2])
+sources.restart()
+while sources.lookup('hello'):
+ print sources.package, sources.version, sources.maintainer, \
+ sources.section, repr(sources.binaries)
+ print sources.files
+ print sources.index.archive_uri(sources.files[0][2])
diff --git a/doc/examples/tagfile.py b/doc/examples/tagfile.py
index 770e40de..d8984cad 100755
--- a/doc/examples/tagfile.py
+++ b/doc/examples/tagfile.py
@@ -3,6 +3,6 @@ import apt_pkg
Parse = apt_pkg.TagFile(open("/var/lib/dpkg/status", "r"))
-while Parse.Step() == 1:
- print Parse.Section.get("Package")
- print apt_pkg.ParseDepends(Parse.Section.get("Depends", ""))
+while Parse.step() == 1:
+ print Parse.section.get("Package")
+ print apt_pkg.parse_depends(Parse.section.get("Depends", ""))
diff --git a/doc/examples/update.py b/doc/examples/update.py
index 5929c9f8..3ff80fde 100755
--- a/doc/examples/update.py
+++ b/doc/examples/update.py
@@ -4,9 +4,9 @@ import apt_pkg
import os.path
if __name__ == "__main__":
- apt_pkg.Config.Set("APT::Update::Pre-Invoke::",
+ apt_pkg.config.set("APT::Update::Pre-Invoke::",
"touch /tmp/update-about-to-run")
- apt_pkg.Config.Set("APT::Update::Post-Invoke::",
+ apt_pkg.config.set("APT::Update::Post-Invoke::",
"touch /tmp/update-was-run")
c = apt.Cache()
res = c.update(apt.progress.TextFetchProgress())
diff --git a/doc/examples/versiontest.py b/doc/examples/versiontest.py
index fa13cc1c..2f736161 100755
--- a/doc/examples/versiontest.py
+++ b/doc/examples/versiontest.py
@@ -5,19 +5,19 @@ import apt_pkg
import sys
import re
-apt_pkg.InitConfig()
-apt_pkg.InitSystem()
+apt_pkg.init_config()
+apt_pkg.init_system()
-TestFile = apt_pkg.ParseCommandLine(apt_pkg.Config, [], sys.argv)
+TestFile = apt_pkg.parse_commandline(apt_pkg.config, [], sys.argv)
if len(TestFile) != 1:
print "Must have exactly 1 file name"
sys.exit(0)
# Go over the file..
-List = open(TestFile[0], "r")
+list = open(TestFile[0], "r")
CurLine = 0
while(1):
- Line = List.readline()
+ Line = list.readline()
CurLine = CurLine + 1
if Line == "":
break
@@ -28,12 +28,12 @@ while(1):
Split = re.split("[ \n]", Line)
# Check forward
- if apt_pkg.VersionCompare(Split[0], Split[1]) != int(Split[2]):
+ if apt_pkg.version_compare(Split[0], Split[1]) != int(Split[2]):
print "Comparision failed on line %u. '%s' ? '%s' %i != %i" % (CurLine,
- Split[0], Split[1], apt_pkg.VersionCompare(Split[0], Split[1]),
+ Split[0], Split[1], apt_pkg.version_compare(Split[0], Split[1]),
int(Split[2]))
# Check reverse
- if apt_pkg.VersionCompare(Split[1], Split[0]) != -1 * int(Split[2]):
+ if apt_pkg.version_compare(Split[1], Split[0]) != -1 * int(Split[2]):
print "Comparision failed on line %u. '%s' ? '%s' %i != %i" % (CurLine,
- Split[1], Split[0], apt_pkg.VersionCompare(Split[1], Split[0]),
+ Split[1], Split[0], apt_pkg.version_compare(Split[1], Split[0]),
-1 * int(Split[2]))
diff --git a/doc/source/c++/api.rst b/doc/source/c++/api.rst
index 63ed1599..632966bb 100644
--- a/doc/source/c++/api.rst
+++ b/doc/source/c++/api.rst
@@ -14,379 +14,379 @@ a _CheckExact() function, a _FromCpp() and a _ToCpp() function.
Acquire (pkgAcquire)
--------------------
-.. cvar:: PyTypeObject PyAcquire_Type
+.. c:var:: PyTypeObject PyAcquire_Type
The type object for :class:`apt_pkg.Acquire` objects.
-.. cfunction:: int PyAcquire_Check(PyObject *object)
+.. c:function:: int PyAcquire_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Acquire` object, or
a subclass thereof.
-.. cfunction:: int PyAcquire_CheckExact(PyObject *object)
+.. c:function:: int PyAcquire_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Acquire` object and no
subclass thereof.
-.. cfunction:: PyObject* PyAcquire_FromCpp(pkgAcquire *acquire, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyAcquire_FromCpp(pkgAcquire *acquire, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Acquire` object from the :ctype:`pkgAcquire`
+ Create a new :class:`apt_pkg.Acquire` object from the :c:type:`pkgAcquire`
pointer given by the parameter *acquire*. If the parameter *delete* is
true, the object pointed to by *acquire* will be deleted when the refcount
of the return value reaches 0.
-.. cfunction:: pkgAcquire* PyAcquire_ToCpp(PyObject *acquire)
+.. c:function:: pkgAcquire* PyAcquire_ToCpp(PyObject *acquire)
- Return the :ctype:`pkgAcquire` pointer contained in the Python object
+ Return the :c:type:`pkgAcquire` pointer contained in the Python object
*acquire*.
AcquireFile (pkgAcqFile)
------------------------
-.. cvar:: PyTypeObject PyAcquireFile_Type
+.. c:var:: PyTypeObject PyAcquireFile_Type
The type object for :class:`apt_pkg.AcquireFile` objects.
-.. cfunction:: int PyAcquireFile_Check(PyObject *object)
+.. c:function:: int PyAcquireFile_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireFile` object, or
a subclass thereof.
-.. cfunction:: int PyAcquireFile_CheckExact(PyObject *object)
+.. c:function:: int PyAcquireFile_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireFile` object
and no subclass thereof.
-.. cfunction:: PyObject* PyAcquireFile_FromCpp(pkgAcqFile *file, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyAcquireFile_FromCpp(pkgAcqFile *file, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.AcquireFile` object from the :ctype:`pkgAcqFile`
+ Create a new :class:`apt_pkg.AcquireFile` object from the :c:type:`pkgAcqFile`
pointer given by the parameter *file*. If the parameter *delete* is
true, the object pointed to by *file* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* should point
to a :class:`apt_pkg.Acquire` object.
-.. cfunction:: pkgAcqFile* PyAcquireFile_ToCpp(PyObject *acquire)
+.. c:function:: pkgAcqFile* PyAcquireFile_ToCpp(PyObject *acquire)
- Return the :ctype:`pkgAcqFile` pointer contained in the Python object
+ Return the :c:type:`pkgAcqFile` pointer contained in the Python object
*acquire*.
AcquireItem (pkgAcquire::Item)
------------------------------
-.. cvar:: PyTypeObject PyAcquireItem_Type
+.. c:var:: PyTypeObject PyAcquireItem_Type
The type object for :class:`apt_pkg.AcquireItem` objects.
-.. cfunction:: int PyAcquireItem_Check(PyObject *object)
+.. c:function:: int PyAcquireItem_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireItem` object, or
a subclass thereof.
-.. cfunction:: int PyAcquireItem_CheckExact(PyObject *object)
+.. c:function:: int PyAcquireItem_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireItem` object
and no subclass thereof.
-.. cfunction:: PyObject* PyAcquireItem_FromCpp(pkgAcquire::Item *item, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyAcquireItem_FromCpp(pkgAcquire::Item *item, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.AcquireItem` object from the :ctype:`pkgAcquire::Item`
+ Create a new :class:`apt_pkg.AcquireItem` object from the :c:type:`pkgAcquire::Item`
pointer given by the parameter *item*. If the parameter *delete* is
true, the object pointed to by *item* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* should point
to a :class:`apt_pkg.Acquire` object.
-.. cfunction:: pkgAcquire::Item* PyAcquireItem_ToCpp(PyObject *object)
+.. c:function:: pkgAcquire::Item* PyAcquireItem_ToCpp(PyObject *object)
- Return the :ctype:`pkgAcquire::Item` pointer contained in the Python object
+ Return the :c:type:`pkgAcquire::Item` pointer contained in the Python object
*object*.
AcquireItemDesc (pkgAcquire::ItemDesc)
--------------------------------------
-.. cvar:: PyTypeObject PyAcquireItemDesc_Type
+.. c:var:: PyTypeObject PyAcquireItemDesc_Type
The type object for :class:`apt_pkg.AcquireItemDesc` objects.
-.. cfunction:: int PyAcquireItemDesc_Check(PyObject *object)
+.. c:function:: int PyAcquireItemDesc_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireItemDesc` object, or
a subclass thereof.
-.. cfunction:: int PyAcquireItemDesc_CheckExact(PyObject *object)
+.. c:function:: int PyAcquireItemDesc_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireItemDesc` object
and no subclass thereof.
-.. cfunction:: PyObject* PyAcquireItemDesc_FromCpp(pkgAcquire::ItemDesc *desc, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyAcquireItemDesc_FromCpp(pkgAcquire::ItemDesc *desc, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.AcquireItemDesc` object from the :ctype:`pkgAcquire::ItemDesc`
+ Create a new :class:`apt_pkg.AcquireItemDesc` object from the :c:type:`pkgAcquire::ItemDesc`
pointer given by the parameter *desc*. If the parameter *delete* is
true, the object pointed to by *desc* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* should point
to a :class:`apt_pkg.AcquireItem` object.
-.. cfunction:: pkgAcquire::ItemDesc* PyAcquireItemDesc_ToCpp(PyObject *object)
+.. c:function:: pkgAcquire::ItemDesc* PyAcquireItemDesc_ToCpp(PyObject *object)
- Return the :ctype:`pkgAcquire::ItemDesc` pointer contained in the Python object
+ Return the :c:type:`pkgAcquire::ItemDesc` pointer contained in the Python object
*object*.
AcquireWorker (pkgAcquire::Worker)
----------------------------------
-.. cvar:: PyTypeObject PyAcquireWorker_Type
+.. c:var:: PyTypeObject PyAcquireWorker_Type
The type object for :class:`apt_pkg.AcquireWorker` objects.
-.. cfunction:: int PyAcquireWorker_Check(PyObject *object)
+.. c:function:: int PyAcquireWorker_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireWorker` object, or
a subclass thereof.
-.. cfunction:: int PyAcquireWorker_CheckExact(PyObject *object)
+.. c:function:: int PyAcquireWorker_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.AcquireWorker` object
and no subclass thereof.
-.. cfunction:: PyObject* PyAcquireWorker_FromCpp(pkgAcquire::Worker *worker, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyAcquireWorker_FromCpp(pkgAcquire::Worker *worker, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.AcquireWorker` object from the :ctype:`pkgAcquire::Worker`
+ Create a new :class:`apt_pkg.AcquireWorker` object from the :c:type:`pkgAcquire::Worker`
pointer given by the parameter *worker*. If the parameter *delete* is
true, the object pointed to by *worker* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* should point
to a :class:`apt_pkg.Acquire` object.
-.. cfunction:: pkgAcquire::Worker* PyAcquireWorker_ToCpp(PyObject *object)
+.. c:function:: pkgAcquire::Worker* PyAcquireWorker_ToCpp(PyObject *object)
- Return the :ctype:`pkgAcquire::Worker` pointer contained in the Python object
+ Return the :c:type:`pkgAcquire::Worker` pointer contained in the Python object
*object*.
ActionGroup (pkgDepCache::ActionGroup)
--------------------------------------
-.. cvar:: PyTypeObject PyActionGroup_Type
+.. c:var:: PyTypeObject PyActionGroup_Type
The type object for :class:`apt_pkg.ActionGroup` objects.
-.. cfunction:: int PyActionGroup_Check(PyObject *object)
+.. c:function:: int PyActionGroup_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.ActionGroup` object, or
a subclass thereof.
-.. cfunction:: int PyActionGroup_CheckExact(PyObject *object)
+.. c:function:: int PyActionGroup_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.ActionGroup` object
and no subclass thereof.
-.. cfunction:: PyObject* PyActionGroup_FromCpp(pkgDepCache::ActionGroup *agroup, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyActionGroup_FromCpp(pkgDepCache::ActionGroup *agroup, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.ActionGroup` object from the :ctype:`pkgDepCache::ActionGroup`
+ Create a new :class:`apt_pkg.ActionGroup` object from the :c:type:`pkgDepCache::ActionGroup`
pointer given by the parameter *agroup*. If the parameter *delete* is
true, the object pointed to by *agroup* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* should point
to a :class:`apt_pkg.DepCache` object.
-.. cfunction:: pkgDepCache::ActionGroup* PyActionGroup_ToCpp(PyObject *object)
+.. c:function:: pkgDepCache::ActionGroup* PyActionGroup_ToCpp(PyObject *object)
- Return the :ctype:`pkgDepCache::ActionGroup` pointer contained in the
+ Return the :c:type:`pkgDepCache::ActionGroup` pointer contained in the
Python object *object*.
Cache (pkgCache)
------------------------
-.. cvar:: PyTypeObject PyCache_Type
+.. c:var:: PyTypeObject PyCache_Type
The type object for :class:`apt_pkg.Cache` objects.
-.. cfunction:: int PyCache_Check(PyObject *object)
+.. c:function:: int PyCache_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Cache` object, or
a subclass thereof.
-.. cfunction:: int PyCache_CheckExact(PyObject *object)
+.. c:function:: int PyCache_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Cache` object
and no subclass thereof.
-.. cfunction:: PyObject* PyCache_FromCpp(pkgCache *cache, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyCache_FromCpp(pkgCache *cache, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Cache` object from the :ctype:`pkgCache`
+ Create a new :class:`apt_pkg.Cache` object from the :c:type:`pkgCache`
pointer given by the parameter *cache*. If the parameter *delete* is
true, the object pointed to by *cache* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* shall point
- to a object of the type :cdata:`PyCacheFile_Type`.
+ to a object of the type :c:data:`PyCacheFile_Type`.
-.. cfunction:: pkgCache* PyCache_ToCpp(PyObject *object)
+.. c:function:: pkgCache* PyCache_ToCpp(PyObject *object)
- Return the :ctype:`pkgCache` pointer contained in the Python object
+ Return the :c:type:`pkgCache` pointer contained in the Python object
*object*.
CacheFile (pkgCacheFile)
------------------------
-.. cvar:: PyTypeObject PyCacheFile_Type
+.. c:var:: PyTypeObject PyCacheFile_Type
The type object for CacheFile. This type is internal and not exported to
Python anywhere.
-.. cfunction:: int PyCacheFile_Check(PyObject *object)
+.. c:function:: int PyCacheFile_Check(PyObject *object)
- Check that the object *object* is of the type :cdata:`PyCacheFile_Type` or
+ Check that the object *object* is of the type :c:data:`PyCacheFile_Type` or
a subclass thereof.
-.. cfunction:: int PyCacheFile_CheckExact(PyObject *object)
+.. c:function:: int PyCacheFile_CheckExact(PyObject *object)
- Check that the object *object* is of the type :cdata:`PyCacheFile_Type` and
+ Check that the object *object* is of the type :c:data:`PyCacheFile_Type` and
no subclass thereof.
-.. cfunction:: PyObject* PyCacheFile_FromCpp(pkgCacheFile *file, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyCacheFile_FromCpp(pkgCacheFile *file, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.CacheFile` object from the :ctype:`pkgCacheFile`
+ Create a new :class:`apt_pkg.CacheFile` object from the :c:type:`pkgCacheFile`
pointer given by the parameter *file* If the parameter *delete* is
true, the object pointed to by *file* will be deleted when the reference
count of the returned object reaches 0.
-.. cfunction:: pkgCacheFile* PyCacheFile_ToCpp(PyObject *object)
+.. c:function:: pkgCacheFile* PyCacheFile_ToCpp(PyObject *object)
- Return the :ctype:`pkgCacheFile` pointer contained in the Python object
+ Return the :c:type:`pkgCacheFile` pointer contained in the Python object
*object*.
Cdrom (pkgCdrom)
------------------------
-.. cvar:: PyTypeObject PyCdrom_Type
+.. c:var:: PyTypeObject PyCdrom_Type
The type object for :class:`apt_pkg.Cdrom` objects.
-.. cfunction:: int PyCdrom_Check(PyObject *object)
+.. c:function:: int PyCdrom_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Cdrom` object, or
a subclass thereof.
-.. cfunction:: int PyCdrom_CheckExact(PyObject *object)
+.. c:function:: int PyCdrom_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Cdrom` object
and no subclass thereof.
-.. cfunction:: PyObject* PyCdrom_FromCpp(pkgCdrom &cdrom, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyCdrom_FromCpp(pkgCdrom &cdrom, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Cdrom` object from the :ctype:`pkgCdrom`
+ Create a new :class:`apt_pkg.Cdrom` object from the :c:type:`pkgCdrom`
reference given by the parameter *cdrom*. If the parameter *delete* is
true, *cdrom* will be deleted when the reference count of the returned
object reaches 0.
-.. cfunction:: pkgCdrom& PyCdrom_ToCpp(PyObject *object)
+.. c:function:: pkgCdrom& PyCdrom_ToCpp(PyObject *object)
- Return the :ctype:`pkgCdrom` reference contained in the Python object
+ Return the :c:type:`pkgCdrom` reference contained in the Python object
*object*.
Configuration (Configuration)
-------------------------------
-.. cvar:: PyTypeObject PyConfiguration_Type
+.. c:var:: PyTypeObject PyConfiguration_Type
The type object for :class:`apt_pkg.Configuration` objects.
-.. cfunction:: int PyConfiguration_Check(PyObject *object)
+.. c:function:: int PyConfiguration_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Configuration` object, or
a subclass thereof.
-.. cfunction:: int PyConfiguration_CheckExact(PyObject *object)
+.. c:function:: int PyConfiguration_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Configuration` object
and no subclass thereof.
-.. cfunction:: PyObject* PyConfiguration_FromCpp(Configuration *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyConfiguration_FromCpp(Configuration *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Configuration` object from the :ctype:`Configuration`
+ Create a new :class:`apt_pkg.Configuration` object from the :c:type:`Configuration`
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* may refer to
a parent object (e.g. when exposing a sub tree of a configuration object).
-.. cfunction:: Configuration* PyConfiguration_ToCpp(PyObject *object)
+.. c:function:: Configuration* PyConfiguration_ToCpp(PyObject *object)
- Return the :ctype:`Configuration` pointer contained in the Python object
+ Return the :c:type:`Configuration` pointer contained in the Python object
*object*.
DepCache (pkgDepCache)
------------------------
-.. cvar:: PyTypeObject PyDepCache_Type
+.. c:var:: PyTypeObject PyDepCache_Type
The type object for :class:`apt_pkg.DepCache` objects.
-.. cfunction:: int PyDepCache_Check(PyObject *object)
+.. c:function:: int PyDepCache_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.DepCache` object, or
a subclass thereof.
-.. cfunction:: int PyDepCache_CheckExact(PyObject *object)
+.. c:function:: int PyDepCache_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.DepCache` object
and no subclass thereof.
-.. cfunction:: PyObject* PyDepCache_FromCpp(pkgDepCache *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyDepCache_FromCpp(pkgDepCache *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.DepCache` object from the :ctype:`pkgDepCache`
+ Create a new :class:`apt_pkg.DepCache` object from the :c:type:`pkgDepCache`
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* must be
- a PyObject of the type :cdata:`PyCache_Type`.
+ a PyObject of the type :c:data:`PyCache_Type`.
-.. cfunction:: pkgDepCache* PyDepCache_ToCpp(PyObject *object)
+.. c:function:: pkgDepCache* PyDepCache_ToCpp(PyObject *object)
- Return the :ctype:`pkgDepCache` pointer contained in the Python object
+ Return the :c:type:`pkgDepCache` pointer contained in the Python object
*object*.
Dependency (pkgCache::DepIterator)
----------------------------------
-.. cvar:: PyTypeObject PyDependency_Type
+.. c:var:: PyTypeObject PyDependency_Type
The type object for :class:`apt_pkg.Dependency` objects.
-.. cfunction:: int PyDependency_Check(PyObject *object)
+.. c:function:: int PyDependency_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Dependency` object, or
a subclass thereof.
-.. cfunction:: int PyDependency_CheckExact(PyObject *object)
+.. c:function:: int PyDependency_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Dependency` object
and no subclass thereof.
-.. cfunction:: PyObject* PyDependency_FromCpp(pkgCache::DepIterator &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyDependency_FromCpp(pkgCache::DepIterator &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Dependency` object from the :ctype:`pkgCache::DepIterator`
+ Create a new :class:`apt_pkg.Dependency` object from the :c:type:`pkgCache::DepIterator`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *cpp* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* must be
- a PyObject of the type :cdata:`PyPackage_Type`.
+ a PyObject of the type :c:data:`PyPackage_Type`.
-.. cfunction:: pkgCache::DepIterator& PyDependency_ToCpp(PyObject *object)
+.. c:function:: pkgCache::DepIterator& PyDependency_ToCpp(PyObject *object)
- Return the :ctype:`pkgCache::DepIterator` reference contained in the
+ Return the :c:type:`pkgCache::DepIterator` reference contained in the
Python object *object*.
Description (pkgCache::DescIterator)
------------------------------------
-.. cvar:: PyTypeObject PyDescription_Type
+.. c:var:: PyTypeObject PyDescription_Type
The type object for :class:`apt_pkg.Description` objects.
-.. cfunction:: int PyDescription_Check(PyObject *object)
+.. c:function:: int PyDescription_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Description` object, or
a subclass thereof.
-.. cfunction:: int PyDescription_CheckExact(PyObject *object)
+.. c:function:: int PyDescription_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Description` object
and no subclass thereof.
-.. cfunction:: PyObject* PyDescription_FromCpp(pkgCache::DescIterator &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyDescription_FromCpp(pkgCache::DescIterator &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Description` object from the :ctype:`pkgCache::DescIterator`
+ Create a new :class:`apt_pkg.Description` object from the :c:type:`pkgCache::DescIterator`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *cpp* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* must be
- a PyObject of the type :cdata:`PyPackage_Type`.
+ a PyObject of the type :c:data:`PyPackage_Type`.
-.. cfunction:: pkgCache::DescIterator& PyDescription_ToCpp(PyObject *object)
+.. c:function:: pkgCache::DescIterator& PyDescription_ToCpp(PyObject *object)
- Return the :ctype:`pkgCache::DescIterator` reference contained in the
+ Return the :c:type:`pkgCache::DescIterator` reference contained in the
Python object *object*.
@@ -394,465 +394,465 @@ Group (pkgCache::GrpIterator)
----------------------------------
.. versionadded:: 0.8.0
-.. cvar:: PyTypeObject PyGroup_Type
+.. c:var:: PyTypeObject PyGroup_Type
The type object for :class:`apt_pkg.Group` objects.
-.. cfunction:: int PyGroup_Check(PyObject *object)
+.. c:function:: int PyGroup_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Group` object, or
a subclass thereof.
-.. cfunction:: int PyGroup_CheckExact(PyObject *object)
+.. c:function:: int PyGroup_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Group` object
and no subclass thereof.
-.. cfunction:: PyObject* PyGroup_FromCpp(pkgCache::GrpIterator &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyGroup_FromCpp(pkgCache::GrpIterator &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Group` object from the :ctype:`pkgCache::GrpIterator`
+ Create a new :class:`apt_pkg.Group` object from the :c:type:`pkgCache::GrpIterator`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *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:`PyCache_Type`.
+ a PyObject of the type :c:data:`PyCache_Type`.
-.. cfunction:: pkgCache::GrpIterator& PyGroup_ToCpp(PyObject *object)
+.. c:function:: pkgCache::GrpIterator& PyGroup_ToCpp(PyObject *object)
- Return the :ctype:`pkgCache::GrpIterator` reference contained in the
+ Return the :c:type:`pkgCache::GrpIterator` reference contained in the
Python object *object*.
Hashes (Hashes)
----------------------------------
-.. cvar:: PyTypeObject PyHashes_Type
+.. c:var:: PyTypeObject PyHashes_Type
The type object for :class:`apt_pkg.Hashes` objects.
-.. cfunction:: int PyHashes_Check(PyObject *object)
+.. c:function:: int PyHashes_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Hashes` object, or
a subclass thereof.
-.. cfunction:: int PyHashes_CheckExact(PyObject *object)
+.. c:function:: int PyHashes_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Hashes` object
and no subclass thereof.
-.. cfunction:: PyObject* PyHashes_FromCpp(Hashes &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyHashes_FromCpp(Hashes &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Hashes` object from the :ctype:`Hashes`
+ Create a new :class:`apt_pkg.Hashes` object from the :c:type:`Hashes`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *cpp* will be deleted when the reference count of the returned
object reaches 0.
-.. cfunction:: Hashes& PyHashes_ToCpp(PyObject *object)
+.. c:function:: Hashes& PyHashes_ToCpp(PyObject *object)
- Return the :ctype:`Hashes` reference contained in the
+ Return the :c:type:`Hashes` reference contained in the
Python object *object*.
HashString (HashString)
------------------------
-.. cvar:: PyTypeObject PyHashString_Type
+.. c:var:: PyTypeObject PyHashString_Type
The type object for :class:`apt_pkg.HashString` objects.
-.. cfunction:: int PyHashString_Check(PyObject *object)
+.. c:function:: int PyHashString_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.HashString` object, or
a subclass thereof.
-.. cfunction:: int PyHashString_CheckExact(PyObject *object)
+.. c:function:: int PyHashString_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.HashString` object
and no subclass thereof.
-.. cfunction:: PyObject* PyHashString_FromCpp(HashString *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyHashString_FromCpp(HashString *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.HashString` object from the :ctype:`HashString`
+ Create a new :class:`apt_pkg.HashString` object from the :c:type:`HashString`
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.
-.. cfunction:: HashString* PyHashString_ToCpp(PyObject *object)
+.. c:function:: HashString* PyHashString_ToCpp(PyObject *object)
- Return the :ctype:`HashString` pointer contained in the Python object
+ Return the :c:type:`HashString` pointer contained in the Python object
*object*.
IndexRecords (indexRecords)
----------------------------
-.. cvar:: PyTypeObject PyIndexRecords_Type
+.. c:var:: PyTypeObject PyIndexRecords_Type
The type object for :class:`apt_pkg.IndexRecords` objects.
-.. cfunction:: int PyIndexRecords_Check(PyObject *object)
+.. c:function:: int PyIndexRecords_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.IndexRecords` object, or
a subclass thereof.
-.. cfunction:: int PyIndexRecords_CheckExact(PyObject *object)
+.. c:function:: int PyIndexRecords_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.IndexRecords` object
and no subclass thereof.
-.. cfunction:: PyObject* PyIndexRecords_FromCpp(indexRecords *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyIndexRecords_FromCpp(indexRecords *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.IndexRecords` object from the :ctype:`indexRecords`
+ Create a new :class:`apt_pkg.IndexRecords` object from the :c:type:`indexRecords`
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.
-.. cfunction:: indexRecords* PyIndexRecords_ToCpp(PyObject *object)
+.. c:function:: indexRecords* PyIndexRecords_ToCpp(PyObject *object)
- Return the :ctype:`indexRecords` pointer contained in the Python object
+ Return the :c:type:`indexRecords` pointer contained in the Python object
*object*.
MetaIndex (metaIndex)
------------------------
-.. cvar:: PyTypeObject PyMetaIndex_Type
+.. c:var:: PyTypeObject PyMetaIndex_Type
The type object for :class:`apt_pkg.MetaIndex` objects.
-.. cfunction:: int PyMetaIndex_Check(PyObject *object)
+.. c:function:: int PyMetaIndex_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.MetaIndex` object, or
a subclass thereof.
-.. cfunction:: int PyMetaIndex_CheckExact(PyObject *object)
+.. c:function:: int PyMetaIndex_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.MetaIndex` object
and no subclass thereof.
-.. cfunction:: PyObject* PyMetaIndex_FromCpp(metaIndex *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyMetaIndex_FromCpp(metaIndex *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.MetaIndex` object from the :ctype:`metaIndex`
+ Create a new :class:`apt_pkg.MetaIndex` object from the :c:type:`metaIndex`
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:`PySourceList_Type`.
+ a PyObject of the type :c:data:`PySourceList_Type`.
-.. cfunction:: metaIndex* PyMetaIndex_ToCpp(PyObject *object)
+.. c:function:: metaIndex* PyMetaIndex_ToCpp(PyObject *object)
- Return the :ctype:`metaIndex` pointer contained in the Python object
+ Return the :c:type:`metaIndex` pointer contained in the Python object
*object*.
Package (pkgCache::PkgIterator)
----------------------------------
-.. cvar:: PyTypeObject PyPackage_Type
+.. c:var:: PyTypeObject PyPackage_Type
The type object for :class:`apt_pkg.Package` objects.
-.. cfunction:: int PyPackage_Check(PyObject *object)
+.. c:function:: int PyPackage_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Package` object, or
a subclass thereof.
-.. cfunction:: int PyPackage_CheckExact(PyObject *object)
+.. c:function:: int PyPackage_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Package` object
and no subclass thereof.
-.. cfunction:: PyObject* PyPackage_FromCpp(pkgCache::PkgIterator &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyPackage_FromCpp(pkgCache::PkgIterator &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Package` object from the :ctype:`pkgCache::PkgIterator`
+ Create a new :class:`apt_pkg.Package` object from the :c:type:`pkgCache::PkgIterator`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *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:`PyCache_Type`.
+ a PyObject of the type :c:data:`PyCache_Type`.
-.. cfunction:: pkgCache::PkgIterator& PyPackage_ToCpp(PyObject *object)
+.. c:function:: pkgCache::PkgIterator& PyPackage_ToCpp(PyObject *object)
- Return the :ctype:`pkgCache::PkgIterator` reference contained in the
+ Return the :c:type:`pkgCache::PkgIterator` reference contained in the
Python object *object*.
PackageFile (pkgCache::PkgFileIterator)
----------------------------------------
-.. cvar:: PyTypeObject PyPackageFile_Type
+.. c:var:: PyTypeObject PyPackageFile_Type
The type object for :class:`apt_pkg.PackageFile` objects.
-.. cfunction:: int PyPackageFile_Check(PyObject *object)
+.. c:function:: int PyPackageFile_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.PackageFile` object, or
a subclass thereof.
-.. cfunction:: int PyPackageFile_CheckExact(PyObject *object)
+.. c:function:: int PyPackageFile_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.PackageFile` object
and no subclass thereof.
-.. cfunction:: PyObject* PyPackageFile_FromCpp(pkgCache::PkgFileIterator &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyPackageFile_FromCpp(pkgCache::PkgFileIterator &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.PackageFile` object from the :ctype:`pkgCache::PkgFileIterator`
+ Create a new :class:`apt_pkg.PackageFile` object from the :c:type:`pkgCache::PkgFileIterator`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *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:`PyCache_Type`.
+ a PyObject of the type :c:data:`PyCache_Type`.
-.. cfunction:: pkgCache::PkgFileIterator& PyPackageFile_ToCpp(PyObject *object)
+.. c:function:: pkgCache::PkgFileIterator& PyPackageFile_ToCpp(PyObject *object)
- Return the :ctype:`pkgCache::PkgFileIterator` reference contained in the
+ Return the :c:type:`pkgCache::PkgFileIterator` reference contained in the
Python object *object*.
IndexFile (pkgIndexFile)
--------------------------------------
-.. cvar:: PyTypeObject PyIndexFile_Type
+.. c:var:: PyTypeObject PyIndexFile_Type
The type object for :class:`apt_pkg.IndexFile` objects.
-.. cfunction:: int PyIndexFile_Check(PyObject *object)
+.. c:function:: int PyIndexFile_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.IndexFile` object, or
a subclass thereof.
-.. cfunction:: int PyIndexFile_CheckExact(PyObject *object)
+.. c:function:: int PyIndexFile_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.IndexFile` object
and no subclass thereof.
-.. cfunction:: PyObject* PyIndexFile_FromCpp(pkgIndexFile *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyIndexFile_FromCpp(pkgIndexFile *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.IndexFile` object from the :ctype:`pkgIndexFile`
+ Create a new :class:`apt_pkg.IndexFile` object from the :c:type:`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`.
+ a PyObject of the type :c:data:`PyMetaIndex_Type`.
-.. cfunction:: pkgIndexFile* PyIndexFile_ToCpp(PyObject *object)
+.. c:function:: pkgIndexFile* PyIndexFile_ToCpp(PyObject *object)
- Return the :ctype:`pkgIndexFile` pointer contained in the Python object
+ Return the :c:type:`pkgIndexFile` pointer contained in the Python object
*object*.
OrderList (pkgOrderList)
---------------------------
-.. cvar:: PyTypeObject PyOrderList_Type
+.. c:var:: PyTypeObject PyOrderList_Type
The type object for :class:`apt_pkg.OrderList` objects.
-.. cfunction:: int PyOrderList_Check(PyObject *object)
+.. c:function:: int PyOrderList_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.OrderList` object, or
a subclass thereof.
-.. cfunction:: int PyOrderList_CheckExact(PyObject *object)
+.. c:function:: int PyOrderList_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.OrderList` object
and no subclass thereof.
-.. cfunction:: PyObject* PyOrderList_FromCpp(pkgOrderList *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyOrderList_FromCpp(pkgOrderList *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.OrderList` object from the :ctype:`pkgOrderList`
+ Create a new :class:`apt_pkg.OrderList` object from the :c:type:`pkgOrderList`
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 owner must be a
:class:`apt_pkg.DepCache` object.
-.. cfunction:: pkgOrderList* PyOrderList_ToCpp(PyObject *object)
+.. c:function:: pkgOrderList* PyOrderList_ToCpp(PyObject *object)
- Return the :ctype:`pkgOrderList` pointer contained in the Python object
+ Return the :c:type:`pkgOrderList` pointer contained in the Python object
*object*.
PackageManager (pkgPackageManager)
----------------------------------
-.. cvar:: PyTypeObject PyPackageManager_Type
+.. c:var:: PyTypeObject PyPackageManager_Type
The type object for :class:`apt_pkg.PackageManager` objects.
-.. cfunction:: int PyPackageManager_Check(PyObject *object)
+.. c:function:: int PyPackageManager_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.PackageManager` object, or
a subclass thereof.
-.. cfunction:: int PyPackageManager_CheckExact(PyObject *object)
+.. c:function:: int PyPackageManager_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.PackageManager` object
and no subclass thereof.
-.. cfunction:: PyObject* PyPackageManager_FromCpp(pkgPackageManager *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyPackageManager_FromCpp(pkgPackageManager *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.PackageManager` object from the :ctype:`pkgPackageManager`
+ Create a new :class:`apt_pkg.PackageManager` object from the :c:type:`pkgPackageManager`
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.
-.. cfunction:: pkgPackageManager* PyPackageManager_ToCpp(PyObject *object)
+.. c:function:: pkgPackageManager* PyPackageManager_ToCpp(PyObject *object)
- Return the :ctype:`pkgPackageManager` pointer contained in the Python object
+ Return the :c:type:`pkgPackageManager` pointer contained in the Python object
*object*.
Policy (pkgPolicy)
------------------
-.. cvar:: PyTypeObject PyPolicy_Type
+.. c:var:: PyTypeObject PyPolicy_Type
The type object for :class:`apt_pkg.Policy` objects.
-.. cfunction:: int PyPolicy_Check(PyObject *object)
+.. c:function:: int PyPolicy_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Policy` object, or
a subclass thereof.
-.. cfunction:: int PyPolicy_CheckExact(PyObject *object)
+.. c:function:: int PyPolicy_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Policy` object
and no subclass thereof.
-.. cfunction:: PyObject* PyPolicy_FromCpp(pkgPolicy *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyPolicy_FromCpp(pkgPolicy *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Policy` object from the :ctype:`pkgPolicy`
+ Create a new :class:`apt_pkg.Policy` object from the :c:type:`pkgPolicy`
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* must be
- a PyObject of the type :cdata:`PyCache_Type`.
+ a PyObject of the type :c:data:`PyCache_Type`.
-.. cfunction:: pkgPolicy* PyPolicy_ToCpp(PyObject *object)
+.. c:function:: pkgPolicy* PyPolicy_ToCpp(PyObject *object)
- Return the :ctype:`pkgPolicy` pointer contained in the Python object
+ Return the :c:type:`pkgPolicy` pointer contained in the Python object
*object*.
ProblemResolver (pkgProblemResolver)
--------------------------------------
-.. cvar:: PyTypeObject PyProblemResolver_Type
+.. c:var:: PyTypeObject PyProblemResolver_Type
The type object for :class:`apt_pkg.ProblemResolver` objects.
-.. cfunction:: int PyProblemResolver_Check(PyObject *object)
+.. c:function:: int PyProblemResolver_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.ProblemResolver` object, or
a subclass thereof.
-.. cfunction:: int PyProblemResolver_CheckExact(PyObject *object)
+.. c:function:: int PyProblemResolver_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.ProblemResolver` object
and no subclass thereof.
-.. cfunction:: PyObject* PyProblemResolver_FromCpp(pkgProblemResolver *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyProblemResolver_FromCpp(pkgProblemResolver *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.ProblemResolver` object from the :ctype:`pkgProblemResolver`
+ Create a new :class:`apt_pkg.ProblemResolver` object from the :c:type:`pkgProblemResolver`
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* must be
- a PyObject of the type :cdata:`PyDepCache_Type`.
+ a PyObject of the type :c:data:`PyDepCache_Type`.
-.. cfunction:: pkgProblemResolver* PyProblemResolver_ToCpp(PyObject *object)
+.. c:function:: pkgProblemResolver* PyProblemResolver_ToCpp(PyObject *object)
- Return the :ctype:`pkgProblemResolver` pointer contained in the Python object
+ Return the :c:type:`pkgProblemResolver` pointer contained in the Python object
*object*.
SourceList (pkgSourceList)
---------------------------
-.. cvar:: PyTypeObject PySourceList_Type
+.. c:var:: PyTypeObject PySourceList_Type
The type object for :class:`apt_pkg.SourceList` objects.
-.. cfunction:: int PySourceList_Check(PyObject *object)
+.. c:function:: int PySourceList_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.SourceList` object, or
a subclass thereof.
-.. cfunction:: int PySourceList_CheckExact(PyObject *object)
+.. c:function:: int PySourceList_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.SourceList` object
and no subclass thereof.
-.. cfunction:: PyObject* PySourceList_FromCpp(pkgSourceList *cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PySourceList_FromCpp(pkgSourceList *cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.SourceList` object from the :ctype:`pkgSourceList`
+ Create a new :class:`apt_pkg.SourceList` object from the :c:type:`pkgSourceList`
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.
-.. cfunction:: pkgSourceList* PySourceList_ToCpp(PyObject *object)
+.. c:function:: pkgSourceList* PySourceList_ToCpp(PyObject *object)
- Return the :ctype:`pkgSourceList` pointer contained in the Python object
+ Return the :c:type:`pkgSourceList` pointer contained in the Python object
*object*.
TagFile (pkgTagFile)
----------------------------------
-.. cvar:: PyTypeObject PyTagFile_Type
+.. c:var:: PyTypeObject PyTagFile_Type
The type object for :class:`apt_pkg.TagFile` objects.
-.. cfunction:: int PyTagFile_Check(PyObject *object)
+.. c:function:: int PyTagFile_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.TagFile` object, or
a subclass thereof.
-.. cfunction:: int PyTagFile_CheckExact(PyObject *object)
+.. c:function:: int PyTagFile_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.TagFile` object
and no subclass thereof.
-.. cfunction:: PyObject* PyTagFile_FromCpp(pkgTagFile &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyTagFile_FromCpp(pkgTagFile &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.TagFile` object from the :ctype:`pkgTagFile`
+ Create a new :class:`apt_pkg.TagFile` object from the :c:type:`pkgTagFile`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *cpp* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* may be any
Python object.
-.. cfunction:: pkgTagFile& PyTagFile_ToCpp(PyObject *object)
+.. c:function:: pkgTagFile& PyTagFile_ToCpp(PyObject *object)
- Return the :ctype:`pkgTagFile` reference contained in the
+ Return the :c:type:`pkgTagFile` reference contained in the
Python object *object*.
TagSection (pkgTagSection)
----------------------------------
-.. cvar:: PyTypeObject PyTagSection_Type
+.. c:var:: PyTypeObject PyTagSection_Type
The type object for :class:`apt_pkg.TagSection` objects.
-.. cfunction:: int PyTagSection_Check(PyObject *object)
+.. c:function:: int PyTagSection_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.TagSection` object, or
a subclass thereof.
-.. cfunction:: int PyTagSection_CheckExact(PyObject *object)
+.. c:function:: int PyTagSection_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.TagSection` object
and no subclass thereof.
-.. cfunction:: PyObject* PyTagSection_FromCpp(pkgTagSection &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyTagSection_FromCpp(pkgTagSection &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.TagSection` object from the :ctype:`pkgTagSection`
+ Create a new :class:`apt_pkg.TagSection` object from the :c:type:`pkgTagSection`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *cpp* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* may be
- a PyObject of the type :cdata:`PyTagFile_Type`.
+ a PyObject of the type :c:data:`PyTagFile_Type`.
-.. cfunction:: pkgTagSection& PyTagSection_ToCpp(PyObject *object)
+.. c:function:: pkgTagSection& PyTagSection_ToCpp(PyObject *object)
- Return the :ctype:`pkgTagSection` reference contained in the
+ Return the :c:type:`pkgTagSection` reference contained in the
Python object *object*.
Version (pkgCache::VerIterator)
----------------------------------
-.. cvar:: PyTypeObject PyVersion_Type
+.. c:var:: PyTypeObject PyVersion_Type
The type object for :class:`apt_pkg.Version` objects.
-.. cfunction:: int PyVersion_Check(PyObject *object)
+.. c:function:: int PyVersion_Check(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Version` object, or
a subclass thereof.
-.. cfunction:: int PyVersion_CheckExact(PyObject *object)
+.. c:function:: int PyVersion_CheckExact(PyObject *object)
Check that the object *object* is an :class:`apt_pkg.Version` object
and no subclass thereof.
-.. cfunction:: PyObject* PyVersion_FromCpp(pkgCache::VerIterator &cpp, bool delete, PyObject *owner)
+.. c:function:: PyObject* PyVersion_FromCpp(pkgCache::VerIterator &cpp, bool delete, PyObject *owner)
- Create a new :class:`apt_pkg.Version` object from the :ctype:`pkgCache::VerIterator`
+ Create a new :class:`apt_pkg.Version` object from the :c:type:`pkgCache::VerIterator`
reference given by the parameter *cpp*. If the parameter *delete* is
true, *cpp* will be deleted when the reference
count of the returned object reaches 0. The parameter *owner* must be
- a PyObject of the type :cdata:`PyPackage_Type`.
+ a PyObject of the type :c:data:`PyPackage_Type`.
-.. cfunction:: pkgCache::VerIterator& PyVersion_ToCpp(PyObject *object)
+.. c:function:: pkgCache::VerIterator& PyVersion_ToCpp(PyObject *object)
- Return the :ctype:`pkgCache::VerIterator` reference contained in the
+ Return the :c:type:`pkgCache::VerIterator` reference contained in the
Python object *object*.
diff --git a/doc/source/c++/embedding.rst b/doc/source/c++/embedding.rst
index 754ad398..445e9c6f 100644
--- a/doc/source/c++/embedding.rst
+++ b/doc/source/c++/embedding.rst
@@ -12,7 +12,7 @@ To use the python-apt C++ bindings, first include the
#include <python-apt/python-apt.h>
Now, the module needs to be initialized. This is done by calling the function
-:cfunc:`import_apt_pkg`. This function returns 0 on success and a negative
+:c:func:`import_apt_pkg`. This function returns 0 on success and a negative
value in case of failure::
if (import_apt_pkg() < 0)
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 8fbf2c11..c4dde305 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -26,18 +26,16 @@ if os.path.exists("../../build"):
sys.path.insert(0, os.path.abspath(os.path.dirname(apt_pkg_path)))
try:
import apt_pkg
+ apt_pkg # pyflakes
except ImportError as exc:
# Not the correct version
sys.stderr.write('W: Ignoring error %s\n' % exc)
sys.path.pop(0)
else:
sys.stdout.write('I: Found apt_pkg.so in %s\n' % sys.path[0])
- # Hack: Disable compatibility mode
- apt_pkg._COMPAT_0_7 = 0
break
-
# General configuration
# ---------------------
@@ -69,7 +67,7 @@ copyright = u'2009-2010, Julian Andres Klode <jak@debian.org>'
#
try:
- release=os.environ['DEBVER']
+ release = os.environ['DEBVER']
except KeyError:
from subprocess import Popen, PIPE
p1 = Popen(["dpkg-parsechangelog", "-l../../debian/changelog"],
@@ -77,13 +75,15 @@ except KeyError:
p2 = Popen(["sed", "-n", 's/^Version: //p'], stdin=p1.stdout, stdout=PIPE)
release = p2.communicate()[0]
+if sys.version_info.major >= 3:
+ release = release.decode("utf-8")
# Handle the alpha release scheme
release_raw = "0"
for c in release.split("~")[0].split(".")[2]:
if not c.isdigit():
break
release_raw += c
-
+
if int(release_raw) >= 90:
version_s = release.split("~")[0].split(".")[:3]
# Set the version to 0.X.100 if the release is 0.X.9Y (0.7.90 => 0.7.100)
@@ -95,7 +95,7 @@ if int(release_raw) >= 90:
version = '.'.join(version_s)
del version_s
else:
- version = '.'.join(release.split("~")[0].split('.')[:3])
+ version = '.'.join(release.split("~")[0].split('.')[:2])
del release_raw
# The language for content autogenerated by Sphinx. Refer to documentation
@@ -164,7 +164,7 @@ html_static_path = ['.static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-html_last_updated_fmt = '%b %d, %Y'
+html_last_updated_fmt = None
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
@@ -213,8 +213,8 @@ htmlhelp_basename = 'python-aptdoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source index, target name, title, author, document class [howto/manual]).
latex_documents = [
- ('contents', 'python-apt.tex', ur'python-apt Documentation',
- ur'Julian Andres Klode <jak@debian.org>', 'manual'),
+ ('contents', 'python-apt.tex', u'python-apt Documentation',
+ u'Julian Andres Klode <jak@debian.org>', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
diff --git a/doc/source/contents.rst b/doc/source/contents.rst
index 3c9fb511..6c4e161d 100644
--- a/doc/source/contents.rst
+++ b/doc/source/contents.rst
@@ -16,5 +16,4 @@ Indices and tables
==================
* :ref:`genindex`
-* :ref:`modindex`
* :ref:`search`
diff --git a/doc/source/examples/apt-gtk.py b/doc/source/examples/apt-gtk.py
deleted file mode 100644
index ad46454e..00000000
--- a/doc/source/examples/apt-gtk.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/python
-"""Example for gtk widgets"""
-import pygtk
-pygtk.require("2.0")
-import gtk
-
-import apt.progress.gtk2
-
-
-def main():
- """Main function."""
- win = gtk.Window()
- win.connect("destroy", gtk.main_quit)
- progress = apt.progress.gtk2.GtkAptProgress()
- win.set_title("GtkAptProgress Demo")
- win.add(progress)
- progress.show()
- win.show()
- cache = apt.cache.Cache(progress.open)
- if cache["xterm"].is_installed:
- cache["xterm"].mark_delete()
- else:
- cache["xterm"].mark_install()
- progress.show_terminal(expanded=True)
- cache.commit(progress.fetch, progress.install)
- gtk.main()
-
-if __name__ == "__main__":
- main()
diff --git a/doc/source/examples/cache-pkgfile.py b/doc/source/examples/cache-pkgfile.py
index f4cc2e66..10216c19 100644
--- a/doc/source/examples/cache-pkgfile.py
+++ b/doc/source/examples/cache-pkgfile.py
@@ -8,7 +8,7 @@ def main():
cache = apt_pkg.Cache()
for pkgfile in cache.file_list:
print 'Package-File:', pkgfile.filename
- print 'Index-Type:', pkgfile.index_type # 'Debian Package Index'
+ print 'Index-Type:', pkgfile.index_type # 'Debian Package Index'
if pkgfile.not_source:
print 'Source: None'
else:
diff --git a/doc/source/examples/dpkg-info.py b/doc/source/examples/dpkg-info.py
index 6be8595c..af220590 100644
--- a/doc/source/examples/dpkg-info.py
+++ b/doc/source/examples/dpkg-info.py
@@ -2,7 +2,7 @@
"""Emulate dpkg --info package.deb control-file"""
import sys
-from apt_inst import deb_extract_control
+from apt_inst import DebFile
def main():
@@ -12,7 +12,7 @@ def main():
sys.exit(0)
fobj = open(sys.argv[1])
try:
- print deb_extract_control(fobj, sys.argv[2])
+ print DebFile(fobj).control.extractdata(sys.argv[2])
finally:
fobj.close()
diff --git a/doc/source/examples/missing-deps.py b/doc/source/examples/missing-deps.py
index 7af18128..b9ccdc19 100644
--- a/doc/source/examples/missing-deps.py
+++ b/doc/source/examples/missing-deps.py
@@ -43,7 +43,7 @@ def main():
# Check every version
for pfile, _ in version.file_list:
if (pfile.origin == "Debian" and pfile.component == "main" and
- pfile.archive == "unstable"):
+ pfile.archive == "unstable"):
# We only want packages from Debian unstable main.
check_version(version)
break
diff --git a/doc/source/library/apt.package.rst b/doc/source/library/apt.package.rst
index 01a26973..1a69c1e2 100644
--- a/doc/source/library/apt.package.rst
+++ b/doc/source/library/apt.package.rst
@@ -23,26 +23,8 @@ The Version class
Dependency Information
----------------------
-.. class:: BaseDependency
-
- The :class:`BaseDependency` class defines various attributes for accessing
- the parts of a dependency. The attributes are as follows:
-
- .. attribute:: name
-
- The name of the dependency
-
- .. attribute:: relation
-
- The relation (>,>=,==,<,<=,)
-
- .. attribute:: version
-
- The version or None.
-
- .. attribute:: pre_depend
-
- Boolean value whether this is a pre-dependency.
+.. autoclass:: BaseDependency
+ :members:
.. class:: Dependency
diff --git a/doc/source/library/apt.progress.gtk2.rst b/doc/source/library/apt.progress.gtk2.rst
deleted file mode 100644
index 0d53ad41..00000000
--- a/doc/source/library/apt.progress.gtk2.rst
+++ /dev/null
@@ -1,131 +0,0 @@
-:mod:`apt.progress.gtk2` --- Progress reporting for GTK+ interfaces
-===================================================================
-.. 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:: GAcquireProgress
-
- An implementation of :class:`apt.progress.base.AcquireProgress` 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()
-
- Hide the expander with the terminal widget.
-
- .. attribute:: install
-
- Return the install progress handler.
-
- .. attribute:: open
-
- Return the cache opening progress handler.
-
- .. method:: show()
-
- Show the Box
-
- .. method:: show_terminal(expanded=False)
-
- Show an expander with a terminal widget which provides a way to
- interact with dpkg.
-
-
-Example
--------
-.. literalinclude:: ../examples/apt-gtk.py
diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst
index 7a359652..c704db3b 100644
--- a/doc/source/library/apt_pkg.rst
+++ b/doc/source/library/apt_pkg.rst
@@ -487,7 +487,7 @@ Installation ordering with :class:`OrderList`
.. class:: OrderList(depcache: DepCache)
- Represent a :ctype:`pkgOrderList`, used for installation
+ Represent a :c:type:`pkgOrderList`, used for installation
ordering. This class provides several methods and attributes,
is complicated and should not be used by normal programs.
@@ -715,7 +715,7 @@ Resolving Dependencies with :class:`ProblemResolver`
The version currently installed as a :class:`Version` object, or None
if the package is not installed.
- .. method:: get_fullname([pretty: bool = False]) -> str
+ .. method:: get_fullname([pretty: bool = False]) -> str
Get the full name of the package, including the architecture. If
*pretty* is ``True``, the architecture is omitted for native packages,
@@ -723,7 +723,7 @@ Resolving Dependencies with :class:`ProblemResolver`
.. versionadded:: 0.7.100.3
- .. attribute:: has_provides
+ .. attribute:: has_provides
A boolean value determining whether the list available via the
attribute :attr:`provides_list` has at least one element. This
@@ -733,7 +733,7 @@ Resolving Dependencies with :class:`ProblemResolver`
pkg.has_provides and not pkg.has_versions
- .. attribute:: has_versions
+ .. attribute:: has_versions
A boolean value determining whether the list available via the
attribute :attr:`version_list` has at least one element. This
@@ -787,6 +787,11 @@ Resolving Dependencies with :class:`ProblemResolver`
The section of the package, as specified in the record. The list of
possible sections is defined in the Policy. This is a string.
+ .. deprecated:: 1.0
+
+ A package can have multiple versions with different sections, so
+ the section information should be accessed from the version class.
+
.. attribute:: version_list
A list of :class:`Version` objects for all versions of this package
@@ -815,13 +820,6 @@ Resolving Dependencies with :class:`ProblemResolver`
**Flags**:
- .. attribute:: auto
-
- This flag is here for compatibility purposes and does not appear to
- be used anymore in APT. To find out whether a package is marked as
- automatically installed, use :meth:`DepCache.is_auto_installed`
- instead.
-
.. attribute:: essential
Whether the package has the 'Essential' flag set; that is,
@@ -916,7 +914,7 @@ Example:
The multi-arch state of the package. Can be one of the following
attributes.
- .. attribute:: MULTI_ARCH_NONE
+ .. attribute:: MULTI_ARCH_NO
No multi-arch
@@ -1022,7 +1020,8 @@ Example:
.. attribute:: comp_type
- The type of comparison (>=, ==, >>, <=), as string.
+ The type of comparison (<,<=,=,!=,>=,>,), as string. Note that the
+ empty string is a valid string as well, if no version is specified.
.. attribute:: dep_type
@@ -1353,10 +1352,10 @@ Records (Release files, Packages, Sources)
Example (shortened)::
- cand = depcache.GetCandidateVer(cache['python-apt'])
- records.Lookup(cand.FileList[0])
+ cand = depcache.get_candidate_ver(cache['python-apt'])
+ records.lookup(cand.file_list[0])
# Now you can access the record
- print records.SourcePkg # == python-apt
+ print records.source_pkg # == python-apt
.. attribute:: filename
@@ -1480,6 +1479,8 @@ Records (Release files, Packages, Sources)
``(str: md5, int: size, str: path, str:type)``, where
'type' can be 'diff' (includes .debian.tar.gz), 'dsc', 'tar'.
+ .. deprecated: 1.0
+
.. attribute:: index
A list of :class:`IndexFile` objects associated with this
@@ -1533,8 +1534,7 @@ installation.
The constructor takes an optional parameter *progress* which takes an
:class:`apt.progress.base.AcquireProgress` object. This object may then
report progress information (see :mod:`apt.progress.text` for reporting
- progress to a I/O stream and :mod:`apt.progress.gtk2` for GTK+ progress
- reporting).
+ progress to a I/O stream).
Acquire items have two methods to start and stop the fetching:
@@ -1599,8 +1599,12 @@ installation.
.. attribute:: RESULT_CONTINUE
- All items have been fetched successfully and the process has not been
- canceled.
+ All items have been fetched successfully or failed transiently
+ and the process has not been canceled.
+
+ You need to look at the status of each item and check if it has not
+ failed transiently to discover errors like a Not Found when acquiring
+ packages.
.. attribute:: RESULT_FAILED
@@ -1703,7 +1707,7 @@ installation.
There was a network error.
-.. class:: AcquireFile(owner, uri[, md5, size, descr, short_descr, destdir, destfile])
+.. class:: AcquireFile(owner, uri[, hash, size, descr, short_descr, destdir, destfile])
Create a new :class:`AcquireFile()` object and register it with *acquire*,
so it will be fetched. You must always keep around a reference to the
@@ -1716,8 +1720,9 @@ installation.
The parameter *uri* refers to the location of the file, any protocol
of apt is supported.
- The parameter *md5* refers to the md5sum of the file. This can be used
- for checking the file.
+ The parameter *hash* refers to the hash of the file. If this is set
+ libapt will check the file after downloading. See :class:`HashString`
+ for the combined form string format description.
The parameter *size* can be used to specify the size of the package,
which can then be used to calculate the progress and validate the download.
@@ -1849,8 +1854,8 @@ generic hash support:
.. attribute:: hashtype
- The type of the hash, as a string. This may be "MD5Sum", "SHA1"
- or "SHA256".
+ The type of the hash, as a string. This may be "MD5Sum", "SHA1",
+ "SHA256" or "SHA512".
.. method:: verify_file(filename: str) -> bool
@@ -1907,16 +1912,38 @@ section as a string.
.. 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
- kinds of API which should not be used together:
+ Packages, Sources, control, Release, etc.
+
+ The *file* argument shall be a path name or an open file object. The
+ argument *bytes* specifies whether the file shall be represented using
+ bytes (``True``) or unicode (``False``) strings.
+
+ It is a context manager that can be used with a with statement or the
+ :meth:`close` method.
+
+ .. describe:: with TagFile(...) as ...:
+
+ Use the :class:`TagFile` as a context manager. This will automatically
+ close the file after the body finished execution.
+
+ .. versionadded:: 1.0
+
+ .. method:: close()
+
+ Close the file. It's recommended to use the context manager
+ instead (that is, the `with` statement).
+
+ .. versionadded:: 1.0
+
+ It provides two kinds of API which should not be used together:
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']
+ with apt_pkg.TagFile('/var/lib/dpkg/status') as tagfile:
+ for section in tagfile:
+ print section['Package']
.. versionchanged:: 0.7.100
Added support for using gzip files, via :class:`gzip.GzipFile` or any
@@ -1942,9 +1969,9 @@ section as a string.
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()
- print tagf.section['Package']
+ with apt_pkg.TagFile('/var/lib/dpkg/status') as tagf:
+ tagf.step()
+ print tagf.section['Package']
.. method:: step() -> bool
diff --git a/doc/source/library/index.rst b/doc/source/library/index.rst
index 70e91f84..0b048c80 100644
--- a/doc/source/library/index.rst
+++ b/doc/source/library/index.rst
@@ -10,9 +10,9 @@ When going through the library, the first two modules are :mod:`apt_pkg` and
apt-pkg and apt-inst libraries and the base for the rest of python-apt.
Going forward, the :mod:`apt` package appears. This package is using
-:mod:`apt_pkg` and :mod`apt_inst` to provide easy to use ways to manipulate
+:mod:`apt_pkg` and :mod:`apt_inst` to provide easy to use ways to manipulate
the cache, fetch packages, or install new packages. It also provides useful
-progress classes, for text and GTK+ interfaces. The last package is
+progress classes, currently only for text interfaces. The last package is
:mod:`aptsources`. The aptsources package provides classes and functions to
read files like :file:`/etc/apt/sources.list` and to modify them.
@@ -28,7 +28,6 @@ read files like :file:`/etc/apt/sources.list` and to modify them.
apt.package
apt.progress.base
apt.progress.text
- apt.progress.gtk2
aptsources.distinfo
aptsources.distro
diff --git a/doc/source/templates/indexcontent.html b/doc/source/templates/indexcontent.html
index 394b46d5..b1395816 100644
--- a/doc/source/templates/indexcontent.html
+++ b/doc/source/templates/indexcontent.html
@@ -35,7 +35,7 @@
<p><strong>Indices and tables:</strong></p>
<table class="contentstable" align="center"><tr>
<td width="50%">
- <p class="biglink"><a class="biglink" href="{{ pathto("modindex") }}">Global Module Index</a><br/>
+ <p class="biglink"><a class="biglink" href="{{ pathto("py-modindex") }}">Global Module Index</a><br/>
<span class="linkdescr">quick access to all modules</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br/>
<span class="linkdescr">all functions, classes, terms</span></p>
diff --git a/doc/source/templates/layout.html b/doc/source/templates/layout.html
index 60298719..04a3e0d4 100644
--- a/doc/source/templates/layout.html
+++ b/doc/source/templates/layout.html
@@ -1,10 +1,4 @@
{% extends "!layout.html" %}
{% block rootrellink %}
- <li><img src="{{ pathto('_static/py.png', 1) }}" alt=""
- style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
{% endblock %}
-{% block extrahead %}
- <link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" />
-{{ super() }}
-{% endblock %}
diff --git a/doc/source/tutorials/apt-get.rst b/doc/source/tutorials/apt-get.rst
index 3bac473b..f8dd0895 100644
--- a/doc/source/tutorials/apt-get.rst
+++ b/doc/source/tutorials/apt-get.rst
@@ -11,7 +11,7 @@ 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
+simple ``apt-get --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`.
diff --git a/doc/source/whatsnew/0.9.4.rst b/doc/source/whatsnew/0.9.4.rst
new file mode 100644
index 00000000..617ef08f
--- /dev/null
+++ b/doc/source/whatsnew/0.9.4.rst
@@ -0,0 +1,17 @@
+What's New In python-apt 0.9.4
+==============================
+Python-apt 0.9.4 is a maintenance update.
+
+New features
+------------
+
+ * Support for apt_pkg.sha512sum()
+ * Support for apt_pkg.maybe_open_clear_signed_file()
+ * Use apt_pkg.open_maybe_clear_signed_file() when opening a .dsc file
+ * add MULTI_ARCH_NO constant (MULTI_ARCH_NONE is deprecated)
+
+Maintenance
+-----------
+
+ * Add Ubuntu Wily
+ * Update examples
diff --git a/doc/source/whatsnew/1.0.rst b/doc/source/whatsnew/1.0.rst
new file mode 100644
index 00000000..ab59f1a7
--- /dev/null
+++ b/doc/source/whatsnew/1.0.rst
@@ -0,0 +1,53 @@
+What's New In python-apt 1.0
+==============================
+Python-Apt 1.0 fixes several issues and use of deprecated methods. Most
+importantly, it introduces large file support
+
+New features
+------------
+* :class:`apt_pkg.AcquireFile` can now take a hash string that is not an
+ md5 value, using the new `hash` argument.
+* A new a :meth:`apt_pkg.TagFile.close` method was added
+* :class:`apt_pkg.TagFile` is now a context manager
+
+* The high-level cache class, :class:`apt.cache.Cache` and it's companion
+ :class:`apt.cache.FilteredCache` now support package
+ names with special architecture qualifiers such as :all and :native.
+
+* The method :meth:`apt.cache.Cache.connect2` allows connecting callbacks on
+ cache changes that take the cache as their first argument, reducing the
+ potential for reference cycles.
+
+Deprecated
+----------
+The following features are deprecated, starting with this release:
+
+* The `section` member of :class:`apt_pkg.Package`
+* The `files` member of of :class:`apt_pkg.SourceRecords`
+* The `md5` argument to :class:`apt_pkg.AcquireFile`, it is replaced by
+ the `hash` argument.
+* The method :meth:`apt.cache.Cache.connect` has been deprecated. It is
+ replaced by :meth:`apt.cache.Cache.connect2` which is more flexible and
+ less prone to reference cycles.
+
+Removed
+-------
+* The module :mod:`apt.progress.gtk2` has been removed. There were no
+ users in the Debian archive, its last update was in 2013, and it was buggy
+ already. Apart from that, it suggested that it is OK to run a graphical
+ application as root, and used the unmaintained GTK+ 2 version.
+
+ Therefore, there is no replacement, please use PackageKit or aptdaemon
+ for installation in graphical environments.
+* The attribute :attr:`apt_pkg.Package.auto` was not set anymore, and thus
+ removed.
+
+Maintenance
+-----------
+* The classes :class:`apt.cache.Cache` and :class:`apt.cache.FilteredCache` no
+ longer store cyclic references to/between them. This fixes a huge issue,
+ because a cache can have tens of open file descriptors, causing the maximum
+ of file descriptors to be reached easily.
+
+* :mod:`apt_inst` now supports ar and tar archives that are larger than 4 GiB
+* Various smaller bug fixes
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a3c54e3c..eb91d526 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,6 @@
[type: gettext/rfc822deb] data/templates/Ubuntu.info.in
[type: gettext/rfc822deb] data/templates/Debian.info.in
aptsources/distro.py
-apt/progress/gtk2.py
apt/package.py
apt/debfile.py
apt/progress/text.py
diff --git a/po/ar.po b/po/ar.po
index cf476639..73c76541 100644
--- a/po/ar.po
+++ b/po/ar.po
@@ -359,7 +359,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr ""
#. Description
diff --git a/po/be.po b/po/be.po
index 22cfda03..53470c39 100644
--- a/po/be.po
+++ b/po/be.po
@@ -359,8 +359,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/bg.po b/po/bg.po
index be5b379e..2c9942d7 100644
--- a/po/bg.po
+++ b/po/bg.po
@@ -405,7 +405,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 „Sarge“"
#. Description
diff --git a/po/bn.po b/po/bn.po
index 71bb1585..a20804c6 100644
--- a/po/bn.po
+++ b/po/bn.po
@@ -399,7 +399,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "ডেবিয়ান ৩.১ \"সার্জ\""
#. Description
diff --git a/po/ca.po b/po/ca.po
index c40b1df1..524a4ce4 100644
--- a/po/ca.po
+++ b/po/ca.po
@@ -403,7 +403,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/cs.po b/po/cs.po
index 283da4ae..5e9fd73d 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -390,7 +390,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/csb.po b/po/csb.po
index 2f81e949..73359928 100644
--- a/po/csb.po
+++ b/po/csb.po
@@ -359,7 +359,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr ""
#. Description
diff --git a/po/da.po b/po/da.po
index 23e40cf1..9deb9672 100644
--- a/po/da.po
+++ b/po/da.po
@@ -358,8 +358,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 \"Wheezy\" "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 \"Wheezy\" "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/de.po b/po/de.po
index 5f3fb0fa..c7ee73ee 100644
--- a/po/de.po
+++ b/po/de.po
@@ -360,8 +360,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 »Wheezy«"
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 »Wheezy«"
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/el.po b/po/el.po
index f5599eaf..a4a48cfd 100644
--- a/po/el.po
+++ b/po/el.po
@@ -357,8 +357,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/en_AU.po b/po/en_AU.po
index 05557e67..3dc30fba 100644
--- a/po/en_AU.po
+++ b/po/en_AU.po
@@ -389,7 +389,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/en_CA.po b/po/en_CA.po
index 17e4c85e..d272067b 100644
--- a/po/en_CA.po
+++ b/po/en_CA.po
@@ -409,7 +409,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian Stable Security Updates"
#. Description
diff --git a/po/eo.po b/po/eo.po
index 3eceb847..648006ad 100644
--- a/po/eo.po
+++ b/po/eo.po
@@ -362,8 +362,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debiano 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debiano 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/es.po b/po/es.po
index f33ae04f..16113198 100644
--- a/po/es.po
+++ b/po/es.po
@@ -382,8 +382,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 «Wheezy» "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 «Wheezy» "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/fi.po b/po/fi.po
index 3f018385..ba718ff2 100644
--- a/po/fi.po
+++ b/po/fi.po
@@ -356,8 +356,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 \"Wheezy\" "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 \"Wheezy\" "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/fr.po b/po/fr.po
index 116dff6f..6ba61f22 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -362,8 +362,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 « Wheezy »"
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 « Wheezy »"
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/gl.po b/po/gl.po
index 1fb36503..505ccc27 100644
--- a/po/gl.po
+++ b/po/gl.po
@@ -391,7 +391,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/he.po b/po/he.po
index f2d9a596..6942f568 100644
--- a/po/he.po
+++ b/po/he.po
@@ -395,7 +395,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "דביאן 3.1 \"סארג'\""
#. Description
diff --git a/po/hr.po b/po/hr.po
index a092208a..66c76e34 100644
--- a/po/hr.po
+++ b/po/hr.po
@@ -390,7 +390,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/hu.po b/po/hu.po
index f775801e..8045f25a 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -357,8 +357,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 „Wheezy” "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 „Wheezy” "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/id.po b/po/id.po
index 8eb83d70..56980963 100644
--- a/po/id.po
+++ b/po/id.po
@@ -359,8 +359,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/it.po b/po/it.po
index 3ce4df2f..2981eb3a 100644
--- a/po/it.po
+++ b/po/it.po
@@ -390,7 +390,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/ja.po b/po/ja.po
index 8171cc85..2a3b0333 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -360,8 +360,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/ka.po b/po/ka.po
index 904c50e0..d2844a68 100644
--- a/po/ka.po
+++ b/po/ka.po
@@ -391,7 +391,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/ko.po b/po/ko.po
index 2cd59397..46d26133 100644
--- a/po/ko.po
+++ b/po/ko.po
@@ -388,7 +388,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "데비안 3.1 \"Sarge\""
#. Description
diff --git a/po/ku.po b/po/ku.po
index 300f8dbc..9ba4a544 100644
--- a/po/ku.po
+++ b/po/ku.po
@@ -390,7 +390,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/lt.po b/po/lt.po
index 6a9e00b0..7fd8f1f6 100644
--- a/po/lt.po
+++ b/po/lt.po
@@ -394,7 +394,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 „Sarge“"
#. Description
diff --git a/po/lv.po b/po/lv.po
index fd0a5966..272b8c93 100644
--- a/po/lv.po
+++ b/po/lv.po
@@ -366,7 +366,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr ""
#. Description
diff --git a/po/mk.po b/po/mk.po
index 5fab2d56..bb6f0c94 100644
--- a/po/mk.po
+++ b/po/mk.po
@@ -405,7 +405,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/nb.po b/po/nb.po
index cb9cf12b..58e1b56a 100644
--- a/po/nb.po
+++ b/po/nb.po
@@ -406,7 +406,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/ne.po b/po/ne.po
index 13c876d6..e7de8d81 100644
--- a/po/ne.po
+++ b/po/ne.po
@@ -410,7 +410,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "डेबियन अचल सुरक्षा अद्यावधिकहरु"
#. Description
diff --git a/po/nl.po b/po/nl.po
index c9995edf..24f3e26a 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -357,8 +357,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/oc.po b/po/oc.po
index 8155fcd1..4b4647ce 100644
--- a/po/oc.po
+++ b/po/oc.po
@@ -393,7 +393,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/pl.po b/po/pl.po
index ed27d066..d6c4c480 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -362,8 +362,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 \"Wheezy\" "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 \"Wheezy\" "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/pt.po b/po/pt.po
index 5496a46c..aca824ff 100644
--- a/po/pt.po
+++ b/po/pt.po
@@ -387,7 +387,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/pt_BR.po b/po/pt_BR.po
index a19c5c2c..fe0d5ce1 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -357,8 +357,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/python-apt.pot b/po/python-apt.pot
index d9cc96c9..dab57174 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: 2013-08-05 22:44+0200\n"
+"POT-Creation-Date: 2015-06-10 15:57+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -25,346 +25,401 @@ msgstr ""
#. Description
#: ../data/templates/Ubuntu.info.in:33
+msgid "Ubuntu development series"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:140
+msgid "Ubuntu 15.10 'Wily Werewolf'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:147
+msgid "Cdrom with Ubuntu 15.10 'Wily Werewolf'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:249
+msgid "Ubuntu 15.04 'Vivid Vervet'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:256
+msgid "Cdrom with Ubuntu 15.04 'Vivid Vervet'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:368
+msgid "Ubuntu 14.10 'Utopic Unicorn'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:375
+msgid "Cdrom with Ubuntu 14.10 'Utopic Unicorn'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:487
+msgid "Ubuntu 14.04 'Trusty Tahr'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:494
+msgid "Cdrom with Ubuntu 14.04 'Trusty Tahr'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:606
+msgid "Ubuntu 13.10 'Saucy Salamander'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:613
+msgid "Cdrom with Ubuntu 13.10 'Saucy Salamander'"
+msgstr ""
+
+#. Description
+#: ../data/templates/Ubuntu.info.in:725
msgid "Ubuntu 13.04 'Raring Ringtail'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:40
+#: ../data/templates/Ubuntu.info.in:732
msgid "Cdrom with Ubuntu 13.04 'Raring Ringtail'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:152
+#: ../data/templates/Ubuntu.info.in:844
msgid "Ubuntu 12.10 'Quantal Quetzal'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:159
+#: ../data/templates/Ubuntu.info.in:851
msgid "Cdrom with Ubuntu 12.10 'Quantal Quetzal'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:270
+#: ../data/templates/Ubuntu.info.in:962
msgid "Ubuntu 12.04 'Precise Pangolin'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:277
+#: ../data/templates/Ubuntu.info.in:969
msgid "Cdrom with Ubuntu 12.04 'Precise Pangolin'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:388
+#: ../data/templates/Ubuntu.info.in:1080
msgid "Ubuntu 11.10 'Oneiric Ocelot'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:395
+#: ../data/templates/Ubuntu.info.in:1087
msgid "Cdrom with Ubuntu 11.10 'Oneiric Ocelot'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:507
+#: ../data/templates/Ubuntu.info.in:1199
msgid "Ubuntu 11.04 'Natty Narwhal'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:514
+#: ../data/templates/Ubuntu.info.in:1206
msgid "Cdrom with Ubuntu 11.04 'Natty Narwhal'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:605
+#: ../data/templates/Ubuntu.info.in:1297
msgid "Ubuntu 10.10 'Maverick Meerkat'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:625
+#: ../data/templates/Ubuntu.info.in:1317
msgid "Cdrom with Ubuntu 10.10 'Maverick Meerkat'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:637
+#: ../data/templates/Ubuntu.info.in:1329
msgid "Canonical Partners"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:639
+#: ../data/templates/Ubuntu.info.in:1331
msgid "Software packaged by Canonical for their partners"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:640
+#: ../data/templates/Ubuntu.info.in:1332
msgid "This software is not part of Ubuntu."
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:647
+#: ../data/templates/Ubuntu.info.in:1339
msgid "Independent"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:649
+#: ../data/templates/Ubuntu.info.in:1341
msgid "Provided by third-party software developers"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:650
+#: ../data/templates/Ubuntu.info.in:1342
msgid "Software offered by third party developers."
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:688
+#: ../data/templates/Ubuntu.info.in:1380
msgid "Ubuntu 10.04 'Lucid Lynx'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:708
+#: ../data/templates/Ubuntu.info.in:1400
msgid "Cdrom with Ubuntu 10.04 'Lucid Lynx'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:751
+#: ../data/templates/Ubuntu.info.in:1443
msgid "Ubuntu 9.10 'Karmic Koala'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:771
+#: ../data/templates/Ubuntu.info.in:1463
msgid "Cdrom with Ubuntu 9.10 'Karmic Koala'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:814
+#: ../data/templates/Ubuntu.info.in:1506
msgid "Ubuntu 9.04 'Jaunty Jackalope'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:833
+#: ../data/templates/Ubuntu.info.in:1525
msgid "Cdrom with Ubuntu 9.04 'Jaunty Jackalope'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:876
+#: ../data/templates/Ubuntu.info.in:1568
msgid "Ubuntu 8.10 'Intrepid Ibex'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:896
+#: ../data/templates/Ubuntu.info.in:1588
msgid "Cdrom with Ubuntu 8.10 'Intrepid Ibex'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:940
+#: ../data/templates/Ubuntu.info.in:1632
msgid "Ubuntu 8.04 'Hardy Heron'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:960
+#: ../data/templates/Ubuntu.info.in:1652
msgid "Cdrom with Ubuntu 8.04 'Hardy Heron'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1005
+#: ../data/templates/Ubuntu.info.in:1697
msgid "Ubuntu 7.10 'Gutsy Gibbon'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1024
+#: ../data/templates/Ubuntu.info.in:1716
msgid "Cdrom with Ubuntu 7.10 'Gutsy Gibbon'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1069
+#: ../data/templates/Ubuntu.info.in:1761
msgid "Ubuntu 7.04 'Feisty Fawn'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1088
+#: ../data/templates/Ubuntu.info.in:1780
msgid "Cdrom with Ubuntu 7.04 'Feisty Fawn'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1130
+#: ../data/templates/Ubuntu.info.in:1822
msgid "Ubuntu 6.10 'Edgy Eft'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1135
+#: ../data/templates/Ubuntu.info.in:1827
msgid "Community-maintained"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1141
+#: ../data/templates/Ubuntu.info.in:1833
msgid "Restricted software"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1149
+#: ../data/templates/Ubuntu.info.in:1841
msgid "Cdrom with Ubuntu 6.10 'Edgy Eft'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1191
+#: ../data/templates/Ubuntu.info.in:1883
msgid "Ubuntu 6.06 LTS 'Dapper Drake'"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:1194
+#: ../data/templates/Ubuntu.info.in:1886
msgid "Canonical-supported free and open-source software"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1196
+#: ../data/templates/Ubuntu.info.in:1888
msgid "Community-maintained (universe)"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:1197
+#: ../data/templates/Ubuntu.info.in:1889
msgid "Community-maintained free and open-source software"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1199
+#: ../data/templates/Ubuntu.info.in:1891
msgid "Non-free drivers"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:1200
+#: ../data/templates/Ubuntu.info.in:1892
msgid "Proprietary drivers for devices"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1202
+#: ../data/templates/Ubuntu.info.in:1894
msgid "Restricted software (Multiverse)"
msgstr ""
#. CompDescriptionLong
-#: ../data/templates/Ubuntu.info.in:1203
+#: ../data/templates/Ubuntu.info.in:1895
msgid "Software restricted by copyright or legal issues"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1210
+#: ../data/templates/Ubuntu.info.in:1902
msgid "Cdrom with Ubuntu 6.06 LTS 'Dapper Drake'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1226
+#: ../data/templates/Ubuntu.info.in:1918
msgid "Important security updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1231 ../data/templates/Debian.info.in:26
+#: ../data/templates/Ubuntu.info.in:1923 ../data/templates/Debian.info.in:56
msgid "Recommended updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1236
+#: ../data/templates/Ubuntu.info.in:1928
msgid "Pre-released updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1241
+#: ../data/templates/Ubuntu.info.in:1933
msgid "Unsupported updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1252
+#: ../data/templates/Ubuntu.info.in:1944
msgid "Ubuntu 5.10 'Breezy Badger'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1267
+#: ../data/templates/Ubuntu.info.in:1959
msgid "Cdrom with Ubuntu 5.10 'Breezy Badger'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1283
+#: ../data/templates/Ubuntu.info.in:1975
msgid "Ubuntu 5.10 Security Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1288
+#: ../data/templates/Ubuntu.info.in:1980
msgid "Ubuntu 5.10 Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1293
+#: ../data/templates/Ubuntu.info.in:1985
msgid "Ubuntu 5.10 Backports"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1304
+#: ../data/templates/Ubuntu.info.in:1996
msgid "Ubuntu 5.04 'Hoary Hedgehog'"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1319
+#: ../data/templates/Ubuntu.info.in:2011
msgid "Cdrom with Ubuntu 5.04 'Hoary Hedgehog'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1322 ../data/templates/Debian.info.in:179
+#: ../data/templates/Ubuntu.info.in:2014 ../data/templates/Debian.info.in:209
msgid "Officially supported"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1335
+#: ../data/templates/Ubuntu.info.in:2027
msgid "Ubuntu 5.04 Security Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1340
+#: ../data/templates/Ubuntu.info.in:2032
msgid "Ubuntu 5.04 Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1345
+#: ../data/templates/Ubuntu.info.in:2037
msgid "Ubuntu 5.04 Backports"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1351
+#: ../data/templates/Ubuntu.info.in:2043
msgid "Ubuntu 4.10 'Warty Warthog'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1357
+#: ../data/templates/Ubuntu.info.in:2049
msgid "Community-maintained (Universe)"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1359
+#: ../data/templates/Ubuntu.info.in:2051
msgid "Non-free (Multiverse)"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1366
+#: ../data/templates/Ubuntu.info.in:2058
msgid "Cdrom with Ubuntu 4.10 'Warty Warthog'"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1369
+#: ../data/templates/Ubuntu.info.in:2061
msgid "No longer officially supported"
msgstr ""
#. CompDescription
-#: ../data/templates/Ubuntu.info.in:1371
+#: ../data/templates/Ubuntu.info.in:2063
msgid "Restricted copyright"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1378
+#: ../data/templates/Ubuntu.info.in:2070
msgid "Ubuntu 4.10 Security Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1383
+#: ../data/templates/Ubuntu.info.in:2075
msgid "Ubuntu 4.10 Updates"
msgstr ""
#. Description
-#: ../data/templates/Ubuntu.info.in:1388
+#: ../data/templates/Ubuntu.info.in:2080
msgid "Ubuntu 4.10 Backports"
msgstr ""
@@ -376,66 +431,71 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 8 'jessie'"
msgstr ""
#. Description
#: ../data/templates/Debian.info.in:38
+msgid "Debian 7 'Wheezy' "
+msgstr ""
+
+#. Description
+#: ../data/templates/Debian.info.in:68
msgid "Debian 6.0 'Squeeze' "
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:63
+#: ../data/templates/Debian.info.in:93
msgid "Debian 5.0 'Lenny' "
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:88
+#: ../data/templates/Debian.info.in:118
msgid "Debian 4.0 'Etch'"
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:113
+#: ../data/templates/Debian.info.in:143
msgid "Debian 3.1 'Sarge'"
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:124
+#: ../data/templates/Debian.info.in:154
msgid "Proposed updates"
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:131
+#: ../data/templates/Debian.info.in:161
msgid "Security updates"
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:138
+#: ../data/templates/Debian.info.in:168
msgid "Debian current stable release"
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:151
+#: ../data/templates/Debian.info.in:181
msgid "Debian testing"
msgstr ""
#. Description
-#: ../data/templates/Debian.info.in:177
+#: ../data/templates/Debian.info.in:207
msgid "Debian 'Sid' (unstable)"
msgstr ""
#. CompDescription
-#: ../data/templates/Debian.info.in:181
+#: ../data/templates/Debian.info.in:211
msgid "DFSG-compatible Software with Non-Free Dependencies"
msgstr ""
#. CompDescription
-#: ../data/templates/Debian.info.in:183
+#: ../data/templates/Debian.info.in:213
msgid "Non-DFSG-compatible Software"
msgstr ""
#. TRANSLATORS: %s is a country
-#: ../aptsources/distro.py:211 ../aptsources/distro.py:441
+#: ../aptsources/distro.py:211 ../aptsources/distro.py:442
#, python-format
msgid "Server for %s"
msgstr ""
@@ -452,39 +512,16 @@ msgstr ""
msgid "Custom servers"
msgstr ""
-#: ../apt/progress/gtk2.py:258 ../apt/progress/gtk2.py:314
-#, python-format
-msgid "Downloading file %(current)li of %(total)li with %(speed)s/s"
-msgstr ""
-
-#: ../apt/progress/gtk2.py:264 ../apt/progress/gtk2.py:320
-#, python-format
-msgid "Downloading file %(current)li of %(total)li"
-msgstr ""
-
-#. Setup some child widgets
-#: ../apt/progress/gtk2.py:340
-msgid "Details"
-msgstr ""
-
-#: ../apt/progress/gtk2.py:428
-msgid "Starting..."
-msgstr ""
-
-#: ../apt/progress/gtk2.py:434
-msgid "Complete"
-msgstr ""
-
-#: ../apt/package.py:361
+#: ../apt/package.py:380
#, python-format
msgid "Invalid unicode in description for '%s' (%s). Please report."
msgstr ""
-#: ../apt/package.py:1093 ../apt/package.py:1199
+#: ../apt/package.py:951 ../apt/package.py:1057
msgid "The list of changes is not available"
msgstr ""
-#: ../apt/package.py:1205
+#: ../apt/package.py:1063
#, python-format
msgid ""
"The list of changes is not available yet.\n"
@@ -493,123 +530,120 @@ msgid ""
"until the changes become available or try again later."
msgstr ""
-#: ../apt/package.py:1212
+#: ../apt/package.py:1070
msgid ""
"Failed to download the list of changes. \n"
"Please check your Internet connection."
msgstr ""
-#: ../apt/debfile.py:85
+#: ../apt/debfile.py:89
#, python-format
msgid "List of files for '%s' could not be read"
msgstr ""
-#: ../apt/debfile.py:96
+#: ../apt/debfile.py:101
#, python-format
msgid "List of control files for '%s' could not be read"
msgstr ""
-#: ../apt/debfile.py:215
+#: ../apt/debfile.py:226
#, python-format
msgid "Dependency is not satisfiable: %s\n"
msgstr ""
-#: ../apt/debfile.py:236
+#: ../apt/debfile.py:249
#, python-format
msgid "Conflicts with the installed package '%s'"
msgstr ""
-#. TRANSLATORS: the first '%s' is the package that breaks, the second the dependency that makes it break, the third the relation (e.g. >=) and the latest the version for the releation
-#: ../apt/debfile.py:377
+#: ../apt/debfile.py:396
#, python-format
msgid ""
"Breaks existing package '%(pkgname)s' dependency %(depname)s "
"(%(deprelation)s %(depversion)s)"
msgstr ""
-#. TRANSLATORS: the first '%s' is the package that conflicts, the second the packagename that it conflicts with (so the name of the deb the user tries to install), the third is the relation (e.g. >=) and the last is the version for the relation
-#: ../apt/debfile.py:393
+#: ../apt/debfile.py:423
#, python-format
msgid ""
"Breaks existing package '%(pkgname)s' conflict: %(targetpkg)s (%(comptype)s "
"%(targetver)s)"
msgstr ""
-#: ../apt/debfile.py:403
+#: ../apt/debfile.py:437
#, python-format
msgid ""
"Breaks existing package '%(pkgname)s' that conflict: '%(targetpkg)s'. But "
"the '%(debfile)s' provides it via: '%(provides)s'"
msgstr ""
-#: ../apt/debfile.py:451
+#: ../apt/debfile.py:488
msgid "No Architecture field in the package"
msgstr ""
-#: ../apt/debfile.py:461
+#: ../apt/debfile.py:498
#, python-format
msgid "Wrong architecture '%s'"
msgstr ""
-#. the deb is older than the installed
-#: ../apt/debfile.py:468
+#: ../apt/debfile.py:506
msgid "A later version is already installed"
msgstr ""
-#: ../apt/debfile.py:493
+#: ../apt/debfile.py:531
msgid "Failed to satisfy all dependencies (broken cache)"
msgstr ""
-#: ../apt/debfile.py:523
+#: ../apt/debfile.py:560
#, python-format
msgid "Cannot install '%s'"
msgstr ""
-#: ../apt/debfile.py:597
+#: ../apt/debfile.py:636
msgid ""
"Automatically decompressed:\n"
"\n"
msgstr ""
-#: ../apt/debfile.py:603
+#: ../apt/debfile.py:642
msgid "Automatically converted to printable ascii:\n"
msgstr ""
-#: ../apt/debfile.py:693
+#: ../apt/debfile.py:746
#, python-format
msgid "Install Build-Dependencies for source package '%s' that builds %s\n"
msgstr ""
-#: ../apt/debfile.py:704
+#: ../apt/debfile.py:757
msgid "An essential package would be removed"
msgstr ""
-#: ../apt/progress/text.py:82
+#: ../apt/progress/text.py:89
#, python-format
msgid "%c%s... Done"
msgstr ""
-#: ../apt/progress/text.py:122
+#: ../apt/progress/text.py:129
msgid "Hit "
msgstr ""
-#: ../apt/progress/text.py:131
+#: ../apt/progress/text.py:138
msgid "Ign "
msgstr ""
-#: ../apt/progress/text.py:133
+#: ../apt/progress/text.py:140
msgid "Err "
msgstr ""
-#: ../apt/progress/text.py:144
+#: ../apt/progress/text.py:151
msgid "Get:"
msgstr ""
-#: ../apt/progress/text.py:203
+#: ../apt/progress/text.py:211
msgid " [Working]"
msgstr ""
-#: ../apt/progress/text.py:214
+#: ../apt/progress/text.py:222
#, python-format
msgid ""
"Media change: please insert the disc labeled\n"
@@ -618,19 +652,19 @@ msgid ""
msgstr ""
#. Trick for getting a translation from apt
-#: ../apt/progress/text.py:223
+#: ../apt/progress/text.py:231
#, python-format
msgid "Fetched %sB in %s (%sB/s)\n"
msgstr ""
-#: ../apt/progress/text.py:239
+#: ../apt/progress/text.py:247
msgid "Please provide a name for this Disc, such as 'Debian 2.1r1 Disk 1'"
msgstr ""
-#: ../apt/progress/text.py:255
+#: ../apt/progress/text.py:263
msgid "Please insert a Disc in the drive and press enter"
msgstr ""
-#: ../apt/cache.py:162
+#: ../apt/cache.py:163
msgid "Building data structures"
msgstr ""
diff --git a/po/ro.po b/po/ro.po
index 46c79e7e..05885f0c 100644
--- a/po/ro.po
+++ b/po/ro.po
@@ -392,7 +392,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/ru.po b/po/ru.po
index aa8be8e4..4a457f02 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -387,8 +387,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/sk.po b/po/sk.po
index d01acebb..a34b84b3 100644
--- a/po/sk.po
+++ b/po/sk.po
@@ -357,8 +357,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 „Wheezy“ "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 „Wheezy“ "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/sl.po b/po/sl.po
index ce5d7081..3c67f3ef 100644
--- a/po/sl.po
+++ b/po/sl.po
@@ -365,8 +365,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/sq.po b/po/sq.po
index 9f813577..5bf5e5d9 100644
--- a/po/sq.po
+++ b/po/sq.po
@@ -358,7 +358,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr ""
#. Description
diff --git a/po/sr.po b/po/sr.po
index 0726da4c..7e2fbcad 100644
--- a/po/sr.po
+++ b/po/sr.po
@@ -370,8 +370,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/sv.po b/po/sv.po
index 4bd106ca..08e858b4 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -390,7 +390,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/th.po b/po/th.po
index 424324e6..bfc7ca6c 100644
--- a/po/th.po
+++ b/po/th.po
@@ -388,7 +388,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "เดเบียน 3.1 \"Sarge\""
#. Description
diff --git a/po/tl.po b/po/tl.po
index 24260ca9..3273376e 100644
--- a/po/tl.po
+++ b/po/tl.po
@@ -357,8 +357,8 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
-msgid "Debian 7.0 'Wheezy' "
-msgstr "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
+msgstr "Debian 7 'Wheezy' "
#. Description
#: ../data/templates/Debian.info.in:33
diff --git a/po/tr.po b/po/tr.po
index 3dfe2d4d..aea46617 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -389,7 +389,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/uk.po b/po/uk.po
index 29b6c79c..9ed1185a 100644
--- a/po/uk.po
+++ b/po/uk.po
@@ -365,7 +365,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/vi.po b/po/vi.po
index 8d2eb836..31ac60cb 100644
--- a/po/vi.po
+++ b/po/vi.po
@@ -407,7 +407,7 @@ msgstr ""
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 « Sarge »"
#. Description
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 979beb23..004245ce 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -391,7 +391,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 \"Sarge\""
#. Description
diff --git a/po/zh_HK.po b/po/zh_HK.po
index 08083738..08190a3d 100644
--- a/po/zh_HK.po
+++ b/po/zh_HK.po
@@ -363,7 +363,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1「Sarge」"
#. Description
diff --git a/po/zh_TW.po b/po/zh_TW.po
index da3fe57a..8fb1060d 100644
--- a/po/zh_TW.po
+++ b/po/zh_TW.po
@@ -383,7 +383,7 @@ msgstr "http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog"
#. Description
#: ../data/templates/Debian.info.in:8
#, fuzzy
-msgid "Debian 7.0 'Wheezy' "
+msgid "Debian 7 'Wheezy' "
msgstr "Debian 3.1 “Sarge”"
#. Description
diff --git a/pre-build.sh b/pre-build.sh
index 1c5a9183..08c0bef6 100755
--- a/pre-build.sh
+++ b/pre-build.sh
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-dpkg-checkbuilddeps -d 'python-debian, python-feedparser'
+dpkg-checkbuilddeps -d 'python-debian, python3-feedparser'
echo "updating Ubuntu mirror list from launchpad"
if [ -n "$https_proxy" ]; then
diff --git a/python/acquire-item.cc b/python/acquire-item.cc
index 5e7423ab..d07f4c82 100644
--- a/python/acquire-item.cc
+++ b/python/acquire-item.cc
@@ -224,23 +224,43 @@ PyTypeObject PyAcquireItem_Type = {
static PyObject *acquirefile_new(PyTypeObject *type, PyObject *Args, PyObject * kwds)
{
PyObject *pyfetcher;
- char *uri, *md5, *descr, *shortDescr, *destDir, *destFile;
+ const char *uri, *hash, *md5, *descr, *shortDescr;
+ PyApt_Filename destDir, destFile;
int size = 0;
- uri = md5 = descr = shortDescr = destDir = destFile = "";
+ uri = hash = md5 = descr = shortDescr = destDir = destFile = "";
- char *kwlist[] = {"owner","uri", "md5", "size", "descr", "short_descr",
- "destdir", "destfile", NULL
+ // "md5" is only in this list for backward compatiblity, everyone should
+ // use "hash"
+ char *kwlist[] = {"owner", "uri", "hash", "size", "descr", "short_descr",
+ "destdir", "destfile", "md5", NULL
};
-
- if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist,
- &PyAcquire_Type, &pyfetcher, &uri, &md5,
- &size, &descr, &shortDescr, &destDir, &destFile) == 0)
+#if PY_MAJOR_VERSION >= 3
+ const char *fmt = "O!s|sissO&O&$s";
+#else
+ // no "$" support to indicate that the remaining args are keyword only
+ // in py2.x :/
+ const char *fmt = "O!s|sissO&O&s";
+#endif
+ if (PyArg_ParseTupleAndKeywords(Args, kwds, fmt, kwlist,
+ &PyAcquire_Type, &pyfetcher, &uri, &hash,
+ &size, &descr, &shortDescr,
+ PyApt_Filename::Converter, &destDir,
+ PyApt_Filename::Converter, &destFile,
+ &md5) == 0)
return 0;
+ // issue deprecation warning for md5
+ if (strlen(md5) > 0) {
+ PyErr_Warn(PyExc_DeprecationWarning,
+ "Using the md5 keyword is deprecated, please use 'hash' instead");
+ }
+ // support "md5" keyword for backward compatiblity
+ if (strlen(hash) == 0 && strlen(md5) != 0)
+ hash = md5;
pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyfetcher);
pkgAcqFile *af = new pkgAcqFile(fetcher, // owner
uri, // uri
- md5, // md5
+ hash, // hash
size, // size
descr, // descr
shortDescr,
@@ -320,41 +340,3 @@ PyTypeObject PyAcquireFile_Type = {
acquirefile_new, // tp_new
};
-#ifdef COMPAT_0_7
-char *doc_GetPkgAcqFile =
- "GetPkgAcqFile(pkgAquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) -> PkgAcqFile\n";
-PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgAcqFile() is "
- "deprecated. Please see apt_pkg.AcquireFile() for the "
- "replacement", 1);
- PyObject *pyfetcher;
- char *uri, *md5, *descr, *shortDescr, *destDir, *destFile;
- int size = 0;
- uri = md5 = descr = shortDescr = destDir = destFile = "";
-
- char * kwlist[] = {"owner","uri", "md5", "size", "descr", "shortDescr",
- "destDir", "destFile", NULL
- };
-
- if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist,
- &PyAcquire_Type, &pyfetcher, &uri, &md5,
- &size, &descr, &shortDescr, &destDir, &destFile) == 0)
- return 0;
-
- pkgAcquire *fetcher = GetCpp<pkgAcquire*>(pyfetcher);
- pkgAcqFile *af = new pkgAcqFile(fetcher, // owner
- uri, // uri
- md5, // md5
- size, // size
- descr, // descr
- shortDescr,
- destDir,
- destFile); // short-desc
- CppPyObject<pkgAcqFile*> *AcqFileObj = CppPyObject_NEW<pkgAcqFile*>(NULL, &PyAcquireFile_Type);
- AcqFileObj->Object = af;
- AcqFileObj->NoDelete = true;
-
- return AcqFileObj;
-}
-#endif
diff --git a/python/acquire.cc b/python/acquire.cc
index 45b4493c..621f0eef 100644
--- a/python/acquire.cc
+++ b/python/acquire.cc
@@ -244,10 +244,11 @@ static PyObject *PkgAcquireShutdown(PyObject *Self,PyObject *Args)
static PyMethodDef PkgAcquireMethods[] = {
{"run",PkgAcquireRun,METH_VARARGS,
"run() -> int\n\nRun the fetcher and return one of RESULT_CANCELLED,\n"
- "RESULT_CONTINUE, RESULT_FAILED. RESULT_CONTINUE means that all items\n"
- "which where queued prior to calling run() have been fetched\n"
- "successfully. RESULT_CANCELLED means that the process was canceled\n"
- "by the progress class. And RESULT_FAILED means a generic failure."},
+ "RESULT_CONTINUE, RESULT_FAILED.\n\n"
+ "RESULT_CONTINUE means that all items which where queued prior to\n"
+ "calling run() have been fetched successfully or failed transiently.\n\n"
+ "RESULT_CANCELLED means canceled by the progress class.\n\n"
+ "RESULT_FAILED means a generic failure."},
{"shutdown",PkgAcquireShutdown, METH_VARARGS,
"shutdown()\n\n"
"Shut the fetcher down, removing all items from it. Future access to\n"
@@ -400,12 +401,4 @@ PyTypeObject PyAcquire_Type = {
PkgAcquireNew, // tp_new
};
-#ifdef COMPAT_0_7
-PyObject *GetAcquire(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetAcquire() is deprecated."
- " Please see apt_pkg.Acquire() for the replacement.", 1);
- return PkgAcquireNew(&PyAcquire_Type,Args,0);
-}
-#endif
diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc
index 732f1bd0..8094550a 100644
--- a/python/apt_instmodule.cc
+++ b/python/apt_instmodule.cc
@@ -23,148 +23,7 @@
#include <Python.h>
/*}}}*/
-#ifdef COMPAT_0_7
-
-// debExtractControl - Exctract an arbitary control member /*{{{*/
-// ---------------------------------------------------------------------
-/* This is a common operation so this function will stay, but others that
- expose the full range of the apt-inst .deb processing will join it some
- day. */
-static char *doc_debExtractControl =
-"deb_extract_control(file[,member]) -> String\n"
-"Returns the indicated file from the control tar. The default is 'control'\n";
-static PyObject *debExtractControl(PyObject *Self,PyObject *Args)
-{
- char *Member = "control";
- PyObject *File;
- 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
- int fileno = PyObject_AsFileDescriptor(File);
- if (fileno == -1)
- return 0;
- FileFd Fd(fileno,false);
- debDebFile Deb(Fd);
- if (_error->PendingError() == true)
- return HandleErrors();
-
- debDebFile::MemControlExtract Extract(Member);
- if (Extract.Read(Deb) == false)
- return HandleErrors();
-
- // Build the return result
-
- if (Extract.Control == 0)
- {
- Py_INCREF(Py_None);
- Res = Py_None;
- }
- else
- Res = PyString_FromStringAndSize(Extract.Control,Extract.Length+2);
- }
-
- return HandleErrors(Res);
-}
- /*}}}*/
-
-// debExtractArchive - Exctract the archive /*{{{*/
-// ---------------------------------------------------------------------
-static char *doc_debExtractArchive =
-"deb_extract_archive(File,rootdir) -> Bool\n"
-"Extracts the Archive into the given root dir";
-static PyObject *debExtractArchive(PyObject *Self,PyObject *Args)
-{
- char *Rootdir = NULL;
- char cwd[512];
- PyObject *File;
- if (PyArg_ParseTuple(Args,"O|s",&File,&Rootdir) == 0)
- return 0;
-
- // Subscope makes sure any clean up errors are properly handled.
- bool res = false;
- {
- if(Rootdir != NULL)
- {
- getcwd(cwd, sizeof(cwd));
- chdir(Rootdir);
- }
-
- // Open the file and associate the .deb
- int fileno = PyObject_AsFileDescriptor(File);
- if (fileno == -1)
- return 0;
- FileFd Fd(fileno,false);
- debDebFile Deb(Fd);
- if (_error->PendingError() == true) {
- if (Rootdir != NULL)
- chdir (cwd);
- return HandleErrors();
- }
-
- // extracts relative to the current dir
- pkgDirStream Extract;
- res = Deb.ExtractArchive(Extract);
-
- if (Rootdir != NULL)
- chdir (cwd);
- if (res == false)
- return HandleErrors(PyBool_FromLong(res));
- }
- return HandleErrors(PyBool_FromLong(res));
-}
- /*}}}*/
-// arFindMember - Find member in AR archive /*{{{*/
-// ---------------------------------------------------------------------
-static char *doc_arCheckMember =
-"ar_check_member(file, membername) -> Bool\n";
-static PyObject *arCheckMember(PyObject *Self,PyObject *Args)
-{
- char *Member = NULL;
- bool res = false;
- PyObject *File;
- if (PyArg_ParseTuple(Args,"Os",&File,&Member) == 0)
- return 0;
-
- // Open the file and associate the .deb
- int fileno = PyObject_AsFileDescriptor(File);
- if (fileno == -1)
- return 0;
- FileFd Fd(fileno,false);
- ARArchive AR(Fd);
- if (_error->PendingError() == true)
- return HandleErrors();
-
- if(AR.FindMember(Member) != 0)
- res = true;
-
- return HandleErrors(PyBool_FromLong(res));
-}
- /*}}}*/
-
-// initapt_inst - Core Module Initialization /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyMethodDef methods[] =
-{
- // access to ar files
- {"arCheckMember", arCheckMember, METH_VARARGS, doc_arCheckMember},
-
- // access to deb files
- {"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl},
- {"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive},
-
- // access to tar streams
- {"tarExtract",tarExtract,METH_VARARGS,doc_tarExtract},
- {"debExtract",debExtract,METH_VARARGS,doc_debExtract},
- {}
-};
-#else
static PyMethodDef *methods = 0;
-#endif // defined(COMPAT_0_7)
static const char *apt_inst_doc =
@@ -193,7 +52,7 @@ static struct PyModuleDef moduledef = {
extern "C" PyObject * PyInit_apt_inst()
#else
extern "C" void initapt_inst()
-#define RETURN(x)
+#define RETURN(x) return
#endif
{
#if PY_MAJOR_VERSION >= 3
diff --git a/python/apt_instmodule.h b/python/apt_instmodule.h
index f6b337f4..ad4e9f72 100644
--- a/python/apt_instmodule.h
+++ b/python/apt_instmodule.h
@@ -14,12 +14,6 @@
#include "generic.h"
#include <apt-pkg/extracttar.h>
-#ifdef COMPAT_0_7
-PyObject *debExtract(PyObject *Self,PyObject *Args);
-extern char *doc_debExtract;
-PyObject *tarExtract(PyObject *Self,PyObject *Args);
-extern char *doc_tarExtract;
-#endif
extern PyTypeObject PyArMember_Type;
extern PyTypeObject PyArArchive_Type;
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index 1a991a48..8870a6e0 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -21,12 +21,13 @@
#include <apt-pkg/tagfile.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
-#include <apt-pkg/sha256.h>
+#include <apt-pkg/sha2.h>
#include <apt-pkg/init.h>
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/orderlist.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/gpgv.h>
#include <sys/stat.h>
#include <libintl.h>
@@ -53,23 +54,15 @@ static PyObject *py_gettext(PyObject *self, PyObject *Args) {
// newConfiguration - Build a new configuration class /*{{{*/
// ---------------------------------------------------------------------
-#ifdef COMPAT_0_7
-static char *doc_newConfiguration = "Construct a configuration instance";
-static PyObject *newConfiguration(PyObject *self,PyObject *args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.newConfiguration() is "
- "deprecated. Use apt_pkg.Configuration() instead.", 1);
- return CppPyObject_NEW<Configuration*>(NULL, &PyConfiguration_Type, new Configuration());
-}
-#endif
/*}}}*/
// Version Wrappers /*{{{*/
// These are kind of legacy..
static char *doc_VersionCompare =
"version_compare(a: str, b: str) -> int\n\n"
- "Compare the given versions; return -1 if 'a' is smaller than 'b',\n"
- "0 if they are equal, and 2 if 'a' is larger than 'b'.";
+ "Compare the given versions; return a strictly negative value if 'a' is \n"
+ "smaller than 'b', 0 if they are equal, and a strictly positive value if\n"
+ "'a' is larger than 'b'.";
static PyObject *VersionCompare(PyObject *Self,PyObject *Args)
{
char *A;
@@ -124,32 +117,6 @@ static PyObject *CheckDep(PyObject *Self,PyObject *Args)
return PyBool_FromLong(_system->VS->CheckDep(A,Op,B));
}
-#ifdef COMPAT_0_7
-static char *doc_CheckDepOld = "CheckDep(PkgVer,DepOp,DepVer) -> bool";
-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)
- {
- PyErr_SetString(PyExc_ValueError,"Bad comparision operation");
- return 0;
- }
-
- if (_system == 0)
- {
- PyErr_SetString(PyExc_ValueError,"_system not initialized");
- return 0;
- }
-
- return PyBool_FromLong(_system->VS->CheckDep(A,Op,B));
-}
-#endif
static char *doc_UpstreamVersion =
"upstream_version(ver: str) -> str\n\n"
@@ -163,17 +130,19 @@ static PyObject *UpstreamVersion(PyObject *Self,PyObject *Args)
}
static const char *doc_ParseDepends =
-"parse_depends(s: str) -> list\n"
+"parse_depends(s: str[, strip_multi_arch : bool = True]) -> list\n"
"\n"
"Parse the dependencies given by 's' and return a list of lists. Each of\n"
"these lists represents one or more options for an 'or' dependency in\n"
"the form of '(pkg, ver, comptype)' tuples. The tuple element 'pkg'\n"
"is the name of the package; the element 'ver' is the version, or ''\n"
"if no version was requested. The element 'ver' is a comparison\n"
-"operator ('<', '<=', '=', '>=', or '>').";
+"operator ('<', '<=', '=', '>=', or '>').\n\n"
+"If 'strip_multi_arch' is True, :any (and potentially other special values)\n"
+"will be stripped from the full package name";
static const char *parse_src_depends_doc =
-"parse_src_depends(s: str) -> list\n"
+"parse_src_depends(s: str[, strip_multi_arch : bool = True]) -> list\n"
"\n"
"Parse the dependencies given by 's' and return a list of lists. Each of\n"
"these lists represents one or more options for an 'or' dependency in\n"
@@ -184,10 +153,12 @@ static const char *parse_src_depends_doc =
"\n\n"
"Dependencies may be restricted to certain architectures and the result\n"
"only contains those dependencies for the architecture set in the\n"
-"configuration variable APT::Architecture";
+"configuration variable APT::Architecture\n\n"
+"If 'strip_multi_arch' is True, :any (and potentially other special values)\n"
+"will be stripped from the full package name";
static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
- bool ParseArchFlags, std::string name,
- bool debStyle=false)
+ bool ParseArchFlags, bool ParseRestrictionsList,
+ std::string name, bool debStyle=false)
{
std::string Package;
std::string Version;
@@ -210,7 +181,8 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
break;
Start = debListParser::ParseDepends(Start,Stop,Package,Version,Op,
- ParseArchFlags, StripMultiArch);
+ ParseArchFlags, StripMultiArch,
+ ParseRestrictionsList);
if (Start == 0)
{
PyErr_SetString(PyExc_ValueError,"Problem Parsing Dependency");
@@ -243,22 +215,12 @@ static PyObject *RealParseDepends(PyObject *Self,PyObject *Args,
}
static PyObject *ParseDepends(PyObject *Self,PyObject *Args)
{
- return RealParseDepends(Self, Args, false, "parse_depends");
+ return RealParseDepends(Self, Args, false, false, "parse_depends");
}
static PyObject *ParseSrcDepends(PyObject *Self,PyObject *Args)
{
- return RealParseDepends(Self, Args, true, "parse_src_depends");
+ return RealParseDepends(Self, Args, true, true, "parse_src_depends");
}
-#ifdef COMPAT_0_7
-static PyObject *ParseDepends_old(PyObject *Self,PyObject *Args)
-{
- return RealParseDepends(Self, Args, false, "ParseDepends", true);
-}
-static PyObject *ParseSrcDepends_old(PyObject *Self,PyObject *Args)
-{
- return RealParseDepends(Self, Args, true, "ParseSrcDepends", true);
-}
-#endif
/*}}}*/
// md5sum - Compute the md5sum of a file or string /*{{{*/
// ---------------------------------------------------------------------
@@ -350,7 +312,7 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args)
return 0;
}
/*}}}*/
-// sha256sum - Compute the sha1sum of a file or string /*{{{*/
+// sha256sum - Compute the sha256sum of a file or string /*{{{*/
// ---------------------------------------------------------------------
static const char *doc_sha256sum =
"sha256sum(object) -> str\n\n"
@@ -395,6 +357,51 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args)
return 0;
}
/*}}}*/
+// sha512sum - Compute the sha512sum of a file or string /*{{{*/
+// ---------------------------------------------------------------------
+static const char *doc_sha512sum =
+ "sha512sum(object) -> str\n\n"
+ "Return the sha512sum of the object. 'object' may either be a string, in\n"
+ "which case the sha512sum of the string is returned, or a file() object\n"
+ "(or file descriptor), in which case the sha512sum of its contents is\n"
+ "returned.";;
+static PyObject *sha512sum(PyObject *Self,PyObject *Args)
+{
+ PyObject *Obj;
+ if (PyArg_ParseTuple(Args,"O",&Obj) == 0)
+ return 0;
+
+ // Digest of a string.
+ if (PyBytes_Check(Obj) != 0)
+ {
+ char *s;
+ Py_ssize_t len;
+ SHA512Summation Sum;
+ PyBytes_AsStringAndSize(Obj, &s, &len);
+ Sum.Add((const unsigned char*)s, len);
+ return CppPyString(Sum.Result().Value());
+ }
+
+ // Digest of a file
+ int Fd = PyObject_AsFileDescriptor(Obj);
+ if (Fd != -1)
+ {
+ SHA512Summation Sum;
+ 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;
+}
+ /*}}}*/
// get_architectures - return the list of architectures /*{{{*/
// ---------------------------------------------------------------------
static const char *doc_GetArchitectures =
@@ -466,6 +473,25 @@ static PyObject *InitSystem(PyObject *Self,PyObject *Args)
return HandleErrors(Py_None);
}
/*}}}*/
+// gpgv.cc:OpenMaybeClearSignedFile /*{{{*/
+// ---------------------------------------------------------------------
+static char *doc_OpenMaybeClearSignedFile =
+"open_maybe_clear_signed_file(file: str) -> int\n\n"
+"Open a file and ignore a PGP clear signature.\n"
+"Return a open file descriptor or a error.";
+static PyObject *PyOpenMaybeClearSignedFile(PyObject *Self,PyObject *Args)
+{
+ PyApt_Filename file;
+ char errors = false;
+ if (PyArg_ParseTuple(Args,"O&",PyApt_Filename::Converter, &file,&errors) == 0)
+ return 0;
+
+ FileFd Fd;
+ if (OpenMaybeClearSignedFile(file, Fd) == false)
+ return HandleErrors(MkPyNumber(-1));
+
+ return HandleErrors(MkPyNumber(dup(Fd.Fd())));
+}
// fileutils.cc: GetLock /*{{{*/
// ---------------------------------------------------------------------
@@ -479,9 +505,9 @@ static char *doc_GetLock =
"provided by apt_pkg.FileLock instead using the with-statement.";
static PyObject *GetLock(PyObject *Self,PyObject *Args)
{
- const char *file;
+ PyApt_Filename file;
char errors = false;
- if (PyArg_ParseTuple(Args,"s|b",&file,&errors) == 0)
+ if (PyArg_ParseTuple(Args,"O&|b",PyApt_Filename::Converter, &file,&errors) == 0)
return 0;
int fd = GetLock(file, errors);
@@ -542,6 +568,9 @@ static PyMethodDef methods[] =
{"rewrite_section",RewriteSection,METH_VARARGS,doc_RewriteSection},
#endif
+ {"open_maybe_clear_signed_file",PyOpenMaybeClearSignedFile,METH_VARARGS,
+ doc_OpenMaybeClearSignedFile},
+
// Locking
{"get_lock",GetLock,METH_VARARGS,doc_GetLock},
{"pkgsystem_lock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock},
@@ -562,10 +591,11 @@ static PyMethodDef methods[] =
{"parse_depends",ParseDepends,METH_VARARGS,doc_ParseDepends},
{"parse_src_depends",ParseSrcDepends,METH_VARARGS,parse_src_depends_doc},
- // Stuff
+ // Hashes
{"md5sum",md5sum,METH_VARARGS,doc_md5sum},
{"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum},
{"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum},
+ {"sha512sum",sha512sum,METH_VARARGS,doc_sha512sum},
// multiarch
{"get_architectures", GetArchitectures, METH_VARARGS, doc_GetArchitectures},
@@ -617,57 +647,6 @@ static PyMethodDef methods[] =
"Convert the given RFC 1123 formatted string to a Unix timestamp."},
// 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},
-
- {"ParseSection",ParseSection,METH_VARARGS,doc_ParseSection},
- {"ParseTagFile",ParseTagFile,METH_VARARGS,doc_ParseTagFile},
-#ifdef HAVE_OPEN_MEMSTREAM
- {"RewriteSection",RewriteSection,METH_VARARGS,doc_RewriteSection},
-#endif
-
- {"GetLock",GetLock,METH_VARARGS,doc_GetLock},
- {"PkgSystemLock",PkgSystemLock,METH_VARARGS,doc_PkgSystemLock},
- {"PkgSystemUnLock",PkgSystemUnLock,METH_VARARGS,doc_PkgSystemUnLock},
-
- {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig},
- {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir},
- {"ReadConfigFileISC",LoadConfigISC,METH_VARARGS,doc_LoadConfig},
- {"ParseCommandLine",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine},
-
- {"VersionCompare",VersionCompare,METH_VARARGS,doc_VersionCompare},
- {"UpstreamVersion",UpstreamVersion,METH_VARARGS,doc_UpstreamVersion},
-
- {"ParseDepends",ParseDepends_old,METH_VARARGS,doc_ParseDepends},
- {"ParseSrcDepends",ParseSrcDepends_old,METH_VARARGS,doc_ParseDepends},
-
- {"CheckDomainList",StrCheckDomainList,METH_VARARGS,
- "CheckDomainList(String,String) -> Bool"},
- {"QuoteString",StrQuoteString,METH_VARARGS,"QuoteString(String,String) -> String"},
- {"DeQuoteString",StrDeQuote,METH_VARARGS,"DeQuoteString(String) -> String"},
- {"SizeToStr",StrSizeToStr,METH_VARARGS,"SizeToStr(int) -> String"},
- {"TimeToStr",StrTimeToStr,METH_VARARGS,"TimeToStr(int) -> String"},
- {"URItoFileName",StrURItoFileName,METH_VARARGS,"URItoFileName(String) -> String"},
- {"Base64Encode",StrBase64Encode,METH_VARARGS,"Base64Encode(String) -> String"},
- {"StringToBool",StrStringToBool,METH_VARARGS,"StringToBool(String) -> int"},
- {"TimeRFC1123",StrTimeRFC1123,METH_VARARGS,"TimeRFC1123(int) -> String"},
- {"StrToTime",StrStrToTime,METH_VARARGS,"StrToTime(String) -> Int"},
-
- {"GetCache",TmpGetCache,METH_VARARGS,"GetCache() -> PkgCache"},
- {"GetDepCache",GetDepCache,METH_VARARGS,"GetDepCache(Cache) -> DepCache"},
- {"GetPkgRecords",GetPkgRecords,METH_VARARGS,"GetPkgRecords(Cache) -> PkgRecords"},
- {"GetPkgSrcRecords",GetPkgSrcRecords,METH_VARARGS,"GetPkgSrcRecords() -> PkgSrcRecords"},
- {"GetPkgSourceList",GetPkgSourceList,METH_VARARGS,"GetPkgSourceList() -> PkgSourceList"},
- {"GetPkgProblemResolver",GetPkgProblemResolver,METH_VARARGS,"GetDepProblemResolver(DepCache) -> PkgProblemResolver"},
- {"GetPkgActionGroup",GetPkgActionGroup,METH_VARARGS,"GetPkgActionGroup(DepCache) -> PkgActionGroup"},
- {"GetCdrom",GetCdrom,METH_VARARGS,"GetCdrom() -> Cdrom"},
- {"GetAcquire",GetAcquire,METH_VARARGS,"GetAcquire() -> Acquire"},
- {"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS, doc_GetPkgAcqFile},
- {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager(DepCache) -> PackageManager"},
- #endif
{}
};
@@ -825,10 +804,6 @@ extern "C" void initapt_pkg()
// Global configuration, should never be deleted.
Config->NoDelete = true;
PyModule_AddObject(Module,"config",Config);
- #ifdef COMPAT_0_7
- Py_INCREF(Config);
- PyModule_AddObject(Module,"Config",Config);
- #endif
@@ -908,14 +883,6 @@ extern "C" void initapt_pkg()
MkPyNumber(pkgAcquire::Continue));
PyDict_SetItemString(PyAcquire_Type.tp_dict, "RESULT_FAILED",
MkPyNumber(pkgAcquire::Failed));
-#ifdef COMPAT_0_7
- PyDict_SetItemString(PyAcquire_Type.tp_dict, "ResultCancelled",
- MkPyNumber(pkgAcquire::Cancelled));
- PyDict_SetItemString(PyAcquire_Type.tp_dict, "ResultContinue",
- MkPyNumber(pkgAcquire::Continue));
- PyDict_SetItemString(PyAcquire_Type.tp_dict, "ResultFailed",
- MkPyNumber(pkgAcquire::Failed));
-#endif
// Dependency constants
PyDict_SetItemString(PyDependency_Type.tp_dict, "TYPE_DEPENDS",
MkPyNumber(pkgCache::Dep::Depends));
@@ -945,15 +912,9 @@ extern "C" void initapt_pkg()
PyDict_SetItemString(PyPackageManager_Type.tp_dict, "RESULT_INCOMPLETE",
MkPyNumber(pkgPackageManager::Incomplete));
-#ifdef COMPAT_0_7
- PyDict_SetItemString(PyPackageManager_Type.tp_dict, "ResultCompleted",
- MkPyNumber(pkgPackageManager::Completed));
- PyDict_SetItemString(PyPackageManager_Type.tp_dict, "ResultFailed",
- MkPyNumber(pkgPackageManager::Failed));
- PyDict_SetItemString(PyPackageManager_Type.tp_dict, "ResultIncomplete",
- MkPyNumber(pkgPackageManager::Incomplete));
-#endif
-
+ PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_NO",
+ MkPyNumber(pkgCache::Version::None));
+ // NONE is deprecated (#782802)
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_NONE",
MkPyNumber(pkgCache::Version::None));
PyDict_SetItemString(PyVersion_Type.tp_dict, "MULTI_ARCH_ALL",
@@ -982,18 +943,6 @@ extern "C" void initapt_pkg()
PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "STAT_AUTH_ERROR",
MkPyNumber(pkgAcquire::Item::StatAuthError));
-#ifdef COMPAT_0_7
- PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatIdle",
- MkPyNumber(pkgAcquire::Item::StatIdle));
- PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatFetching",
- MkPyNumber(pkgAcquire::Item::StatFetching));
- PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatDone",
- MkPyNumber(pkgAcquire::Item::StatDone));
- PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatError",
- MkPyNumber(pkgAcquire::Item::StatError));
- PyDict_SetItemString(PyAcquireItem_Type.tp_dict, "StatAuthError",
- MkPyNumber(pkgAcquire::Item::StatAuthError));
-#endif
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 1
PyObject *PyCapsule = PyCapsule_New(&API, "apt_pkg._C_API", NULL);
@@ -1004,8 +953,13 @@ extern "C" void initapt_pkg()
// Version..
PyModule_AddStringConstant(Module,"VERSION",(char *)pkgVersion);
PyModule_AddStringConstant(Module,"LIB_VERSION",(char *)pkgLibVersion);
- PyModule_AddStringConstant(Module,"DATE",__DATE__);
- PyModule_AddStringConstant(Module,"TIME",__TIME__);
+#ifdef DATE
+ PyModule_AddStringConstant(Module,"DATE",DATE);
+ PyModule_AddStringConstant(Module,"TIME",TIME);
+#else
+ PyModule_AddStringConstant(Module,"DATE", "Jan 1 1970");
+ PyModule_AddStringConstant(Module,"TIME", "00:00:00");
+#endif
// My constants
PyModule_AddIntConstant(Module,"PRI_IMPORTANT",pkgCache::State::Important);
@@ -1033,39 +987,6 @@ extern "C" void initapt_pkg()
PyModule_AddIntConstant(Module,"INSTSTATE_HOLD_REINSTREQ",pkgCache::State::HoldReInstReq);
- // DEPRECATED API
- #ifdef COMPAT_0_7
- PyModule_AddObject(Module,"RewritePackageOrder",
- CharCharToList(TFRewritePackageOrder));
- PyModule_AddObject(Module,"RewriteSourceOrder",
- CharCharToList(TFRewriteSourceOrder));
- PyModule_AddStringConstant(Module,"LibVersion",(char *)pkgLibVersion);
- PyModule_AddStringConstant(Module,"Date",__DATE__);
- PyModule_AddStringConstant(Module,"Time",__TIME__);
- PyModule_AddIntConstant(Module,"PriImportant",pkgCache::State::Important);
- PyModule_AddIntConstant(Module,"PriRequired",pkgCache::State::Required);
- PyModule_AddIntConstant(Module,"PriStandard",pkgCache::State::Standard);
- PyModule_AddIntConstant(Module,"PriOptional",pkgCache::State::Optional);
- PyModule_AddIntConstant(Module,"PriExtra",pkgCache::State::Extra);
- PyModule_AddIntConstant(Module,"CurStateNotInstalled",pkgCache::State::NotInstalled);
- PyModule_AddIntConstant(Module,"CurStateUnPacked",pkgCache::State::UnPacked);
- PyModule_AddIntConstant(Module,"CurStateHalfConfigured",pkgCache::State::HalfConfigured);
- PyModule_AddIntConstant(Module,"CurStateHalfInstalled",pkgCache::State::HalfInstalled);
- PyModule_AddIntConstant(Module,"CurStateConfigFiles",pkgCache::State::ConfigFiles);
- PyModule_AddIntConstant(Module,"CurStateInstalled",pkgCache::State::Installed);
- PyModule_AddIntConstant(Module,"SelStateUnknown",pkgCache::State::Unknown);
- PyModule_AddIntConstant(Module,"SelStateInstall",pkgCache::State::Install);
- PyModule_AddIntConstant(Module,"SelStateHold",pkgCache::State::Hold);
- PyModule_AddIntConstant(Module,"SelStateDeInstall",pkgCache::State::DeInstall);
- PyModule_AddIntConstant(Module,"SelStatePurge",pkgCache::State::Purge);
- PyModule_AddIntConstant(Module,"InstStateOk",pkgCache::State::Ok);
- PyModule_AddIntConstant(Module,"InstStateReInstReq",pkgCache::State::ReInstReq);
- PyModule_AddIntConstant(Module,"InstStateHold",pkgCache::State::Hold);
- PyModule_AddIntConstant(Module,"InstStateHoldReInstReq",pkgCache::State::HoldReInstReq);
- PyModule_AddIntConstant(Module,"_COMPAT_0_7",1);
- #else
- PyModule_AddIntConstant(Module,"_COMPAT_0_7",0);
- #endif
#if PY_MAJOR_VERSION >= 3
return Module;
#endif
diff --git a/python/arfile.cc b/python/arfile.cc
index 96702f57..d4d7eed6 100644
--- a/python/arfile.cc
+++ b/python/arfile.cc
@@ -147,14 +147,14 @@ static const char *ararchive_getmember_doc =
"LookupError if there is no ArMember with the given name.";
static PyObject *ararchive_getmember(PyArArchiveObject *self, PyObject *arg)
{
- const char *name;
+ PyApt_Filename name;
CppPyObject<ARArchive::Member*> *ret;
- if (! (name = PyObject_AsString(arg)))
+ if (!name.init(arg))
return 0;
const ARArchive::Member *member = self->Object->FindMember(name);
if (!member) {
- PyErr_Format(PyExc_LookupError,"No member named '%s'",name);
+ PyErr_Format(PyExc_LookupError,"No member named '%s'",name.path);
return 0;
}
@@ -171,18 +171,30 @@ static const char *ararchive_extractdata_doc =
"LookupError if there is no ArMember with the given name.";
static PyObject *ararchive_extractdata(PyArArchiveObject *self, PyObject *args)
{
- char *name = 0;
- if (PyArg_ParseTuple(args, "s:extractdata", &name) == 0)
+ PyApt_Filename name;
+ if (PyArg_ParseTuple(args, "O&:extractdata", PyApt_Filename::Converter, &name) == 0)
return 0;
const ARArchive::Member *member = self->Object->FindMember(name);
if (!member) {
- PyErr_Format(PyExc_LookupError,"No member named '%s'",name);
+ PyErr_Format(PyExc_LookupError,"No member named '%s'",name.path);
+ return 0;
+ }
+ if (member->Size > SIZE_MAX) {
+ PyErr_Format(PyExc_MemoryError,
+ "Member '%s' is too large to read into memory",name.path);
return 0;
}
if (!self->Fd.Seek(member->Start))
return HandleErrors();
- char* value = new char[member->Size];
+ char* value;
+ try {
+ value = new char[member->Size];
+ } catch (std::bad_alloc&) {
+ PyErr_Format(PyExc_MemoryError,
+ "Member '%s' is too large to read into memory",name.path);
+ return 0;
+ }
self->Fd.Read(value, member->Size, true);
PyObject *result = PyBytes_FromStringAndSize(value, member->Size);
delete[] value;
@@ -221,18 +233,19 @@ static PyObject *_extract(FileFd &Fd, const ARArchive::Member *member,
// Read 4 KiB from the file, until all of the file is read. Deallocated
// automatically when the function returns.
SPtrArray<char> value = new char[4096];
- unsigned long size = member->Size;
- unsigned long read = 4096;
+ unsigned long long size = member->Size;
+ unsigned long long read = 4096;
while (size > 0) {
if (size < read)
read = size;
if (!Fd.Read(value, read, true))
return HandleErrors();
- if (write(outfd, value, read) != (signed)read)
+ if (write(outfd, value, read) != (signed long long)read)
return PyErr_SetFromErrnoWithFilename(PyExc_OSError, outfile);
size -= read;
}
- utimbuf time = {member->MTime, member->MTime};
+ utimbuf time = {static_cast<time_t>(member->MTime),
+ static_cast<time_t>(member->MTime)};
if (utime(outfile,&time) == -1)
return PyErr_SetFromErrnoWithFilename(PyExc_OSError, outfile);
Py_RETURN_TRUE;
@@ -247,15 +260,17 @@ static const char *ararchive_extract_doc =
"does not exist, raise LookupError.";
static PyObject *ararchive_extract(PyArArchiveObject *self, PyObject *args)
{
- char *name = 0;
- char *target = "";
- if (PyArg_ParseTuple(args, "s|s:extract", &name, &target) == 0)
+ PyApt_Filename name;
+ PyApt_Filename target;
+
+ target = "";
+ if (PyArg_ParseTuple(args, "O&|O&:extract", PyApt_Filename::Converter, &name, PyApt_Filename::Converter, &target) == 0)
return 0;
const ARArchive::Member *member = self->Object->FindMember(name);
if (!member) {
- PyErr_Format(PyExc_LookupError,"No member named '%s'",name);
+ PyErr_Format(PyExc_LookupError,"No member named '%s'",name.path);
return 0;
}
return _extract(self->Fd, member, target);
@@ -269,8 +284,9 @@ static const char *ararchive_extractall_doc =
static PyObject *ararchive_extractall(PyArArchiveObject *self, PyObject *args)
{
- char *target = "";
- if (PyArg_ParseTuple(args, "|s:extractall", &target) == 0)
+ PyApt_Filename target;
+ target = "";
+ if (PyArg_ParseTuple(args, "|O&:extractall", PyApt_Filename::Converter, &target) == 0)
return 0;
const ARArchive::Member *member = self->Object->Members();
@@ -292,14 +308,14 @@ static const char *ararchive_gettar_doc =
"It just opens a new TarFile on the given position in the stream.";
static PyObject *ararchive_gettar(PyArArchiveObject *self, PyObject *args)
{
- const char *name;
+ PyApt_Filename name;
const char *comp;
- if (PyArg_ParseTuple(args, "ss:gettar", &name, &comp) == 0)
+ if (PyArg_ParseTuple(args, "O&s:gettar", PyApt_Filename::Converter, &name, &comp) == 0)
return 0;
const ARArchive::Member *member = self->Object->FindMember(name);
if (!member) {
- PyErr_Format(PyExc_LookupError,"No member named '%s'",name);
+ PyErr_Format(PyExc_LookupError,"No member named '%s'",name.path);
return 0;
}
@@ -374,13 +390,13 @@ static PyObject *ararchive_new(PyTypeObject *type, PyObject *args,
{
PyObject *file;
PyArArchiveObject *self;
- char *filename = 0;
+ PyApt_Filename filename;
int fileno;
if (PyArg_ParseTuple(args,"O:__new__",&file) == 0)
return 0;
// We receive a filename.
- if ((filename = (char*)PyObject_AsString(file))) {
+ if (filename.init(file)) {
self = (PyArArchiveObject *)CppPyObject_NEW<ARArchive*>(0,type);
new (&self->Fd) FileFd(filename,FileFd::ReadOnly);
}
@@ -409,8 +425,8 @@ static void ararchive_dealloc(PyObject *self)
// Return bool or -1 (exception).
static int ararchive_contains(PyObject *self, PyObject *arg)
{
- const char *name = PyObject_AsString(arg);
- if (!name)
+ PyApt_Filename name;
+ if (!name.init(arg))
return -1;
return (GetCpp<ARArchive*>(self)->FindMember(name) != 0);
}
@@ -519,6 +535,45 @@ static PyObject *_gettar(PyDebFileObject *self, const ARArchive::Member *m,
return tarfile;
}
+/*
+ * Mostly copy-paste from APT
+ */
+static PyObject *debfile_get_tar(PyDebFileObject *self, const char *Name)
+{
+ // Get the archive member
+ const ARArchive::Member *Member = NULL;
+ const ARArchive &AR = *self->Object;
+ std::string Compressor;
+
+ std::vector<APT::Configuration::Compressor> compressor =
+ APT::Configuration::getCompressors();
+ for (std::vector<APT::Configuration::Compressor>::const_iterator c =
+ compressor.begin(); c != compressor.end(); ++c) {
+ Member = AR.FindMember(std::string(Name).append(c->Extension).c_str());
+ if (Member == NULL)
+ continue;
+ Compressor = c->Binary;
+ break;
+ }
+
+ if (Member == NULL)
+ Member = AR.FindMember(std::string(Name).c_str());
+
+ if (Member == NULL) {
+ std::string ext = std::string(Name) + ".{";
+ for (std::vector<APT::Configuration::Compressor>::const_iterator c =
+ compressor.begin(); c != compressor.end(); ++c) {
+ if (!c->Extension.empty())
+ ext.append(c->Extension.substr(1));
+ }
+ ext.append("}");
+ _error->Error(("Internal error, could not locate member %s"),
+ ext.c_str());
+ return HandleErrors();
+ }
+
+ return _gettar(self, Member, Compressor.c_str());
+}
static PyObject *debfile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
@@ -528,34 +583,13 @@ static PyObject *debfile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
// 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");
-
- // try all compression types
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin();
- t != types.end(); ++t) {
- std::string member = std::string("data.tar.").append(*t);
- std::string comp = _config->Find(std::string("Acquire::CompressionTypes::").append(*t));
- self->data = _gettar(self, self->Object->FindMember(member.c_str()),
- comp.c_str());
- if (self->data)
- break;
- }
- // no data found, we need to
- if (!self->data) {
- std::string error;
- for (std::vector<std::string>::const_iterator t = types.begin();
- t != types.end(); ++t)
- error.append(*t + ",");
- return PyErr_Format(PyExc_SystemError,
- "No debian archive, missing data.tar.{%s}",
- error.c_str());
- }
+ self->control = debfile_get_tar(self, "control.tar");
+ if (self->control == NULL)
+ return NULL;
+ self->data = debfile_get_tar(self, "data.tar");
+ if (self->data == NULL)
+ return NULL;
const ARArchive::Member *member = self->Object->FindMember("debian-binary");
if (!member)
diff --git a/python/cache.cc b/python/cache.cc
index 01330adb..e03462a5 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -49,7 +49,7 @@ template<typename T> struct IterListStruct
IterListStruct() : LastIndex(0) {};
bool move(unsigned long Index) {
- if (Index < 0 || (unsigned)Index >= Count())
+ if ((unsigned)Index >= Count())
{
PyErr_SetNone(PyExc_IndexError);
return false;
@@ -161,63 +161,10 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args)
return HandleErrors(PyRes);
}
-#ifdef COMPAT_0_7
-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<pkgCache*>(Self);
- pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy);
- Cache->Close();
-
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
-}
-
-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<pkgCache*>(Self);
- pkgCacheFile *Cache = GetCpp<pkgCacheFile*>(CacheFilePy);
-
- PyObject *pyCallbackInst = 0;
- if (PyArg_ParseTuple(Args, "|O", &pyCallbackInst) == 0)
- return 0;
-
- if(pyCallbackInst != 0) {
- PyOpProgress progress;
- progress.setCallbackInst(pyCallbackInst);
- if (Cache->Open(progress,false) == false)
- return HandleErrors();
- } else {
- OpTextProgress Prog;
- if (Cache->Open(Prog,false) == false)
- return HandleErrors();
- }
-
- //std::cout << "new cache is " << (pkgCache*)(*Cache) << std::endl;
-
- // ensure that the states are correct (LP: #659438)
- pkgApplyStatus(*Cache);
-
- // update the cache pointer after the cache was rebuild
- ((CppPyObject<pkgCache*> *)Self)->Object = (pkgCache*)(*Cache);
-
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
-}
-#endif
static PyMethodDef PkgCacheMethods[] =
{
{"update",PkgCacheUpdate,METH_VARARGS,cache_update_doc},
-#ifdef COMPAT_0_7
- {"Open", PkgCacheOpen, METH_VARARGS,
- "Open the cache; deprecated and unsafe"},
- {"Close", PkgCacheClose, METH_VARARGS,"Close the cache"},
-#endif
{}
};
@@ -233,8 +180,12 @@ static PyObject *PkgCacheGetGroups(PyObject *Self, void*) {
static PyObject *PkgCacheGetPolicy(PyObject *Self, void*) {
pkgCacheFile *CacheFile = GetCpp<pkgCacheFile *>(Self);
- std::cerr << "policy: " << CacheFile->Policy << std::endl;
- return CppPyObject_NEW<pkgPolicy*>(Self,&PyPolicy_Type,CacheFile->Policy);
+ CppPyObject<pkgPolicy*> *obj;
+
+ obj = CppPyObject_NEW<pkgPolicy*>(Self,&PyPolicy_Type,CacheFile->Policy);
+ obj->NoDelete = true;
+
+ return obj;
}
static PyObject *PkgCacheGetPackages(PyObject *Self, void*) {
@@ -378,7 +329,7 @@ static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
if (pyCallbackInst == Py_None) {
OpProgress Prog;
- if (Cache->Open(Prog,false) == false)
+ if (Cache->Open(&Prog,false) == false)
return HandleErrors();
} else if(pyCallbackInst != 0) {
// sanity check for the progress object, see #497049
@@ -394,12 +345,12 @@ static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
}
PyOpProgress progress;
progress.setCallbackInst(pyCallbackInst);
- if (Cache->Open(progress,false) == false)
+ if (Cache->Open(&progress,false) == false)
return HandleErrors();
}
else {
OpTextProgress Prog;
- if (Cache->Open(Prog,false) == false)
+ if (Cache->Open(&Prog,false) == false)
return HandleErrors();
}
@@ -645,7 +596,16 @@ PyTypeObject PyGroupList_Type =
MkGet(PackageGetName,PyString_FromString(Pkg.Name()))
MkGet(PackageGetArch,PyString_FromString(Pkg.Arch()))
-MkGet(PackageGetSection,Safe_FromString(Pkg.Section()))
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+static PyObject *PackageGetSection(PyObject *Self,void*)
+{
+ pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self);
+ if (PyErr_WarnEx(PyExc_DeprecationWarning, "Package.section is deprecated, use Version.section instead", 1) == -1)
+ return NULL;
+ return Safe_FromString(Pkg.Section());
+}
+#pragma GCC diagnostic pop
MkGet(PackageGetRevDependsList,CppPyObject_NEW<RDepListStruct>(Owner,
&PyDependencyList_Type, Pkg.RevDependsList()))
MkGet(PackageGetProvidesList,CreateProvides(Owner,Pkg.ProvidesList()))
@@ -654,7 +614,6 @@ MkGet(PackageGetInstState,MkPyNumber(Pkg->InstState))
MkGet(PackageGetCurrentState,MkPyNumber(Pkg->CurrentState))
MkGet(PackageGetID,MkPyNumber(Pkg->ID))
#
-MkGet(PackageGetAuto,PyBool_FromLong((Pkg->Flags & pkgCache::Flag::Auto) != 0))
MkGet(PackageGetEssential,PyBool_FromLong((Pkg->Flags & pkgCache::Flag::Essential) != 0))
MkGet(PackageGetImportant,PyBool_FromLong((Pkg->Flags & pkgCache::Flag::Important) != 0))
#undef MkGet
@@ -755,9 +714,6 @@ static PyGetSetDef PackageGetSet[] = {
"CURSTATE_UNPACKED of the apt_pkg module."},
{"id",PackageGetID,0,
"The numeric ID of the package"},
- {"auto",PackageGetAuto,0,
- "Ignore it, it does nothing. You want to use\n"
- "DepCache.is_auto_installed instead."},
{"essential",PackageGetEssential,0,
"Boolean value determining whether the package is essential."},
{"important",PackageGetImportant,0,
@@ -777,11 +733,8 @@ static PyGetSetDef PackageGetSet[] = {
static PyObject *PackageRepr(PyObject *Self)
{
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self);
-
- return PyString_FromFormat("<%s object: name:'%s' section: "
- "'%s' id:%u>", Self->ob_type->tp_name,
- Pkg.Name(), (Pkg.Section() ? Pkg.Section() : ""),
- Pkg->ID);
+ return PyString_FromFormat("<%s object: name:'%s' id:%u>", Self->ob_type->tp_name,
+ Pkg.Name(), Pkg->ID);
}
static const char *package_doc =
@@ -1506,7 +1459,8 @@ static PyObject *DependencyGetID(PyObject *Self,void*)
static PyGetSetDef DependencyGetSet[] = {
{"comp_type",DependencyGetCompType,0,
- "The type of comparison, as a string (one of '<', '<=', '=', '>=', '>')."},
+ "The type of comparison, as a string, namely one of:\n"
+ "'<', '<=', '=', '!=', '>=', '>', ''."},
{"dep_type",DependencyGetDepType,0,
"The type of the dependency; may be translated"},
{"dep_type_untranslated",DependencyGetDepTypeUntranslated,0,
@@ -1654,11 +1608,3 @@ PyTypeObject PyDependencyList_Type =
/*}}}*/
-#ifdef COMPAT_0_7
-PyObject *TmpGetCache(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCache() is deprecated. "
- "Please see apt_pkg.Cache() for the replacement.", 1);
- return PkgCacheNew(&PyCache_Type,Args,0);
-}
-#endif
diff --git a/python/cdrom.cc b/python/cdrom.cc
index 46bb769c..392dd834 100644
--- a/python/cdrom.cc
+++ b/python/cdrom.cc
@@ -78,38 +78,10 @@ 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<pkgCdrom>(Self);
-
- PyObject *pyCdromProgressInst = 0;
- if (PyArg_ParseTuple(Args, "O", &pyCdromProgressInst) == 0) {
- return 0;
- }
-
- PyCdromProgress progress;
- progress.setCallbackInst(pyCdromProgressInst);
-
- std::string ident;
- bool res = Cdrom.Ident(ident, &progress);
-
- PyObject *boolres = PyBool_FromLong(res);
- PyObject *result = Py_BuildValue("(Os)", boolres, ident.c_str());
-
- return HandleErrors(result);
-}
-#endif
static PyMethodDef cdrom_methods[] = {
{"add",cdrom_add,METH_VARARGS,cdrom_add_doc},
{"ident",cdrom_ident,METH_VARARGS,cdrom_ident_doc},
-#ifdef COMPAT_0_7
- {"Ident",cdrom_ident_old,METH_VARARGS,"DEPRECATED. DO NOT USE"},
-#endif
{}
};
@@ -165,11 +137,3 @@ PyTypeObject PyCdrom_Type = {
cdrom_new, // tp_new
};
-#ifdef COMPAT_0_7
-PyObject *GetCdrom(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetCdrom() is deprecated. "
- "Please see apt_pkg.Cdrom() for the replacement.", 1);
- return cdrom_new(&PyCdrom_Type,Args,0);
-}
-#endif
diff --git a/python/configuration.cc b/python/configuration.cc
index 37374625..c57bc79c 100644
--- a/python/configuration.cc
+++ b/python/configuration.cc
@@ -351,8 +351,8 @@ char *doc_LoadConfig =
"options in the configuration object.";
PyObject *LoadConfig(PyObject *Self,PyObject *Args)
{
- char *Name = 0;
- if (PyArg_ParseTuple(Args,"Os",&Self,&Name) == 0)
+ PyApt_Filename Name;
+ if (PyArg_ParseTuple(Args,"OO&",&Self,PyApt_Filename::Converter, &Name) == 0)
return 0;
if (PyConfiguration_Check(Self)== 0)
{
@@ -373,8 +373,8 @@ char *doc_LoadConfigISC =
"configuration files.";
PyObject *LoadConfigISC(PyObject *Self,PyObject *Args)
{
- char *Name = 0;
- if (PyArg_ParseTuple(Args,"Os",&Self,&Name) == 0)
+ PyApt_Filename Name;
+ if (PyArg_ParseTuple(Args,"OO&",&Self,PyApt_Filename::Converter, &Name) == 0)
return 0;
if (PyConfiguration_Check(Self)== 0)
{
@@ -394,8 +394,8 @@ char *doc_LoadConfigDir =
"correct order.";
PyObject *LoadConfigDir(PyObject *Self,PyObject *Args)
{
- char *Name = 0;
- if (PyArg_ParseTuple(Args,"Os",&Self,&Name) == 0)
+ PyApt_Filename Name;
+ if (PyArg_ParseTuple(Args,"OO&",&Self,PyApt_Filename::Converter, &Name) == 0)
return 0;
if (PyConfiguration_Check(Self)== 0)
{
diff --git a/python/depcache.cc b/python/depcache.cc
index 73993c82..c9dc79f3 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -89,9 +89,11 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args)
PyFetchProgress progress;
progress.setCallbackInst(pyFetchProgressInst);
- pkgAcquire Fetcher(&progress);
+ pkgAcquire Fetcher;
pkgPackageManager *PM;
PM = _system->CreatePM(depcache);
+
+ Fetcher.Setup(&progress);
if(PM->GetArchives(&Fetcher, &List, &Recs) == false ||
_error->PendingError() == true) {
std::cerr << "Error in GetArchives" << std::endl;
@@ -109,7 +111,7 @@ static PyObject *PkgDepCacheCommit(PyObject *Self,PyObject *Args)
bool Transient = false;
if (Fetcher.Run() == pkgAcquire::Failed)
- return false;
+ return HandleErrors();
// Print out errors
bool Failed = false;
@@ -794,14 +796,6 @@ PyTypeObject PyDepCache_Type =
PkgDepCacheNew, // tp_new
};
-#ifdef COMPAT_0_7
-PyObject *GetDepCache(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning,"apt_pkg.GetDepCache() is deprecated"
- ". Please see apt_pkg.DepCache() for the replacement.",1);
- return PkgDepCacheNew(&PyDepCache_Type,Args,0);
-}
-#endif
@@ -829,14 +823,6 @@ static PyObject *PkgProblemResolverNew(PyTypeObject *type,PyObject *Args,PyObjec
return PkgProblemResolverPyObj;
}
-#ifdef COMPAT_0_7
-PyObject *GetPkgProblemResolver(PyObject *Self,PyObject *Args) {
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgProblemResolver() is"
- " deprecated. Please see apt_pkg.ProblemResolver() for the "
- "replacement.", 1);
- return PkgProblemResolverNew(&PyProblemResolver_Type,Args,0);
-}
-#endif
static PyObject *PkgProblemResolverResolve(PyObject *Self,PyObject *Args)
{
@@ -909,7 +895,9 @@ static PyObject *PkgProblemResolverInstallProtect(PyObject *Self,PyObject *Args)
pkgProblemResolver *fixer = GetCpp<pkgProblemResolver *>(Self);
if (PyArg_ParseTuple(Args,"") == 0)
return 0;
+ PY_APT_BEGIN_DEPRECATED;
fixer->InstallProtect();
+ PY_APT_END_DEPRECATED;
Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -1121,15 +1109,6 @@ PyTypeObject PyActionGroup_Type =
PkgActionGroupNew, // tp_new
};
-#ifdef COMPAT_0_7
-PyObject *GetPkgActionGroup(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgActionGroup() is "
- "deprecated. Please see apt_pkg.ActionGroup() for the "
- "replacement.", 1);
- return PkgActionGroupNew(&PyActionGroup_Type,Args,0);
-}
-#endif
/*}}}*/
diff --git a/python/generic.cc b/python/generic.cc
index e04743ff..5e712899 100644
--- a/python/generic.cc
+++ b/python/generic.cc
@@ -49,75 +49,6 @@ PyObject *HandleErrors(PyObject *Res)
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, "ArchiveURI") == 0) return PyString_FromString("archive_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");
- 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;
- 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 {
- Py_XINCREF(ptype);
- Py_XINCREF(pvalue);
- Py_XINCREF(ptraceback);
- PyErr_Restore(ptype, pvalue, ptraceback);
- }
- Py_DECREF(newattr);
- Py_XDECREF(ptype);
- Py_XDECREF(pvalue);
- Py_XDECREF(ptraceback);
- }
- return value;
-}
-# endif //COMPAT_0_7
/*}}}*/
// ListToCharChar - Convert a list to an array of char char /*{{{*/
// ---------------------------------------------------------------------
@@ -162,3 +93,26 @@ PyObject *CharCharToList(const char **List,unsigned long Size)
return PList;
}
/*}}}*/
+
+int PyApt_Filename::init(PyObject *object)
+{
+ this->object = NULL;
+ this->path = NULL;
+
+#if PY_MAJOR_VERSION < 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 2)
+ this->path = PyObject_AsString(object);
+ return this->path ? 1 : 0;
+#else
+ if (PyUnicode_Check(object)) {
+ object = PyUnicode_EncodeFSDefault(object);
+ } else if (PyBytes_Check(object)) {
+ Py_INCREF(object);
+ } else {
+ return 0;
+ }
+
+ this->object = object;
+ this->path = PyBytes_AS_STRING(this->object);
+ return 1;
+#endif
+}
diff --git a/python/generic.h b/python/generic.h
index 914456e2..bcc4a5e4 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -58,8 +58,6 @@ typedef int Py_ssize_t;
#define PyInt_Check PyLong_Check
#define PyInt_AsLong PyLong_AsLong
#define PyInt_FromLong PyLong_FromLong
-// Force 0.7 compatibility to be off in Python 3 builds
-#undef COMPAT_0_7
#else
// Compatibility for Python 2.5 and previous.
#if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 5)
@@ -77,6 +75,11 @@ typedef int Py_ssize_t;
#define PyErr_WarnEx(cat,msg,stacklevel) PyErr_Warn(cat,msg)
#endif
+#define PY_APT_BEGIN_DEPRECATED { \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\""); }
+#define PY_APT_END_DEPRECATED _Pragma("GCC diagnostic pop")
+
static inline const char *PyUnicode_AsString(PyObject *op) {
// Convert to bytes object, using the default encoding.
@@ -247,14 +250,50 @@ inline PyObject *MkPyNumber(long long o) { return PyLong_FromLongLong(o); }
inline PyObject *MkPyNumber(long o) { return PyInt_FromLong(o); }
inline PyObject *MkPyNumber(int o) { return PyInt_FromLong(o); }
inline PyObject *MkPyNumber(short o) { return PyInt_FromLong(o); }
-inline PyObject *MkPyNumber(char o) { return PyInt_FromLong(o); }
+inline PyObject *MkPyNumber(signed char o) { return PyInt_FromLong(o); }
inline PyObject *MkPyNumber(double o) { return PyFloat_FromDouble(o); }
-# ifdef COMPAT_0_7
-PyObject *_PyAptObject_getattro(PyObject *self, PyObject *attr);
-# else
# define _PyAptObject_getattro 0
-# endif
+
+
+/**
+ * Magic class for file name handling
+ *
+ * This manages decoding file names from Python objects; bytes and unicode
+ * objects. On Python 2, this does the same conversion as PyObject_AsString,
+ * on Python3, it uses PyUnicode_EncodeFSDefault for unicode objects.
+ */
+class PyApt_Filename {
+public:
+ PyObject *object;
+ const char *path;
+
+ PyApt_Filename() {
+ object = NULL;
+ path = NULL;
+ }
+
+ int init(PyObject *object);
+
+ ~PyApt_Filename() {
+ Py_XDECREF(object);
+ }
+
+ static int Converter(PyObject *object, void *out) {
+ return static_cast<PyApt_Filename *>(out)->init(object);
+ }
+
+ operator const char *() {
+ return path;
+ }
+ operator const std::string() {
+ return path;
+ }
+
+ const char *operator=(const char *path) {
+ return this->path = path;
+ }
+};
#endif
diff --git a/python/indexfile.cc b/python/indexfile.cc
index bf0df516..1a146bac 100644
--- a/python/indexfile.cc
+++ b/python/indexfile.cc
@@ -18,9 +18,9 @@
static PyObject *IndexFileArchiveURI(PyObject *Self,PyObject *Args)
{
pkgIndexFile *File = GetCpp<pkgIndexFile*>(Self);
- char *path;
+ PyApt_Filename path;
- if (PyArg_ParseTuple(Args, "s",&path) == 0)
+ if (PyArg_ParseTuple(Args, "O&", PyApt_Filename::Converter, &path) == 0)
return 0;
return HandleErrors(Safe_FromString(File->ArchiveURI(path).c_str()));
}
diff --git a/python/indexrecords.cc b/python/indexrecords.cc
index c7623cfd..9446fad1 100644
--- a/python/indexrecords.cc
+++ b/python/indexrecords.cc
@@ -37,8 +37,8 @@ static PyObject *indexrecords_new(PyTypeObject *type,PyObject *Args,
static PyObject *indexrecords_load(PyObject *self,PyObject *args)
{
- const char *filename;
- if (PyArg_ParseTuple(args, "s", &filename) == 0)
+ PyApt_Filename filename;
+ if (PyArg_ParseTuple(args, "O&", PyApt_Filename::Converter, &filename) == 0)
return 0;
indexRecords *records = GetCpp<indexRecords*>(self);
return HandleErrors(PyBool_FromLong(records->Load(filename)));
@@ -51,8 +51,8 @@ static char *indexrecords_lookup_doc =
"and the second element 'size' is an int object.";
static PyObject *indexrecords_lookup(PyObject *self,PyObject *args)
{
- const char *keyname;
- if (PyArg_ParseTuple(args, "s", &keyname) == 0)
+ PyApt_Filename keyname;
+ if (PyArg_ParseTuple(args, "O&", PyApt_Filename::Converter, &keyname) == 0)
return 0;
indexRecords *records = GetCpp<indexRecords*>(self);
const indexRecords::checkSum *result = records->Lookup(keyname);
diff --git a/python/lock.cc b/python/lock.cc
index 38a2bc74..7a76c9fd 100644
--- a/python/lock.cc
+++ b/python/lock.cc
@@ -183,9 +183,10 @@ static PyObject *filelock_exit(filelock_object *self, PyObject *args)
static PyObject *filelock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- char *filename = 0;
+ PyApt_Filename filename;
char *kwlist[] = {"filename", NULL};
- if (PyArg_ParseTupleAndKeywords(args, kwds, "s:__init__", kwlist,
+ if (PyArg_ParseTupleAndKeywords(args, kwds, "O&:__init__", kwlist,
+ PyApt_Filename::Converter,
&filename) == 0) {
return NULL;
}
diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc
index 9a5d0e5b..05f033f3 100644
--- a/python/pkgmanager.cc
+++ b/python/pkgmanager.cc
@@ -191,7 +191,7 @@ class PyPkgManager : public pkgDPkgPM {
StatusFd));
}
virtual void Reset() {
- CppPyRef(PyObject_CallMethod(pyinst, "reset", NULL));
+ Py_XDECREF(PyObject_CallMethod(pyinst, "reset", NULL));
}
public:
@@ -225,23 +225,14 @@ static PyObject *PkgManagerNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
return PkgManagerObj;
}
-#ifdef COMPAT_0_7
-PyObject *GetPkgManager(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPackageManager() is "
- "deprecated. Please see apt_pkg.PackageManager() for the "
- "replacement.", 1);
- return PkgManagerNew(&PyPackageManager2_Type,Args,0);
-}
-#endif
static PyObject *PkgManagerInstall(PyObject *Self,PyObject *Args)
{
PyPkgManager *pm = GetCpp<PyPkgManager*>(Self);
PyObject *pkg;
- const char *file;
+ PyApt_Filename file;
- if (PyArg_ParseTuple(Args, "O!s", &PyPackage_Type,&pkg, &file) == 0)
+ if (PyArg_ParseTuple(Args, "O!O&", &PyPackage_Type,&pkg, PyApt_Filename::Converter, &file) == 0)
return 0;
return HandleErrors(PyBool_FromLong(pm->callInstall(PyPackage_ToCpp(pkg), file)));
diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc
index 8d2cb502..8e6084a9 100644
--- a/python/pkgrecords.cc
+++ b/python/pkgrecords.cc
@@ -218,12 +218,3 @@ PyTypeObject PyPackageRecords_Type =
/*}}}*/
-#ifdef COMPAT_0_7
-PyObject *GetPkgRecords(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgRecords() is "
- "deprecated. Please see apt_pkg.Records() for the "
- "replacement.", 1);
- return PkgRecordsNew(&PyPackageRecords_Type,Args,0);
-}
-#endif
diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc
index 4c889129..6ec4e63c 100644
--- a/python/pkgsrcrecords.cc
+++ b/python/pkgsrcrecords.cc
@@ -75,10 +75,34 @@ static PyObject *PkgSrcRecordsRestart(PyObject *Self,PyObject *Args)
return HandleErrors(Py_None);
}
+static char *doc_PkgSrcRecordsStep =
+ "step() -> bool\n\n"
+ "Go to the source package. Each call moves\n"
+ "the position of the records parser forward. If there are no\n"
+ "more records, return None. If the lookup failed this way,\n"
+ "access to any of the attributes will result in an AttributeError.";
+static PyObject *PkgSrcRecordsStep(PyObject *Self,PyObject *Args)
+{
+ PkgSrcRecordsStruct &Struct = GetCpp<PkgSrcRecordsStruct>(Self);
+
+ if (PyArg_ParseTuple(Args,"") == 0)
+ return 0;
+
+ Struct.Last = (pkgSrcRecords::Parser*)Struct.Records->Step();
+ if (Struct.Last == 0) {
+ Struct.Records->Restart();
+ Py_INCREF(Py_None);
+ return HandleErrors(Py_None);
+ }
+
+ return PyBool_FromLong(1);
+}
+
static PyMethodDef PkgSrcRecordsMethods[] =
{
{"lookup",PkgSrcRecordsLookup,METH_VARARGS,doc_PkgSrcRecordsLookup},
{"restart",PkgSrcRecordsRestart,METH_VARARGS,doc_PkgSrcRecordsRestart},
+ {"step",PkgSrcRecordsStep,METH_VARARGS,doc_PkgSrcRecordsStep},
{}
};
@@ -205,29 +229,6 @@ static PyObject *PkgSrcRecordsGetBuildDepends(PyObject *Self,void*) {
return Dict;
}
-#ifdef COMPAT_0_7
-static PyObject *PkgSrcRecordsGetBuildDepends_old(PyObject *Self,void*) {
- PkgSrcRecordsStruct &Struct = GetStruct(Self,"BuildDepends");
- if (Struct.Last == 0)
- return 0;
- PyObject *List = PyList_New(0);
-
- vector<pkgSrcRecords::Parser::BuildDepRec> bd;
- if(!Struct.Last->BuildDepends(bd, false /* arch-only*/))
- return NULL; // error
-
- PyObject *v;
- for(unsigned int i=0;i<bd.size();i++) {
- v = Py_BuildValue("(ssNN)", bd[i].Package.c_str(),
- bd[i].Version.c_str(),
- MkPyNumber(bd[i].Op),
- MkPyNumber(bd[i].Type));
- PyList_Append(List, v);
- Py_DECREF(v);
- }
- return List;
-}
-#endif
static PyGetSetDef PkgSrcRecordsGetSet[] = {
{"binaries",PkgSrcRecordsGetBinaries,0,
@@ -251,9 +252,6 @@ static PyGetSetDef PkgSrcRecordsGetSet[] = {
"The section of the source package."},
{"version",PkgSrcRecordsGetVersion,0,
"The version of the source package."},
-#ifdef COMPAT_0_7
- {"BuildDepends",PkgSrcRecordsGetBuildDepends_old,0,"Deprecated function and deprecated output format."},
-#endif
{}
};
@@ -316,15 +314,3 @@ PyTypeObject PySourceRecords_Type =
/*}}}*/
-#ifdef COMPAT_0_7
-PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSrcRecords() is "
- "deprecated. Please see apt_pkg.SourceRecords() for the "
- "replacement.", 1);
- if (PyArg_ParseTuple(Args,"") == 0)
- return 0;
-
- return HandleErrors(CppPyObject_NEW<PkgSrcRecordsStruct>(NULL, &PySourceRecords_Type));
-}
-#endif
diff --git a/python/policy.cc b/python/policy.cc
index 96b83abd..0ace3e67 100644
--- a/python/policy.cc
+++ b/python/policy.cc
@@ -93,11 +93,12 @@ static char *policy_read_pinfile_doc =
"and add it to the policy.";
static PyObject *policy_read_pinfile(PyObject *self, PyObject *arg) {
- if (!PyString_Check(arg))
+ PyApt_Filename name;
+ if (!name.init(arg))
return 0;
pkgPolicy *policy = GetCpp<pkgPolicy *>(self);
- return PyBool_FromLong(ReadPinFile(*policy, PyString_AsString(arg)));
+ return PyBool_FromLong(ReadPinFile(*policy, name));
}
#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 8)
@@ -107,11 +108,12 @@ static char *policy_read_pindir_doc =
"and add them to the policy.";
static PyObject *policy_read_pindir(PyObject *self, PyObject *arg) {
- if (!PyString_Check(arg))
+ PyApt_Filename name;
+ if (!name.init(arg))
return 0;
pkgPolicy *policy = GetCpp<pkgPolicy *>(self);
- return PyBool_FromLong(ReadPinDir(*policy, PyString_AsString(arg)));
+ return PyBool_FromLong(ReadPinDir(*policy, name));
}
#endif
@@ -132,9 +134,9 @@ static PyObject *policy_create_pin(PyObject *self, PyObject *args) {
pkgPolicy *policy = GetCpp<pkgPolicy *>(self);
if (strcmp(type,"Version") == 0 || strcmp(type, "version") == 0)
match_type = pkgVersionMatch::Version;
- if (strcmp(type,"Release") == 0 || strcmp(type, "release") == 0)
+ else if (strcmp(type,"Release") == 0 || strcmp(type, "release") == 0)
match_type = pkgVersionMatch::Release;
- if (strcmp(type,"Origin") == 0 || strcmp(type, "origin") == 0)
+ else if (strcmp(type,"Origin") == 0 || strcmp(type, "origin") == 0)
match_type = pkgVersionMatch::Origin;
else
match_type = pkgVersionMatch::None;
diff --git a/python/progress.cc b/python/progress.cc
index 9e870875..425ca501 100644
--- a/python/progress.cc
+++ b/python/progress.cc
@@ -95,15 +95,7 @@ void PyOpProgress::Update()
setattr(callbackInst, "subop", "s", SubOp.c_str());
setattr(callbackInst, "major_change", "b", MajorChange);
setattr(callbackInst, "percent", "N", MkPyNumber(Percent));
-#ifdef COMPAT_0_7
- setattr(callbackInst, "Op", "s", Op.c_str());
- setattr(callbackInst, "subOp", "s", SubOp.c_str());
- setattr(callbackInst, "majorChange", "b", MajorChange);
- PyObject *arglist = Py_BuildValue("(N)", MkPyNumber(Percent));
- RunSimpleCallback("update", arglist);
-#else
RunSimpleCallback("update");
-#endif
}
void PyOpProgress::Done()
@@ -134,7 +126,7 @@ bool PyFetchProgress::MediaChange(std::string Media, std::string Drive)
PyCbObj_END_ALLOW_THREADS
//std::cout << "MediaChange" << std::endl;
PyObject *arglist = Py_BuildValue("(ss)", Media.c_str(), Drive.c_str());
- PyObject *result;
+ PyObject *result = NULL;
if(PyObject_HasAttrString(callbackInst, "mediaChange"))
RunSimpleCallback("mediaChange", arglist, &result);
@@ -241,13 +233,6 @@ void PyFetchProgress::Start()
//std::cout << "Start" << std::endl;
pkgAcquireStatus::Start();
-#ifdef COMPAT_0_7
- setattr(callbackInst, "currentCPS", "N", MkPyNumber(0));
- setattr(callbackInst, "currentBytes", "N", MkPyNumber(0));
- setattr(callbackInst, "currentItems", "N", MkPyNumber(0));
- setattr(callbackInst, "totalItems", "N", MkPyNumber(0));
- setattr(callbackInst, "totalBytes", "N", MkPyNumber(0));
-#endif
RunSimpleCallback("start");
/* After calling the start method we can safely allow
@@ -314,106 +299,7 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner)
PyCbObj_BEGIN_ALLOW_THREADS
return true;
}
-#ifdef COMPAT_0_7
- setattr(callbackInst, "currentCPS", "N", MkPyNumber(CurrentCPS));
- setattr(callbackInst, "currentBytes", "N", MkPyNumber(CurrentBytes));
- setattr(callbackInst, "totalBytes", "N", MkPyNumber(TotalBytes));
- setattr(callbackInst, "fetchedBytes", "N", MkPyNumber(FetchedBytes));
- setattr(callbackInst, "currentItems", "N", MkPyNumber(CurrentItems));
- setattr(callbackInst, "totalItems", "N", MkPyNumber(TotalItems));
- // Go through the list of items and add active items to the
- // activeItems vector.
- map<pkgAcquire::Worker *, pkgAcquire::ItemDesc *> activeItemMap;
-
- for(pkgAcquire::Worker *Worker = Owner->WorkersBegin();
- Worker != 0; Worker = Owner->WorkerStep(Worker)) {
-
- if (Worker->CurrentItem == 0) {
- // Ignore workers with no item running
- continue;
- }
- activeItemMap.insert(std::make_pair(Worker, Worker->CurrentItem));
- }
-
- // Create the tuple that is passed as argument to pulse().
- // This tuple contains activeItemMap.size() item tuples.
- PyObject *arglist;
-
- if (((int)activeItemMap.size()) > 0) {
- PyObject *itemsTuple = PyTuple_New((Py_ssize_t) activeItemMap.size());
-
- // Go through activeItems, create an item tuple in the form
- // (URI, Description, ShortDesc, FileSize, PartialSize) and
- // add that tuple to itemsTuple.
- map<pkgAcquire::Worker *, pkgAcquire::ItemDesc *>::iterator iter;
- int tuplePos;
-
- for(tuplePos = 0, iter = activeItemMap.begin();
- iter != activeItemMap.end(); ++iter, tuplePos++) {
- pkgAcquire::Worker *worker = iter->first;
- pkgAcquire::ItemDesc *itm = iter->second;
-
- PyObject *itmTuple = Py_BuildValue("(sssNN)", itm->URI.c_str(),
- itm->Description.c_str(),
- itm->ShortDesc.c_str(),
- MkPyNumber(worker->TotalSize),
- MkPyNumber(worker->CurrentSize));
- PyTuple_SetItem(itemsTuple, tuplePos, itmTuple);
- }
-
- // Now our itemsTuple is ready for being passed to pulse().
- // pulse() is going to receive a single argument, being the
- // tuple of items, which again contains one tuple with item
- // information per item.
- //
- // Python Example:
- //
- // class MyFetchProgress(FetchProgress):
- // def pulse(self, items):
- // for itm in items:
- // uri, desc, shortdesc, filesize, partialsize = itm
- //
- arglist = PyTuple_Pack(1, itemsTuple);
- }
- else {
- arglist = Py_BuildValue("(())");
- }
-
- PyObject *result;
- bool res = true;
-
- if (RunSimpleCallback("pulse_items", arglist, &result)) {
- if (result != NULL && PyArg_Parse(result, "b", &res) && res == false) {
- // the user returned a explicit false here, stop
- PyCbObj_BEGIN_ALLOW_THREADS
- return false;
- }
- }
-
-
- arglist = Py_BuildValue("()");
- if (!RunSimpleCallback("pulse", arglist, &result)) {
- PyCbObj_BEGIN_ALLOW_THREADS
- return true;
- }
-
- if((result == NULL) || (!PyArg_Parse(result, "b", &res)))
- {
- // most of the time the user who subclasses the pulse()
- // method forgot to add a return {True,False} so we just
- // assume he wants a True. There may be a Python exception on the stack
- // that must be cleared.
- PyErr_Clear();
- PyCbObj_BEGIN_ALLOW_THREADS
- return true;
- }
-
- PyCbObj_BEGIN_ALLOW_THREADS
- // fetching can be canceld by returning false
- return res;
-#else
return false;
-#endif
}
@@ -422,24 +308,21 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner)
void PyInstallProgress::StartUpdate()
{
- if (!RunSimpleCallback("startUpdate"))
- RunSimpleCallback("start_update");
+ RunSimpleCallback("start_update");
PyCbObj_BEGIN_ALLOW_THREADS
}
void PyInstallProgress::UpdateInterface()
{
PyCbObj_END_ALLOW_THREADS
- if (!RunSimpleCallback("updateInterface"))
- RunSimpleCallback("update_interface");
+ RunSimpleCallback("update_interface");
PyCbObj_BEGIN_ALLOW_THREADS
}
void PyInstallProgress::FinishUpdate()
{
PyCbObj_END_ALLOW_THREADS
- if (!RunSimpleCallback("finishUpdate"))
- RunSimpleCallback("finish_update");
+ RunSimpleCallback("finish_update");
}
pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm)
@@ -476,6 +359,9 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm)
child_id = fork();
}
+ PyObject *child_o = PyLong_FromLong(child_id);
+ PyObject_SetAttrString(callbackInst, "child_pid", child_o);
+ Py_DECREF(child_o);
#if 0 // FIXME: this needs to be merged into apt to support medium swaping
if (child_id == 0) {
@@ -548,16 +434,13 @@ void PyCdromProgress::Update(std::string text, int current)
{
PyObject *arglist = Py_BuildValue("(si)", text.c_str(), current);
setattr(callbackInst, "total_steps", "i", totalSteps);
- #ifdef COMPAT_0_7
- setattr(callbackInst, "totalSteps", "i", totalSteps);
- #endif
RunSimpleCallback("update", arglist);
}
bool PyCdromProgress::ChangeCdrom()
{
PyObject *arglist = Py_BuildValue("()");
- PyObject *result;
+ PyObject *result = NULL;
if (PyObject_HasAttrString(callbackInst, "changeCdrom"))
RunSimpleCallback("changeCdrom", arglist, &result);
else
@@ -576,7 +459,7 @@ bool PyCdromProgress::AskCdromName(std::string &Name)
PyObject *arglist = Py_BuildValue("()");
const char *new_name;
bool res;
- PyObject *result;
+ PyObject *result = NULL;
// Old style: (True, name) on success, (False, name) on failure.
if (PyObject_HasAttrString(callbackInst, "askAdromName")) {
diff --git a/python/sourcelist.cc b/python/sourcelist.cc
index 784b161e..a38cb1bb 100644
--- a/python/sourcelist.cc
+++ b/python/sourcelist.cc
@@ -168,12 +168,3 @@ PyTypeObject PySourceList_Type =
PkgSourceListNew, // tp_new
};
-#ifdef COMPAT_0_7
-PyObject *GetPkgSourceList(PyObject *Self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.GetPkgSourceList() is "
- "deprecated. Please see apt_pkg.SourceList() for the "
- "replacement.", 1);
- return PkgSourceListNew(&PySourceList_Type,Args,0);
-}
-#endif
diff --git a/python/string.cc b/python/string.cc
index 62aa34e7..9b02c933 100644
--- a/python/string.cc
+++ b/python/string.cc
@@ -113,8 +113,10 @@ PyObject *StrStrToTime(PyObject *Self,PyObject *Args)
return 0;
time_t Result;
+ PY_APT_BEGIN_DEPRECATED;
if (StrToTime(Str,Result) == false)
{
+ PY_APT_END_DEPRECATED;
Py_INCREF(Py_None);
return Py_None;
}
diff --git a/python/tag.cc b/python/tag.cc
index 46fb8f34..61b919aa 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -338,11 +338,14 @@ static PyObject *TagFileNext(PyObject *Self)
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);
+ // Duplicate the data and
+ // append a \n because GetSection() will only give us a single \n
+ // but Scan() needs \n\n to work
+ Obj.Section->Data = new char[Stop-Start+2];
+ snprintf(Obj.Section->Data, Stop-Start+2, "%s\n", Start);
// Rescan it
- Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start);
+ if(Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start+2) == false)
+ return HandleErrors(NULL);
Py_INCREF(Obj.Section);
return HandleErrors(Obj.Section);
@@ -381,6 +384,61 @@ static PyObject *TagFileJump(PyObject *Self,PyObject *Args)
return HandleErrors(PyBool_FromLong(1));
}
+
+static char *doc_Close =
+ "close()\n\n"
+ "Close the file.";
+static PyObject *TagFileClose(PyObject *self, PyObject *args)
+{
+ if (args != NULL && !PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ TagFileData &Obj = *(TagFileData *) self;
+
+ Obj.Fd.Close();
+
+ Py_INCREF(Py_None);
+ return HandleErrors(Py_None);
+}
+
+static PyObject *TagFileExit(PyObject *self, PyObject *args)
+{
+
+ PyObject *exc_type = 0;
+ PyObject *exc_value = 0;
+ PyObject *traceback = 0;
+ if (!PyArg_UnpackTuple(args, "__exit__", 3, 3, &exc_type, &exc_value,
+ &traceback)) {
+ return 0;
+ }
+
+ PyObject *res = TagFileClose(self, NULL);
+
+ if (res == NULL) {
+ // The close failed. If no exception happened within the suite, we
+ // will raise an error here. Otherwise, we just display the error, so
+ // Python can handle the original exception instead.
+ if (exc_type == Py_None)
+ return NULL;
+
+ PyErr_WriteUnraisable(self);
+ } else {
+ Py_DECREF(res);
+ }
+ // Return False, as required by the context manager protocol.
+ Py_RETURN_FALSE;
+}
+
+static PyObject *TagFileEnter(PyObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ Py_INCREF(self);
+
+ return self;
+}
+
/*}}}*/
// ParseSection - Parse a single section from a tag file /*{{{*/
// ---------------------------------------------------------------------
@@ -418,16 +476,6 @@ static PyObject *TagSecNew(PyTypeObject *type,PyObject *Args,PyObject *kwds) {
return New;
}
-#ifdef COMPAT_0_7
-char *doc_ParseSection = "ParseSection(Text) -> TagSection()\n\nDeprecated.";
-PyObject *ParseSection(PyObject *self,PyObject *Args)
-{
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseSection() is "
- "deprecated. Please see apt_pkg.TagSection() for the "
- "replacement.", 1);
- return TagSecNew(&PyTagSection_Type,Args,0);
-}
-#endif
/*}}}*/
// ParseTagFile - Parse a tagd file /*{{{*/
// ---------------------------------------------------------------------
@@ -445,9 +493,8 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
// check if we got a filename or a file object
int fileno = -1;
- const char *filename = NULL;
- filename = PyObject_AsString(File);
- if (filename == NULL) {
+ PyApt_Filename filename;
+ if (!filename.init(File)) {
PyErr_Clear();
fileno = PyObject_AsFileDescriptor(File);
}
@@ -485,6 +532,8 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
#if PY_MAJOR_VERSION >= 3
if (fileno != -1) {
New->Encoding = PyObject_GetAttr(File, PyUnicode_FromString("encoding"));
+ if (!New->Encoding)
+ PyErr_Clear();
if (New->Encoding && !PyUnicode_Check(New->Encoding))
New->Encoding = 0;
} else
@@ -507,15 +556,6 @@ static PyObject *TagFileNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
return HandleErrors(New);
}
-#ifdef COMPAT_0_7
-char *doc_ParseTagFile = "ParseTagFile(file) -> TagFile()\n\nDeprecated.";
-PyObject *ParseTagFile(PyObject *self,PyObject *Args) {
- PyErr_WarnEx(PyExc_DeprecationWarning, "apt_pkg.ParseTagFile() is "
- "deprecated. Please see apt_pkg.TagFile() for the "
- "replacement.", 1);
- return TagFileNew(&PyTagFile_Type,Args,0);
-}
-#endif
/*}}}*/
#ifdef HAVE_OPEN_MEMSTREAM
// RewriteSection - Rewrite a section.. /*{{{*/
@@ -673,6 +713,9 @@ static PyMethodDef TagFileMethods[] =
{"step",TagFileStep,METH_VARARGS,doc_Step},
{"offset",TagFileOffset,METH_VARARGS,doc_Offset},
{"jump",TagFileJump,METH_VARARGS,doc_Jump},
+ {"close",TagFileClose,METH_VARARGS,doc_Close},
+ {"__enter__",TagFileEnter,METH_VARARGS,"Context manager entry, return self."},
+ {"__exit__",TagFileExit,METH_VARARGS,"Context manager exit, calls close."},
{}
};
diff --git a/python/tar.cc b/python/tar.cc
deleted file mode 100644
index e42a9c50..00000000
--- a/python/tar.cc
+++ /dev/null
@@ -1,197 +0,0 @@
-// -*- mode: cpp; mode: fold -*-
-// Description /*{{{*/
-// $Id: tar.cc,v 1.4 2004/12/12 17:55:54 mdz Exp $
-/* ######################################################################
-
- Tar Inteface
- * THIS FILE IS COMPLETELY DEPRECATED, AND NOT USED ANYMORE IF BUILT *
- * WITHOUT COMPATIBILITY. *
-
- ##################################################################### */
- /*}}}*/
-// Include Files /*{{{*/
-#ifdef COMPAT_0_7
-#include "generic.h"
-
-#include <apt-pkg/extracttar.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/debfile.h>
-#include "apt_instmodule.h"
-
-#include <Python.h>
- /*}}}*/
-
-class ProcessTar : public pkgDirStream
-{
- public:
-
- PyObject *Function;
-
- virtual bool DoItem(Item &Itm,int &Fd);
-
- ProcessTar(PyObject *Function) : Function(Function)
- {
- Py_INCREF(Function);
- }
- virtual ~ProcessTar()
- {
- Py_DECREF(Function);
- }
-};
-
-// ProcessTar::DoItem - Feed an item to a python function /*{{{*/
-// ---------------------------------------------------------------------
-/* The function is called with a tuple that has:
- (FileName,Link,Mode,UID,GID,Size,MTime,Major,Minor) */
-bool ProcessTar::DoItem(Item &Itm,int &Fd)
-{
- const char *Type;
- switch (Itm.Type)
- {
- case Item::File:
- Type = "FILE";
- break;
-
- case Item::HardLink:
- Type = "HARDLINK";
- break;
-
- case Item::SymbolicLink:
- Type = "SYMLINK";
- break;
-
- case Item::CharDevice:
- Type = "CHARDEV";
- break;
-
- case Item::BlockDevice:
- Type = "BLKDEV";
- break;
-
- case Item::Directory:
- Type = "DIR";
- break;
-
- case Item::FIFO:
- Type = "FIFO";
- break;
-
- default:
- return false;
- }
-
-
- if (PyObject_CallFunction(Function,"sssiiiiiii",Type,Itm.Name,
- Itm.LinkTarget,Itm.Mode,Itm.UID,Itm.GID,Itm.Size,
- Itm.MTime,Itm.Major,Itm.Minor) == 0)
- return false;
-
- Fd = -1;
- return true;
-}
- /*}}}*/
-
-// tarExtract - Examine files from a tar /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-char *doc_tarExtract =
-"tarExtract(File,Func,Comp) -> None\n"
-"The tar file referenced by the file object File, Func called for each\n"
-"Tar member. Comp must be the string \"gzip\" (gzip is automatically invoked) \n";
-PyObject *tarExtract(PyObject *Self,PyObject *Args)
-{
- PyObject *File;
- PyObject *Function;
- char *Comp;
-
- if (PyArg_ParseTuple(Args,"OOs",&File, &Function,&Comp) == 0)
- return 0;
-
- if (PyCallable_Check(Function) == 0)
- {
- PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable.");
- return 0;
- }
-
- {
- // Open the file and associate the tar
- 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();
-
- ProcessTar Proc(Function);
- if (Tar.Go(Proc) == false)
- return HandleErrors();
- }
-
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
-}
- /*}}}*/
-
-// debExtract - Examine files from a deb /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-char *doc_debExtract =
-"debExtract(File,Func,Chunk) -> None\n"
-"The deb referenced by the file object File is examined. The AR member\n"
-"given by Chunk is treated as a tar.gz and fed through Func like\n"
-"tarExtract\n";
-PyObject *debExtract(PyObject *Self,PyObject *Args)
-{
- PyObject *File;
- PyObject *Function;
- char *Chunk;
- const char *Comp = "gzip";
-
- if (PyArg_ParseTuple(Args,"OOs",&File,&Function,&Chunk) == 0)
- return 0;
-
- if (PyCallable_Check(Function) == 0)
- {
- PyErr_SetString(PyExc_TypeError,"argument 2: expected something callable.");
- 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,false);
- debDebFile Deb(Fd);
- if (_error->PendingError() == true)
- return HandleErrors();
-
- // Get the archive member and positition the file
- const ARArchive::Member *Member = Deb.GotoMember(Chunk);
- if (Member == 0)
- {
- _error->Error("Cannot find chunk %s",Chunk);
- return HandleErrors();
- }
-
- // Extract it.
- if (strcmp(".bz2", &Chunk[strlen(Chunk)-4]) == 0)
- Comp = "bzip2";
- else if(strcmp(".lzma", &Chunk[strlen(Chunk)-5]) == 0)
- Comp = "lzma";
- else if(strcmp(".xz", &Chunk[strlen(Chunk)-3]) == 0)
- Comp = "xz";
- ExtractTar Tar(Deb.GetFile(),Member->Size,Comp);
- ProcessTar Proc(Function);
- if (Tar.Go(Proc) == false)
- return HandleErrors();
- }
-
- Py_INCREF(Py_None);
- return HandleErrors(Py_None);
-}
- /*}}}*/
-#endif // defined(COMPAT_0_7)
diff --git a/python/tarfile.cc b/python/tarfile.cc
index 920f032e..0aeae662 100644
--- a/python/tarfile.cc
+++ b/python/tarfile.cc
@@ -43,7 +43,8 @@ public:
PyObject *py_data;
// The requested member or NULL.
const char *member;
- // Set to true if an error occured in the Python callback.
+ // Set to true if an error occured in the Python callback, or a file
+ // was too large to read in extractdata.
bool error;
// Place where the copy of the data is stored.
char *copy;
@@ -52,9 +53,13 @@ public:
virtual bool DoItem(Item &Itm,int &Fd);
virtual bool FinishedFile(Item &Itm,int Fd);
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 14)
+ virtual bool Process(Item &Itm,const unsigned char *Data,
+ unsigned long long Size,unsigned long long Pos);
+#else
virtual bool Process(Item &Itm,const unsigned char *Data,
unsigned long Size,unsigned long Pos);
-
+#endif
PyDirStream(PyObject *callback, const char *member=0) : callback(callback),
py_data(0), member(member), error(false), copy(0), copy_size(0)
{
@@ -72,9 +77,13 @@ bool PyDirStream::DoItem(Item &Itm, int &Fd)
{
if (!member || strcmp(Itm.Name, member) == 0) {
// Allocate a new buffer if the old one is too small.
+ if (Itm.Size > SIZE_MAX)
+ goto to_large;
if (copy == NULL || copy_size < Itm.Size) {
delete[] copy;
- copy = new char[Itm.Size];
+ copy = new (std::nothrow) char[Itm.Size];
+ if (copy == NULL)
+ goto to_large;
copy_size = Itm.Size;
}
Fd = -2;
@@ -82,12 +91,31 @@ bool PyDirStream::DoItem(Item &Itm, int &Fd)
Fd = -1;
}
return true;
+to_large:
+ delete[] copy;
+ copy = NULL;
+ copy_size = 0;
+ /* If we are looking for a specific member, abort reading now */
+ if (member) {
+ error = true;
+ PyErr_Format(PyExc_MemoryError,
+ "The member %s was too large to read into memory",
+ Itm.Name);
+ return false;
+ }
+ return true;
}
+#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 14)
+bool PyDirStream::Process(Item &Itm,const unsigned char *Data,
+ unsigned long long Size,unsigned long long Pos)
+#else
bool PyDirStream::Process(Item &Itm,const unsigned char *Data,
unsigned long Size,unsigned long Pos)
+#endif
{
- memcpy(copy + Pos, Data,Size);
+ if (copy != NULL)
+ memcpy(copy + Pos, Data,Size);
return true;
}
@@ -98,7 +126,12 @@ bool PyDirStream::FinishedFile(Item &Itm,int Fd)
return true;
Py_XDECREF(py_data);
- py_data = PyBytes_FromStringAndSize(copy, Itm.Size);
+ if (copy == NULL) {
+ Py_INCREF(Py_None);
+ py_data = Py_None;
+ } else {
+ py_data = PyBytes_FromStringAndSize(copy, Itm.Size);
+ }
if (!callback)
return true;
@@ -309,7 +342,7 @@ static PyObject *tarfile_new(PyTypeObject *type,PyObject *args,PyObject *kwds)
{
PyObject *file;
PyTarFileObject *self;
- char *filename;
+ PyApt_Filename filename;
int fileno;
int min = 0;
int max = 0xFFFFFFFF;
@@ -323,8 +356,8 @@ static PyObject *tarfile_new(PyTypeObject *type,PyObject *args,PyObject *kwds)
self = (PyTarFileObject*)CppPyObject_NEW<ExtractTar*>(file,type);
// We receive a filename.
- if ((filename = (char*)PyObject_AsString(file)))
- new (&self->Fd) FileFd(filename,FileFd::ReadOnly);
+ if (filename.init(file))
+ new (&self->Fd) FileFd((const char *) filename,FileFd::ReadOnly);
else if ((fileno = PyObject_AsFileDescriptor(file)) != -1) {
// clear the error set by PyObject_AsString().
PyErr_Clear();
@@ -349,8 +382,8 @@ static const char *tarfile_extractall_doc =
static PyObject *tarfile_extractall(PyObject *self, PyObject *args)
{
std::string cwd = SafeGetCWD();
- char *rootdir = 0;
- if (PyArg_ParseTuple(args,"|s:extractall",&rootdir) == 0)
+ PyApt_Filename rootdir;
+ if (PyArg_ParseTuple(args,"|O&:extractall", PyApt_Filename::Converter, &rootdir) == 0)
return 0;
if (rootdir) {
@@ -384,8 +417,8 @@ static const char *tarfile_go_doc =
static PyObject *tarfile_go(PyObject *self, PyObject *args)
{
PyObject *callback;
- char *member = 0;
- if (PyArg_ParseTuple(args,"O|s",&callback,&member) == 0)
+ PyApt_Filename member;
+ if (PyArg_ParseTuple(args,"O|O&",&callback, PyApt_Filename::Converter, &member) == 0)
return 0;
if (member && strcmp(member, "") == 0)
member = 0;
@@ -397,7 +430,7 @@ static PyObject *tarfile_go(PyObject *self, PyObject *args)
return 0;
if (member && !stream.py_data)
return PyErr_Format(PyExc_LookupError, "There is no member named '%s'",
- member);
+ member.path);
return HandleErrors(PyBool_FromLong(res));
}
@@ -407,20 +440,20 @@ static const char *tarfile_extractdata_doc =
"LookupError if there is no member with the given name.";
static PyObject *tarfile_extractdata(PyObject *self, PyObject *args)
{
- const char *member;
- if (PyArg_ParseTuple(args,"s",&member) == 0)
+ PyApt_Filename member;
+ if (PyArg_ParseTuple(args,"O&", PyApt_Filename::Converter, &member) == 0)
return 0;
PyDirStream stream(NULL, member);
((PyTarFileObject*)self)->Fd.Seek(((PyTarFileObject*)self)->min);
// Go through the stream.
GetCpp<ExtractTar*>(self)->Go(stream);
+ if (stream.error)
+ return 0;
+
if (!stream.py_data)
return PyErr_Format(PyExc_LookupError, "There is no member named '%s'",
- member);
- if (stream.error) {
- return 0;
- }
+ member.path);
return Py_INCREF(stream.py_data), stream.py_data;
}
diff --git a/setup.py b/setup.py
index 8af5c2a6..d704f51c 100644
--- a/setup.py
+++ b/setup.py
@@ -6,6 +6,7 @@ import os
import sys
from distutils.core import setup, Extension
+from distutils import sysconfig
cmdclass = {}
try:
@@ -23,13 +24,23 @@ try:
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
- from lib2to3.refactor import get_fixers_from_package
- cmdclass['build_py'] = build_py_2to3
- cmdclass['build_py'].fixer_names = sorted(
- set(get_fixers_from_package("lib2to3.fixes")) -
- set(["lib2to3.fixes.fix_future"]))
+
+def get_version():
+ """Get a PEP 0440 compatible version string"""
+ version = os.environ.get('DEBVER')
+ if not version:
+ return version
+
+ version = version.replace("~alpha", ".a")
+ version = version.replace("~beta", ".b")
+ version = version.replace("~rc", ".rc")
+ version = version.replace("~exp", ".dev")
+ version = version.replace("ubuntu", "+ubuntu")
+ version = version.replace("tanglu", "+tanglu")
+ version = version.split("build")[0]
+
+ return version
+
# The apt_pkg module.
files = ['apt_pkgmodule.cc', 'acquire.cc', 'cache.cc', 'cdrom.cc',
@@ -43,7 +54,7 @@ files = sorted(['python/' + fname for fname in files], key=lambda s: s[:-3])
apt_pkg = Extension("apt_pkg", files, libraries=["apt-pkg"])
# The apt_inst module
-files = ["python/apt_instmodule.cc", "python/generic.cc", "python/tar.cc",
+files = ["python/apt_instmodule.cc", "python/generic.cc",
"python/arfile.cc", "python/tarfile.cc"]
apt_inst = Extension("apt_inst", files, libraries=["apt-pkg", "apt-inst"])
@@ -61,19 +72,25 @@ if len(sys.argv) > 1 and sys.argv[1] == "build":
for template in glob.glob('data/templates/*.mirrors'):
import shutil
shutil.copy(template, os.path.join("build", template))
-
+
+# Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++.
+# See http://bugs.python.org/issue9031 and http://bugs.python.org/issue1222585
+cfg_vars = sysconfig.get_config_vars()
+for key, value in cfg_vars.items():
+ if type(value) == str:
+ cfg_vars[key] = value.replace("-Wstrict-prototypes", "")
setup(name="python-apt",
description="Python bindings for APT",
- version=os.environ.get('DEBVER'),
+ version=get_version(),
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 = cmdclass,
- license = 'GNU GPL',
- platforms = 'posix')
+ data_files=[('share/python-apt/templates',
+ glob.glob('build/data/templates/*.info')),
+ ('share/python-apt/templates',
+ glob.glob('data/templates/*.mirrors'))],
+ cmdclass=cmdclass,
+ license='GNU GPL',
+ platforms='posix')
diff --git a/tests/data/aptsources/sources.list b/tests/data/aptsources/sources.list
index 376d6961..8ca68075 100644
--- a/tests/data/aptsources/sources.list
+++ b/tests/data/aptsources/sources.list
@@ -7,3 +7,4 @@ deb http://de.archive.ubuntu.com/ubuntu/ edgy universe
# multi-arch
deb [arch=amd64,i386] http://de.archive.ubuntu.com/ubuntu/ natty main
+deb [arch=amd64,i386 trusted=yes] http://de.archive.ubuntu.com/ubuntu/ natty main
diff --git a/tests/data/aptsources/sources.list.testDistribution b/tests/data/aptsources/sources.list.testDistribution
index 79224a34..021ee879 100644
--- a/tests/data/aptsources/sources.list.testDistribution
+++ b/tests/data/aptsources/sources.list.testDistribution
@@ -6,6 +6,7 @@ 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://archive.tanglu.org/tanglu aequorea 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
diff --git a/tests/old/hashsum_test.data b/tests/data/hashsums/hashsum_test.data
index 19102815..19102815 100644
--- a/tests/old/hashsum_test.data
+++ b/tests/data/hashsums/hashsum_test.data
diff --git a/tests/old/hashsum_test_with_zero.data b/tests/data/hashsums/hashsum_test_with_zero.data
index 2ec9a6df..2ec9a6df 100644
--- a/tests/old/hashsum_test_with_zero.data
+++ b/tests/data/hashsums/hashsum_test_with_zero.data
Binary files differ
diff --git a/tests/data/test_debs/data-tar-xz.deb b/tests/data/test_debs/data-tar-xz.deb
index fc15f597..9dd4d670 100644
--- a/tests/data/test_debs/data-tar-xz.deb
+++ b/tests/data/test_debs/data-tar-xz.deb
Binary files differ
diff --git a/tests/data/test_debs/data-tar.deb b/tests/data/test_debs/data-tar.deb
new file mode 100644
index 00000000..d8e4a988
--- /dev/null
+++ b/tests/data/test_debs/data-tar.deb
Binary files differ
diff --git a/tests/data/test_debs/gdebi-test13.deb b/tests/data/test_debs/gdebi-test13.deb
new file mode 100644
index 00000000..4e7a8289
--- /dev/null
+++ b/tests/data/test_debs/gdebi-test13.deb
Binary files differ
diff --git a/tests/data/test_debs/hello_2.5-1.dsc b/tests/data/test_debs/hello_2.5-1.dsc
index c079f2d3..d00db522 100644
--- a/tests/data/test_debs/hello_2.5-1.dsc
+++ b/tests/data/test_debs/hello_2.5-1.dsc
@@ -3,7 +3,8 @@ Hash: SHA256
Format: 1.0
Source: hello
-Binary: hello
+Binary: hello, bello,
+ cello
Architecture: any
Version: 2.5-1
Maintainer: Santiago Vila <sanvila@debian.org>
diff --git a/tests/data/test_debs/large-package-content_1.0_all.deb b/tests/data/test_debs/large-package-content_1.0_all.deb
new file mode 100644
index 00000000..56bdce3d
--- /dev/null
+++ b/tests/data/test_debs/large-package-content_1.0_all.deb
Binary files differ
diff --git a/tests/data/test_debs/testdep-allowed-any_1.0-1_i386.deb b/tests/data/test_debs/testdep-allowed-any_1.0-1_i386.deb
new file mode 100644
index 00000000..c56f8192
--- /dev/null
+++ b/tests/data/test_debs/testdep-allowed-any_1.0-1_i386.deb
Binary files differ
diff --git a/tests/data/test_debs/testdep-same-arch_1.0-1_i386.deb b/tests/data/test_debs/testdep-same-arch_1.0-1_i386.deb
new file mode 100644
index 00000000..872f3b6f
--- /dev/null
+++ b/tests/data/test_debs/testdep-same-arch_1.0-1_i386.deb
Binary files differ
diff --git a/tests/data/test_debs/var/lib/dpkg/status b/tests/data/test_debs/var/lib/dpkg/status
index f0c48151..5c2c48a0 100644
--- a/tests/data/test_debs/var/lib/dpkg/status
+++ b/tests/data/test_debs/var/lib/dpkg/status
@@ -51,3 +51,42 @@ Description: Debian configuration management system
Debconf is a configuration management system for debian packages. Packages
use Debconf to ask questions when they are installed.
Python-Version: 2.6, 3.1
+
+Package: testdep-same
+Status: install ok installed
+Source: testdep
+Version: 1.0-1
+Architecture: amd64
+Maintainer: Francois Gouget <fgouget@codeweavers.com>
+Installed-Size: 25
+Provides: testdep-virtual-same
+Section: unknown
+Priority: extra
+Multi-Arch: same
+Description: Multi-arch = same package, no dependency
+ This is a multiarch package that can only satisfy dependencies for the same
+ architecture. But multiple instances of this package can be co-installed,
+ one for each architecture.
+ .
+ Library and development packages typically fall into this category.
+
+Package: testdep-allowed
+Status: install ok installed
+Source: testdep
+Version: 1.0-1
+Architecture: amd64
+Maintainer: Francois Gouget <fgouget@codeweavers.com>
+Installed-Size: 25
+Provides: testdep-virtual-allowed
+Section: unknown
+Priority: extra
+Multi-Arch: allowed
+Description: Multi-arch = allowed package, no dependency
+ This is a multiarch package. By default it can only satisfy dependencies for
+ packages of the same architecture but that can be changed with ':any'
+ dependencies.
+ .
+ It can only be installed for one architecture at a time. Trying to install the
+ same package for another architecture will remove the first one.
+ .
+ Packages providing tools or shells typically fall into this category.
diff --git a/tests/old/__init__.py b/tests/old/__init__.py
index afd0f074..e93c0b65 100644
--- a/tests/old/__init__.py
+++ b/tests/old/__init__.py
@@ -2,7 +2,6 @@ import os
import unittest
-
if __name__ == '__main__':
os.chdir(os.path.dirname(__file__))
print os.getcwd()
diff --git a/tests/old/apt-test.py b/tests/old/apt-test.py
index fac2ff43..423fb03a 100644
--- a/tests/old/apt-test.py
+++ b/tests/old/apt-test.py
@@ -8,19 +8,19 @@ if __name__ == "__main__":
cache = apt.Cache(progress)
print cache
for pkg in cache:
- if pkg.isUpgradable:
- pkg.markInstall()
- for pkg in cache.getChanges():
- #print pkg.Name()
+ if pkg.is_upgradable:
+ pkg.mark_install()
+ for pkg in cache.get_changes():
+ #print pkg.name()
pass
- print "Broken: %s " % cache._depcache.BrokenCount
- print "InstCount: %s " % cache._depcache.InstCount
+ print "Broken: %s " % cache._depcache.broken_count
+ print "inst_count: %s " % cache._depcache.inst_count
# get a new cache
cache = apt.Cache(progress)
for name in cache.keys():
import random
if random.randint(0, 1) == 1:
- cache[name].markDelete()
- print "Broken: %s " % cache._depcache.BrokenCount
- print "DelCount: %s " % cache._depcache.DelCount
+ cache[name].mark_delete()
+ print "Broken: %s " % cache._depcache.broken_count
+ print "del_count: %s " % cache._depcache.del_count
diff --git a/tests/old/cache.py b/tests/old/cache.py
index f0bf6761..5cbf19d9 100644
--- a/tests/old/cache.py
+++ b/tests/old/cache.py
@@ -11,22 +11,22 @@ def main():
apt_pkg.init()
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
- depcache.Init()
- i=0
- all=cache.PackageCount
+ depcache.init()
+ i = 0
+ all = cache.package_count
print "Running Cache test on all packages:"
# first, get all pkgs
- for pkg in cache.Packages:
+ for pkg in cache.packages:
i += 1
- x = pkg.Name
+ x = pkg.name
# then get each version
- for ver in pkg.VersionList:
+ for ver in pkg.version_list:
# get some version information
- a = ver.FileList
- b = ver.VerStr
- c = ver.Arch
- d = ver.DependsListStr
- dl = ver.DependsList
+ a = ver.file_list
+ b = ver.ver_str
+ c = ver.arch
+ d = ver.depends_listStr
+ dl = ver.depends_list
# get all dependencies (a dict of string->list,
# e.g. "depends:" -> [ver1,ver2,..]
for dep in dl.keys():
@@ -35,12 +35,12 @@ def main():
for z in depVerList:
# get all TargetVersions of
# the dependency object
- for j in z.AllTargets():
- f = j.FileList
- g = ver.VerStr
- h = ver.Arch
- k = ver.DependsListStr
- j = ver.DependsList
+ for j in z.all_targets():
+ f = j.file_list
+ g = ver.ver_str
+ h = ver.arch
+ k = ver.depends_listStr
+ j = ver.depends_list
pass
print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)),
diff --git a/tests/old/depcache.py b/tests/old/depcache.py
index 0d59648e..67a47503 100644
--- a/tests/old/depcache.py
+++ b/tests/old/depcache.py
@@ -11,42 +11,42 @@ def main():
apt_pkg.init()
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
- depcache.Init()
- i=0
- all=cache.PackageCount
+ depcache.init()
+ i = 0
+ all = cache.package_count
print "Running DepCache test on all packages"
print "(trying to install each and then mark it keep again):"
# first, get all pkgs
- for pkg in cache.Packages:
+ for pkg in cache.packages:
i += 1
- x = pkg.Name
+ x = pkg.name
# then get each version
- ver =depcache.GetCandidateVer(pkg)
+ ver = depcache.get_candidate_ver(pkg)
if ver is not None:
- depcache.MarkInstall(pkg)
- if depcache.InstCount == 0:
- if depcache.IsUpgradable(pkg):
+ depcache.mark_install(pkg)
+ if depcache.inst_count == 0:
+ if depcache.is_upgradable(pkg):
print "Error marking %s for install" % x
- for p in cache.Packages:
- if depcache.MarkedInstall(p):
- depcache.MarkKeep(p)
- if depcache.InstCount != 0:
- print "Error undoing the selection for %s (InstCount: %s)" % (
- x, depcache.InstCount)
+ for p in cache.packages:
+ if depcache.marked_install(p):
+ depcache.mark_keep(p)
+ if depcache.inst_count != 0:
+ print "Error undoing the selection for %s (inst_count: %s)" % (
+ x, depcache.inst_count)
print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)),
print
- print "Trying Upgrade:"
- depcache.Upgrade()
- print "To install: %s " % depcache.InstCount
- print "To remove: %s " % depcache.DelCount
- print "Kept back: %s " % depcache.KeepCount
+ print "Trying upgrade:"
+ depcache.upgrade()
+ print "To install: %s " % depcache.inst_count
+ print "To remove: %s " % depcache.del_count
+ print "Kept back: %s " % depcache.keep_count
print "Trying DistUpgrade:"
- depcache.Upgrade(True)
- print "To install: %s " % depcache.InstCount
- print "To remove: %s " % depcache.DelCount
- print "Kept back: %s " % depcache.KeepCount
+ depcache.upgrade(True)
+ print "To install: %s " % depcache.inst_count
+ print "To remove: %s " % depcache.del_count
+ print "Kept back: %s " % depcache.keep_count
if __name__ == "__main__":
diff --git a/tests/old/lock.py b/tests/old/lock.py
index f19d3e43..71812918 100644
--- a/tests/old/lock.py
+++ b/tests/old/lock.py
@@ -14,27 +14,27 @@ if __name__ == "__main__":
apt_pkg.init()
# system-lock
- apt_pkg.PkgSystemLock()
+ apt_pkg.pkgsystem_lock()
pid = os.fork()
if pid == 0:
try:
- apt_pkg.PkgSystemLock()
+ apt_pkg.pkgsystem_lock()
except SystemError as s:
print "Can't get lock: (error text:\n%s)" % s
sys.exit(0)
- apt_pkg.PkgSystemUnLock()
+ apt_pkg.pkgsystem_unlock()
# low-level lock
- fd = apt_pkg.GetLock(lock, True)
+ fd = apt_pkg.get_lock(lock, True)
print "Lockfile fd: %s" % fd
# try to get lock without error flag
pid = os.fork()
if pid == 0:
# child
- fd = apt_pkg.GetLock(lock, False)
+ fd = apt_pkg.get_lock(lock, False)
print "Lockfile fd (child): %s" % fd
sys.exit(0)
@@ -42,6 +42,6 @@ if __name__ == "__main__":
pid = os.fork()
if pid == 0:
# child
- fd = apt_pkg.GetLock(lock, True)
+ fd = apt_pkg.get_lock(lock, True)
print "Lockfile fd (child): %s" % fd
sys.exit(0)
diff --git a/tests/old/memleak.py b/tests/old/memleak.py
index 5299f35f..1b7ec5d8 100644
--- a/tests/old/memleak.py
+++ b/tests/old/memleak.py
@@ -33,11 +33,11 @@ for i in range(100):
depcache = apt_pkg.DepCache(cache)
records = apt_pkg.PackageRecords(cache)
list = apt_pkg.SourceList()
- list.ReadMainList()
+ list.read_main_list()
dict = {}
- for pkg in cache.Packages:
- if len(pkg.VersionList) > 0:
- dict[pkg.Name] = apt.Package(cache, depcache,
+ for pkg in cache.packages:
+ if len(pkg.version_list) > 0:
+ dict[pkg.name] = apt.package(cache, depcache,
records, list, None, pkg)
print cache["apt"]
diff --git a/tests/old/pkgproblemresolver.py b/tests/old/pkgproblemresolver.py
index 0d6d0611..feaa3cb1 100644
--- a/tests/old/pkgproblemresolver.py
+++ b/tests/old/pkgproblemresolver.py
@@ -11,58 +11,58 @@ def main():
apt_pkg.init()
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
- depcache.Init()
- i=0
- all=cache.PackageCount
+ depcache.init()
+ i = 0
+ all = cache.package_count
print "Running DepCache test on all packages"
print "(trying to install each and then mark it keep again):"
# first, get all pkgs
- for pkg in cache.Packages:
+ for pkg in cache.packages:
i += 1
- x = pkg.Name
+ x = pkg.name
# then get each version
- ver =depcache.GetCandidateVer(pkg)
+ ver = depcache.get_candidate_ver(pkg)
if ver is not None:
- depcache.MarkInstall(pkg)
- if depcache.BrokenCount > 0:
+ depcache.mark_install(pkg)
+ if depcache.broken_count > 0:
fixer = apt_pkg.ProblemResolver(depcache)
- fixer.Clear(pkg)
- fixer.Protect(pkg)
+ fixer.clear(pkg)
+ fixer.protect(pkg)
# we first try to resolve the problem
# with the package that should be installed
# protected
try:
- fixer.Resolve(True)
+ fixer.resolve(True)
except SystemError:
# the pkg seems to be broken, the
# returns a exception
- fixer.Clear(pkg)
- fixer.Resolve(True)
- if not depcache.MarkedInstall(pkg):
- print "broken in archive: %s " % pkg.Name
+ fixer.clear(pkg)
+ fixer.resolve(True)
+ if not depcache.marked_install(pkg):
+ print "broken in archive: %s " % pkg.name
fixer = None
- if depcache.InstCount == 0:
- if depcache.IsUpgradable(pkg):
+ if depcache.inst_count == 0:
+ if depcache.is_upgradable(pkg):
print "Error marking %s for install" % x
- for p in cache.Packages:
- if depcache.MarkedInstall(p) or depcache.MarkedUpgrade(p):
- depcache.MarkKeep(p)
- if depcache.InstCount != 0:
+ for p in cache.packages:
+ if depcache.marked_install(p) or depcache.marked_upgrade(p):
+ depcache.mark_keep(p)
+ if depcache.inst_count != 0:
print "Error undoing the selection for %s" % x
print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)),
print
- print "Trying Upgrade:"
- depcache.Upgrade()
- print "To install: %s " % depcache.InstCount
- print "To remove: %s " % depcache.DelCount
- print "Kept back: %s " % depcache.KeepCount
+ print "Trying upgrade:"
+ depcache.upgrade()
+ print "To install: %s " % depcache.inst_count
+ print "To remove: %s " % depcache.del_count
+ print "Kept back: %s " % depcache.keep_count
print "Trying DistUpgrade:"
- depcache.Upgrade(True)
- print "To install: %s " % depcache.InstCount
- print "To remove: %s " % depcache.DelCount
- print "Kept back: %s " % depcache.KeepCount
+ depcache.upgrade(True)
+ print "To install: %s " % depcache.inst_count
+ print "To remove: %s " % depcache.del_count
+ print "Kept back: %s " % depcache.keep_count
if __name__ == "__main__":
diff --git a/tests/old/pkgrecords.py b/tests/old/pkgrecords.py
index 2fe6ad20..3f253bf3 100644
--- a/tests/old/pkgrecords.py
+++ b/tests/old/pkgrecords.py
@@ -12,27 +12,27 @@ def main():
apt_pkg.init()
cache = apt_pkg.Cache()
depcache = apt_pkg.DepCache(cache)
- depcache.Init()
- i=0
+ depcache.init()
+ i = 0
print "Running PkgRecords test on all packages:"
- for pkg in cache.Packages:
+ for pkg in cache.packages:
i += 1
records = apt_pkg.PackageRecords(cache)
- if len(pkg.VersionList) == 0:
+ if len(pkg.version_list) == 0:
#print "no available version, cruft"
continue
- version = depcache.GetCandidateVer(pkg)
+ version = depcache.get_candidate_ver(pkg)
if not version:
continue
- file, index = version.FileList.pop(0)
- if records.Lookup((file, index)):
- #print records.FileName
- x = records.FileName
- y = records.LongDesc
+ file, index = version.file_list.pop(0)
+ if records.lookup((file, index)):
+ #print records.filename
+ x = records.filename
+ y = records.long_desc
pass
print "\r%i/%i=%.3f%% " % (
- i, cache.PackageCount,
- (float(i) / float(cache.PackageCount) * 100)),
+ i, cache.package_count,
+ (float(i) / float(cache.package_count) * 100)),
if __name__ == "__main__":
diff --git a/tests/old/pkgsrcrecords.py b/tests/old/pkgsrcrecords.py
index 2ea9dd3a..42b545ed 100644
--- a/tests/old/pkgsrcrecords.py
+++ b/tests/old/pkgsrcrecords.py
@@ -11,17 +11,17 @@ import sys
def main():
apt_pkg.init()
cache = apt_pkg.Cache()
- i=0
+ i = 0
print "Running PkgSrcRecords test on all packages:"
- for x in cache.Packages:
+ for x in cache.packages:
i += 1
src = apt_pkg.SourceRecords()
- if src.Lookup(x.Name):
- #print src.Package
+ if src.lookup(x.name):
+ #print src.package
pass
print "\r%i/%i=%.3f%% " % (
- i, cache.PackageCount,
- (float(i) / float(cache.PackageCount) * 100)),
+ i, cache.package_count,
+ (float(i) / float(cache.package_count) * 100)),
if __name__ == "__main__":
diff --git a/tests/old/refcount.py b/tests/old/refcount.py
index a29744ae..70adc0c1 100755
--- a/tests/old/refcount.py
+++ b/tests/old/refcount.py
@@ -1,14 +1,13 @@
#!/usr/bin/python-dbg
-from pprint import pprint, pformat
+from pprint import pprint
import apt
import sys
import gc
-import difflib
# get initial cache
print sys.gettotalrefcount()
-progress= apt.progress.OpTextProgress()
+progress = apt.progress.OpTextProgress()
c = apt.Cache(progress)
print "refcount after first cache instance: ", sys.gettotalrefcount()
@@ -41,13 +40,13 @@ print "refcount after second cache.update(): ", sys.gettotalrefcount()
# test install()
c.open(apt.progress.OpProgress())
gc.collect()
-print "refcount before cache['hello'].markInstall(): ", sys.gettotalrefcount()
-c["hello"].markInstall()
+print "refcount before cache['hello'].mark_install(): ", sys.gettotalrefcount()
+c["hello"].mark_install()
c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress())
gc.collect()
print "refcount after: ", sys.gettotalrefcount()
c.open(apt.progress.OpProgress())
-c["hello"].markDelete()
+c["hello"].mark_delete()
c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress())
gc.collect()
print "refcount after: ", sys.gettotalrefcount()
diff --git a/tests/old/test_debextract.py b/tests/old/test_debextract.py
index 4ba498ae..b80d4b1e 100755
--- a/tests/old/test_debextract.py
+++ b/tests/old/test_debextract.py
@@ -4,9 +4,9 @@ import sys
import apt_inst
-def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor):
+def Callback(What, name, Link, Mode, UID, GID, size, MTime, Major, Minor):
print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % (
- What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor)
+ What, name, Link, Mode, UID, GID, size, MTime, Major, Minor)
def main():
diff --git a/tests/old/test_enhances.py b/tests/old/test_enhances.py
index 3eced9f9..a86d57da 100644
--- a/tests/old/test_enhances.py
+++ b/tests/old/test_enhances.py
@@ -10,8 +10,8 @@ for pkg in cache:
for or_list in pkg.installed.enhances:
for enhances in or_list.or_dependencies:
s += " %s" % enhances.name
- if (cache.has_key(enhances.name) and
- not cache[enhances.name].isInstalled):
+ if (enhances.name in cache and
+ not cache[enhances.name].is_installed):
s += "(*missing*) "
s += ","
print s[:-1]
diff --git a/tests/old/test_hashsums.py b/tests/old/test_hashsums.py
deleted file mode 100644
index 0cf6beb7..00000000
--- a/tests/old/test_hashsums.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/python
-
-import unittest
-import apt_pkg
-
-
-class testHashes(unittest.TestCase):
- " test the hashsum functions against strings and files "
-
- def testMD5(self):
- # simple
- s = "foo"
- s_md5 = "acbd18db4cc2f85cedef654fccc4a4d8"
- res = apt_pkg.md5sum(s)
- self.assert_(res == s_md5)
- # file
- res = apt_pkg.md5sum(open("hashsum_test.data"))
- self.assert_(res == s_md5)
- # with zero (\0) in the string
- s = "foo\0bar"
- s_md5 = "f6f5f8cd0cb63668898ba29025ae824e"
- res = apt_pkg.md5sum(s)
- self.assert_(res == s_md5)
- # file
- res = apt_pkg.md5sum(open("hashsum_test_with_zero.data"))
- self.assert_(res == s_md5)
-
- def testSHA1(self):
- # simple
- s = "foo"
- s_hash = "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
- res = apt_pkg.sha1sum(s)
- self.assert_(res == s_hash)
- # file
- res = apt_pkg.sha1sum(open("hashsum_test.data"))
- self.assert_(res == s_hash)
- # with zero (\0) in the string
- s = "foo\0bar"
- s_hash = "e2c300a39311a2dfcaff799528415cb74c19317f"
- res = apt_pkg.sha1sum(s)
- self.assert_(res == s_hash)
- # file
- res = apt_pkg.sha1sum(open("hashsum_test_with_zero.data"))
- self.assert_(res == s_hash)
-
- def testSHA256(self):
- # simple
- s = "foo"
- s_hash = \
- "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"
- res = apt_pkg.sha256sum(s)
- self.assert_(res == s_hash)
- # file
- res = apt_pkg.sha256sum(open("hashsum_test.data"))
- self.assert_(res == s_hash)
- # with zero (\0) in the string
- s = "foo\0bar"
- s_hash = \
- "d6b681bfce7155d44721afb79c296ef4f0fa80a9dd6b43c5cf74dd0f64c85512"
- res = apt_pkg.sha256sum(s)
- self.assert_(res == s_hash)
- # file
- res = apt_pkg.sha256sum(open("hashsum_test_with_zero.data"))
- self.assert_(res == s_hash)
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/test_all.py b/tests/test_all.py
index 25774617..6eebb0cf 100644
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -6,24 +6,18 @@
# notice and this notice are preserved.
"""Run all available unit tests."""
import os
+import unittest.runner
+import unittest
import sys
-try:
- import unittest.runner
- import unittest
-except ImportError:
- # py2.6 compat
- import unittest2 as unittest
-
-
-# workaround for py3.2 that apparently does not have this anymore
-# it has "abiflags"
+# Python 3 only provides abiflags since 3.2
if not hasattr(sys, "pydebug"):
if sys.abiflags.startswith("d"):
sys.pydebug = True
else:
sys.pydebug = False
+
def get_library_dir():
# Find the path to the built apt_pkg and apt_inst extensions
if not os.path.exists("../build"):
@@ -32,22 +26,21 @@ def get_library_dir():
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)
+ library_dir = "../build/lib%s%s" % (plat_specifier,
+ (sys.pydebug and "-pydebug" or ""))
return os.path.abspath(library_dir)
+
class MyTestRunner(unittest.runner.TextTestRunner):
def __init__(self, *args, **kwargs):
kwargs["stream"] = sys.stdout
super(MyTestRunner, self).__init__(*args, **kwargs)
+
if __name__ == '__main__':
if not os.access("/etc/apt/sources.list", os.R_OK):
- sys.stdout.write("[tests] Skipping because sources.list is not readable\n")
+ sys.stdout.write(
+ "[tests] Skipping because sources.list is not readable\n")
sys.exit(0)
sys.stdout.write("[tests] Running on %s\n" % sys.version.replace("\n", ""))
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index 21dfeb98..4df5e27d 100644
--- a/tests/test_apt_cache.py
+++ b/tests/test_apt_cache.py
@@ -16,11 +16,6 @@ import sys
import tempfile
import unittest
-if sys.version_info[0] == 2 and sys.version_info[1] == 6:
- from unittest2 import TestCase
-else:
- from unittest import TestCase
-
from test_all import get_library_dir
libdir = get_library_dir()
@@ -36,7 +31,8 @@ def if_sources_list_is_readable(f):
if os.access("/etc/apt/sources.list", os.R_OK):
f(*args, **kwargs)
else:
- logging.warning("skipping '%s' because sources.list is not readable" % f)
+ logging.warning(
+ "skipping '%s' because sources.list is not readable" % f)
return wrapper
@@ -49,7 +45,7 @@ def get_open_file_descriptors():
return set(map(int, fds))
-class TestAptCache(TestCase):
+class TestAptCache(unittest.TestCase):
""" test the apt cache """
def setUp(self):
@@ -124,20 +120,23 @@ class TestAptCache(TestCase):
cache = apt.Cache(rootdir="./data/test-provides/")
cache.open()
if len(cache) == 0:
- logging.warning("skipping test_get_provided_packages, cache empty?!?")
+ logging.warning(
+ "skipping test_get_provided_packages, cache empty?!?")
return
# a true virtual pkg
l = cache.get_providing_packages("mail-transport-agent")
self.assertTrue(len(l) > 0)
self.assertTrue("postfix" in [p.name for p in l])
- self.assertTrue("mail-transport-agent" in cache["postfix"].candidate.provides)
+ self.assertTrue(
+ "mail-transport-agent" in cache["postfix"].candidate.provides)
def test_low_level_pkg_provides(self):
apt.apt_pkg.config.set("Apt::architecture", "i386")
# create highlevel cache and get the lowlevel one from it
highlevel_cache = apt.Cache(rootdir="./data/test-provides")
if len(highlevel_cache) == 0:
- logging.warning("skipping test_log_level_pkg_provides, cache empty?!?")
+ logging.warning(
+ "skipping test_log_level_pkg_provides, cache empty?!?")
return
# low level cache provides list of the pkg
cache = highlevel_cache._cache
@@ -150,24 +149,24 @@ class TestAptCache(TestCase):
break
else:
self.assertNotReached()
-
+
@if_sources_list_is_readable
def test_dpkg_journal_dirty(self):
# create tmp env
tmpdir = tempfile.mkdtemp()
- dpkg_dir = os.path.join(tmpdir,"var","lib","dpkg")
- os.makedirs(os.path.join(dpkg_dir,"updates"))
- open(os.path.join(dpkg_dir,"status"), "w").close()
+ dpkg_dir = os.path.join(tmpdir, "var", "lib", "dpkg")
+ os.makedirs(os.path.join(dpkg_dir, "updates"))
+ open(os.path.join(dpkg_dir, "status"), "w").close()
apt_pkg.config.set("Dir::State::status",
- os.path.join(dpkg_dir,"status"))
+ os.path.join(dpkg_dir, "status"))
cache = apt.Cache()
# test empty
self.assertFalse(cache.dpkg_journal_dirty)
# that is ok, only [0-9] are dpkg jounral entries
- open(os.path.join(dpkg_dir,"updates","xxx"), "w").close()
- self.assertFalse(cache.dpkg_journal_dirty)
+ open(os.path.join(dpkg_dir, "updates", "xxx"), "w").close()
+ self.assertFalse(cache.dpkg_journal_dirty)
# that is a dirty journal
- open(os.path.join(dpkg_dir,"updates","000"), "w").close()
+ open(os.path.join(dpkg_dir, "updates", "000"), "w").close()
self.assertTrue(cache.dpkg_journal_dirty)
@if_sources_list_is_readable
@@ -188,7 +187,8 @@ class TestAptCache(TestCase):
old_source_list = apt_pkg.config.find("dir::etc::sourcelist")
old_source_parts = apt_pkg.config.find("dir::etc::sourceparts")
apt_pkg.config.set("dir::etc::sourcelist", base_sources)
- apt_pkg.config.set("dir::etc::sourceparts", "/tmp")
+ # TODO: /dev/null is not a dir, perhaps find something better
+ apt_pkg.config.set("dir::etc::sourceparts", "/dev/null")
# main sources.list
sources_list = base_sources
with open(sources_list, "w") as f:
@@ -208,29 +208,29 @@ class TestAptCache(TestCase):
# update a single sources.list
cache = apt.Cache()
cache.update(sources_list=sources_list)
- # verify we just got the excpected package file
+ # verify we just got the excpected package file
needle_packages = glob.glob(
- lists_dir+"/*tests_data_test-repo_Packages*")
+ lists_dir + "/*tests_data_test-repo_Packages*")
self.assertEqual(len(needle_packages), 1)
# verify that we *only* got the Packages file from a single source
- all_packages = glob.glob(lists_dir+"/*_Packages*")
+ all_packages = glob.glob(lists_dir + "/*_Packages*")
self.assertEqual(needle_packages, all_packages)
# verify that the listcleaner was not run and the marker file is
# still there
self.assertTrue("marker" in os.listdir(lists_dir))
-
# now run update again (without the "normal" sources.list that
# contains test-repo2 and verify that we got the normal sources.list
cache.update()
- needle_packages = glob.glob(lists_dir+"/*tests_data_test-repo2_Packages*")
+ needle_packages = glob.glob(
+ lists_dir + "/*tests_data_test-repo2_Packages*")
self.assertEqual(len(needle_packages), 1)
- all_packages = glob.glob(lists_dir+"/*_Packages*")
+ all_packages = glob.glob(lists_dir + "/*_Packages*")
self.assertEqual(needle_packages, all_packages)
# and another update with a single source only
cache = apt.Cache()
cache.update(sources_list=sources_list)
- all_packages = glob.glob(lists_dir+"/*_Packages*")
+ all_packages = glob.glob(lists_dir + "/*_Packages*")
self.assertEqual(len(all_packages), 2)
apt_pkg.config.set("dir::state", old_state)
apt_pkg.config.set("dir::etc::sourcelist", old_source_list)
diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py
index 75dd91c1..f174bd41 100644
--- a/tests/test_aptsources.py
+++ b/tests/test_aptsources.py
@@ -40,11 +40,11 @@ class TestAptSources(unittest.TestCase):
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
"sources.list")
sources = aptsources.sourceslist.SourcesList(True, self.templates)
- self.assertEqual(len(sources.list), 9)
+ self.assertEqual(len(sources.list), 10)
# test load
sources.list = []
sources.load("data/aptsources/sources.list")
- self.assertEqual(len(sources.list), 9)
+ self.assertEqual(len(sources.list), 10)
def testSourcesListAdding(self):
"""aptsources: Test additions to sources.list"""
@@ -70,7 +70,6 @@ class TestAptSources(unittest.TestCase):
["main"], architectures=["amd64", "i386"])
self.assertTrue(sources.list == before.list)
-
# test to add something new: multiverse
sources.add("deb", "http://de.archive.ubuntu.com/ubuntu/",
"edgy",
@@ -78,9 +77,9 @@ class TestAptSources(unittest.TestCase):
found = False
for entry in sources:
if (entry.type == "deb" and
- entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
- entry.dist == "edgy" and
- "multiverse" in entry.comps):
+ entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
+ entry.dist == "edgy" and
+ "multiverse" in entry.comps):
found = True
self.assertTrue(found)
@@ -91,10 +90,10 @@ class TestAptSources(unittest.TestCase):
found = False
for entry in sources:
if (entry.type == "deb" and
- entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
- entry.dist == "natty" and
- entry.architectures == [] and
- "multiverse" in entry.comps):
+ entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
+ entry.dist == "natty" and
+ entry.architectures == [] and
+ "multiverse" in entry.comps):
found = True
self.assertTrue(found)
@@ -105,10 +104,10 @@ class TestAptSources(unittest.TestCase):
found = False
for entry in sources:
if (entry.type == "deb" and
- entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
- entry.dist == "natty" and
- set(entry.architectures) == set(["amd64", "i386"]) and
- set(entry.comps) == set(["main", "universe"])):
+ entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
+ entry.dist == "natty" and
+ set(entry.architectures) == set(["amd64", "i386"]) and
+ set(entry.comps) == set(["main", "universe"])):
found = True
self.assertTrue(found)
# test to add something new: multiverse *and*
@@ -121,8 +120,8 @@ class TestAptSources(unittest.TestCase):
found_something = 0
for entry in sources:
if (entry.type == "deb" and
- entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
- entry.dist == "edgy"):
+ entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
+ entry.dist == "edgy"):
for c in entry.comps:
if c == "universe":
found_universe += 1
@@ -140,7 +139,6 @@ class TestAptSources(unittest.TestCase):
distro = aptsources.distro.get_distro(id="Ubuntu")
distro.get_sources(sources)
# test if all suits of the current distro were detected correctly
- dist_templates = set()
for s in sources:
if not s.template:
self.fail("source entry '%s' has no matcher" % s)
@@ -151,17 +149,32 @@ class TestAptSources(unittest.TestCase):
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
"sources.list")
sources = aptsources.sourceslist.SourcesList(True, self.templates)
-
- assert sources.list[8].invalid == False
+ assert not sources.list[8].invalid
assert sources.list[8].type == "deb"
assert sources.list[8].architectures == ["amd64", "i386"]
assert sources.list[8].uri == "http://de.archive.ubuntu.com/ubuntu/"
assert sources.list[8].dist == "natty"
assert sources.list[8].comps == ["main"]
assert sources.list[8].line.strip() == str(sources.list[8])
+ assert sources.list[8].trusted is None
+
+ def testMultipleOptions(self):
+ """aptsources: Test multi-arch parsing"""
+
+ apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
+ "sources.list")
+ sources = aptsources.sourceslist.SourcesList(True, self.templates)
+ assert sources.list[9].invalid is False
+ assert sources.list[9].type == "deb"
+ assert sources.list[9].architectures == ["amd64", "i386"]
+ self.assertEqual(
+ sources.list[9].uri, "http://de.archive.ubuntu.com/ubuntu/")
+ assert sources.list[9].dist == "natty"
+ assert sources.list[9].comps == ["main"]
+ assert sources.list[9].trusted
+ assert sources.list[9].line.strip() == str(sources.list[9])
def test_enable_component(self):
- from subprocess import Popen, PIPE
target = "./data/aptsources/sources.list.enable_comps"
line = "deb http://archive.ubuntu.com/ubuntu lucid main\n"
with open(target, "w") as target_file:
@@ -183,7 +196,7 @@ class TestAptSources(unittest.TestCase):
comps = comps.union(set(entry.comps))
self.assertTrue("multiverse" in comps)
self.assertTrue("universe" in comps)
-
+
def testDistribution(self):
"""aptsources: Test distribution detection."""
apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/"
@@ -206,11 +219,11 @@ class TestAptSources(unittest.TestCase):
found = {}
for entry in sources:
if (entry.type == "deb" and
- entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
- "edgy" in entry.dist):
+ entry.uri == "http://de.archive.ubuntu.com/ubuntu/" and
+ "edgy" in entry.dist):
for c in entry.comps:
if c == comp:
- if not entry.dist in found:
+ if entry.dist not in found:
found[entry.dist] = 0
found[entry.dist] += 1
#print "".join([s.str() for s in sources])
@@ -223,11 +236,11 @@ class TestAptSources(unittest.TestCase):
found = {}
for entry in sources:
if (entry.type == "deb" and
- entry.template and
- entry.template.name == "edgy"):
+ entry.template and
+ entry.template.name == "edgy"):
for c in entry.comps:
if c == comp:
- if not entry.dist in found.has_key:
+ if entry.dist not in found.has_key:
found[entry.dist] = 0
found[entry.dist] += 1
#print "".join([s.str() for s in sources])
diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py
index 67c21b9c..b625b8c4 100644
--- a/tests/test_aptsources_ports.py
+++ b/tests/test_aptsources_ports.py
@@ -31,7 +31,6 @@ class TestAptSourcesPorts(unittest.TestCase):
"8.04")
distro.get_sources(sources)
# test if all suits of the current distro were detected correctly
- dist_templates = set()
for s in sources:
if not s.line.strip() or s.line.startswith("#"):
continue
diff --git a/tests/test_auth.py b/tests/test_auth.py
index bc353427..67377363 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -15,17 +15,13 @@ import unittest
if sys.version_info[0] > 2:
from http.server import HTTPServer
from http.server import SimpleHTTPRequestHandler as HTTPRequestHandler
+ HTTPServer # pyflakes
+ HTTPRequestHandler # pyflakes
else:
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler as HTTPRequestHandler
-if sys.version_info[0] == 2 and sys.version_info[1] == 6:
- from unittest2 import TestCase
-else:
- from unittest import TestCase
-
-
import apt_pkg
import apt.auth
@@ -115,22 +111,10 @@ DHcut3Yey8o=
-----END PGP PUBLIC KEY BLOCK-----"""
-class TestAuthKeys(TestCase):
+class TestAuthKeys(unittest.TestCase):
"""Test handling of keys for signed repositories."""
- if sys.version_info[0] == 2 and sys.version_info[1] < 7:
- def addCleanup(self, function, *args, **kwds):
- try:
- self.cleanup.append(lambda: function(*args, **kwds))
- except AttributeError:
- self.cleanup = [lambda: function(*args, **kwds)]
-
- def tearDown(self):
- for f in self.cleanup:
- f()
- self.cleanup = []
-
def setUp(self):
# reset any config manipulations done in the individual tests
apt_pkg.init_config()
@@ -215,7 +199,8 @@ class TestAuthKeys(TestCase):
def test_add_key_from_keyserver_too_short(self):
"""Ensure that short keyids are not imported"""
with self.assertRaises(apt.auth.AptKeyError):
- apt.auth.add_key_from_keyserver("46925553", "hkp://localhost:19191")
+ apt.auth.add_key_from_keyserver(
+ "46925553", "hkp://localhost:19191")
def test_add_key_from_server_mitm(self):
"""Verify that the key fingerprint is verified after download"""
@@ -227,7 +212,11 @@ class TestAuthKeys(TestCase):
"0101010178F7FE5C3E65D8AF8B48AD6246925553",
"hkp://localhost:%d" % self.keyserver_port)
self.assertTrue(
- str(cm.exception).startswith("Fingerprints do not match"), cm.exception)
+ str(cm.exception).startswith(
+ "recv from 'hkp://localhost:%d' failed for '%s'" % (
+ self.keyserver_port,
+ "0101010178F7FE5C3E65D8AF8B48AD6246925553")),
+ cm.exception)
def testAddKeyFromServer(self):
"""Install a GnuPG key from a remote server."""
@@ -236,7 +225,7 @@ class TestAuthKeys(TestCase):
with self._discard_stderr():
apt.auth.add_key_from_keyserver(
- "0xa1bD8E9D78F7FE5C3E65D8AF8B48AD6246925553",
+ "0xa1bD8E9D78F7FE5C3E65D8AF8B48AD6246925553",
"hkp://localhost:%d" % self.keyserver_port)
ret = apt.auth.list_keys()
diff --git a/tests/test_cache_invocation.py b/tests/test_cache_invocation.py
index a89ef557..4bba0813 100644
--- a/tests/test_cache_invocation.py
+++ b/tests/test_cache_invocation.py
@@ -25,6 +25,7 @@ class TestCache(unittest.TestCase):
"""cache_invocation: Test correct invocation."""
apt_cache = apt_pkg.Cache(progress=None)
apt_depcache = apt_pkg.DepCache(apt_cache)
+ self.assertNotEqual(apt_depcache, None)
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_configuration.py b/tests/test_configuration.py
index 80509cff..adf33719 100644
--- a/tests/test_configuration.py
+++ b/tests/test_configuration.py
@@ -7,7 +7,6 @@
# notice and this notice are preserved.
"""Unit tests for verifying the correctness of apt_pkg.Configuration"""
import unittest
-
import apt_pkg
@@ -21,9 +20,9 @@ class TestConfiguration(unittest.TestCase):
def test_lp707416(self):
"""configuration: Test empty arguments (LP: #707416)"""
self.assertRaises(ValueError, apt_pkg.parse_commandline,
- apt_pkg.config,[], [])
+ apt_pkg.config, [], [])
self.assertRaises(SystemError, apt_pkg.parse_commandline,
- apt_pkg.config,[], ["cmd", "--arg0"])
+ apt_pkg.config, [], ["cmd", "--arg0"])
if __name__ == "__main__":
diff --git a/tests/test_debfile.py b/tests/test_debfile.py
index 2ae73a45..d6cc88b2 100644
--- a/tests/test_debfile.py
+++ b/tests/test_debfile.py
@@ -19,6 +19,7 @@ if libdir:
import apt_pkg
import apt.debfile
+
class TestDebfile(unittest.TestCase):
""" test the debfile """
@@ -32,51 +33,71 @@ class TestDebfile(unittest.TestCase):
# Conflicts: apt (<= 0.1)
('gdebi-test4.deb', True),
# Conflicts: apt (>= 0.1)
- ('gdebi-test5.deb', False),
+ ('gdebi-test5.deb', False),
# invalid unicode in descr
('gdebi-test6.deb', True),
# provides/conflicts against "foobarbaz"
('gdebi-test7.deb', True),
# provides/conflicts/replaces against "mail-transport-agent"
# (should fails if mail-transport-agent is installed)
- ('gdebi-test8.deb', False),
+ ('gdebi-test8.deb', False),
# provides/conflicts against real pkg
('gdebi-test9.deb', True),
- # provides debconf-tiny and the real debconf conflicts with
+ # provides debconf-tiny and the real debconf conflicts with
('gdebi-test10.deb', False),
]
def setUp(self):
apt_pkg.init_config()
- apt_pkg.config.set("APT::Architecture","i386")
+ apt_pkg.config.set("APT::Architecture", "i386")
# FIXME: When run via test_all.py, the tests fail without this if it
# is set in the system.
apt_pkg.config.clear("APT::Architectures")
- apt_pkg.config.set("Dir::State::status",
+ apt_pkg.config.set("Dir::State::status",
"./data/test_debs/var/lib/dpkg/status")
- apt_pkg.config.set("Dir::State::lists",
+ apt_pkg.config.set("Dir::State::lists",
"./data/test_debs/var/lib/apt/lists")
- apt_pkg.config.set("Dir::Etc::sourcelist",
+ apt_pkg.config.set("Dir::Etc::sourcelist",
"./data/test_debs/etc/apt/sources.list")
apt_pkg.init_system()
self.cache = apt.Cache()
- def testDscFile(self):
+ def test_dsc_file(self):
filename = "hello_2.5-1.dsc"
deb = apt.debfile.DscSrcPackage(cache=self.cache)
deb.open(os.path.join("data", "test_debs", filename))
self.assertTrue(deb.check(), "got failure '%s'" % deb._failure_string)
missing = set(['autotools-dev'])
self.assertEqual(set(deb.missing_deps), missing)
+ # specialized properties
+ self.assertEqual(deb.pkgname, "hello")
+ self.assertEqual(deb.binaries, ["hello", "bello", "cello"])
+ self.assertEqual(deb.filelist, ["hello_2.5.orig.tar.gz",
+ "hello_2.5-1.diff.gz"])
+ self.assertEqual(deb.depends, [[("autotools-dev", "", "")]])
+ # tag fields are available as a dict
+ self.assertEqual(deb["Format"], "1.0")
+ self.assertEqual(deb["Source"], "hello")
+ self.assertEqual(deb["Binary"], "hello, bello,\n cello")
+ self.assertEqual(deb["Architecture"], "any")
+ self.assertEqual(deb["Version"], "2.5-1")
+ self.assertEqual(
+ deb["Maintainer"], "Santiago Vila <sanvila@debian.org>")
+ self.assertEqual(deb["Homepage"], "http://www.gnu.org/software/hello")
+ self.assertEqual(deb["Standards-Version"], "3.8.4")
+
+ def test_dsc_file_with_impossible_build_dep(self):
filename = "impossible-build-depends_2.5-1.dsc"
deb = apt.debfile.DscSrcPackage(cache=self.cache)
deb.open(os.path.join("data", "test_debs", filename))
self.assertFalse(deb.check())
+ self.assertEqual(deb.depends, [[("debhelper", "101", ">")]])
- def testDebFile(self):
+ def test_deb_file(self):
deb = apt.debfile.DebPackage(cache=self.cache)
for (filename, expected_res) in self.TEST_DEBS:
- logging.debug("testing %s, expecting %s" % (filename, expected_res))
+ logging.debug("testing %s, expecting %s" % (
+ filename, expected_res))
deb.open(os.path.join("data", "test_debs", filename))
res = deb.check()
self.assertEqual(res, expected_res,
@@ -85,7 +106,8 @@ class TestDebfile(unittest.TestCase):
def test_utf8_sections(self):
deb = apt.debfile.DebPackage(cache=self.cache)
- deb.open(os.path.join("data","test_debs","utf8-package_1.0-1_all.deb"))
+ deb.open(
+ os.path.join("data", "test_debs", "utf8-package_1.0-1_all.deb"))
self.assertEqual(deb["Maintainer"],
"Samuel Lidén Borell <samuel@slbdata.se>")
@@ -99,7 +121,8 @@ class TestDebfile(unittest.TestCase):
deb = apt.debfile.DebPackage(cache=self.cache)
deb.open(os.path.join("data", "test_debs", "gdebi-test12.deb"))
content = deb.data_content("usr/bin/binary")
- self.assertTrue(content.startswith("Automatically converted to printable ascii:\n\x7fELF "))
+ self.assertTrue(content.startswith(
+ "Automatically converted to printable ascii:\n\x7fELF "))
# control file
needle = """Package: gdebi-test12
Version: 1.0
@@ -116,6 +139,12 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading
deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb")
self.assertEqual(deb.filelist, ["./", "usr/", "usr/bin/"])
+ @unittest.skipIf(apt_pkg.version_compare(apt_pkg.VERSION, "0.9.15.4~") < 0,
+ "APT too old for uncompressed control.tar/data.tar")
+ def test_uncompressed_data(self):
+ deb = apt.debfile.DebPackage("./data/test_debs/data-tar.deb")
+ self.assertEqual(deb.filelist, ["./", "usr/", "usr/bin/"])
+
def test_check_exception(self):
deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb")
self.assertRaises(AttributeError, lambda: deb.missing_deps)
@@ -123,20 +152,37 @@ Description: testpackage for gdebi - contains usr/bin/binary for file reading
deb.missing_deps
def test_no_supported_data_tar(self):
- # ensure that a unknown data.tar.xxx raises a exception
- raised = False
- try:
- deb = apt.debfile.DebPackage("./data/test_debs/data-tar-broken.deb")
- except SystemError:
- raised = True
- # with self.assertRaises(SystemError): is more elegant above, but
- # we need to support python2.6
- self.assertTrue(raised)
+ with self.assertRaises(SystemError):
+ apt.debfile.DebPackage("./data/test_debs/data-tar-broken.deb")
def test_contains(self):
deb = apt.debfile.DebPackage("./data/test_debs/data-tar-xz.deb")
self.assertTrue("Package" in deb)
+ def test_multi_arch_allowed(self):
+ apt_pkg.config["APT::Architectures::"] = "i386"
+ apt_pkg.config["APT::Architectures::"] = "amd64"
+ apt_pkg.config["APT::Architecture"] = "amd64"
+ apt_pkg.init_system()
+
+ allowed_any = apt.debfile.DebPackage(
+ "./data/test_debs/testdep-allowed-any_1.0-1_i386.deb")
+ self.assertTrue(allowed_any.check(), allowed_any._failure_string)
+
+ def test_multi_arch_same(self):
+ apt_pkg.config["APT::Architectures::"] = "i386"
+ apt_pkg.config["APT::Architectures::"] = "amd64"
+ apt_pkg.config["APT::Architecture"] = "amd64"
+ apt_pkg.init_system()
+ same = apt.debfile.DebPackage(
+ "./data/test_debs/testdep-same-arch_1.0-1_i386.deb")
+ self.assertTrue(same.check(), same._failure_string)
+
+ def test_get_content_gzip_data(self):
+ deb = apt.debfile.DebPackage("./data/test_debs/gdebi-test13.deb")
+ data = deb.data_content("./lala.gz")
+ self.assertEqual(data, "Automatically decompressed:\n\nlala\n")
+
if __name__ == "__main__":
#logging.basicConfig(level=logging.DEBUG)
diff --git a/tests/test_debfile_multiarch.py b/tests/test_debfile_multiarch.py
index bbf62016..f8847838 100644
--- a/tests/test_debfile_multiarch.py
+++ b/tests/test_debfile_multiarch.py
@@ -7,8 +7,6 @@
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
"""Unit tests for verifying the correctness of DebPackage in apt.debfile."""
-import os
-import logging
import unittest
from test_all import get_library_dir
@@ -20,13 +18,15 @@ import apt
import apt_pkg
import apt.debfile
+
class TestDebfileMultiarch(unittest.TestCase):
""" test the multiarch debfile """
def test_multiarch_deb_check(self):
if apt_pkg.get_architectures() != ["amd64", "i386"]:
# TODO: use unittest.skip
- #logging.warning("skipping test because running on a non-multiarch system")
+ #logging.warning("skipping test because running on a "
+ # "non-multiarch system")
return
deb = apt.debfile.DebPackage(
"./data/test_debs/multiarch-test1_i386.deb")
@@ -39,7 +39,7 @@ class TestDebfileMultiarch(unittest.TestCase):
# WARNING: this assumes that lib3ds-1-3 is a non-multiarch lib
# use "lib3ds-1-3" as a test to see if non-multiach lib conflicts work
canary = "lib3ds-1-3"
- if not canary in cache:
+ if canary not in cache:
# TODO: use unittest.skip
#logging.warning("skipping test because %s is missing" % canary)
return
@@ -50,10 +50,9 @@ class TestDebfileMultiarch(unittest.TestCase):
installable = deb.check()
#print deb._failure_string
self.assertFalse(installable)
- self.assertEqual(deb._failure_string,
+ self.assertEqual(deb._failure_string,
"Conflicts with the installed package 'lib3ds-1-3'")
-
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_deps.py b/tests/test_deps.py
index e9a75ee2..96bcd57b 100644
--- a/tests/test_deps.py
+++ b/tests/test_deps.py
@@ -6,9 +6,11 @@
# 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 itertools
import unittest
import apt_pkg
+import apt.package
class TestDependencies(unittest.TestCase):
@@ -110,6 +112,22 @@ class TestDependencies(unittest.TestCase):
self.assertEqual(len(depends_this), len(depends_this_too), 1)
self.assertEqual(len(depends_other), len(depends_other_too), 0)
+ def test_dstr(self):
+ """Test apt.package.BaseDependency.__dstr"""
+ dstr = apt.package.BaseDependency._BaseDependency__dstr
+ equal = {"<": {"<<", "<"},
+ "=": {"==", "="},
+ ">": {">>", ">"}}
+ operators = ["<<", "<", "<=", "!=", "=", "==", ">=", ">", ">>"]
+
+ for a, b in itertools.product(equal.keys(), operators):
+ if b in equal[a]:
+ self.assertEqual(dstr(a), b)
+ self.assertEqual(b, dstr(a))
+ else:
+ self.assertNotEqual(dstr(a), b)
+ self.assertNotEqual(b, dstr(a))
+
def testParseDepends(self):
"""dependencies: Test apt_pkg.ParseDepends()."""
if not hasattr(apt_pkg, 'ParseDepends'):
diff --git a/tests/test_group.py b/tests/test_group.py
index 3c3a5b7a..e70d2479 100644
--- a/tests/test_group.py
+++ b/tests/test_group.py
@@ -22,7 +22,6 @@ class TestGroup(unittest.TestCase):
list(group) == list(group)
-
def test_cache_groups(self):
"""group: Iterate over all groups"""
assert len(list(self.cache.groups)) == self.cache.group_count
diff --git a/tests/test_hashes.py b/tests/test_hashes.py
index 660373cb..be817f88 100644
--- a/tests/test_hashes.py
+++ b/tests/test_hashes.py
@@ -90,7 +90,7 @@ class TestHashString(unittest.TestCase):
def tearDown(self):
"""Cleanup, Close the file object used for the tests."""
- self.file.close()
+ self.file.close()
def test_md5(self):
"""hashes: Test apt_pkg.HashString().md5"""
diff --git a/tests/test_hashsums.py b/tests/test_hashsums.py
new file mode 100644
index 00000000..bd2dba91
--- /dev/null
+++ b/tests/test_hashsums.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+
+import unittest
+import apt_pkg
+
+
+class testHashes(unittest.TestCase):
+ " test the hashsum functions against strings and files "
+
+ DATA_PATH = "data/hashsums/hashsum_test.data"
+ DATA_WITH_ZERO_PATH = "data/hashsums/hashsum_test_with_zero.data"
+
+ def testMD5(self):
+ # simple
+ s = b"foo"
+ s_md5 = "acbd18db4cc2f85cedef654fccc4a4d8"
+ res = apt_pkg.md5sum(s)
+ self.assertEqual(res, s_md5)
+ # file
+ with open(self.DATA_PATH) as fobj:
+ self.assertEqual(apt_pkg.md5sum(fobj), s_md5)
+ # with zero (\0) in the string
+ s = b"foo\0bar"
+ s_md5 = "f6f5f8cd0cb63668898ba29025ae824e"
+ res = apt_pkg.md5sum(s)
+ self.assertEqual(res, s_md5)
+ # file
+ with open(self.DATA_WITH_ZERO_PATH) as fobj:
+ self.assertEqual(apt_pkg.md5sum(fobj), s_md5)
+
+ def testSHA1(self):
+ # simple
+ s = b"foo"
+ s_hash = "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
+ res = apt_pkg.sha1sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha1sum(fobj), s_hash)
+ # with zero (\0) in the string
+ s = b"foo\0bar"
+ s_hash = "e2c300a39311a2dfcaff799528415cb74c19317f"
+ res = apt_pkg.sha1sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_WITH_ZERO_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha1sum(fobj), s_hash)
+
+ def testSHA256(self):
+ # simple
+ s = b"foo"
+ s_hash = \
+ "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"
+ res = apt_pkg.sha256sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha256sum(fobj), s_hash)
+ # with zero (\0) in the string
+ s = b"foo\0bar"
+ s_hash = \
+ "d6b681bfce7155d44721afb79c296ef4f0fa80a9dd6b43c5cf74dd0f64c85512"
+ res = apt_pkg.sha256sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_WITH_ZERO_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha256sum(fobj), s_hash)
+
+ def testSHA512(self):
+ # simple
+ s = b"foo"
+ s_hash = \
+ "f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d" \
+ "0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19" \
+ "594a7eb539453e1ed7"
+ res = apt_pkg.sha512sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha512sum(fobj), s_hash)
+ # with zero (\0) in the string
+ s = b"foo\0bar"
+ s_hash = \
+ "8c5e791db8f6bfb40eba884f70c9ac52231f01a393e4e55b4576d45" \
+ "9a827f34f77e41e7fac806724517b9e96bb42387c5f9bbf325d2f99" \
+ "ed52a4aa6abebc3350"
+ res = apt_pkg.sha512sum(s)
+ self.assertEqual(res, s_hash)
+ # file
+ with open(self.DATA_WITH_ZERO_PATH) as fobj:
+ self.assertEqual(apt_pkg.sha512sum(fobj), s_hash)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_large_file.py b/tests/test_large_file.py
new file mode 100644
index 00000000..852c8579
--- /dev/null
+++ b/tests/test_large_file.py
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+
+import sys
+import unittest
+
+import apt_inst
+
+IS_NOT_32BIT = sys.maxsize > 2 ** 32
+
+
+@unittest.skipIf(IS_NOT_32BIT, "Large File support is for 32 bit systems")
+class testHashes(unittest.TestCase):
+ " test the hashsum functions against strings and files "
+
+ LARGE_PACKAGE_CONTENT = "data/test_debs/large-package-content_1.0_all.deb"
+
+ def testExtractData(self):
+ deb = apt_inst.DebFile(self.LARGE_PACKAGE_CONTENT)
+
+ self.assertRaises(MemoryError, deb.data.extractdata, "large-file")
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_lp659438.py b/tests/test_lp659438.py
index b9a837b4..40943d10 100644
--- a/tests/test_lp659438.py
+++ b/tests/test_lp659438.py
@@ -20,7 +20,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Licensed under the GNU General Public License Version 2
-__author__ = "Sebastian Heinlein <devel@glatzor.de>"
+__author__ = "Sebastian Heinlein <devel@glatzor.de>"
import os
import shutil
@@ -63,7 +63,7 @@ Architecture: all""")
def tearDown(self):
# this resets the rootdir apt_pkg.config to ensure it does not
# "pollute" the later tests
- cache = apt.cache.Cache(rootdir="/")
+ apt.cache.Cache(rootdir="/")
shutil.rmtree(self.chroot_path)
def test_survive_reqreinst(self):
diff --git a/tests/test_paths.py b/tests/test_paths.py
new file mode 100644
index 00000000..d647e6e2
--- /dev/null
+++ b/tests/test_paths.py
@@ -0,0 +1,160 @@
+#
+# Test that both unicode and bytes path names work
+#
+import os
+import shutil
+import unittest
+import warnings
+
+import apt_inst
+import apt_pkg
+
+
+class TestPath(unittest.TestCase):
+
+ dir_unicode = u'data/tmp'
+ dir_bytes = b'data/tmp'
+ file_unicode = u'data/tmp/python-apt-test'
+ file_bytes = b'data/tmp/python-apt-test'
+
+ def setUp(self):
+ apt_pkg.init()
+ if os.path.exists(self.dir_bytes):
+ shutil.rmtree(self.dir_bytes)
+
+ os.mkdir(self.dir_bytes)
+
+ def tearDown(self):
+ apt_pkg.config["dir"] = "/"
+ shutil.rmtree(self.dir_bytes)
+
+ def test_acquire(self):
+ apt_pkg.AcquireFile(apt_pkg.Acquire(), "http://example.com",
+ destdir=self.file_bytes, destfile=self.file_bytes)
+ apt_pkg.AcquireFile(apt_pkg.Acquire(),
+ "http://example.com",
+ destdir=self.file_unicode,
+ destfile=self.file_unicode)
+
+ def test_acquire_file_md5_keyword_backward_compat(self):
+ """
+ Ensure that both "md5" and "hash" is supported as keyword for
+ AcquireFile
+ """
+ with warnings.catch_warnings(record=True) as caught_warnings:
+ warnings.simplefilter("always")
+ apt_pkg.AcquireFile(
+ apt_pkg.Acquire(), "http://example.com",
+ destfile=self.file_bytes,
+ md5="abcdef")
+
+ self.assertEqual(len(caught_warnings), 1)
+ self.assertTrue(issubclass(caught_warnings[0].category,
+ DeprecationWarning))
+ self.assertIn("md5", str(caught_warnings[0].message))
+ self.assertIn("hash", str(caught_warnings[0].message))
+
+ apt_pkg.AcquireFile(
+ apt_pkg.Acquire(), "http://example.com",
+ destfile=self.file_bytes,
+ hash="sha1:41050ed528554fdd6c6c9a086ddd6bdba5857b21")
+
+ def test_ararchive(self):
+ archive = apt_inst.ArArchive(u"data/test_debs/data-tar-xz.deb")
+
+ apt_inst.ArArchive(b"data/test_debs/data-tar-xz.deb")
+
+ archive.extract(u"debian-binary", u"data/tmp")
+ archive.extract(b"debian-binary", b"data/tmp")
+ archive.extractall(u"data/tmp")
+ archive.extractall(b"data/tmp")
+ self.assertEqual(archive.extractdata(u"debian-binary"), b"2.0\n")
+ self.assertEqual(archive.extractdata(b"debian-binary"), b"2.0\n")
+ self.assertTrue(archive.getmember(u"debian-binary"))
+ self.assertTrue(archive.getmember(b"debian-binary"))
+ self.assertTrue(u"debian-binary" in archive)
+ self.assertTrue(b"debian-binary" in archive)
+ self.assertTrue(archive[b"debian-binary"])
+ self.assertTrue(archive[u"debian-binary"])
+
+ tar = archive.gettar(u"control.tar.xz", "xz")
+ tar = archive.gettar(b"control.tar.xz", "xz")
+
+ tar.extractall(self.dir_unicode)
+ tar.extractall(self.dir_bytes)
+ self.assertRaises(LookupError, tar.extractdata, u"Do-not-exist")
+ self.assertRaises(LookupError, tar.extractdata, b"Do-not-exist")
+ tar.extractdata(b"control")
+ tar.extractdata(u"control")
+
+ apt_inst.TarFile(os.path.join(self.dir_unicode, u"control.tar.xz"))
+ apt_inst.TarFile(os.path.join(self.dir_bytes, b"control.tar.xz"))
+
+ def test_configuration(self):
+ with open(self.file_unicode, 'w') as config:
+ config.write("Hello { World 1; };")
+ apt_pkg.read_config_file(apt_pkg.config, self.file_bytes)
+ apt_pkg.read_config_file(apt_pkg.config, self.file_unicode)
+ apt_pkg.read_config_file_isc(apt_pkg.config, self.file_bytes)
+ apt_pkg.read_config_file_isc(apt_pkg.config, self.file_unicode)
+ apt_pkg.read_config_dir(apt_pkg.config, self.dir_unicode)
+ apt_pkg.read_config_dir(apt_pkg.config, b"/etc/apt/apt.conf.d")
+
+ def test_index_file(self):
+ apt_pkg.config["dir"] = "data/test_debs"
+ slist = apt_pkg.SourceList()
+ slist.read_main_list()
+
+ for meta in slist.list:
+ for index in meta.index_files:
+ index.archive_uri(self.file_bytes)
+ index.archive_uri(self.file_unicode)
+
+ def test_index_records(self):
+ index = apt_pkg.IndexRecords()
+ index.load(u"./data/misc/foo_Release")
+ index.load(b"./data/misc/foo_Release")
+
+ hash1, size1 = index.lookup(u"main/i18n/Index")
+ hash2, size2 = index.lookup(b"main/i18n/Index")
+
+ self.assertEqual(size1, size2)
+ self.assertEqual(str(hash1), str(hash2))
+ self.assertEqual(str(hash1), ("SHA256:fefed230e286d832ab6eb0fb7b72"
+ "442165b50df23a68402ae6e9d265a31920a2"))
+
+ def test_lock(self):
+ apt_pkg.get_lock(self.file_unicode, True)
+ apt_pkg.get_lock(self.file_bytes, True)
+
+ with apt_pkg.FileLock(self.file_unicode):
+ pass
+ with apt_pkg.FileLock(self.file_bytes):
+ pass
+
+ def test_policy(self):
+ apt_pkg.config["dir"] = "data/test_debs"
+ cache = apt_pkg.Cache(None)
+ policy = apt_pkg.Policy(cache)
+ file_unicode = os.path.join(self.dir_unicode, u"test.prefs")
+ file_bytes = os.path.join(self.dir_bytes, b"test.prefs")
+
+ self.assertTrue(policy.read_pinfile(file_unicode))
+ self.assertTrue(policy.read_pinfile(file_bytes))
+ self.assertTrue(policy.read_pindir(self.dir_unicode))
+ self.assertTrue(policy.read_pindir(self.dir_bytes))
+
+ def test_tag(self):
+ with open(self.file_bytes, "w") as tag:
+ tag.write("Key: value\n")
+ tag1 = apt_pkg.TagFile(self.file_unicode)
+ tag2 = apt_pkg.TagFile(self.file_bytes)
+
+ self.assertEqual(next(tag1)["Key"], "value")
+ self.assertEqual(next(tag2)["Key"], "value")
+
+ self.assertRaises(StopIteration, next, tag1)
+ self.assertRaises(StopIteration, next, tag2)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test_pep8.py b/tests/test_pep8.py
new file mode 100755
index 00000000..eee7c7a6
--- /dev/null
+++ b/tests/test_pep8.py
@@ -0,0 +1,30 @@
+import os
+import subprocess
+import unittest
+
+
+class PackagePep8TestCase(unittest.TestCase):
+
+ def test_pep8(self):
+ res = 0
+ py_dir = os.path.join(os.path.dirname(__file__), "..")
+ res += subprocess.call(
+ ["pep8",
+ # disable for now:
+ # E125 continuation line does not distinguish itself from
+ # next logical line
+ # E126 continuation line over-indented for hanging indent
+ # E127 continuation line over-indented for visual indent
+ # E128 continuation line under-indented for visual indent
+ # E129 continuation line does not distinguish itself from
+ # next logical line
+ # E265 block comment should start with '# '
+ "--ignore=E125,E126,E127,E128,E129,E265",
+ "--exclude", "build,tests/old",
+ "--repeat", py_dir])
+ if res != 0:
+ self.fail("pep8 failed with: %s" % res)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tests/test_policy.py b/tests/test_policy.py
index f7d41152..e9ea151f 100644
--- a/tests/test_policy.py
+++ b/tests/test_policy.py
@@ -9,9 +9,11 @@
import apt
import unittest
+
class TestAptPolicy(unittest.TestCase):
def test_apt_policy_lowlevel(self):
+ return # TODO: Make tests independent of system state
# get a policy
cache = apt.Cache()
policy = cache._depcache.policy
@@ -28,12 +30,12 @@ class TestAptPolicy(unittest.TestCase):
self.assertTrue(policy.get_priority(pkgfile) < 1001)
def test_apt_policy_highlevel(self):
+ return # TODO: Make tests independent of system state
cache = apt.Cache()
pkg = cache["apt"]
self.assertTrue(pkg.candidate.policy_priority > 1 and
pkg.candidate.policy_priority < 1001)
-
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_progress.py b/tests/test_progress.py
index b7bba02f..01cd8a2d 100644
--- a/tests/test_progress.py
+++ b/tests/test_progress.py
@@ -12,6 +12,7 @@ import apt
import apt_pkg
import os
+
class TestAcquireProgress(apt.progress.base.AcquireProgress):
def pulse(self, owner):
self.pulsed = True
@@ -19,6 +20,7 @@ class TestAcquireProgress(apt.progress.base.AcquireProgress):
# but often this is forgoten (and causes odd error messages)
# so the lib supports it. we test the lack of support value here
+
class TestProgress(unittest.TestCase):
def setUp(self):
@@ -27,14 +29,15 @@ class TestProgress(unittest.TestCase):
apt_pkg.init()
apt_pkg.config.set("APT::Architecture", "amd64")
apt_pkg.config.set("Dir::Etc", basedir)
- apt_pkg.config.set("Dir::Etc::sourceparts", "/tmp")
+ # TODO: /dev/null is not a dir, perhaps find something better
+ apt_pkg.config.set("Dir::Etc::sourceparts", "/dev/null")
# setup lists dir
if not os.path.exists("./tmp/partial"):
os.makedirs("./tmp/partial")
apt_pkg.config.set("Dir::state::lists", "./tmp")
# create artifical line
deb_line = "deb file:%s/data/fake-packages/ /\n" % basedir
- with open("fetch_sources.list","w") as fobj:
+ with open("fetch_sources.list", "w") as fobj:
fobj.write(deb_line)
apt_pkg.config.set("Dir::Etc::sourcelist", "fetch_sources.list")
apt_pkg.config.clear("APT::Update::Post-Invoke")
@@ -43,8 +46,9 @@ class TestProgress(unittest.TestCase):
def test_acquire_progress(self):
progress = TestAcquireProgress()
cache = apt.Cache()
- res = cache.update(progress)
+ cache.update(progress)
self.assertTrue(progress.pulsed)
+
if __name__ == "__main__":
unittest.main()
diff --git a/tests/test_pyflakes.py b/tests/test_pyflakes.py
new file mode 100644
index 00000000..9c17a405
--- /dev/null
+++ b/tests/test_pyflakes.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python3
+# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
+
+import os
+import subprocess
+import unittest
+
+
+class TestPyflakesClean(unittest.TestCase):
+
+ EXCLUDES = ["build", "tests/old"]
+ TOPLEVEL = os.path.normpath(
+ os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
+
+ def is_excluded_path(self, path):
+ for exclude in self.EXCLUDES:
+ if path.startswith(os.path.join(self.TOPLEVEL, exclude)):
+ return True
+ return False
+
+ def get_py_files(self, toplevel):
+ files = []
+ for path, dirnames, filenames in os.walk(self.TOPLEVEL):
+ if self.is_excluded_path(path):
+ continue
+ for filename in filenames:
+ if os.path.splitext(filename)[1] == ".py":
+ files.append(os.path.join(path, filename))
+ return files
+
+ def test_pyflakes_clean(self):
+ cmd = ["pyflakes"] + self.get_py_files(self.TOPLEVEL)
+ res = subprocess.call(cmd)
+ if res != 0:
+ self.fail("pyflakes failed with: %s" % res)
+
+
+if __name__ == "__main__":
+ import logging
+ logging.basicConfig(level=logging.DEBUG)
+ unittest.main()
diff --git a/tests/test_size_to_str.py b/tests/test_size_to_str.py
index 2c2c372f..ba1e45b3 100644
--- a/tests/test_size_to_str.py
+++ b/tests/test_size_to_str.py
@@ -1,91 +1,82 @@
#!/usr/bin/python
-__author__ = "Barry Warsaw <barry@ubuntu.com>, James Hunt, Michael Vogt"
+__author__ = "Barry Warsaw <barry@ubuntu.com>, James Hunt, Michael Vogt"
-import sys
import unittest
import apt_pkg
-if sys.version_info[0] == 2 and sys.version_info[1] == 6:
- from unittest2 import TestCase
-else:
- from unittest import TestCase
-
-class SizeToStrTestCase(TestCase):
+class SizeToStrTestCase(unittest.TestCase):
"""Test apt_pkg.size_to_str"""
DATA = {
# XXX: note the trailing spaces for some of these entries!
- 10 ** 1 : "10 ",
- 10 ** 2 : "100 ",
- 10 ** 3 : "1000 ",
- 10 ** 4 : "10.0 k",
- 10 ** 5 : "100 k",
- 10 ** 6 : "1000 k",
- 10 ** 7 : "10.0 M",
- 10 ** 8 : "100 M",
- 10 ** 9 : "1000 M",
- 10 ** 10 : "10.0 G",
- 10 ** 11 : "100 G",
- 10 ** 12 : "1000 G",
- 10 ** 13 : "10.0 T",
- 10 ** 14 : "100 T",
- 10 ** 15 : "1000 T",
- 10 ** 16 : "10.0 P",
- 10 ** 17 : "100 P",
- 10 ** 18 : "1000 P",
- 10 ** 19 : "10.0 E",
- 10 ** 20 : "100 E",
- 10 ** 21 : "1000 E",
- 10 ** 22 : "10.0 Z",
- 10 ** 23 : "100.0 Z",
- 10 ** 24 : "1000 Z",
-# 10 ** 25 : "10.0 Y",
- 10 ** 26 : "100 Y",
- 10 ** 27 : "1000 Y",
-
+ 10 ** 1: "10 ",
+ 10 ** 2: "100 ",
+ 10 ** 3: "1000 ",
+ 10 ** 4: "10.0 k",
+ 10 ** 5: "100 k",
+ 10 ** 6: "1000 k",
+ 10 ** 7: "10.0 M",
+ 10 ** 8: "100 M",
+ 10 ** 9: "1000 M",
+ 10 ** 10: "10.0 G",
+ 10 ** 11: "100 G",
+ 10 ** 12: "1000 G",
+ 10 ** 13: "10.0 T",
+ 10 ** 14: "100 T",
+ 10 ** 15: "1000 T",
+ 10 ** 16: "10.0 P",
+ 10 ** 17: "100 P",
+ 10 ** 18: "1000 P",
+ 10 ** 19: "10.0 E",
+ 10 ** 20: "100 E",
+ 10 ** 21: "1000 E",
+ 10 ** 22: "10.0 Z",
+ 10 ** 23: "100.0 Z",
+ 10 ** 24: "1000 Z",
+ #10 ** 25: "10.0 Y",
+ 10 ** 26: "100 Y",
+ 10 ** 27: "1000 Y",
# That's our limit :)
- 10 ** 28 : "10000 Y",
-
- 0 : "0 ",
- 1 : "1 ",
- 1024 : "1024 ",
- 10240 : "10.2 k",
- 102400 : "102 k",
- 1024000 : "1024 k",
- 10240000 : "10.2 M",
- 102400000 : "102 M",
- 2147483647 : "2147 M",
- 2147483648 : "2147 M",
- 1024000000 : "1024 M",
- 10240000000 : "10.2 G",
-
- 9 : "9 ",
- 99 : "99 ",
- 999 : "999 ",
- 9999 : "9999 ",
- 99999 : "100.0 k",
- 999999 : "1000 k",
- 9999999 : "10000 k",
- 99999999 : "100.0 M",
- 999999999 : "1000 M",
- 9999999999 : "10000 M",
- 99999999999 : "100.0 G",
- 999999999999 : "1000 G",
- 9999999999999 : "10000 G",
- 99999999999999 : "100.0 T",
- 999999999999999 : "1000 T",
- 9999999999999999 : "10.0 P",
- 99999999999999999 : "100 P",
- 999999999999999999 : "1000 P",
- 9999999999999999999 : "10.0 E",
- 99999999999999999999 : "100 E",
- 999999999999999999999 : "1000 E",
- 9999999999999999999999 : "10.0 Z",
- 999999999999999999999999 : "1000 Z",
- }
+ 10 ** 28: "10000 Y",
+ 0: "0 ",
+ 1: "1 ",
+ 1024: "1024 ",
+ 10240: "10.2 k",
+ 102400: "102 k",
+ 1024000: "1024 k",
+ 10240000: "10.2 M",
+ 102400000: "102 M",
+ 2147483647: "2147 M",
+ 2147483648: "2147 M",
+ 1024000000: "1024 M",
+ 10240000000: "10.2 G",
+ 9: "9 ",
+ 99: "99 ",
+ 999: "999 ",
+ 9999: "9999 ",
+ 99999: "100.0 k",
+ 999999: "1000 k",
+ 9999999: "10000 k",
+ 99999999: "100.0 M",
+ 999999999: "1000 M",
+ 9999999999: "10000 M",
+ 99999999999: "100.0 G",
+ 999999999999: "1000 G",
+ 9999999999999: "10000 G",
+ 99999999999999: "100.0 T",
+ 999999999999999: "1000 T",
+ 9999999999999999: "10.0 P",
+ 99999999999999999: "100 P",
+ 999999999999999999: "1000 P",
+ 9999999999999999999: "10.0 E",
+ 99999999999999999999: "100 E",
+ 999999999999999999999: "1000 E",
+ 9999999999999999999999: "10.0 Z",
+ 999999999999999999999999: "1000 Z",
+ }
def test_from_data(self):
for k, v in self.DATA.items():
@@ -96,7 +87,7 @@ class SizeToStrTestCase(TestCase):
def test_raise_on_unsupported(self):
for v in ["hello", None, {}, [], ()]:
with self.assertRaises(TypeError):
- apt_pkg.size_to_str(v)
+ apt_pkg.size_to_str(v)
class RegressionTestCase(unittest.TestCase):
diff --git a/tests/test_tagfile.py b/tests/test_tagfile.py
index f26f851b..029e2946 100644
--- a/tests/test_tagfile.py
+++ b/tests/test_tagfile.py
@@ -27,6 +27,30 @@ if libdir:
import apt_pkg
+
+class TestOpenMaybeClearSigned(unittest.TestCase):
+
+ def test_open_trivial(self):
+ basepath = os.path.dirname(__file__)
+ fd = apt_pkg.open_maybe_clear_signed_file(
+ os.path.join(basepath, "./data/test_debs/hello_2.5-1.dsc"))
+ with os.fdopen(fd) as f:
+ data = f.read()
+ self.assertTrue(data.startswith("Format: 1.0\n"))
+
+ def test_open_normal(self):
+ basepath = os.path.dirname(__file__)
+ fd = apt_pkg.open_maybe_clear_signed_file(
+ os.path.join(basepath, "./data/misc/foo_Release"))
+ with os.fdopen(fd) as f:
+ data = f.read()
+ self.assertTrue(data.startswith("Origin: Ubuntu\n"))
+
+ def xtest_open_does_not_exit(self):
+ with self.assertRaises(SystemError):
+ apt_pkg.open_maybe_clear_signed_file("does-not-exists")
+
+
class TestTagFile(unittest.TestCase):
""" test the apt_pkg.TagFile """
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 2676bb98..12d5a554 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -8,21 +8,18 @@
import datetime
import os
-import sys
import unittest
-import apt_pkg
-import apt.utils
-
from apt.utils import (
get_maintenance_end_date,
get_release_date_from_release_file,
- )
+)
+
class TestUtils(unittest.TestCase):
def test_get_release_date_from_release_file(self):
- path = os.path.join(os.path.dirname(__file__),
+ path = os.path.join(os.path.dirname(__file__),
"data", "misc", "foo_Release")
t = get_release_date_from_release_file(path)
self.assertEqual(str(datetime.datetime.utcfromtimestamp(t)),
@@ -32,33 +29,38 @@ class TestUtils(unittest.TestCase):
months_of_support = 18
# test historic releases, jaunty
release_date = datetime.datetime(2009, 4, 23)
- (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support)
+ (end_year, end_month) = get_maintenance_end_date(
+ release_date, months_of_support)
self.assertEqual(end_year, 2010)
self.assertEqual(end_month, 10)
# test historic releases, karmic
release_date = datetime.datetime(2009, 10, 29)
- (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support)
+ (end_year, end_month) = get_maintenance_end_date(
+ release_date, months_of_support)
self.assertEqual(end_year, 2011)
self.assertEqual(end_month, 4)
# test maverick
release_date = datetime.datetime(2010, 10, 10)
- (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support)
+ (end_year, end_month) = get_maintenance_end_date(
+ release_date, months_of_support)
self.assertEqual(end_year, 2012)
self.assertEqual(end_month, 4)
# test with modulo zero
release_date = datetime.datetime(2010, 6, 10)
- (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support)
+ (end_year, end_month) = get_maintenance_end_date(
+ release_date, months_of_support)
self.assertEqual(end_year, 2011)
self.assertEqual(end_month, 12)
# test dapper
months_of_support = 60
release_date = datetime.datetime(2008, 4, 24)
- (end_year, end_month) = get_maintenance_end_date(release_date, months_of_support)
+ (end_year, end_month) = get_maintenance_end_date(
+ release_date, months_of_support)
self.assertEqual(end_year, 2013)
self.assertEqual(end_month, 4)
-
+
# what datetime says
#d = datetime.timedelta(18*30)
#print "end date: ", release_date + d
diff --git a/utils/doclint.py b/utils/doclint.py
deleted file mode 100644
index a387b05f..00000000
--- a/utils/doclint.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/python
-# Documentation lint.
-# Copyright (C) 2009 Julian Andres Klode <jak@debian.org>
-#
-# 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.
-#
-# This comes without any warranty.
-"""Read the pickle file created by sphinx and check it."""
-
-from __future__ import with_statement
-import cPickle
-import os
-import sys
-
-
-def handle(filename):
- with open(filename) as fobj:
- index = cPickle.load(fobj)
-
- objects = index['descrefs']
- modules = index['modules']
- types = index['desctypes']
-
- for modname in modules:
- module = __import__(modname, fromlist=["*"])
-
- for modmember in objects[modname]:
- if not modmember in module.__dict__:
- print 'W: Unknown', modname + '.' + modmember
- elif types[objects[modname][modmember][1]] == u'class':
- if modname + '.' + modmember not in objects:
- print 'I: No members', modname + '.' + modmember
- continue
- for member in objects.get(modname + '.' + modmember):
- if not member in dir(module.__dict__[modmember]):
- print 'W: Unknown', modname + '.' + modmember + '.' + member
-
- assert(types[objects[modname+"."+modmember][member][1]] in ('method', 'attribute'))
-
- all = getattr(module, '__all__', [])
- for modmember in dir(module):
- if getattr(module.__dict__[modmember], "__module__", modname) != modname:
- continue
- if isinstance(module.__dict__[modmember], type(module)):
- continue
- if modmember.startswith("_"):
- continue
- if not modmember in objects[modname] and (not all or modmember in all):
- print 'E: Missing', modname + '.' + modmember
- elif not modmember in objects[modname]:
- print 'W: Missing', modname + '.' + modmember
- elif types[objects[modname][modmember][1]] == u'class':
- for member in dir(module.__dict__[modmember]):
- if member.startswith("_"):
- continue
- try:
- contin = False
- for base in module.__dict__[modmember].__bases__:
- if member in dir(base):
- contin = True
- if contin:
- continue
- except:
- pass
- if not member in objects.get(modname + '.' + modmember, ""):
- print 'E: Missing', modname + '.' + modmember + '.' + member
-
-
-if __name__ == '__main__':
- scriptdir = os.path.dirname(__file__)
- parentdir = os.path.join(scriptdir, "..")
- directory = os.path.join(parentdir, "doc", "build", "pickle")
- directory = os.path.normpath(directory)
- sys.path.insert(0, os.path.abspath(parentdir))
- handle(os.path.join(directory, "searchindex.pickle"))
diff --git a/utils/get_debian_mirrors.py b/utils/get_debian_mirrors.py
index c1ec3be8..de4ebb95 100755
--- a/utils/get_debian_mirrors.py
+++ b/utils/get_debian_mirrors.py
@@ -17,7 +17,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
+from __future__ import print_function
import collections
+import sys
import urllib2
from debian_bundle import deb822
@@ -27,7 +29,7 @@ masterlist = urllib2.urlopen("http://anonscm.debian.org/viewvc/"
"mirror/Mirrors.masterlist?revision=HEAD")
for mirror in deb822.Deb822.iter_paragraphs(masterlist):
- if not "Country" in mirror:
+ if "Country" not in mirror:
continue
country = mirror["Country"].split(None, 1)[0]
site = mirror["Site"]
@@ -36,6 +38,10 @@ for mirror in deb822.Deb822.iter_paragraphs(masterlist):
mirrors[country].add("%s://%s%s" % (proto, site,
mirror["Archive-%s" % proto]))
+if len(mirrors) == 0:
+ sys.stderr.write("E: Could not read the mirror list due to "
+ "some unknown issue\n")
+ sys.exit(1)
for country in sorted(mirrors):
- print "#LOC:%s" % country
- print "\n".join(sorted(mirrors[country]))
+ print("#LOC:%s" % country)
+ print("\n".join(sorted(mirrors[country])))
diff --git a/utils/get_ubuntu_mirrors.py b/utils/get_ubuntu_mirrors.py
deleted file mode 100755
index ddd1e369..00000000
--- a/utils/get_ubuntu_mirrors.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-#
-# get_ubuntu_mirrors.py
-#
-# Download the latest list with available mirrors from the Ubuntu
-# wiki and extract the hosts from the raw page
-#
-# Copyright (c) 2006 Free Software Foundation Europe
-#
-# Author: Sebastian Heinlein <glatzor@ubuntu.com>
-#
-# 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
-
-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/Ubuntu.mirrors"
-
-req = urllib2.Request("https://wiki.ubuntu.com/Archive?action=raw")
-
-try:
- print "Downloading mirrors list from the Ubuntu wiki..."
- uri=urllib2.urlopen(req)
- p = re.compile('^.*((http|ftp):\/\/[A-Za-z0-9-.:\/_]+).*\n*$')
- for line in uri.readlines():
- if r"[[Anchor(dvd-images)]]" in line:
- break
- if "http://" in line or "ftp://" in line:
- mirrors.append(p.sub(r"\1", line))
- uri.close()
-except:
- print "Failed to download or 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\n" % mirror)
-list.close()
-print "Done."
diff --git a/utils/get_ubuntu_mirrors_from_lp.py b/utils/get_ubuntu_mirrors_from_lp.py
index ef049f78..41d37be9 100755
--- a/utils/get_ubuntu_mirrors_from_lp.py
+++ b/utils/get_ubuntu_mirrors_from_lp.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# get_ubuntu_lp_mirrors.py
#
@@ -24,8 +24,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
-import feedparser
import sys
+import feedparser
d = feedparser.parse("https://launchpad.net/ubuntu/+archivemirrors-rss")
#d = feedparser.parse(open("+archivemirrors-rss"))
@@ -34,13 +34,19 @@ countries = {}
for entry in d.entries:
countrycode = entry.mirror_countrycode
- if not countrycode in countries:
+ if countrycode not in countries:
countries[countrycode] = set()
for link in entry.links:
countries[countrycode].add(link.href)
keys = sorted(countries)
+
+if len(keys) == 0:
+ sys.stderr.write("E: Could not read the mirror list due to some issue"
+ " -- status code: %s\n" % d.status)
+ sys.exit(1)
+
print("mirror://mirrors.ubuntu.com/mirrors.txt")
for country in keys:
print("#LOC:%s" % country)
diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py
deleted file mode 100755
index 555257a9..00000000
--- a/utils/migrate-0.8.py
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/usr/bin/python2.6
-#
-# migrate-0.8.py - Find use of deprecated methods/attributes in the code.
-#
-# Copyright (C) 2009 Julian Andres Klode <jak@debian.org>
-#
-# 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] <file/directory>...
-
-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 len(sys.argv) > 1 and 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__)))
-
-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', '.has_key'])
-
-def do_color(string, words):
- """Colorize (red) the given words in the given string."""
- if not color:
- return string
- for word in words:
- word = re.escape(word)
- string = re.sub('([^_]*)(%s)([^_]*)' % word, "\\1\033[31m\033[1m" +
- r"\2" + "\033[0m\\3", string)
- return string
-
-def find_deprecated_py():
- """Find all the deprecated functions and attributes.
-
- 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',
- 'apt.progress', 'apt.progress.old', '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, fromlist=['*'])
-
- for clsname in dir(module):
- cls = getattr(module, clsname)
- if not isinstance(cls, types.TypeType):
- new.add(clsname)
- continue
- # Attributes/Methods
- new.update(clsname + '.' + name for name in 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, fromlist=['*'])
- for clsname in dir(module):
- cls = getattr(module, clsname)
- if not isinstance(cls, types.TypeType):
- deprecated.add(clsname)
- continue
- for name in dir(cls):
- if not clsname + '.' + name in new:
- # Attributes/Methods, which are deprecated (not in new).
- deprecated.add('.' + name)
-
- 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 not os.path.exists(fname):
- continue
- if not (fname in sys.argv or fname.endswith('.py') or
- re.match('^#.*python.*', open(fname).readline())):
- continue
-
- words = defaultdict(lambda: set())
- try:
- node = ast.parse(open(fname, "rU").read(), fname)
- except Exception as e:
- print >> sys.stderr, "Ignoring %s: %s" % (fname, e)
- continue
- for i in ast.walk(node):
- 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
-print fill('Information: Please verify that the results are correct before '
- 'you modify any code, because there may be false positives.', 79)
-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 = deprecated_cpp_stuff
-
-if not '-P' in sys.argv:
- all_old |= find_deprecated_py()
-else:
- sys.argv.remove('-P')
-
-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))
diff --git a/utils/mirrortest b/utils/mirrortest
index a724c81f..cec37e8d 100755
--- a/utils/mirrortest
+++ b/utils/mirrortest
@@ -1,9 +1,9 @@
-#!/usr/bin/env python
-import threading, Queue, time, re, os, tempfile
+#!/usr/bin/env python3
+import threading, queue, time, re, os, tempfile
import aptsources.sourceslist
import aptsources.distro
from timeit import Timer
-import urllib
+import urllib.request, urllib.parse, urllib.error
import socket
import random
socket.setdefaulttimeout(2)
@@ -24,9 +24,9 @@ class MirrorTest:
host = mirror.hostname
except:
continue
- print "Pinging (Worker %s) %s (%s) ..." % (self.id,
+ print("Pinging (Worker %s) %s (%s) ..." % (self.id,
host,
- MirrorTest.completed_pings)
+ MirrorTest.completed_pings))
commando = os.popen("ping -q -c 4 -W 2 -i 0.3 %s" % host,
"r")
while True:
@@ -43,17 +43,17 @@ class MirrorTest:
def speed_test(self, mirror):
url = "%s/%s" % (mirror.get_repo_urls()[0],
self.test_file)
- print "Downloading %s ..." % url
+ print("Downloading %s ..." % url)
start = time.time()
try:
- data = urllib.urlopen(url).read(51200)
+ data = urllib.request.urlopen(url).read(51200)
return 50 / (time.time() - start)
except:
return 0
def __init__(self, hosts, test_file):
self.test_file = test_file
- jobs = Queue.Queue()
+ jobs = queue.Queue()
results = []
for h in hosts:
jobs.put(h)
@@ -71,21 +71,20 @@ class MirrorTest:
t.join()
results.sort()
- print "\n\nTop ten RTTs:"
+ print("\n\nTop ten RTTs:")
for r in results[0:10]:
- print "%s: %s" % (r[1], r[0])
- print "\n\n"
+ print("%s: %s" % (r[1], r[0]))
+ print("\n\n")
results.insert(0, [0, "rand", hosts[random.randint(1, len(hosts))]])
results.insert(0, [0, "rand", hosts[random.randint(1, len(hosts))]])
- final = map(lambda r: (self.speed_test(r[2]), r[2]),
- results[0:12])
+ final = [(self.speed_test(r[2]), r[2]) for r in results[0:12]]
final.sort()
final.reverse()
- print "\n\nBest mirrors:"
+ print("\n\nBest mirrors:")
for f in final:
- print "%s: %s KByte/s" % (f[1].hostname, int(f[0]))
+ print("%s: %s KByte/s" % (f[1].hostname, int(f[0])))
if __name__ == "__main__":
distro = aptsources.distro.get_distro()