From 1ce91d4909f2678430715163a76e9416ddb8a616 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 27 Aug 2010 14:33:55 +0200 Subject: python/cache.cc: doc update for provides_list --- python/cache.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/cache.cc b/python/cache.cc index e31f6a65..b153d1f2 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -573,9 +573,8 @@ static PyGetSetDef PackageGetSet[] = { {"rev_depends_list",PackageGetRevDependsList,0, "An apt_pkg.DependencyList object of all reverse dependencies."}, {"provides_list",PackageGetProvidesList,0, - "A list of all packages providing this package. The list contains\n" - "tuples in the format (providesname, providesver, version)\n" - "where 'version' is an apt_pkg.Version object."}, + "Ignore it, it does nothing. You want to use\n" + "apt_pkg.Version.provides_list instead."}, {"selected_state",PackageGetSelectedState,0, "The state of the selection, which can be compared against the constants\n" "SELSTATE_DEINSTALL, SELSTATE_HOLD, SELSTATE_INSTALL, SELSTATE_PURGE,\n" -- cgit v1.2.3 From 6d564eafe80ebe60c91587dd1bb70a666b70485d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 27 Aug 2010 15:01:44 +0200 Subject: python/cache.cc: improve documentation --- python/cache.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/cache.cc b/python/cache.cc index b153d1f2..e87d73d4 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -978,8 +978,9 @@ static PyGetSetDef VersionGetSet[] = { {"priority_str",VersionGetPriorityStr,0, "The priority of the package, as a string."}, {"provides_list",VersionGetProvidesList,0, - "A list of all packages provided by this version. See\n" - "Package.provides_list for a description of the format."}, + "A list of all packages provided by this version. The list contains\n" + "tuples in the format (providesname, providesver, version)\n" + "where 'version' is an apt_pkg.Version object."}, {"section",VersionGetSection,0, "The section of this package version."}, {"size",VersionGetSize,0, -- cgit v1.2.3 From 980c1cbd0d883c9e429aaa64633680456a0a776d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 27 Aug 2010 15:06:54 +0200 Subject: add "provides" property to the apt.Version objects --- apt/package.py | 5 +++++ debian/changelog | 1 + tests/test_apt_cache.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/apt/package.py b/apt/package.py index 228a3385..871c1e16 100644 --- a/apt/package.py +++ b/apt/package.py @@ -414,6 +414,11 @@ class Version(object): pass return depends_list + @property + 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.""" diff --git a/debian/changelog b/debian/changelog index 761742ca..9478bf89 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ python-apt (0.7.97) UNRELEASED; urgency=low - return long long when calling TotalNeeded(), FetchNeeded() and PartialPresent() from pkgAcquire(). This follows the change in libapt. + * add "provides" property to the apt.Version objects -- Julian Andres Klode Fri, 23 Jul 2010 16:14:39 +0200 diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index a43e92d2..2ace0201 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -1,6 +1,7 @@ #!/usr/bin/python # # Copyright (C) 2010 Julian Andres Klode +# 2010 Michael Vogt # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -50,6 +51,7 @@ class TestAptCache(unittest.TestCase): # 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]) # this is a not virtual (transitional) package provided by another l = cache.get_providing_packages("scrollkeeper") self.assertEqual(l, []) @@ -58,6 +60,7 @@ class TestAptCache(unittest.TestCase): l = cache.get_providing_packages("scrollkeeper", include_nonvirtual=True) self.assertTrue(len(l), 1) + self.assertTrue("mail-transport-agent" in cache["postfix"].candidate.provides) def test_dpkg_journal_dirty(self): -- cgit v1.2.3 From aaaa4e322280c780711f4242ed3d01c9e9d28af6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Aug 2010 14:40:22 +0200 Subject: add content reading test --- tests/data/test_debs/gdebi-test11.deb | Bin 0 -> 634 bytes tests/test_debfile.py | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 tests/data/test_debs/gdebi-test11.deb diff --git a/tests/data/test_debs/gdebi-test11.deb b/tests/data/test_debs/gdebi-test11.deb new file mode 100644 index 00000000..af9b441f Binary files /dev/null and b/tests/data/test_debs/gdebi-test11.deb differ diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 5874dfc4..04a5e0b3 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -77,6 +77,12 @@ class TestDebfilee(unittest.TestCase): "Unexpected result for package '%s' (got %s wanted %s)\n%s" % ( filename, res, expected_res, deb._failure_string)) + def testContent(self): + deb = apt.debfile.DebPackage(cache=self.cache) + deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) + self.assertEqual('#!/bin/sh\necho "test"\n', + deb.data_content("usr/bin/test")) + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) unittest.main() -- cgit v1.2.3 From 306d93a0257ddb2442d03df05952ce5bacbc5802 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Aug 2010 15:12:54 +0200 Subject: tests/test_debfile.py: add test for binary reading --- tests/data/test_debs/gdebi-test12.deb | Bin 0 -> 966 bytes tests/test_debfile.py | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 tests/data/test_debs/gdebi-test12.deb diff --git a/tests/data/test_debs/gdebi-test12.deb b/tests/data/test_debs/gdebi-test12.deb new file mode 100644 index 00000000..36544cc7 Binary files /dev/null and b/tests/data/test_debs/gdebi-test12.deb differ diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 04a5e0b3..72b9100c 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -78,10 +78,16 @@ class TestDebfilee(unittest.TestCase): filename, res, expected_res, deb._failure_string)) def testContent(self): + # normal deb = apt.debfile.DebPackage(cache=self.cache) deb.open(os.path.join("data", "test_debs", "gdebi-test11.deb")) self.assertEqual('#!/bin/sh\necho "test"\n', deb.data_content("usr/bin/test")) + # binary + deb = apt.debfile.DebPackage(cache=self.cache) + deb.open(os.path.join("data", "test_debs", "gdebi-test12.deb")) + self.assertEqual('#!/bin/sh\necho "test"\n', + deb.data_content("usr/bin/binary")) if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) -- cgit v1.2.3 From 96476d01e881f52d53a70f1ae700594a0f321056 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 31 Aug 2010 15:18:42 +0200 Subject: * apt/debfile.py: - fix error when reading binary content and add regresion test --- apt/debfile.py | 4 ++-- debian/changelog | 2 ++ tests/test_debfile.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apt/debfile.py b/apt/debfile.py index 33f0f04d..73f7d88e 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -512,7 +512,7 @@ class DebPackage(object): return sorted(content) @staticmethod - def to_hex(self, in_data): + def to_hex(in_data): hex = "" for (i, c) in enumerate(in_data): if i%80 == 0: @@ -521,7 +521,7 @@ class DebPackage(object): return hex @staticmethod - def to_strish(self, in_data): + def to_strish(in_data): s = "" for c in in_data: if ord(c) < 10 or ord(c) > 127: diff --git a/debian/changelog b/debian/changelog index 9478bf89..7fd04b41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ python-apt (0.7.97) UNRELEASED; urgency=low PartialPresent() from pkgAcquire(). This follows the change in libapt. * add "provides" property to the apt.Version objects + * apt/debfile.py: + - fix error when reading binary content and add regresion test -- Julian Andres Klode Fri, 23 Jul 2010 16:14:39 +0200 diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 72b9100c..42cda6f6 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -86,8 +86,9 @@ class TestDebfilee(unittest.TestCase): # binary deb = apt.debfile.DebPackage(cache=self.cache) deb.open(os.path.join("data", "test_debs", "gdebi-test12.deb")) - self.assertEqual('#!/bin/sh\necho "test"\n', - deb.data_content("usr/bin/binary")) + content = deb.data_content("usr/bin/binary") + self.assertTrue(content.startswith("Automatically converted to printable ascii:\n\x7fELF ")) + if __name__ == "__main__": #logging.basicConfig(level=logging.DEBUG) -- cgit v1.2.3 From 0d622864bf45b2826335b3be31330829f43db7cd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 2 Sep 2010 16:55:43 +0200 Subject: merged patch from Samuel Lidén Borell to fix crash if there utf8 in the control file (LP: #624290) and add test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apt/debfile.py | 2 +- debian/changelog | 2 ++ tests/data/test_debs/utf8-package_1.0-1_all.deb | Bin 0 -> 1150 bytes tests/test_debfile.py | 7 +++++++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/data/test_debs/utf8-package_1.0-1_all.deb diff --git a/apt/debfile.py b/apt/debfile.py index 73f7d88e..1e7a66cc 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -66,7 +66,7 @@ class DebPackage(object): self._debfile = apt_inst.DebFile(open(self.filename)) control = self._debfile.control.extractdata("control") # hm, 'replace' is probably better but python2.6 test fail with that - self._sections = apt_pkg.TagSection(control.decode("UTF-8", 'ignore')) + self._sections = apt_pkg.TagSection(control) self.pkgname = self._sections["Package"] def __getitem__(self, key): diff --git a/debian/changelog b/debian/changelog index 7fd04b41..d23bd54a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ python-apt (0.7.97) UNRELEASED; urgency=low * add "provides" property to the apt.Version objects * apt/debfile.py: - fix error when reading binary content and add regresion test + * merged patch from Samuel Lidén Borell to fix crash if there utf8 + in the control file (LP: #624290) and add test -- Julian Andres Klode Fri, 23 Jul 2010 16:14:39 +0200 diff --git a/tests/data/test_debs/utf8-package_1.0-1_all.deb b/tests/data/test_debs/utf8-package_1.0-1_all.deb new file mode 100644 index 00000000..e0339c2e Binary files /dev/null and b/tests/data/test_debs/utf8-package_1.0-1_all.deb differ diff --git a/tests/test_debfile.py b/tests/test_debfile.py index 42cda6f6..571c2ec9 100644 --- a/tests/test_debfile.py +++ b/tests/test_debfile.py @@ -1,4 +1,5 @@ #!/usr/bin/python +# -*- coding: utf-8 -*- # # Copyright (C) 2010 Michael Vogt # @@ -77,6 +78,12 @@ class TestDebfilee(unittest.TestCase): "Unexpected result for package '%s' (got %s wanted %s)\n%s" % ( filename, res, expected_res, deb._failure_string)) + 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")) + self.assertEqual(deb["Maintainer"], + "Samuel Lidén Borell ") + def testContent(self): # normal deb = apt.debfile.DebPackage(cache=self.cache) -- cgit v1.2.3 From 297adb794c0f2548ea45dc3582ae0912724fcf9c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Sep 2010 11:57:44 +0200 Subject: * apt/cache.py: - add "sources_list" parameter to cache.update() to force updating a single sources.list entry only --- apt/cache.py | 18 +++++++++++++++++- debian/changelog | 3 +++ tests/test_apt_cache.py | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index f64b489a..585fca0a 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -327,12 +327,14 @@ class Cache(object): @deprecated_args def update(self, fetch_progress=None, pulse_interval=0, - raise_on_error=True): + raise_on_error=True, sources_list=None): """Run the equivalent of apt-get update. The first parameter *fetch_progress* may be set to an instance of 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 """ lockfile = apt_pkg.config.find_dir("Dir::State::Lists") + "lock" lock = apt_pkg.get_lock(lockfile) @@ -340,6 +342,15 @@ class Cache(object): if lock < 0: raise LockFailedException("Failed to lock %s" % lockfile) + if sources_list: + 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::sourceparts", "xxx") + apt_pkg.config.set("APT::List-Cleanup", "0") + self._list.read_main_list() + try: if fetch_progress is None: fetch_progress = apt.progress.base.AcquireProgress() @@ -354,6 +365,11 @@ class Cache(object): return res finally: os.close(lock) + if sources_list: + apt_pkg.config.set("Dir::Etc::sourcelist", old_sources_list) + apt_pkg.config.set("Dir::Etc::sourceparts", old_sources_list_d) + apt_pkg.config.set("APT::List-Cleanup", old_cleanup) + self._list.read_main_list() @deprecated_args def install_archives(self, pm, install_progress): diff --git a/debian/changelog b/debian/changelog index d23bd54a..9e03434e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,9 @@ python-apt (0.7.97) UNRELEASED; urgency=low - fix error when reading binary content and add regresion test * merged patch from Samuel Lidén Borell to fix crash if there utf8 in the control file (LP: #624290) and add test + * apt/cache.py: + - add "sources_list" parameter to cache.update() to force updating + a single sources.list entry only -- Julian Andres Klode Fri, 23 Jul 2010 16:14:39 +0200 diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 2ace0201..054ef8b2 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -16,7 +16,7 @@ sys.path.insert(0, "..") import apt import apt_pkg - +import shutil class TestAptCache(unittest.TestCase): """ test the apt cache """ @@ -84,7 +84,43 @@ class TestAptCache(unittest.TestCase): self.assertTrue(cache.dpkg_journal_dirty) # reset config value apt_pkg.config.set("Dir::State::status", old_status) + + def test_apt_update(self): + try: + os.makedirs("./data/tmp/var/lib/apt/lists/partial") + except OSError, e: + pass + apt_pkg.config.set("dir::state", "./data/tmp/var/lib/apt") + + # test single sources.list fetching + sources_list = "./data/tmp/test.list" + f=open(sources_list,"w") + f.write("deb http://archive.ubuntu.com/ubuntu lucid restricted\n") + f.close() + self.assertTrue(os.path.exists(sources_list)) + # write marker to ensure listcleaner is not run + open("./data/tmp/var/lib/apt/lists/marker","w") + + # update a single sources.list + cache = apt.Cache() + cache.update(sources_list=sources_list) + # verify we just got a single source + files = filter(lambda f: not (f == "lock" or f == "partial"), + os.listdir("./data/tmp/var/lib/apt/lists")) + self.assertTrue("archive.ubuntu.com_ubuntu_dists_lucid_Release" in files) + # ensure the listcleaner was not run + self.assertTrue("marker" in files) + # ensure we don't get additional stuff from /etc/apt/sources.list + self.assertTrue(len(files) < 5) + # now run update again and verify that we got the normal sources.list + cache.update() + full_update = filter(lambda f: not (f == "lock" or f == "partial"), + os.listdir("./data/tmp/var/lib/apt/lists")) + self.assertTrue(len(files) < len(full_update)) + + # cleanup + shutil.rmtree("./data/tmp/") if __name__ == "__main__": unittest.main() -- cgit v1.2.3 From 56494ed686d4e379f8fc449323232503295c1c1e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Sep 2010 12:08:20 +0200 Subject: apt/cache.py: use alternative SourceList if sources_list is used --- apt/cache.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index 585fca0a..586df366 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -349,13 +349,16 @@ class Cache(object): 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") - self._list.read_main_list() + slist = apt_pkg.SourceList() + slist.read_main_list() + else: + slist = self._list try: if fetch_progress is None: fetch_progress = apt.progress.base.AcquireProgress() try: - res = self._cache.update(fetch_progress, self._list, + res = self._cache.update(fetch_progress, slist, pulse_interval) except SystemError, e: raise FetchFailedException(e) @@ -369,7 +372,6 @@ class Cache(object): apt_pkg.config.set("Dir::Etc::sourcelist", old_sources_list) apt_pkg.config.set("Dir::Etc::sourceparts", old_sources_list_d) apt_pkg.config.set("APT::List-Cleanup", old_cleanup) - self._list.read_main_list() @deprecated_args def install_archives(self, pm, install_progress): -- cgit v1.2.3 From f438a6d0345bedd85f443e9943d3f76942feae02 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Sep 2010 18:05:25 +0200 Subject: * debian/control: - add missing build-depends on python-debian (needed to run the tests for apt.debfile.DebPackage() --- debian/changelog | 3 +++ debian/control | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 9e03434e..7d5aced1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,9 @@ python-apt (0.7.97) UNRELEASED; urgency=low * apt/cache.py: - add "sources_list" parameter to cache.update() to force updating a single sources.list entry only + * debian/control: + - add missing build-depends on python-debian (needed to run the + tests for apt.debfile.DebPackage() -- Julian Andres Klode Fri, 23 Jul 2010 16:14:39 +0200 diff --git a/debian/control b/debian/control index a3decb78..1655a06e 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,8 @@ Build-Depends: apt-utils, python3.1-dbg, python-central (>= 0.5), python-distutils-extra (>= 2.0), - python-sphinx (>= 0.5) + python-sphinx (>= 0.5), + python-debian Vcs-Bzr: http://bzr.debian.org/apt/python-apt/debian-sid Vcs-Browser: http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/changes -- cgit v1.2.3 From 6809becd9c7dccc797dde7be2046cad55712c5de Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Sep 2010 18:18:18 +0200 Subject: not not depend on network when running the tests, some style fixes (thanks to Jak for the code-review) --- tests/data/test-repo/Packages.gz | Bin 0 -> 675 bytes tests/test_apt_cache.py | 13 +++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 tests/data/test-repo/Packages.gz diff --git a/tests/data/test-repo/Packages.gz b/tests/data/test-repo/Packages.gz new file mode 100644 index 00000000..81daf2bb Binary files /dev/null and b/tests/data/test-repo/Packages.gz differ diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 054ef8b2..22af97f2 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -94,20 +94,21 @@ class TestAptCache(unittest.TestCase): # test single sources.list fetching sources_list = "./data/tmp/test.list" - f=open(sources_list,"w") - f.write("deb http://archive.ubuntu.com/ubuntu lucid restricted\n") + f=open(sources_list, "w") + repo = os.path.abspath("./data/test-repo") + f.write("deb copy:%s /\n" % repo) f.close() self.assertTrue(os.path.exists(sources_list)) # write marker to ensure listcleaner is not run - open("./data/tmp/var/lib/apt/lists/marker","w") + open("./data/tmp/var/lib/apt/lists/marker", "w") # update a single sources.list cache = apt.Cache() cache.update(sources_list=sources_list) # verify we just got a single source - files = filter(lambda f: not (f == "lock" or f == "partial"), + files = filter(lambda f: f not in ("lock", "partial"), os.listdir("./data/tmp/var/lib/apt/lists")) - self.assertTrue("archive.ubuntu.com_ubuntu_dists_lucid_Release" in files) + self.assertEqual(len([f for f in files if f.endswith("tests_data_test-repo_Packages")]), 1) # ensure the listcleaner was not run self.assertTrue("marker" in files) # ensure we don't get additional stuff from /etc/apt/sources.list @@ -115,7 +116,7 @@ class TestAptCache(unittest.TestCase): # now run update again and verify that we got the normal sources.list cache.update() - full_update = filter(lambda f: not (f == "lock" or f == "partial"), + full_update = filter(lambda f: f not in ("lock", "partial"), os.listdir("./data/tmp/var/lib/apt/lists")) self.assertTrue(len(files) < len(full_update)) -- cgit v1.2.3 From ab8da1ea6e1a965b819243045bfd50c8e1843366 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 7 Sep 2010 11:52:42 +0200 Subject: merged from lp:~kiwinote/python-apt/reinstall-same-file --- apt/debfile.py | 3 ++- debian/changelog | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apt/debfile.py b/apt/debfile.py index 1e7a66cc..eca07d14 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -347,7 +347,8 @@ class DebPackage(object): 'targetver' : c_or.target_ver } self._cache.op_progress.done() return False - if c_or.target_pkg.name in provides: + 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), diff --git a/debian/changelog b/debian/changelog index 7d5aced1..a1b060e6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +python-apt (0.7.97.2) UNRELEASED; urgency=low + + [ Kiwinote ] + * apt/debfile: + - don't fail if we conflict with the pkgs we are reinstalling + + -- Michael Vogt Fri, 27 Aug 2010 11:22:23 +0200 + python-apt (0.7.97) UNRELEASED; urgency=low [ Julian Andres Klode ] -- cgit v1.2.3 From b390a866fc3af9e7050148f11fb558fd52a8a703 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 7 Sep 2010 13:13:29 +0200 Subject: tests/test_apt_cache.py: improve the tests so that they do not require a working network --- tests/data/test-repo2/Packages.gz | Bin 0 -> 675 bytes tests/test_apt_cache.py | 63 ++++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 tests/data/test-repo2/Packages.gz diff --git a/tests/data/test-repo2/Packages.gz b/tests/data/test-repo2/Packages.gz new file mode 100644 index 00000000..81daf2bb Binary files /dev/null and b/tests/data/test-repo2/Packages.gz differ diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 22af97f2..428060f3 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -86,17 +86,31 @@ class TestAptCache(unittest.TestCase): apt_pkg.config.set("Dir::State::status", old_status) def test_apt_update(self): + rootdir = "./data/tmp" + shutil.rmtree(rootdir) try: - os.makedirs("./data/tmp/var/lib/apt/lists/partial") + os.makedirs(os.path.join(rootdir, "var/lib/apt/lists/partial")) except OSError, e: pass - apt_pkg.config.set("dir::state", "./data/tmp/var/lib/apt") + state_dir = os.path.join(rootdir, "var/lib/apt") + lists_dir = os.path.join(rootdir, "var/lib/apt/lists") + apt_pkg.config.set("dir::state", state_dir) + # set a local sources.list that does not need the network + base_sources = os.path.abspath(os.path.join(rootdir, "sources.list")) + apt_pkg.config.set("dir::etc::sourcelist", base_sources) + apt_pkg.config.set("dir::etc::sourceparts", "xxx") + # main sources.list + sources_list = base_sources + f=open(sources_list, "w") + repo = os.path.abspath("./data/test-repo2") + f.write("deb copy:%s /\n" % repo) + f.close() # test single sources.list fetching - sources_list = "./data/tmp/test.list" + sources_list = os.path.join(rootdir, "test.list") f=open(sources_list, "w") - repo = os.path.abspath("./data/test-repo") - f.write("deb copy:%s /\n" % repo) + repo_dir = os.path.abspath("./data/test-repo") + f.write("deb copy:%s /\n" % repo_dir) f.close() self.assertTrue(os.path.exists(sources_list)) # write marker to ensure listcleaner is not run @@ -105,23 +119,34 @@ class TestAptCache(unittest.TestCase): # update a single sources.list cache = apt.Cache() cache.update(sources_list=sources_list) - # verify we just got a single source - files = filter(lambda f: f not in ("lock", "partial"), - os.listdir("./data/tmp/var/lib/apt/lists")) - self.assertEqual(len([f for f in files if f.endswith("tests_data_test-repo_Packages")]), 1) - # ensure the listcleaner was not run - self.assertTrue("marker" in files) - # ensure we don't get additional stuff from /etc/apt/sources.list - self.assertTrue(len(files) < 5) + # verify we just got the excpected package file + needle_packages = [f for f in os.listdir(lists_dir) + if f.endswith("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 = [f for f in os.listdir(lists_dir) + if f.endswith("_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 and verify that we got the normal sources.list + # now run update again (without the "normal" sources.list that + # contains test-repo2 and verify that we got the normal sources.list cache.update() - full_update = filter(lambda f: f not in ("lock", "partial"), - os.listdir("./data/tmp/var/lib/apt/lists")) - self.assertTrue(len(files) < len(full_update)) + needle_packages = [f for f in os.listdir(lists_dir) + if f.endswith("tests_data_test-repo2_Packages")] + self.assertEqual(len(needle_packages), 1) + all_packages = [f for f in os.listdir(lists_dir) + if f.endswith("_Packages")] + self.assertEqual(needle_packages, all_packages) - # cleanup - shutil.rmtree("./data/tmp/") + # and another update with a single source only + cache = apt.Cache() + cache.update(sources_list=sources_list) + all_packages = [f for f in os.listdir(lists_dir) + if f.endswith("_Packages")] + self.assertEqual(len(all_packages), 2) if __name__ == "__main__": unittest.main() -- cgit v1.2.3 From 3aaf50270475e0a2a5fc8e7783e2f8917f8ac327 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 7 Sep 2010 13:34:02 +0200 Subject: cherry pick -r453 from lp:~mvo/python-apt/debian-sid --- python/cache.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/cache.cc b/python/cache.cc index e87d73d4..cd51fcc3 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -573,8 +573,9 @@ static PyGetSetDef PackageGetSet[] = { {"rev_depends_list",PackageGetRevDependsList,0, "An apt_pkg.DependencyList object of all reverse dependencies."}, {"provides_list",PackageGetProvidesList,0, - "Ignore it, it does nothing. You want to use\n" - "apt_pkg.Version.provides_list instead."}, + "A list of all packages providing this package. The list contains\n" + "tuples in the format (providesname, providesver, version)\n" + "where 'version' is an apt_pkg.Version object."}, {"selected_state",PackageGetSelectedState,0, "The state of the selection, which can be compared against the constants\n" "SELSTATE_DEINSTALL, SELSTATE_HOLD, SELSTATE_INSTALL, SELSTATE_PURGE,\n" -- cgit v1.2.3