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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt') 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): -- 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(-) (limited to 'apt') 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(-) (limited to 'apt') 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 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(-) (limited to 'apt') 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