From 754744630ff6228029cd025074dc0cfe3de08495 Mon Sep 17 00:00:00 2001 From: Emanuele Rocca Date: Mon, 6 Oct 2008 10:31:30 +0200 Subject: Test case and proposed fix for Debian bug #497049 --- python/cache.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/cache.cc b/python/cache.cc index bd280dec..523444b5 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -936,14 +936,25 @@ PyObject *TmpGetCache(PyObject *Self,PyObject *Args) pkgCacheFile *Cache = new pkgCacheFile(); if(pyCallbackInst != 0) { + if (PyObject_HasAttrString(pyCallbackInst, "done") != 1) { + PyErr_SetString(PyExc_ValueError, + "progress object must implement done()"); + return 0; + } + if (PyObject_HasAttrString(pyCallbackInst, "update") != 1) { + PyErr_SetString(PyExc_ValueError, + "progress object must implement update()"); + return 0; + } PyOpProgress progress; progress.setCallbackInst(pyCallbackInst); if (Cache->Open(progress,false) == false) - return HandleErrors(); - } else { + return HandleErrors(); + } + else { OpTextProgress Prog; if (Cache->Open(Prog,false) == false) - return HandleErrors(); + return HandleErrors(); } CppOwnedPyObject *CacheFileObj = -- cgit v1.2.3 From 5cbf0b5807b4cc67818eae652b59a25d52eb9f7b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 29 Jan 2009 09:26:03 +0100 Subject: * apt/cache.py: - when setting a alternative rootdir, read the config from it as well * python/configuration.cc, python/apt_pkgmodule.cc: - add apt_pkg.ReadConfigDir() --- apt/cache.py | 3 +++ debian/changelog | 5 +++++ po/python-apt.pot | 19 +++++++------------ python/apt_pkgmodule.cc | 1 + python/apt_pkgmodule.h | 2 ++ python/configuration.cc | 18 ++++++++++++++++++ 6 files changed, 36 insertions(+), 12 deletions(-) (limited to 'python') diff --git a/apt/cache.py b/apt/cache.py index 0065d14c..b74f8ef1 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -52,6 +52,9 @@ class Cache(object): # force apt to build its caches in memory apt_pkg.Config.Set("Dir::Cache::pkgcache", "") if rootdir: + print "reading apt.conf" + apt_pkg.ReadConfigFile(apt_pkg.Config, rootdir+"/etc/apt/apt.conf") + apt_pkg.ReadConfigDir(apt_pkg.Config, rootdir+"/etc/apt/apt.conf.d") apt_pkg.Config.Set("Dir", rootdir) apt_pkg.Config.Set("Dir::State::status", rootdir + "/var/lib/dpkg/status") diff --git a/debian/changelog b/debian/changelog index 0b41246f..ffacbec0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,11 @@ python-apt (0.7.9~exp3) experimental; urgency=low * apt/package.py: - make sure to set the defaulttimeout back to the original value (in getChangelog(), LP: #314212) + * apt/cache.py: + - when setting a alternative rootdir, read the + config from it as well + * python/configuration.cc, python/apt_pkgmodule.cc: + - add apt_pkg.ReadConfigDir() -- diff --git a/po/python-apt.pot b/po/python-apt.pot index 6af898db..9bcda683 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: 2009-01-09 18:08+0100\n" +"POT-Creation-Date: 2009-01-29 09:24+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -82,11 +82,6 @@ msgstr "" msgid "Community-maintained" msgstr "" -#. CompDescriptionLong -#: ../data/templates/Ubuntu.info.in:305 -msgid "Proprietary drivers for devices" -msgstr "" - #. CompDescription #: ../data/templates/Ubuntu.info.in:307 msgid "Restricted software" @@ -124,7 +119,7 @@ msgstr "" #. CompDescriptionLong #: ../data/templates/Ubuntu.info.in:357 -msgid "Proprietary drivers for devices " +msgid "Proprietary drivers for devices" msgstr "" #. CompDescription @@ -275,7 +270,7 @@ msgstr "" #. Description #: ../data/templates/Debian.info.in:33 -msgid "Debian 4.0 'Etch' " +msgid "Debian 4.0 'Etch'" msgstr "" #. Description @@ -319,7 +314,7 @@ msgid "Non-DFSG-compatible Software" msgstr "" #. TRANSLATORS: %s is a country -#: ../aptsources/distro.py:194 ../aptsources/distro.py:401 +#: ../aptsources/distro.py:207 ../aptsources/distro.py:422 #, python-format msgid "Server for %s" msgstr "" @@ -327,12 +322,12 @@ msgstr "" #. More than one server is used. Since we don't handle this case #. in the user interface we set "custom servers" to true and #. append a list of all used servers -#: ../aptsources/distro.py:213 ../aptsources/distro.py:218 -#: ../aptsources/distro.py:232 +#: ../aptsources/distro.py:225 ../aptsources/distro.py:231 +#: ../aptsources/distro.py:247 msgid "Main server" msgstr "" -#: ../aptsources/distro.py:235 +#: ../aptsources/distro.py:251 msgid "Custom servers" msgstr "" diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 2e488d58..86732781 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -402,6 +402,7 @@ static PyMethodDef methods[] = // Command line {"ReadConfigFile",LoadConfig,METH_VARARGS,doc_LoadConfig}, + {"ReadConfigDir",LoadConfigDir,METH_VARARGS,doc_LoadConfigDir}, {"ReadConfigFileISC",LoadConfigISC,METH_VARARGS,doc_LoadConfig}, {"ParseCommandLine",ParseCommandLine,METH_VARARGS,doc_ParseCommandLine}, diff --git a/python/apt_pkgmodule.h b/python/apt_pkgmodule.h index 38486182..e047bcd8 100644 --- a/python/apt_pkgmodule.h +++ b/python/apt_pkgmodule.h @@ -23,9 +23,11 @@ extern PyTypeObject VersionType; extern char *doc_LoadConfig; extern char *doc_LoadConfigISC; +extern char *doc_LoadConfigDir; extern char *doc_ParseCommandLine; PyObject *LoadConfig(PyObject *Self,PyObject *Args); PyObject *LoadConfigISC(PyObject *Self,PyObject *Args); +PyObject *LoadConfigDir(PyObject *Self,PyObject *Args); PyObject *ParseCommandLine(PyObject *Self,PyObject *Args); // Tag File Stuff diff --git a/python/configuration.cc b/python/configuration.cc index f52c3c97..21f70bc1 100644 --- a/python/configuration.cc +++ b/python/configuration.cc @@ -327,6 +327,24 @@ PyObject *LoadConfigISC(PyObject *Self,PyObject *Args) if (ReadConfigFile(GetSelf(Self),Name,true) == false) return HandleErrors(); + Py_INCREF(Py_None); + return HandleErrors(Py_None); +} +char *doc_LoadConfigDir = "LoadConfigDir(Configuration,DirName) -> None"; +PyObject *LoadConfigDir(PyObject *Self,PyObject *Args) +{ + char *Name = 0; + if (PyArg_ParseTuple(Args,"Os",&Self,&Name) == 0) + return 0; + if (Configuration_Check(Self)== 0) + { + PyErr_SetString(PyExc_TypeError,"argument 1: expected Configuration."); + return 0; + } + + if (ReadConfigDir(GetSelf(Self),Name,false) == false) + return HandleErrors(); + Py_INCREF(Py_None); return HandleErrors(Py_None); } -- cgit v1.2.3