refs #773 do not use python apt module

oglive-ipv6
Natalia Serrano 2024-09-24 13:00:47 +02:00
parent e60695f847
commit a12001f84a
1 changed files with 5 additions and 27 deletions

View File

@ -58,30 +58,8 @@ def cache_search (pkgs):
return res
def install (pkgs, opts={}):
apt_pkg.init()
if opts:
apt_pkg.init_config()
for k in opts:
apt_pkg.config.set (k, opts[k])
cache = apt_pkg.Cache()
sl = apt_pkg.SourceList()
sl.read_main_list()
cache.update (apt.progress.base.AcquireProgress(), sl)
_to_install = []
dep_cache = apt_pkg.DepCache(cache)
for p in pkgs:
package = cache[p]
if not package:
print (f'package "{p}" not found')
continue
_to_install.append (p)
dep_cache.mark_install(package)
if _to_install:
print ('about to install these packages: "{}"'.format (' '.join (_to_install)))
fetcher = apt_pkg.Acquire()
install_progress = apt.progress.base.InstallProgress()
dep_cache.commit(fetcher, install_progress)
opts_list = []
for k in opts: opts_list += ['-o', f'{k}={opts[k]}']
print ('about to install these packages: "{}"'.format (' '.join (pkgs)))
import subprocess
subprocess.run (['apt-get', '--yes', 'install'] + pkgs + opts_list)