Re: Using python-apt's apt_pkg with a chroot

Sebastiaan Couwenberg <[email protected]> Wed, 3 Dec 2025 08:22:01 +0100
Newsgroups gmane.linux.debian.apt.devel
Message-ID <[email protected]>
On 12/3/25 7:52 AM, Sebastiaan Couwenberg wrote:
> The config dump for Perl AptPkg shows a mix of the system apt.conf and the config set in the code, the config dump for python-apt shows only the config set in the code.

That's because apt_pkg.config needs to be used instead of another apt_pkg.Configuration instance:

  https://salsa.debian.org/sebastic/release.debian.org/-/commit/d7428cd396313d20773d0f10331623f1e2cb2ff6

Now both the Perl & Python scripts work as expected with the chroot & chdist:

  # Python with chroot
  $ unshare --map-auto --map-user=65536 --map-group=65536 --keep-caps -- ~/git/release-team/release.debian.org/bin/resolve-dependencies.py -vdp opencv
  Resolving dependencies for: opencv
  Chroot already exists: /var/tmp/testing-chroot
  config:
  [...]
  Dir "/";
  [...]
  RootDir "/var/tmp/testing-chroot";
  
  list:
  [<apt_pkg.MetaIndex object: type='deb', uri:'https://deb.debian.org/debian/' dist='testing' is_trusted='1'>]
  Reading package lists... Done
  Building dependency tree... Done
  Reading state information... Done
  Package: opencv
  Version: 4.10.0+dfsg-6
  [...]


  # Python with chdist
  $ ~/git/release-team/release.debian.org/bin/resolve-dependencies.py -vdp opencv -D
  Resolving dependencies for: opencv
  config:
  [...]
  Dir "/var/tmp/testing-chdist";
  [...]
  
  list:
  [<apt_pkg.MetaIndex object: type='deb', uri:'https://deb.debian.org/debian/' dist='testing' is_trusted='1'>]
  Reading package lists... Done
  Building dependency tree... Done
  Package: opencv
  Version: 4.10.0+dfsg-6
  [...]


  # Perl with chroot
  $ unshare --map-auto --map-user=65536 --map-group=65536 --keep-caps -- ~/git/release-team/release.debian.org/bin/resolve-dependencies.pl -vdp opencv
  config:
  [...]
  Dir "/";
  [...]
  RootDir "/var/tmp/testing-chroot";
  Getting source package: opencv
  Package: opencv
  Version: 4.10.0+dfsg-6
  Source:  https://deb.debian.org/debian/pool/main/o/opencv/opencv_4.10.0%2bdfsg-6.dsc


  # Perl with chdist
  $ ~/git/release-team/release.debian.org/bin/resolve-dependencies.pl -vdp opencv -D
  config:
  [..]
  Dir "/var/tmp/testing-chdist";
  [...]
  Getting source package: opencv
  Package: opencv
  Version: 4.10.0+dfsg-6
  Source:  https://deb.debian.org/debian/pool/main/o/opencv/opencv_4.10.0%2bdfsg-6.dsc


Kind Regards,

Bas

-- 
  PGP Key ID: 4096R/6750F10AE88D4AF1
Fingerprint: 8182 DE41 7056 408D 6146  50D1 6750 F10A E88D 4AF1