summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/cache.py3
-rw-r--r--apt/package.py3
-rw-r--r--aptsources/__init__.py4
-rw-r--r--aptsources/distinfo.py1
-rw-r--r--aptsources/distro.py19
-rw-r--r--data/templates/Ubuntu.info.in84
-rw-r--r--debian/changelog38
-rw-r--r--doc/examples/acquire.py13
-rw-r--r--po/python-apt.pot25
-rw-r--r--python/acquire.cc12
-rw-r--r--python/apt_instmodule.cc13
-rw-r--r--python/apt_pkgmodule.cc8
-rw-r--r--python/apt_pkgmodule.h1
-rw-r--r--python/cache.cc2
-rw-r--r--python/depcache.cc6
-rw-r--r--python/metaindex.cc3
-rw-r--r--python/progress.cc6
-rw-r--r--tests/data/sources.list.testDistribution22
-rw-r--r--tests/test-data-ports/sources.list59
-rw-r--r--tests/test_aptsources.py42
-rw-r--r--tests/test_aptsources_ports.py37
-rwxr-xr-xtests/test_debextract.py13
-rw-r--r--tests/test_extract_archive.py10
23 files changed, 355 insertions, 69 deletions
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/apt/package.py b/apt/package.py
index 096b1bd1..c1c2b1e1 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(UseCandidate=False):
+ return self._pkg.Name
src = self._records.SourcePkg
if src != "":
return src
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/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
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 c3cfe6df..67180bcb 100644
--- a/data/templates/Ubuntu.info.in
+++ b/data/templates/Ubuntu.info.in
@@ -1,11 +1,74 @@
_ChangelogURI: http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/changelog
-Suite: intrepid
+Suite: jaunty
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 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
BaseURI-powerpc: http://ports.ubuntu.com/
-MatchURI-powerpc: 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
+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/
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'
@@ -25,6 +88,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
@@ -37,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
@@ -60,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'
@@ -80,6 +150,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 +205,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 +258,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 +310,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 +362,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 +410,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 +453,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 +495,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 6dd5e4e9..f51cb07a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,41 @@
+python-apt (0.7.8) unstable; urgency=low
+
+ [ Michael Vogt ]
+ * 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)
+ * python/apt_instmodule.cc:
+ - 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
+ * 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
+ * python/metaindex.cc
+ - 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.
+
+ -- Michael Vogt <mvo@debian.org> Mon, 24 Nov 2008 10:24:30 +0200
+
python-apt (0.7.7.1+nmu1) unstable; urgency=medium
* Non-maintainer upload.
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/po/python-apt.pot b/po/python-apt.pot
index 7125757c..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-18 15:22+0100\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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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/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_instmodule.cc b/python/apt_instmodule.cc
index 43d5e7f7..ea703b21 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 (Rootdir != NULL)
+ chdir (cwd);
+ return HandleErrors(Py_BuildValue("b",false));
+ }
// extracts relative to the current dir
pkgDirStream Extract;
res = Deb.ExtractArchive(Extract);
+ if (Rootdir != NULL)
+ chdir (cwd);
if (res == false)
- return HandleErrors();
+ return HandleErrors(Py_BuildValue("b",res));
}
return HandleErrors(Py_BuildValue("b",res));
}
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index fd7a83cd..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"},
@@ -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);
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/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) {
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<pkgCache::PkgIterator>(PackageObj);
- pkgCache::VerIterator I = GetCpp<pkgCache::VerIterator>(VersionObj);
+ pkgCache::VerIterator &I = GetCpp<pkgCache::VerIterator>(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<pkgCache::PkgIterator>(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;
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)
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
diff --git a/tests/data/sources.list.testDistribution b/tests/data/sources.list.testDistribution
index 1687c504..0f40e85a 100644
--- a/tests/data/sources.list.testDistribution
+++ b/tests/data/sources.list.testDistribution
@@ -1,11 +1,13 @@
-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
+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-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.py b/tests/test_aptsources.py
index 3ee106be..49fe6afa 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,21 @@ 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")
+ 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")
- 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 +103,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 +124,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
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()
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)
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()