From c197bef880cf57d4c4257c5053d993f896f697f8 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Dec 2009 16:48:32 +0100 Subject: * apt/progress/__init__.py: - Fix InstallProgress.updateInterface() to cope with read() returning 0 on non-blocking file descriptors (LP: #491027). --- apt/progress/__init__.py | 5 ++++- debian/changelog | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 8a9eb86f..8694de77 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -246,7 +246,10 @@ class InstallProgress(DumbInstallProgress): return try: while not self.read.endswith("\n"): - self.read += os.read(self.statusfd.fileno(), 1) + r = os.read(self.statusfd.fileno(), 1) + if not r: + return + self.read += r except OSError, (errno_, errstr): # resource temporarly unavailable is ignored if errno_ != errno.EAGAIN and errno_ != errno.EWOULDBLOCK: diff --git a/debian/changelog b/debian/changelog index 48d5b78d..7df51cf6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,11 @@ python-apt (0.7.13.4) UNRELEASED; urgency=low + [ Colin Watson ] + * apt/progress/__init__.py: + - Fix InstallProgress.updateInterface() to cope with read() returning 0 + on non-blocking file descriptors (LP: #491027). + + [ Michael Vogt ] * po/zh_CN.po: - updated, thanks to Feng Chao * python/progress.cc: -- cgit v1.2.3 From 51054e7baa348d2037d07102cc2f43392d528ada Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Dec 2009 16:58:09 +0100 Subject: * data/templates/Ubuntu.info.in: - add lucid --- data/templates/Ubuntu.info.in | 61 +++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 4 +++ 2 files changed, 65 insertions(+) diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index a8993d8a..2335454f 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -1,5 +1,66 @@ _ChangelogURI: http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog +Suite: lucid +RepositoryType: deb +BaseURI: http://archive.ubuntu.com/ubuntu/ +MatchURI: archive.ubuntu.com/ubuntu +BaseURI-powerpc: http://ports.ubuntu.com/ +MatchURI-powerpc: ports.ubuntu.com|archive.ubuntu.com +BaseURI-lpia: http://ports.ubuntu.com/ +MatchURI-lpia: ports.ubuntu.com|archive.ubuntu.com +MirrorsFile-amd64: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile-i386: /usr/share/python-apt/templates/Ubuntu.mirrors +_Description: Ubuntu 10.04 'Lucid Lynx' +Component: main +_CompDescription: Officially supported +_CompDescriptionLong: Canonical-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: lucid +MatchName: .* +BaseURI: cdrom:\[Ubuntu.*10.04 +MatchURI: cdrom:\[Ubuntu.*10.04 +_Description: Cdrom with Ubuntu 10.04 'Lucid Lynx' +Available: False +Component: main +_CompDescription: Officially supported +Component: restricted +_CompDescription: Restricted copyright + +Suite: lucid-security +ParentSuite: lucid +RepositoryType: deb +BaseURI: http://security.ubuntu.com/ubuntu/ +MatchURI: archive.ubuntu.com/ubuntu|security.ubuntu.com +BaseURI-powerpc: http://ports.ubuntu.com/ +MatchURI-powerpc: ports.ubuntu.com/ubuntu +BaseURI-lpia: http://ports.ubuntu.com/ +MatchURI-lpia: ports.ubuntu.com/ubuntu +_Description: Important security updates + +Suite: lucid-updates +ParentSuite: lucid +RepositoryType: deb +_Description: Recommended updates + +Suite: lucid-proposed +ParentSuite: lucid +RepositoryType: deb +_Description: Pre-released updates + +Suite: lucid-backports +ParentSuite: lucid +RepositoryType: deb +_Description: Unsupported updates + Suite: karmic RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ diff --git a/debian/changelog b/debian/changelog index 2c280221..60e1f265 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,10 @@ python-apt (0.7.13.5) UNRELEASED; urgency=low - Fix InstallProgress.updateInterface() to cope with read() returning 0 on non-blocking file descriptors (LP: #491027). + [ Michael Vogt ] + * data/templates/Ubuntu.info.in: + - add lucid + -- Michael Vogt Wed, 02 Dec 2009 16:50:55 +0100 python-apt (0.7.13.4) unstable; urgency=low -- cgit v1.2.3 From 2cc697efb0bad365973c9dbfbd88fc7bb90b7a8f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 18 Dec 2009 16:46:37 +0100 Subject: * apt/history.py: - simple abstraction for the apt history file --- apt/history.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 4 ++++ 2 files changed, 59 insertions(+) create mode 100644 apt/history.py diff --git a/apt/history.py b/apt/history.py new file mode 100644 index 00000000..f056e67e --- /dev/null +++ b/apt/history.py @@ -0,0 +1,55 @@ +# histoy.py - apt package abstraction +# +# Copyright (c) 2005-2009 Canonical +# +# Author: Michael Vogt +# +# 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 +"""Functionality related to the apt history file.""" + +import apt_pkg +apt_pkg.InitConfig() + +import gzip +import string + +class Transaction(object): + def __init__(self, sec): + self.start_date = sec.has_key("Start-Date") + for k in ["Install", "Upgrade", "Downgrade" "Remove", "Purge","Error"]: + if sec.has_key(k): + setattr(self, k.lower(), map(string.strip, sec[k].split(","))) + else: + setattr(self, k.lower(), None) + + +class AptHistory(dict): + def __init__(self, history_file=None): + if not history_file: + history_file = apt_pkg.Config.FindFile("Dir::Log::History") + # FIXME: test for .gz ending + f = open(history_file) + self._tagfile = apt_pkg.ParseTagFile(f) + while self._tagfile.Step(): + sec = self._tagfile.Section + start_date = sec['Start-Date'] + self[start_date] = Transaction(sec) + +if __name__ == "__main__": + #h = AptHistory("/var/log/apt/history.log.1.gz") + history = AptHistory() + for date in history: + print "'%s' - '%s'" % (date, history[date].install) diff --git a/debian/changelog b/debian/changelog index 60e1f265..945cfe3e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ python-apt (0.7.13.5) UNRELEASED; urgency=low * apt/progress/__init__.py: - Fix InstallProgress.updateInterface() to cope with read() returning 0 on non-blocking file descriptors (LP: #491027). + + [ Michael Vogt ] + * apt/history.py: + - simple abstraction for the apt history file [ Michael Vogt ] * data/templates/Ubuntu.info.in: -- cgit v1.2.3 From 2e2aa5fc6e4ad31b52aaef236ed54a3b9ea59a5d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 23 Dec 2009 13:36:48 +0100 Subject: * apt/cache.py: - improved docstring for the cache --- apt/cache.py | 7 ++++++- debian/changelog | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index fa6c404c..aa38999d 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -43,7 +43,12 @@ class Cache(object): """Dictionary-like package cache. This class has all the packages that are available in it's - dictionary + dictionary. + + Keyword arguments: + progress -- a OpProgress object + rootdir -- a alternative root directory + memonly -- build the cache in memory only """ def __init__(self, progress=None, rootdir=None, memonly=False): diff --git a/debian/changelog b/debian/changelog index 945cfe3e..59409cb4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,8 +8,8 @@ python-apt (0.7.13.5) UNRELEASED; urgency=low [ Michael Vogt ] * apt/history.py: - simple abstraction for the apt history file - - [ Michael Vogt ] + * apt/cache.py: + - improved docstring for the cache * data/templates/Ubuntu.info.in: - add lucid -- cgit v1.2.3 From 8d4420aecf43b588e8485c71d8e2b0bd9371432d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Jan 2010 11:19:44 +0100 Subject: add "enhances" property --- apt/cache.py | 4 +++- apt/package.py | 5 +++++ debian/changelog | 1 + tests/test_enhances.py | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/test_enhances.py diff --git a/apt/cache.py b/apt/cache.py index aa38999d..ae6f2fcc 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -47,7 +47,9 @@ class Cache(object): Keyword arguments: progress -- a OpProgress object - rootdir -- a alternative root directory + 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 """ diff --git a/apt/package.py b/apt/package.py index 8d3be1b0..f33871c6 100644 --- a/apt/package.py +++ b/apt/package.py @@ -378,6 +378,11 @@ class Version(object): pass return depends_list + @property + def enhances(self): + """Return the list of enhances for the package version.""" + return self.get_dependencies("Enhances") + @property def dependencies(self): """Return the dependencies of the package version.""" diff --git a/debian/changelog b/debian/changelog index 59409cb4..ba5dd918 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ python-apt (0.7.13.5) UNRELEASED; urgency=low - simple abstraction for the apt history file * apt/cache.py: - improved docstring for the cache + - add "enhances" property * data/templates/Ubuntu.info.in: - add lucid diff --git a/tests/test_enhances.py b/tests/test_enhances.py new file mode 100644 index 00000000..3eced9f9 --- /dev/null +++ b/tests/test_enhances.py @@ -0,0 +1,17 @@ +#!/usr/bin/python + +import apt + +cache = apt.Cache() + +for pkg in cache: + if pkg.installed and pkg.installed.enhances: + s = "%s enhances:" % pkg.name + 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): + s += "(*missing*) " + s += "," + print s[:-1] -- cgit v1.2.3 From 06bc637621014289a812d48a5c479dfe699527f2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Jan 2010 12:12:50 +0100 Subject: * python/cache.cc: - add UntranslatedDepType attribute to DependencyType - add DepTypeEnum that returns a value from {DepDepends, DepPreDepends, ...} * python/apt_pkgmodule.cc: - add DepDpkgBreaks, DepEnhances constants * doc/source/apt_pkg/{cache.rst, index.rst}: - update documentation as well --- debian/changelog | 8 ++++++++ doc/source/apt_pkg/cache.rst | 9 +++++++++ doc/source/apt_pkg/index.rst | 3 +++ python/apt_pkgmodule.cc | 2 ++ python/cache.cc | 27 ++++++++++++++++----------- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/debian/changelog b/debian/changelog index ba5dd918..d6d19bbf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,14 @@ python-apt (0.7.13.5) UNRELEASED; urgency=low - add "enhances" property * data/templates/Ubuntu.info.in: - add lucid + * python/cache.cc: + - add UntranslatedDepType attribute to DependencyType + - add DepTypeEnum that returns a value from + {DepDepends, DepPreDepends, ...} + * python/apt_pkgmodule.cc: + - add DepDpkgBreaks, DepEnhances constants + * doc/source/apt_pkg/{cache.rst, index.rst}: + - update documentation as well -- Michael Vogt Wed, 02 Dec 2009 16:50:55 +0100 diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst index 334b7869..1be81b42 100644 --- a/doc/source/apt_pkg/cache.rst +++ b/doc/source/apt_pkg/cache.rst @@ -596,8 +596,17 @@ Example: .. attribute:: DepType + The type of the dependency, as translated string, eg. "Depends". + + .. attribute:: UntranslatedDepType + The type of the dependency, as string, eg. "Depends". + .. attribute:: DepTypeEnum + + The type of the dependency, as integer that matches a value + of `Dependency types`_ + .. attribute:: ID The ID of the package, as integer. diff --git a/doc/source/apt_pkg/index.rst b/doc/source/apt_pkg/index.rst index 6e7b772e..aba7d82e 100644 --- a/doc/source/apt_pkg/index.rst +++ b/doc/source/apt_pkg/index.rst @@ -336,12 +336,15 @@ Dependency types ^^^^^^^^^^^^^^^^ .. data:: DepConflicts .. data:: DepDepends +.. data:: DepDpkgBreaks +.. data:: DepEnhances .. data:: DepObsoletes .. data:: DepPreDepends .. data:: DepRecommends .. data:: DepReplaces .. data:: DepSuggests + .. _InstStates: Installed states diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 86732781..bfa1227e 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -504,6 +504,8 @@ extern "C" void initapt_pkg() AddInt(Dict,"DepConflicts",pkgCache::Dep::Conflicts); AddInt(Dict,"DepReplaces",pkgCache::Dep::Replaces); AddInt(Dict,"DepObsoletes",pkgCache::Dep::Obsoletes); + AddInt(Dict,"DepDpkgBreaks",pkgCache::Dep::DpkgBreaks); + AddInt(Dict,"DepEnhances",pkgCache::Dep::Enhances); AddInt(Dict,"PriImportant",pkgCache::State::Important); AddInt(Dict,"PriRequired",pkgCache::State::Required); diff --git a/python/cache.cc b/python/cache.cc index a88490bd..023cf041 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -27,6 +27,17 @@ class pkgSourceList; +// must be in sync with pkgCache::DepType in libapt +// it sucks to have it here duplicated, but we get it +// translated from libapt and that is certainly not what +// we want in a programing interface +const char *UntranslatedDepTypes[] = +{ + "", "Depends","PreDepends","Suggests", + "Recommends","Conflicts","Replaces", + "Obsoletes", "Breaks", "Enhances" +}; + /*}}}*/ struct PkgListStruct { @@ -495,17 +506,7 @@ static PyObject *MakeDepends(PyObject *Owner,pkgCache::VerIterator &Ver, // Switch/create a new dict entry if (LastDepType != Start->Type || LastDep != 0) { - // must be in sync with pkgCache::DepType in libapt - // it sucks to have it here duplicated, but we get it - // translated from libapt and that is certainly not what - // we want in a programing interface - const char *Types[] = - { - "", "Depends","PreDepends","Suggests", - "Recommends","Conflicts","Replaces", - "Obsoletes", "Breaks", "Enhances" - }; - PyObject *Dep = PyString_FromString(Types[Start->Type]); + PyObject *Dep = PyString_FromString(UntranslatedDepTypes[Start->Type]); LastDepType = Start->Type; LastDep = PyDict_GetItem(Dict,Dep); if (LastDep == 0) @@ -823,6 +824,10 @@ static PyObject *DependencyAttr(PyObject *Self,char *Name) return PyString_FromString(Dep.CompType()); else if (strcmp("DepType",Name) == 0) return PyString_FromString(Dep.DepType()); + else if (strcmp("UntranslatedDepType",Name) == 0) + return PyString_FromString(UntranslatedDepTypes[Dep->Type]); + else if (strcmp("DepTypeEnum",Name) == 0) + return Py_BuildValue("i", Dep->Type); else if (strcmp("ID",Name) == 0) return Py_BuildValue("i",Dep->ID); -- cgit v1.2.3 From 2530221de1657aeac3fa2b93c6b17712a08c6399 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Jan 2010 13:21:46 +0100 Subject: doc/source/apt_pkg/cache.rst: fix cross-reference to _DependencyTypes --- doc/source/apt_pkg/cache.rst | 2 +- doc/source/apt_pkg/index.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/apt_pkg/cache.rst b/doc/source/apt_pkg/cache.rst index 1be81b42..ca9f8b49 100644 --- a/doc/source/apt_pkg/cache.rst +++ b/doc/source/apt_pkg/cache.rst @@ -605,7 +605,7 @@ Example: .. attribute:: DepTypeEnum The type of the dependency, as integer that matches a value - of `Dependency types`_ + of :ref:`Dependency types `. .. attribute:: ID diff --git a/doc/source/apt_pkg/index.rst b/doc/source/apt_pkg/index.rst index aba7d82e..4256d971 100644 --- a/doc/source/apt_pkg/index.rst +++ b/doc/source/apt_pkg/index.rst @@ -329,7 +329,7 @@ Package States .. data:: CurStateNotInstalled .. data:: CurStateUnPacked - +.. _DependencyTypes: Dependency types -- cgit v1.2.3 From 1da29f8e4e578e00e5703a7db7dc8e8d3c7a08bd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 13 Jan 2010 14:35:07 +0100 Subject: apt/history.py: remove from bzr again, its not quite ready yet --- apt/history.py | 55 ------------------------------------------------------- debian/changelog | 2 -- 2 files changed, 57 deletions(-) delete mode 100644 apt/history.py diff --git a/apt/history.py b/apt/history.py deleted file mode 100644 index f056e67e..00000000 --- a/apt/history.py +++ /dev/null @@ -1,55 +0,0 @@ -# histoy.py - apt package abstraction -# -# Copyright (c) 2005-2009 Canonical -# -# Author: Michael Vogt -# -# 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 -"""Functionality related to the apt history file.""" - -import apt_pkg -apt_pkg.InitConfig() - -import gzip -import string - -class Transaction(object): - def __init__(self, sec): - self.start_date = sec.has_key("Start-Date") - for k in ["Install", "Upgrade", "Downgrade" "Remove", "Purge","Error"]: - if sec.has_key(k): - setattr(self, k.lower(), map(string.strip, sec[k].split(","))) - else: - setattr(self, k.lower(), None) - - -class AptHistory(dict): - def __init__(self, history_file=None): - if not history_file: - history_file = apt_pkg.Config.FindFile("Dir::Log::History") - # FIXME: test for .gz ending - f = open(history_file) - self._tagfile = apt_pkg.ParseTagFile(f) - while self._tagfile.Step(): - sec = self._tagfile.Section - start_date = sec['Start-Date'] - self[start_date] = Transaction(sec) - -if __name__ == "__main__": - #h = AptHistory("/var/log/apt/history.log.1.gz") - history = AptHistory() - for date in history: - print "'%s' - '%s'" % (date, history[date].install) diff --git a/debian/changelog b/debian/changelog index d6d19bbf..fa87d5a4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,8 +6,6 @@ python-apt (0.7.13.5) UNRELEASED; urgency=low on non-blocking file descriptors (LP: #491027). [ Michael Vogt ] - * apt/history.py: - - simple abstraction for the apt history file * apt/cache.py: - improved docstring for the cache - add "enhances" property -- cgit v1.2.3