diff options
| -rw-r--r-- | aptsources/distro.py | 19 | ||||
| -rw-r--r-- | data/templates/Ubuntu.info.in | 24 | ||||
| -rw-r--r-- | debian/changelog | 19 | ||||
| -rw-r--r-- | doc/examples/acquire.py | 13 | ||||
| -rw-r--r-- | python/acquire.cc | 12 | ||||
| -rw-r--r-- | python/apt_pkgmodule.cc | 2 | ||||
| -rw-r--r-- | python/apt_pkgmodule.h | 1 | ||||
| -rw-r--r-- | tests/test-data-ports/sources.list | 59 | ||||
| -rw-r--r-- | tests/test_aptsources_ports.py | 37 |
9 files changed, 158 insertions, 28 deletions
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..67180bcb 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -3,9 +3,11 @@ _ChangelogURI: http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/chang 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 +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 9.04 'Jaunty Jackalope' @@ -38,6 +40,10 @@ ParentSuite: jaunty 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: jaunty-updates @@ -58,9 +64,11 @@ _Description: Unsupported updates Suite: intrepid RepositoryType: deb BaseURI: http://archive.ubuntu.com/ubuntu/ -BaseURI-powerpc: http://ports.ubuntu.com/ -MatchURI-powerpc: ports.ubuntu.com 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 8.10 'Intrepid Ibex' @@ -93,6 +101,10 @@ ParentSuite: intrepid 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: intrepid-updates @@ -116,7 +128,9 @@ 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 +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 8.04 'Hardy Heron' diff --git a/debian/changelog b/debian/changelog index 565f5567..91d69206 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,22 @@ +python-apt (0.7.8~ubuntu2) jaunty; urgency=low + + [ Michael Vogt ] + * python/metaindex.cc + - fix crash when incorrect attribute is given + * data/templates/Ubuntu.info.in: + - updated to fix ports.ubuntu.com for powerpc and lpia + (LP: #220890) + * 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. + + -- Michael Vogt <michael.vogt@ubuntu.com> Mon, 10 Nov 2008 11:35:03 +0100 + python-apt (0.7.8~ubuntu1) jaunty; urgency=low * python/apt_pkgmodule.cc: 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<pkgAcquire*>(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<pkgAcqFile*> *AcqFileObj = CppPyObject_NEW<pkgAcqFile*>(&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); 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() |
