[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#728274: python-apt: apt.conf used from /etc/apt instead of root_dir + etc/apt



On Wed, Oct 30, 2013 at 08:20:38AM +0100, Thomas Bechtold wrote:
> Package: python-apt
> Version: 0.9.1
> Severity: normal

Thanks for your bugreport and your test code.
 
> I tried to use python-apt to get all available package versions. I used
> the 'rootdir' parameter for apt.Cache to have a seperate root dir and
> seperated config files.
> In my /etc/apt/apt.conf , I have the following line:
> 
> APT::Default-Release "sid";
[..]

The attached patch should fix this. Thanks David for the reminder
about this. Note that init_config() without the clean() is not helpful
as most of the init config code these days consists of conditional
sets (i.e. will not override existing ones).

Later Versions of apt have a global Clear(), we should probably use
that once bindings are added.

Cheers,
 Michael
diff --git a/apt/cache.py b/apt/cache.py
index 9842cb2..a9b6016 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -83,13 +83,15 @@ class Cache(object):
             # force apt to build its caches in memory
             apt_pkg.config.set("Dir::Cache::pkgcache", "")
         if rootdir:
+            apt_pkg.config.clear("APT")
+            apt_pkg.config.set("Dir", rootdir)
+            apt_pkg.init_config()
             if os.path.exists(rootdir+"/etc/apt/apt.conf"):
                 apt_pkg.read_config_file(apt_pkg.config,
                                        rootdir + "/etc/apt/apt.conf")
             if os.path.isdir(rootdir+"/etc/apt/apt.conf.d"):
                 apt_pkg.read_config_dir(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")
             # also set dpkg to the rootdir path so that its called for the

Reply to: