Package: python-apt Version: 0.8.7 thanks Hi, currently loading of apt and aptsources packages will initialize new configuration instances with apt_pkg.init(). If you have hooks to run with package manager you will see them multiple times. Please check if configuration is already initialized, e.g. with commmon key "APT" (see patch below). To reproduce this issue you can use following hook and snippet. Place the one-liner 'echo' hook e.g. in /etc/apt/apt.conf.d/42testing): DPkg::Pre-Install-Pkgs {"echo preinstallhook1 || exit 1";}; #!/usr/bin/env python import apt_pkg import apt # toggle import aptsources # toggle apt_pkg.init() # toggle cache = apt_pkg.Cache() depcache = apt_pkg.DepCache(cache) pkgmanager = apt_pkg.PackageManager(depcache) depcache.mark_delete(cache['apt']) lock = apt_pkg.SystemLock() with lock: # use lock to not remove anything res = pkgmanager.do_install() exit(res) Expected behavior is to see this hook only one time. Regards Dominique Lasserre diff --git a/apt/__init__.py b/apt/__init__.py 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -31,7 +31,9 @@ from apt_pkg import (size_to_str as SizeToStr, time_to_str as TimeToStr, version_compare as VersionCompare) -# init the package system -apt_pkg.init() +# init the package system and prevent multiple configuration instances +if not apt_pkg.config.exists("APT"): + apt_pkg.init_config() +apt_pkg.init_system() __all__ = ['Cache', 'Cdrom', 'Package'] diff --git a/aptsources/__init__.py b/aptsources/__init__.py 100644 --- a/aptsources/__init__.py +++ b/aptsources/__init__.py @@ -1,4 +1,6 @@ import apt_pkg -# init the package system -apt_pkg.init() +# init the package system and prevent multiple configuration instances +if not apt_pkg.config.exists("APT"): + apt_pkg.init_config() +apt_pkg.init_system()
Attachment:
0xB2E4F4F3.asc
Description: application/pgp-keys
Attachment:
signature.asc
Description: OpenPGP digital signature