From c7817830a12a7136e8e8c28ae433595c56a004d5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 25 Jul 2008 18:15:20 +0200 Subject: * data/templates/Debian.info.in: - add 'lenny' template info --- data/templates/Debian.info.in | 23 +++++++++++++++++++++++ debian/changelog | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/data/templates/Debian.info.in b/data/templates/Debian.info.in index b635de19..c3ce7fd7 100644 --- a/data/templates/Debian.info.in +++ b/data/templates/Debian.info.in @@ -1,5 +1,28 @@ _ChangelogURI: http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/changelog +Suite: lenny +RepositoryType: deb +BaseURI: http://http.us.debian.org/debian/ +MatchURI: ftp[0-9]*\.[a-z]\.debian\.org +MirrorsFile: /usr/share/python-apt/templates/Debian.mirrors +_Description: Debian 5.0 'Lenny' +Component: main +_CompDescription: Officially supported +Component: contrib +_CompDescription: DFSG-compatible Software with Non-Free Dependencies +Component: non-free +_CompDescription: Non-DFSG-compatible Software + +Suite: lenny-proposed-updates +RepositoryType: deb +ParentSuite: lenny +_Description: Proposed updates + +Suite: lenny/updates +RepositoryType: deb +ParentSuite: lenny +_Description: Security updates + Suite: etch RepositoryType: deb BaseURI: http://http.us.debian.org/debian/ diff --git a/debian/changelog b/debian/changelog index a3792386..49673d48 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.7.1) unstable; urgency=low + + * data/templates/Debian.info.in: + - add 'lenny' template info + + -- Michael Vogt Fri, 25 Jul 2008 18:13:53 +0200 + python-apt (0.7.7) unstable; urgency=low [ Emanuele Rocca ] -- cgit v1.2.3 From 4ea2b04891b17eb22b9321a3896d74a809783915 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 25 Jul 2008 18:33:27 +0200 Subject: * aptsources/distinfo.py: - fix template matching for arch specific code (LP: #244093) --- aptsources/distinfo.py | 45 +++++++++++++++++++++++++++++---------------- debian/changelog | 2 ++ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index 9b438701..b962def6 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -40,6 +40,7 @@ class Template: def __init__(self): self.name = None self.child = False + self.parents = [] # ref to parent template(s) self.match_name = None self.description = None self.base_uri = None @@ -163,11 +164,8 @@ class DistInfo: elif field == 'MetaReleaseURI': self.metarelease_uri = value elif field == 'Suite': - if template: - if component and not template.has_component(component.name): - template.components.append(component) - component = None - self.templates.append(template) + self.finish_template(template, component) + component=None template = Template() template.name = value template.distribution = dist @@ -177,13 +175,10 @@ class DistInfo: elif field == 'ParentSuite': template.child = True for nanny in self.templates: + # look for parent and add back ref to it if nanny.name == value: + template.parents.append(nanny) nanny.children.append(template) - # reuse some properties of the parent template - if template.match_uri == None: - template.match_uri = nanny.match_uri - if template.mirror_set == {}: - template.mirror_set = nanny.mirror_set elif field == 'Available': template.available = value elif field == 'RepositoryType': @@ -227,12 +222,30 @@ class DistInfo: component.set_description(_(value)) elif field == 'CompDescriptionLong': component.set_description_long(_(value)) - if template: - if component: - template.components.append(component) - component = None - self.templates.append(template) - template = None + self.finish_template(template, component) + template=None + component=None + + def finish_template(self, template, component): + " finish the current tempalte " + if not template: + return + # reuse some properties of the parent template + if template.match_uri == None and template.child: + for t in template.parents: + if t.match_uri: + template.match_uri = t.match_uri + break + if template.mirror_set == {} and template.child: + for t in template.parents: + if t.match_uri: + template.mirror_set = t.mirror_set + break + if component and not template.has_component(component.name): + template.components.append(component) + component = None + self.templates.append(template) + if __name__ == "__main__": d = DistInfo ("Ubuntu", "/usr/share/python-apt/templates") diff --git a/debian/changelog b/debian/changelog index 49673d48..c196abe6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.7.1) unstable; urgency=low * data/templates/Debian.info.in: - add 'lenny' template info + * aptsources/distinfo.py: + - fix template matching for arch specific code (LP: #244093) -- Michael Vogt Fri, 25 Jul 2008 18:13:53 +0200 -- cgit v1.2.3 From 4922f32e6ee40511775067241bda6d2dde539c1f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 25 Jul 2008 18:53:56 +0200 Subject: close the right bug for the missing lenny template --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c196abe6..571e0ae5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ python-apt (0.7.7.1) unstable; urgency=low * data/templates/Debian.info.in: - - add 'lenny' template info + - add 'lenny' template info (closes: #476364) * aptsources/distinfo.py: - fix template matching for arch specific code (LP: #244093) -- cgit v1.2.3 From c085ac239354d78c3093049a4c48a27f514c6da2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 30 Jul 2008 10:25:23 +0200 Subject: * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL --- debian/changelog | 7 +++++++ po/python-apt.pot | 25 +++++++++++++++---------- python/cache.cc | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/debian/changelog b/debian/changelog index 571e0ae5..7bc2630e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.7.7.2) UNRELEASED; urgency=low + + * python/cache.cc: + - fix crash if Ver.PriorityType() returns NULL + + -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 + python-apt (0.7.7.1) unstable; urgency=low * data/templates/Debian.info.in: diff --git a/po/python-apt.pot b/po/python-apt.pot index 7125757c..9dc6e202 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: 2008-07-18 15:22+0100\n" +"POT-Creation-Date: 2008-07-30 10:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -188,7 +188,7 @@ msgid "Cdrom with Ubuntu 5.04 'Hoary Hedgehog'" msgstr "" #. CompDescription -#: ../data/templates/Ubuntu.info.in:383 ../data/templates/Debian.info.in:94 +#: ../data/templates/Ubuntu.info.in:383 ../data/templates/Debian.info.in:117 msgid "Officially supported" msgstr "" @@ -260,46 +260,51 @@ msgstr "" #. Description #: ../data/templates/Debian.info.in:8 -msgid "Debian 4.0 'Etch' " +msgid "Debian 5.0 'Lenny' " msgstr "" #. Description #: ../data/templates/Debian.info.in:31 +msgid "Debian 4.0 'Etch' " +msgstr "" + +#. Description +#: ../data/templates/Debian.info.in:54 msgid "Debian 3.1 'Sarge'" msgstr "" #. Description -#: ../data/templates/Debian.info.in:42 +#: ../data/templates/Debian.info.in:65 msgid "Proposed updates" msgstr "" #. Description -#: ../data/templates/Debian.info.in:47 +#: ../data/templates/Debian.info.in:70 msgid "Security updates" msgstr "" #. Description -#: ../data/templates/Debian.info.in:54 +#: ../data/templates/Debian.info.in:77 msgid "Debian current stable release" msgstr "" #. Description -#: ../data/templates/Debian.info.in:67 +#: ../data/templates/Debian.info.in:90 msgid "Debian testing" msgstr "" #. Description -#: ../data/templates/Debian.info.in:92 +#: ../data/templates/Debian.info.in:115 msgid "Debian 'Sid' (unstable)" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:96 +#: ../data/templates/Debian.info.in:119 msgid "DFSG-compatible Software with Non-Free Dependencies" msgstr "" #. CompDescription -#: ../data/templates/Debian.info.in:98 +#: ../data/templates/Debian.info.in:121 msgid "Non-DFSG-compatible Software" msgstr "" diff --git a/python/cache.cc b/python/cache.cc index 66a2c5d9..bd280dec 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -599,7 +599,7 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) else if (strcmp("Priority",Name) == 0) return Py_BuildValue("i",Ver->Priority); else if (strcmp("PriorityStr",Name) == 0) - return PyString_FromString(Ver.PriorityType()); + return Safe_FromString(Ver.PriorityType()); else if (strcmp("Downloadable", Name) == 0) return Py_BuildValue("b", Ver.Downloadable()); else if (strcmp("TranslatedDescription", Name) == 0) { -- cgit v1.2.3 From d6343253aa4025376b9a8bb2b2fa140819def747 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 11:22:27 +0200 Subject: * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) --- apt/cache.py | 3 +++ debian/changelog | 2 ++ 2 files changed, 5 insertions(+) diff --git a/apt/cache.py b/apt/cache.py index 384afe31..bbf2165b 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -101,6 +101,9 @@ class Cache(object): def has_key(self, key): return self._dict.has_key(key) + def __contains__(self, key): + return key in self._dict + def __len__(self): return len(self._dict) diff --git a/debian/changelog b/debian/changelog index 7bc2630e..86e5b0c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL + * apt/cache.py: + - support "in" in apt.Cache() (LP: #251587) -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 -- cgit v1.2.3 From b4d0f3a1c38d916c2abda67549a454467a05fb1f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 11:42:55 +0200 Subject: fix GetCandidateVer() reporting incorrect versions after SetCandidateVer() was used. Thanks to Julian Andres Klode for the test-case (LP: #237372) --- debian/changelog | 3 +++ po/python-apt.pot | 2 +- python/depcache.cc | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 86e5b0c9..1afcb16e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL + - fix GetCandidateVer() reporting incorrect versions after + SetCandidateVer() was used. Thanks to Julian Andres Klode for + the test-case (LP: #237372) * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) diff --git a/po/python-apt.pot b/po/python-apt.pot index 9dc6e202..20905fdf 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: 2008-07-30 10:24+0200\n" +"POT-Creation-Date: 2008-07-31 11:40+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/depcache.cc b/python/depcache.cc index 5664a6d8..2446dc71 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -197,7 +197,7 @@ static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); - pkgCache::VerIterator I = GetCpp(VersionObj); + pkgCache::VerIterator &I = GetCpp(VersionObj); if(I.end()) { return HandleErrors(Py_BuildValue("b",false)); } @@ -215,7 +215,9 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); - pkgCache::VerIterator I = depcache->GetCandidateVer(Pkg); + pkgDepCache::StateCache & State = (*depcache)[Pkg]; + pkgCache::VerIterator I = State.CandidateVerIter(*depcache); + if(I.end()) { Py_INCREF(Py_None); return Py_None; -- cgit v1.2.3 From 19fdcab7acc03ceb6aaf57f7ccdd754a41aa7b6e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 12:01:43 +0200 Subject: * python/apt_instmodule.cc: - do not change working dir in debExtractArchive() (LP: #184093) --- debian/changelog | 2 ++ po/python-apt.pot | 2 +- python/apt_instmodule.cc | 13 ++++++++++--- tests/test_extract_archive.py | 10 ++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tests/test_extract_archive.py diff --git a/debian/changelog b/debian/changelog index 1afcb16e..8cac6ae2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low - fix GetCandidateVer() reporting incorrect versions after SetCandidateVer() was used. Thanks to Julian Andres Klode for the test-case (LP: #237372) + * python/apt_instmodule.cc: + - do not change working dir in debExtractArchive() (LP: #184093) * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) diff --git a/po/python-apt.pot b/po/python-apt.pot index 20905fdf..7e731689 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: 2008-07-31 11:40+0200\n" +"POT-Creation-Date: 2008-07-31 12:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 43d5e7f7..6e6c89dd 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -74,6 +74,7 @@ static char *doc_debExtractArchive = static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { char *Rootdir = NULL; + char cwd[512]; PyObject *File; if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0) return 0; @@ -83,21 +84,27 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { if(Rootdir != NULL) { + getcwd(cwd, sizeof(cwd)); chdir(Rootdir); } // Open the file and associate the .deb FileFd Fd(fileno(PyFile_AsFile(File)),false); debDebFile Deb(Fd); - if (_error->PendingError() == true) - return HandleErrors(); + if (_error->PendingError() == true) { + if (cwd != NULL) + chdir (cwd); + return HandleErrors(Py_BuildValue("b",false)); + } // extracts relative to the current dir pkgDirStream Extract; res = Deb.ExtractArchive(Extract); + if (cwd != NULL) + chdir (cwd); if (res == false) - return HandleErrors(); + return HandleErrors(Py_BuildValue("b",res)); } return HandleErrors(Py_BuildValue("b",res)); } diff --git a/tests/test_extract_archive.py b/tests/test_extract_archive.py new file mode 100644 index 00000000..ce202b06 --- /dev/null +++ b/tests/test_extract_archive.py @@ -0,0 +1,10 @@ +#!/usr/bin/python + +import apt +import apt_inst +import os +import sys + +print os.getcwd() +apt_inst.debExtractArchive(open(sys.argv[1]), "/tmp/") +print os.getcwd() -- cgit v1.2.3 From bb53ee921fc357decaa6b1f8660f9d6ce621eafb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 12:18:46 +0200 Subject: * python/apt_instmodule.cc: - fix bug in Rootdir cwd code --- python/apt_instmodule.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 6e6c89dd..ea703b21 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -92,7 +92,7 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) FileFd Fd(fileno(PyFile_AsFile(File)),false); debDebFile Deb(Fd); if (_error->PendingError() == true) { - if (cwd != NULL) + if (Rootdir != NULL) chdir (cwd); return HandleErrors(Py_BuildValue("b",false)); } @@ -101,7 +101,7 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) pkgDirStream Extract; res = Deb.ExtractArchive(Extract); - if (cwd != NULL) + if (Rootdir != NULL) chdir (cwd); if (res == false) return HandleErrors(Py_BuildValue("b",res)); -- cgit v1.2.3 From 1d96f36591c56798021c4e33d01a781507592add Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 12:20:11 +0200 Subject: add test_debextract.py --- tests/test_debextract.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 tests/test_debextract.py diff --git a/tests/test_debextract.py b/tests/test_debextract.py new file mode 100755 index 00000000..53241e92 --- /dev/null +++ b/tests/test_debextract.py @@ -0,0 +1,13 @@ +#!/usr/bin/python + +import apt_inst +import sys + +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) + +member = "data.tar.lzma" +if len(sys.argv) > 2: + member = sys.argv[2] +apt_inst.debExtract(open(sys.argv[1]), Callback, member) -- cgit v1.2.3 From 34503feab88a8aa72ef511f86375933a4d8707ef Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 15 Aug 2008 10:02:54 +0200 Subject: * python/progress.cc: - when pulse() does not return a boolean assume "true" (thanks to Martin Pitt for telling me about the problem) --- debian/changelog | 3 +++ po/python-apt.pot | 2 +- python/progress.cc | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8cac6ae2..6a8b7f7e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low - do not change working dir in debExtractArchive() (LP: #184093) * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) + * python/progress.cc: + - when pulse() does not return a boolean assume "true" + (thanks to Martin Pitt for telling me about the problem) -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 diff --git a/po/python-apt.pot b/po/python-apt.pot index 7e731689..3d513b7b 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: 2008-07-31 12:00+0200\n" +"POT-Creation-Date: 2008-08-15 09:59+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/progress.cc b/python/progress.cc index 793265db..99ad0a25 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -185,8 +185,10 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) bool res = true; if(!PyArg_Parse(result, "b", &res)) { - // mvo: this is harmless, we shouldn't print anything here - //std::cerr << "result could not be parsed" << std::endl; + // 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 + return true; } // fetching can be canceld by returning false -- cgit v1.2.3 From 08687ea30fffba24cf8204299285f3180f6ae3c3 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 23 Aug 2008 10:45:14 +0200 Subject: do not run apt_pkg.init() in the middle of a function, that *destroys* all custom config data --- aptsources/distinfo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index b962def6..a6c0faf8 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -128,7 +128,6 @@ class DistInfo: base_dir = "/usr/share/python-apt/templates"): self.metarelease_uri = '' self.templates = [] - apt_pkg.init() self.arch = apt_pkg.Config.Find("APT::Architecture") location = None -- cgit v1.2.3 From 34fa87e70cd6967805ba6faebf146bc4dcd5c14c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sat, 23 Aug 2008 11:10:57 +0200 Subject: * aptsources/__init__.py, aptsources/distinfo.py: - run apt_pkg.init() when aptsources gets imported and not the distinfo function --- aptsources/__init__.py | 4 ++++ debian/changelog | 3 +++ 2 files changed, 7 insertions(+) diff --git a/aptsources/__init__.py b/aptsources/__init__.py index 8d1c8b69..d6b3605c 100644 --- a/aptsources/__init__.py +++ b/aptsources/__init__.py @@ -1 +1,5 @@ + +import apt_pkg +# init the package system +apt_pkg.init() diff --git a/debian/changelog b/debian/changelog index 6a8b7f7e..a2ae598a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,9 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low * python/progress.cc: - when pulse() does not return a boolean assume "true" (thanks to Martin Pitt for telling me about the problem) + * aptsources/__init__.py, aptsources/distinfo.py: + - run apt_pkg.init() when aptsources gets imported and not + the distinfo function -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 -- cgit v1.2.3 From 69751ac5d60b35daddfe62219283b535892c7007 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Sep 2008 14:15:59 +0200 Subject: * tests/test_aptsources.py: - make the test work again --- tests/data/sources.list.testDistribution | 20 +++++++++---------- tests/test_aptsources.py | 34 ++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution index 1687c504..45c155e9 100644 --- a/tests/data/sources.list.testDistribution +++ b/tests/data/sources.list.testDistribution @@ -1,11 +1,11 @@ -deb http://de.archive.ubuntu.com/ubuntu/ edgy main -deb http://de.archive.ubuntu.com/ubuntu/ edgy restricted -deb http://de.archive.ubuntu.com/ubuntu/ edgy universe -deb http://de.archive.ubuntu.com/ubuntu/ edgy-updates universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ edgy-updates restricted -deb http://de.archive.ubuntu.com/ubuntu/ edgy-security main -deb http://de.archive.ubuntu.com/ubuntu/ edgy-security multiverse +deb http://de.archive.ubuntu.com/ubuntu/ hardy main +deb http://de.archive.ubuntu.com/ubuntu/ hardy restricted +deb http://de.archive.ubuntu.com/ubuntu/ hardy universe +deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe multiverse +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 ftp://ubuntu.cs.utah.edu/pub/ubuntu/ubuntu/ breezy main -deb ftp://ubuntu.cs.utah.edu/pub/ubuntu/ubuntu/ breezy-backports main -deb http://archive.ubuntu.com/ubuntu/ hoary main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main +deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main +deb http://archive.ubuntu.com/ubuntu/ intrepid main diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 3ee106be..4b2c7965 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -1,27 +1,32 @@ #!/usr/bin/env python -import UpdateManager.Common.aptsources as aptsources import unittest import apt_pkg import os import copy +import sys +sys.path.insert(0, "../") +import aptsources +import aptsources.sourceslist +import aptsources.distro + class TestAptSources(unittest.TestCase): def __init__(self, methodName): unittest.TestCase.__init__(self, methodName) apt_pkg.init() apt_pkg.Config.Set("Dir::Etc", os.getcwd()) - apt_pkg.Config.Set("Dir::Etc::sourceparts",".") + apt_pkg.Config.Set("Dir::Etc::sourceparts","/xxx") def testIsMirror(self): - self.assertTrue(aptsources.is_mirror("http://archive.ubuntu.com", - "http://de.archive.ubuntu.com")) - self.assertFalse(aptsources.is_mirror("http://archive.ubuntu.com", - "http://ftp.debian.org")) + self.assertTrue(aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://de.archive.ubuntu.com")) + self.assertFalse(aptsources.sourceslist.is_mirror("http://archive.ubuntu.com", + "http://ftp.debian.org")) def testSourcesListReading(self): apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list") - sources = aptsources.SourcesList() + sources = aptsources.sourceslist.SourcesList() self.assertEqual(len(sources.list), 6) # test load sources.list = [] @@ -30,7 +35,7 @@ class TestAptSources(unittest.TestCase): def testSourcesListAdding(self): apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list") - sources = aptsources.SourcesList() + sources = aptsources.sourceslist.SourcesList() # test to add something that is already there (main) before = copy.deepcopy(sources) sources.add("deb","http://de.archive.ubuntu.com/ubuntu/", @@ -76,10 +81,13 @@ class TestAptSources(unittest.TestCase): self.assertEqual(found_something, 1) self.assertEqual(found_universe, 1) + def testMatcher(self): + apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list.testDistribution") + def testDistribution(self): apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list.testDistribution") - sources = aptsources.SourcesList() - distro = aptsources.Distribution() + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() distro.get_sources(sources) # test if all suits of the current distro were detected correctly dist_templates = set() @@ -87,11 +95,11 @@ class TestAptSources(unittest.TestCase): if s.template: dist_templates.add(s.template.name) #print dist_templates - for d in ["edgy","edgy-security","edgy-updates","hoary","breezy", "breezy-backports"]: + for d in ["hardy","hardy-security","hardy-updates","intrepid","hardy-backports"]: self.assertTrue(d in dist_templates) # test enable comp = "restricted" - distro.enable_component(sources, comp) + distro.enable_component(comp) found = {} for entry in sources: if (entry.type == "deb" and @@ -108,7 +116,7 @@ class TestAptSources(unittest.TestCase): # add a not-already available component comp = "multiverse" - distro.enable_component(sources, comp) + distro.enable_component(comp) found = {} for entry in sources: if (entry.type == "deb" and -- cgit v1.2.3 From d44831bb1d10ac1bc29690fd226209fb71b91b42 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Sep 2008 14:35:14 +0200 Subject: * python/apt_pkgmodule.cc: add "SelState{Unknown,Install,Hold,DeInstall,Purge}" constants - fix detection of cdrom sources and add test for it --- data/templates/Ubuntu.info.in | 9 +++++++++ debian/changelog | 3 +++ tests/data/sources.list.testDistribution | 2 ++ tests/test_aptsources.py | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index c3cfe6df..97554fa8 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -25,6 +25,7 @@ _CompDescriptionLong: Software restricted by copyright or legal issues Suite: intrepid MatchName: .* BaseURI: cdrom:\[Ubuntu.*8.10 +MatchURI: cdrom:\[Ubuntu.*8.10 _Description: Cdrom with Ubuntu 8.10 'Intrepid Ibex' Available: False Component: main @@ -80,6 +81,7 @@ _CompDescriptionLong: Software restricted by copyright or legal issues Suite: hardy MatchName: .* BaseURI: cdrom:\[Ubuntu.*8.04 +MatchURI: cdrom:\[Ubuntu.*8.04 _Description: Cdrom with Ubuntu 8.04 'Hardy Heron' Available: False Component: main @@ -134,6 +136,7 @@ _CompDescriptionLong: Software restricted by copyright or legal issues Suite: gutsy MatchName: .* BaseURI: cdrom:\[Ubuntu.*7.10 +MatchURI: cdrom:\[Ubuntu.*7.10 _Description: Cdrom with Ubuntu 7.10 'Gutsy Gibbon' Available: False Component: main @@ -186,6 +189,7 @@ _CompDescriptionLong: Software restricted by copyright or legal issues Suite: feisty MatchName: .* BaseURI: cdrom:\[Ubuntu.*7.04 +MatchURI: cdrom:\[Ubuntu.*7.04 _Description: Cdrom with Ubuntu 7.04 'Feisty Fawn' Available: False Component: main @@ -237,6 +241,7 @@ _CompDescriptionLong: Software restricted by copyright or legal issues Suite: edgy MatchName: .* BaseURI: cdrom:\[Ubuntu.*6.10 +MatchURI: cdrom:\[Ubuntu.*6.10 _Description: Cdrom with Ubuntu 6.10 'Edgy Eft' Available: False Component: main @@ -288,6 +293,7 @@ _CompDescriptionLong: Software restricted by copyright or legal issues Suite: dapper MatchName: .* BaseURI: cdrom:\[Ubuntu.*6.06 +MatchURI: cdrom:\[Ubuntu.*6.06 _Description: Cdrom with Ubuntu 6.06 LTS 'Dapper Drake' Available: False Component: main @@ -335,6 +341,7 @@ _CompDescription: Non-free (Multiverse) Suite: breezy MatchName: .* BaseURI: cdrom:\[Ubuntu.*5.10 +MatchURI: cdrom:\[Ubuntu.*5.10 _Description: Cdrom with Ubuntu 5.10 'Breezy Badger' Available: False Component: main @@ -377,6 +384,7 @@ _CompDescription: Non-free (Multiverse) Suite: hoary MatchName: .* BaseURI: cdrom:\[Ubuntu.*5.04 +MatchURI: cdrom:\[Ubuntu.*5.04 _Description: Cdrom with Ubuntu 5.04 'Hoary Hedgehog' Available: False Component: main @@ -418,6 +426,7 @@ _CompDescription: Non-free (Multiverse) Suite: warty MatchName: .* BaseURI: cdrom:\[Ubuntu.*4.10 +MatchURI: cdrom:\[Ubuntu.*4.10 _Description: Cdrom with Ubuntu 4.10 'Warty Warthog' Available: False Component: main diff --git a/debian/changelog b/debian/changelog index a2ae598a..e9d5710c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,9 +12,12 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low * python/progress.cc: - when pulse() does not return a boolean assume "true" (thanks to Martin Pitt for telling me about the problem) + * python/apt_pkgmodule.cc: + add "SelState{Unknown,Install,Hold,DeInstall,Purge}" constants * aptsources/__init__.py, aptsources/distinfo.py: - run apt_pkg.init() when aptsources gets imported and not the distinfo function + - fix detection of cdrom sources and add test for it -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution index 45c155e9..0f40e85a 100644 --- a/tests/data/sources.list.testDistribution +++ b/tests/data/sources.list.testDistribution @@ -9,3 +9,5 @@ deb http://ftp.debian.org/debian sid main deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy main deb http://ubuntu.cs.uaf.edu/ubuntu/ hardy-backports main deb http://archive.ubuntu.com/ubuntu/ intrepid main +deb cdrom:[Ubuntu 8.10 _Intrepid Ibex_ - Alpha]/ intrepid main +deb cdrom:[Ubuntu 8.04 _Hardy Heron_] hardy main \ No newline at end of file diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 4b2c7965..49fe6afa 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -83,6 +83,14 @@ class TestAptSources(unittest.TestCase): def testMatcher(self): apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list.testDistribution") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro() + 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) def testDistribution(self): apt_pkg.Config.Set("Dir::Etc::sourcelist","data/sources.list.testDistribution") -- cgit v1.2.3 From 4474bb62bda8087f63a9e35edb2f6fcaa1bd96d1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Sep 2008 14:48:12 +0200 Subject: add "SelState{Unknown,Install,Hold,DeInstall,Purge}" constant --- debian/changelog | 2 +- python/apt_pkgmodule.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e9d5710c..dc9c2501 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.7.2) UNRELEASED; urgency=low +python-apt (0.7.8) UNRELEASED; urgency=low * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index fd7a83cd..fae85f00 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -517,6 +517,12 @@ extern "C" void initapt_pkg() AddInt(Dict,"CurStateConfigFiles",pkgCache::State::ConfigFiles); AddInt(Dict,"CurStateInstalled",pkgCache::State::Installed); + AddInt(Dict,"SelStateUnknown",pkgCache::State::Unknown); + AddInt(Dict,"SelStateInstall",pkgCache::State::Install); + AddInt(Dict,"SelStateHold",pkgCache::State::Hold); + AddInt(Dict,"SelStateDeInstall",pkgCache::State::DeInstall); + AddInt(Dict,"SelStatePurge",pkgCache::State::Purge); + AddInt(Dict,"InstStateOk",pkgCache::State::Ok); AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); -- cgit v1.2.3 From bf833994a066cba0917c87105db41aa72ebe713a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Sep 2008 14:53:30 +0200 Subject: * apt/package.py: - do not return None in sourcePackageName (LP: #123062) - add "SelState{Unknown,Install,Hold,DeInstall,Purge}" constants --- apt/package.py | 3 ++- debian/changelog | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apt/package.py b/apt/package.py index 096b1bd1..6300b91a 100644 --- a/apt/package.py +++ b/apt/package.py @@ -186,7 +186,8 @@ class Package(object): def sourcePackageName(self): """ Return the source package name as string """ if not self._lookupRecord(): - return None + if not self._lookupRecord(UseCanidate=False): + return self._pkg.Name src = self._records.SourcePkg if src != "": return src diff --git a/debian/changelog b/debian/changelog index dc9c2501..28335af0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,11 +9,13 @@ python-apt (0.7.8) UNRELEASED; urgency=low - do not change working dir in debExtractArchive() (LP: #184093) * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) + * apt/package.py: + - do not return None in sourcePackageName (LP: #123062) * python/progress.cc: - when pulse() does not return a boolean assume "true" (thanks to Martin Pitt for telling me about the problem) * python/apt_pkgmodule.cc: - add "SelState{Unknown,Install,Hold,DeInstall,Purge}" constants + - add "SelState{Unknown,Install,Hold,DeInstall,Purge}" constants * aptsources/__init__.py, aptsources/distinfo.py: - run apt_pkg.init() when aptsources gets imported and not the distinfo function -- cgit v1.2.3 From 3bc4cc400ef9a6994e3ed51526811bfa2acd9927 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Sep 2008 14:58:03 +0200 Subject: fix typo --- apt/package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apt/package.py b/apt/package.py index 6300b91a..c1c2b1e1 100644 --- a/apt/package.py +++ b/apt/package.py @@ -186,7 +186,7 @@ class Package(object): def sourcePackageName(self): """ Return the source package name as string """ if not self._lookupRecord(): - if not self._lookupRecord(UseCanidate=False): + if not self._lookupRecord(UseCandidate=False): return self._pkg.Name src = self._records.SourcePkg if src != "": -- cgit v1.2.3