creating apt cache with rootdir= still considers global apt config

Bug #1238616 reported by Michał Sawicz
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-apt (Debian)
Won't Fix
Unknown
python-apt (Ubuntu)
Opinion
Undecided
Unassigned

Bug Description

I've tried to retrace a unity8 .crash from the phone on my desktop, using lp:daisy config, but the retrace process bails out after failing to download i386 and amd64 from ports.ubuntu.com. See the attached log for details.

The command I used:

⟫ LANG=C apport-retrace -v -S daisy/retracer/config/ -C cache/ -o unity8.crash _usr_bin_unity8.32011.crash 2>&1 | tee retrace.log

Revision history for this message
Michał Sawicz (saviq) wrote :
Revision history for this message
Martin Pitt (pitti) wrote :

I tried this with Michal's .crash file, and I cannot reproduce this, so this needs some more investigation what's different on Michal's system.

affects: apport → apport (Ubuntu)
Changed in apport (Ubuntu):
status: New → Incomplete
Revision history for this message
Martin Pitt (pitti) wrote :

Michal and I debugged this over IRC, and tracked it down. He had an /etc/apt/apt.conf with explicitly setting Architecture:, and creating an apt.Cache(rootdir="...") object still takes that global configuration into account.

The attached test as

summary: - Retracing armhf doesn't work on amd64
+ creating apt cache with rootdir= still considers global apt config
affects: apport (Ubuntu) → python-apt (Ubuntu)
Changed in python-apt (Ubuntu):
status: Incomplete → New
Revision history for this message
Martin Pitt (pitti) wrote :

Michal and I debugged this over IRC, and tracked it down. He had an /etc/apt/apt.conf with explicitly setting Architecture:, and creating an apt.Cache(rootdir="...") object still takes that global configuration into account.

The attached test script works on a default installation, downloads the armhf saucy main index, and creates /tmp/r/var/lib/apt/lists/ports.ubuntu.com_dists_saucy_main_binary-armhf_Packages.

But Michal has something like this config:

echo 'APT::Architectures:: "amd64";' | sudo tee /etc/apt/apt.conf.d/01explicit_arch

After doing that, running the test script shows the same failure:

Err http://ports.ubuntu.com saucy/main amd64 Packages
Get:4 http://ports.ubuntu.com saucy/main armhf Packages [1219 kB]
[...]
E:Some index files failed to download. They have been ignored, or old ones used instead.

So, it might certainly be that I'm using python-apt wrongly here, but I would certainly expect apt.Cache(rootdir=/path/to/my/sandbox) to not consider anything from /etc/apt/?

Revision history for this message
Martin Pitt (pitti) wrote :

Michael Vogt, do you have an idea about this?

Revision history for this message
Julian Andres Klode (juliank) wrote :

It needs to use the global configuration, we do not reload configuration files. You can manually clear the config, set rootdir, and then call apt_pkg.init() or the other two init functions after each other.

Revision history for this message
Julian Andres Klode (juliank) wrote :

We are limited here, because APT uses a global configuration instance, so in order to use the configuration of the other root directory, we'd have to drop the other configuration because they cannot co-exist.

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 1238616] Re: creating apt cache with rootdir= still considers global apt config

Hello Julian,

Julian Andres Klode [2013-10-11 15:47 -0000]:
> We are limited here, because APT uses a global configuration instance,
> so in order to use the configuration of the other root directory, we'd
> have to drop the other configuration because they cannot co-exist.

Does that mean it's not possible to ignore /etc/apt/, or that I'm
doing something wrong? I. e. can you reset the Cache() object somehow
to ignore those global settings?

Thanks!

Revision history for this message
Julian Andres Klode (juliank) wrote :

We had that fixed for some time, but had to revert this now, because code broke.

Anyway, you can get that behavior by clearing the config yourself, before creating the cache object; something like:

 for key in apt_pkg.config:
  del apt_pkg.config[key]
apt_pkg.config["dir"] = rootdir

apt_pkg.init_config()

and then creating the cache using the rootdir argument.

Changed in python-apt (Ubuntu):
status: New → Confirmed
Changed in python-apt (Debian):
status: Unknown → New
Changed in python-apt (Debian):
status: New → Won't Fix
Revision history for this message
Julian Andres Klode (juliank) wrote :

As there's nothing we can do about that without breaking other use cases, we have to declare that working as intended.

Please clear your configuration before setting RootDir like options and then re-init the config.

Sorry

Changed in python-apt (Ubuntu):
status: Confirmed → Opinion
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.