单独获取cache

This commit is contained in:
luoxueyi 2021-12-02 15:44:10 +08:00
parent 702c2887d4
commit dcd1432286
1 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,7 @@
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
import os
from apt import Cache
import sys
import shutil
import dbus
@ -417,12 +418,12 @@ class UpdateManager():
depends_count = 0
_error_str = ""
_local_satisfy = False
deb_cache = self.cache
absolute_path, debname = os.path.split(deb_path)
if self.cache == None:
logging.warning('Perform \"UpdateDetect\" first')
return _local_satisfy
if deb_cache == None:
deb_cache = Cache()
try:
deb = DebPackage(deb_path, self.cache)
deb = DebPackage(deb_path, deb_cache)
deb.check()
(install, remove, unauth) = deb.required_changes
except Exception as e:
@ -437,7 +438,7 @@ class UpdateManager():
# return False
# 需要查找本地依赖
elif len(install) > 0:
for pkg in self.cache:
for pkg in deb_cache:
if pkg.marked_install:
depends_pkg.append(pkg)
elif pkg.marked_upgrade: