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 +++++++ 1 file changed, 7 insertions(+) (limited to 'debian') 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: -- 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(+) (limited to 'debian') 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(-) (limited to 'debian') 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 (limited to 'debian') 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 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(-) (limited to 'debian') 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 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(+) (limited to 'debian') 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 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(+) (limited to 'debian') 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(-) (limited to 'debian') 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(-) (limited to 'debian') 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 ab1eacf37a1e9125196dca105a59b186fc1783e2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 22 Oct 2008 15:24:50 +0200 Subject: * python/metaindex.cc - fix crash when incorrect attribute is given --- debian/changelog | 2 ++ python/metaindex.cc | 3 +++ 2 files changed, 5 insertions(+) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 28335af0..87fa1406 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ python-apt (0.7.8) UNRELEASED; urgency=low - run apt_pkg.init() when aptsources gets imported and not the distinfo function - fix detection of cdrom sources and add test for it + * python/metaindex.cc + - fix crash when incorrect attribute is given -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 diff --git a/python/metaindex.cc b/python/metaindex.cc index c9a86ab4..45c8ef2a 100644 --- a/python/metaindex.cc +++ b/python/metaindex.cc @@ -38,6 +38,9 @@ static PyObject *MetaIndexAttr(PyObject *Self,char *Name) } return List; } + + PyErr_SetString(PyExc_AttributeError,Name); + return 0; } static PyObject *MetaIndexRepr(PyObject *Self) -- cgit v1.2.3 From fd973539e3ab0a724a69fa9a9eb6b5f2210bb3e1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 3 Nov 2008 11:42:11 +0100 Subject: * data/templates/Ubuntu.info.in: - updated --- data/templates/Ubuntu.info.in | 55 +++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 2 ++ 2 files changed, 57 insertions(+) (limited to 'debian') diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index 97554fa8..3b8f05c4 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -1,5 +1,60 @@ _ChangelogURI: http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog +Suite: jaunty +RepositoryType: deb +BaseURI: http://archive.ubuntu.com/ubuntu/ +BaseURI-powerpc: http://ports.ubuntu.com/ +MatchURI-powerpc: ports.ubuntu.com +MatchURI: archive.ubuntu.com/ubuntu +MirrorsFile-amd64: /usr/share/python-apt/templates/Ubuntu.mirrors +MirrorsFile-i386: /usr/share/python-apt/templates/Ubuntu.mirrors +_Description: Ubuntu 9.04 'Jaunty Jackalope' +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: jaunty +MatchName: .* +BaseURI: cdrom:\[Ubuntu.*9.04 +MatchURI: cdrom:\[Ubuntu.*9.04 +_Description: Cdrom with Ubuntu 9.04 'Jaunty Jackalope' +Available: False +Component: main +_CompDescription: Officially supported +Component: restricted +_CompDescription: Restricted copyright + +Suite: jaunty-security +ParentSuite: jaunty +RepositoryType: deb +BaseURI: http://security.ubuntu.com/ubuntu/ +MatchURI: archive.ubuntu.com/ubuntu|security.ubuntu.com +_Description: Important security updates + +Suite: jaunty-updates +ParentSuite: jaunty +RepositoryType: deb +_Description: Recommended updates + +Suite: jaunty-proposed +ParentSuite: jaunty +RepositoryType: deb +_Description: Pre-released updates + +Suite: jaunty-backports +ParentSuite: jaunty +RepositoryType: deb +_Description: Unsupported updates + Suite: intrepid RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ diff --git a/debian/changelog b/debian/changelog index 87fa1406..be0fa7cb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ python-apt (0.7.8) UNRELEASED; urgency=low - fix detection of cdrom sources and add test for it * python/metaindex.cc - fix crash when incorrect attribute is given + * data/templates/Ubuntu.info.in: + - updated -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 -- cgit v1.2.3 From 46abf8f70e4ec1c520cd2bcf1a9493f2869193a1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 7 Nov 2008 21:06:03 +0100 Subject: python/acquire.cc (GetPkgAcqFile): Support DestDir and DestFilename. --- debian/changelog | 4 ++++ doc/examples/acquire.py | 13 +------------ python/acquire.cc | 12 ++++++++---- python/apt_pkgmodule.cc | 2 +- python/apt_pkgmodule.h | 1 + 5 files changed, 15 insertions(+), 17 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index be0fa7cb..ac775f9c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ python-apt (0.7.8) UNRELEASED; urgency=low + [ Michael Vogt ] * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL - fix GetCandidateVer() reporting incorrect versions after @@ -25,6 +26,9 @@ python-apt (0.7.8) UNRELEASED; urgency=low * data/templates/Ubuntu.info.in: - updated + [ Julian Andres Klode ] + * python/acquire.cc (GetPkgAcqFile): Support DestDir and DestFilename. + -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 python-apt (0.7.7.1) unstable; urgency=low diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index 1291dbfa..eef6c1f7 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -5,24 +5,13 @@ import sys import tempfile def get_file(fetcher, uri, destFile): - cwd = os.getcwd() - # create a temp dir - dir = tempfile.mkdtemp() - os.chdir(dir) # get the file af = apt_pkg.GetPkgAcqFile(fetcher, uri=uri, - descr="sample descr") + descr="sample descr", destFile=destFile) res = fetcher.Run() if res != fetcher.ResultContinue: - os.rmdir(dir) - os.chdir(cwd) return False - filename = os.path.basename(uri) - os.rename(dir+"/"+filename,destFile) - # cleanup - os.rmdir(dir) - os.chdir(cwd) return True apt_pkg.init() diff --git a/python/acquire.cc b/python/acquire.cc index 65f8f2d7..9cf84928 100644 --- a/python/acquire.cc +++ b/python/acquire.cc @@ -242,6 +242,8 @@ PyTypeObject PkgAcquireFileType = 0, // tp_hash }; +char *doc_GetPkgAcqFile = +"GetPkgAcqFile(pkgAquire, uri[, md5, size, descr, shortDescr, destDir, destFile]) -> PkgAcqFile\n"; PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) { PyObject *pyfetcher; @@ -250,11 +252,11 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) uri = md5 = descr = shortDescr = destDir = destFile = ""; char * kwlist[] = {"owner","uri", "md5", "size", "descr", "shortDescr", - NULL}; + "destDir", "destFile", NULL}; - if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|siss", kwlist, + if (PyArg_ParseTupleAndKeywords(Args, kwds, "O!s|sissss", kwlist, &PkgAcquireType, &pyfetcher, &uri, &md5, - &size, &descr, &shortDescr) == 0) + &size, &descr, &shortDescr, &destDir, &destFile) == 0) return 0; pkgAcquire *fetcher = GetCpp(pyfetcher); @@ -263,7 +265,9 @@ PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject * kwds) md5, // md5 size, // size descr, // descr - shortDescr); // short-desc + shortDescr, + destDir, + destFile); // short-desc CppPyObject *AcqFileObj = CppPyObject_NEW(&PkgAcquireFileType); AcqFileObj->Object = af; diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index fae85f00..7b13c838 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -447,7 +447,7 @@ static PyMethodDef methods[] = // Acquire {"GetAcquire",GetAcquire,METH_VARARGS,"GetAcquire() -> Acquire"}, - {"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS,"GetPkgAcquireFile() -> pkgAcquireFile"}, + {"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS, doc_GetPkgAcqFile}, // PkgManager {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager(DepCache) -> PackageManager"}, diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index f59c8ca0..6e02d8e3 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -75,6 +75,7 @@ PyObject *GetCdrom(PyObject *Self,PyObject *Args); // acquire extern PyTypeObject PkgAcquireType; +extern char *doc_GetPkgAcqFile; PyObject *GetAcquire(PyObject *Self,PyObject *Args); PyObject *GetPkgAcqFile(PyObject *Self, PyObject *Args, PyObject *kwds); -- cgit v1.2.3 From b4fac97986469c356a3b1030c14d600ba333202e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 10 Nov 2008 10:41:45 +0100 Subject: * aptsources/distro.py: - add parameter to get_distro() to make unit testing easier * tests/test_aptsources_ports.py: - add test for arch specific handling (when sub arch is on a different mirror than "main" arches) --- aptsources/distro.py | 19 ++++++++---- data/templates/Ubuntu.info.in | 2 +- debian/changelog | 5 ++++ tests/test-data-ports/sources.list | 59 ++++++++++++++++++++++++++++++++++++++ tests/test_aptsources_ports.py | 37 ++++++++++++++++++++++++ 5 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 tests/test-data-ports/sources.list create mode 100644 tests/test_aptsources_ports.py (limited to 'debian') diff --git a/aptsources/distro.py b/aptsources/distro.py index 6d3b453f..f271bbc4 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -414,15 +414,22 @@ class UbuntuDistribution(Distribution): Distribution.get_mirrors(self, mirror_template="http://%s.archive.ubuntu.com/ubuntu/") -def get_distro(): - ''' Check the currently used distribution and return the corresponding - distriubtion class that supports distro specific features. ''' - lsb_info = [] - for lsb_option in ["-i", "-c", "-d", "-r"]: +def get_distro(id=None,codename=None,description=None,release=None): + """ + Check the currently used distribution and return the corresponding + distriubtion class that supports distro specific features. + + If no paramter are given the distro will be auto detected via + a call to lsb-release + """ + # make testing easier + if not (id and codename and description and release): + lsb_info = [] + for lsb_option in ["-i", "-c", "-d", "-r"]: pipe = os.popen("lsb_release %s -s" % lsb_option) lsb_info.append(pipe.read().strip()) del pipe - (id, codename, description, release) = lsb_info + (id, codename, description, release) = lsb_info if id == "Ubuntu": return UbuntuDistribution(id, codename, description, release) diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index 3b8f05c4..c3ebe052 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -116,7 +116,7 @@ RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ MatchURI: archive.ubuntu.com/ubuntu BaseURI-powerpc: http://ports.ubuntu.com/ -MatchURI-powerpc: ports.ubuntu.com +MatchURI-powerpc: 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 8.04 'Hardy Heron' diff --git a/debian/changelog b/debian/changelog index ac775f9c..f16964f4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,11 @@ python-apt (0.7.8) UNRELEASED; urgency=low - fix crash when incorrect attribute is given * data/templates/Ubuntu.info.in: - updated + * aptsources/distro.py: + - add parameter to get_distro() to make unit testing easier + * tests/test_aptsources_ports.py: + - add test for arch specific handling (when sub arch is on + a different mirror than "main" arches) [ Julian Andres Klode ] * python/acquire.cc (GetPkgAcqFile): Support DestDir and DestFilename. diff --git a/tests/test-data-ports/sources.list b/tests/test-data-ports/sources.list new file mode 100644 index 00000000..a6b2f6ed --- /dev/null +++ b/tests/test-data-ports/sources.list @@ -0,0 +1,59 @@ +# +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted + +# deb cdrom:[Ubuntu-Server 8.04.1 _Hardy Heron_ - Release powerpc (20080703)]/ hardy main restricted +# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to +# newer versions of the distribution. + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy main restricted + +## Major bug fix updates produced after the final release of the +## distribution. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates main restricted +deb-src http://archive.ubuntu.com/ubuntu hardy-updates main restricted + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## universe WILL NOT receive any review or updates from the Ubuntu security +## team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy universe +deb-src http://archive.ubuntu.com/ubuntu hardy universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates universe +deb-src http://archive.ubuntu.com/ubuntu hardy-updates universe + +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## multiverse WILL NOT receive any review or updates from the Ubuntu +## security team. +deb http://ports.ubuntu.com/ubuntu-ports/ hardy multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy multiverse +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-updates multiverse +deb-src http://archive.ubuntu.com/ubuntu hardy-updates multiverse + +## Uncomment the following two lines to add software from the 'backports' +## repository. +## N.B. software from this repository may not have been tested as +## extensively as that contained in the main release, although it includes +## newer versions of some applications which may provide useful features. +## Also, please note that software in backports WILL NOT receive any review +## or updates from the Ubuntu security team. +# deb http://ports.ubuntu.com/ubuntu-ports/ hardy-backports main restricted universe multiverse +# deb-src http://archive.ubuntu.com/ubuntu hardy-backports main restricted universe multiverse + +## Uncomment the following two lines to add software from Canonical's +## 'partner' repository. This software is not part of Ubuntu, but is +## offered by Canonical and the respective vendors as a service to Ubuntu +## users. +# deb http://archive.canonical.com/ubuntu hardy partner +# deb-src http://archive.canonical.com/ubuntu hardy partner + +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security main restricted +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security universe +deb http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://ports.ubuntu.com/ubuntu-ports/ hardy-security multiverse +deb-src http://archive.ubuntu.com/ubuntu/ hardy-proposed restricted main multiverse universe diff --git a/tests/test_aptsources_ports.py b/tests/test_aptsources_ports.py new file mode 100644 index 00000000..203721c7 --- /dev/null +++ b/tests/test_aptsources_ports.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +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("APT::Architecture","powerpc") + apt_pkg.Config.Set("Dir::Etc", os.path.join(os.getcwd(),"test-data-ports")) + apt_pkg.Config.Set("Dir::Etc::sourceparts","/xxx") + + def testMatcher(self): + apt_pkg.Config.Set("Dir::Etc::sourcelist","sources.list") + sources = aptsources.sourceslist.SourcesList() + distro = aptsources.distro.get_distro("Ubuntu","hardy","desc","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 + if not s.template: + self.fail("source entry '%s' has no matcher" % s) + + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3