调整原过滤的方式
This commit is contained in:
parent
5cf4d50986
commit
4b94575403
|
@ -59,7 +59,7 @@ class LocalUpgradeDataList:
|
||||||
self.upgrade_groups_pkgs = upgrade_groups_pkgs
|
self.upgrade_groups_pkgs = upgrade_groups_pkgs
|
||||||
#推送的可升级的单包
|
#推送的可升级的单包
|
||||||
self.single_pkgs = single_pkgs
|
self.single_pkgs = single_pkgs
|
||||||
#调整版本列表
|
#调整版本列表 源过滤
|
||||||
self.adjust_pkgs = adjust_pkgs
|
self.adjust_pkgs = adjust_pkgs
|
||||||
|
|
||||||
class UpdateList():
|
class UpdateList():
|
||||||
|
@ -100,7 +100,7 @@ class UpdateList():
|
||||||
header = ''
|
header = ''
|
||||||
desc = ''
|
desc = ''
|
||||||
pkg_important_list = []
|
pkg_important_list = []
|
||||||
pkg_install_list = []
|
pkg_list = []
|
||||||
group_important_list = []
|
group_important_list = []
|
||||||
|
|
||||||
# 获取importantlist 本次更新推送
|
# 获取importantlist 本次更新推送
|
||||||
|
@ -116,20 +116,18 @@ class UpdateList():
|
||||||
#在可升级的列表当中 此步骤为了排除已安装不需要升级的
|
#在可升级的列表当中 此步骤为了排除已安装不需要升级的
|
||||||
if pkg_obj.is_installed:
|
if pkg_obj.is_installed:
|
||||||
if pkg_obj in pkgs_upgrade:
|
if pkg_obj in pkgs_upgrade:
|
||||||
pkg_important_list.append(pkg_obj.name)
|
#将推送的单包安装 与组中的重复去除掉
|
||||||
|
pkg_obj.mark_install()
|
||||||
|
pkg_list.append(pkg_obj)
|
||||||
pkgs_upgrade.remove(pkg_obj)
|
pkgs_upgrade.remove(pkg_obj)
|
||||||
else:
|
else:
|
||||||
pkg_install_list.append(pkg_obj)
|
pkg_list.append(pkg_obj)
|
||||||
else:
|
else:
|
||||||
group_important_list.append(pkg_name)
|
group_important_list.append(pkg_name)
|
||||||
|
|
||||||
if pkg_install_list != None:
|
if pkg_list != None:
|
||||||
#进行安装列表的过滤
|
install_list,upgrade_list = self._make_fiter(pkg_list)
|
||||||
pkg_install_list,adjust_pkgs = self.fu.check_in_allowed_origin(pkg_install_list)
|
pkg_important_list = install_list + upgrade_list
|
||||||
self.local_upgrade_data.adjust_pkgs += adjust_pkgs
|
|
||||||
for pkg in pkg_install_list:
|
|
||||||
pkg.mark_install()
|
|
||||||
pkg_important_list.append(pkg.name)
|
|
||||||
|
|
||||||
logging.info("pkg_important_list: %a, group_important_list:%a",pkg_important_list,group_important_list)
|
logging.info("pkg_important_list: %a, group_important_list:%a",pkg_important_list,group_important_list)
|
||||||
return True,group_important_list,pkg_important_list,header,desc
|
return True,group_important_list,pkg_important_list,header,desc
|
||||||
|
@ -209,6 +207,21 @@ class UpdateList():
|
||||||
json.dump(output_json, f, ensure_ascii=False, indent=4)
|
json.dump(output_json, f, ensure_ascii=False, indent=4)
|
||||||
logging.info("Generate Jsonfile(%s) to complete... ",output_config_name)
|
logging.info("Generate Jsonfile(%s) to complete... ",output_config_name)
|
||||||
|
|
||||||
|
def _make_fiter(self,all_pkg_obj):
|
||||||
|
new_install_list = []
|
||||||
|
new_upgrade_list = []
|
||||||
|
#进行安装列表的过滤
|
||||||
|
all_pkg_obj,adjust_pkgs = self.fu.check_in_allowed_origin(all_pkg_obj)
|
||||||
|
self.local_upgrade_data.adjust_pkgs += adjust_pkgs
|
||||||
|
|
||||||
|
for pkg_obj in all_pkg_obj:
|
||||||
|
if pkg_obj.is_installed:
|
||||||
|
new_upgrade_list.append(pkg_obj.name)
|
||||||
|
else:
|
||||||
|
new_install_list.append(pkg_obj.name)
|
||||||
|
return new_install_list,new_upgrade_list
|
||||||
|
|
||||||
|
|
||||||
def _make_groups_upgrade(self,cache,group_list, pkgs_upgrade = []):
|
def _make_groups_upgrade(self,cache,group_list, pkgs_upgrade = []):
|
||||||
try:
|
try:
|
||||||
files = os.listdir(INPUT_CONFIG_PATH) #获得文件夹中所有文件的名称列表
|
files = os.listdir(INPUT_CONFIG_PATH) #获得文件夹中所有文件的名称列表
|
||||||
|
@ -242,39 +255,34 @@ class UpdateList():
|
||||||
# remove_pkgs_list = data['remove_list']
|
# remove_pkgs_list = data['remove_list']
|
||||||
|
|
||||||
#检查包是否在cache中 以及是否已经安装 没有安装的话才添加到列表
|
#检查包是否在cache中 以及是否已经安装 没有安装的话才添加到列表
|
||||||
new_install_pkgs_list = self._check_pkg_in_cache(cache,data['install_list'])
|
new_install_list = self._check_pkg_in_cache(cache,data['install_list'])
|
||||||
|
|
||||||
#此在读important 是需要新安装的标记为install,组中的重合去除
|
|
||||||
if new_install_pkgs_list != None:
|
|
||||||
install_pkg_obj = [cache[pkg] for pkg in new_install_pkgs_list]
|
|
||||||
#进行安装列表的过滤
|
|
||||||
install_pkg_obj,adjust_pkgs = self.fu.check_in_allowed_origin(install_pkg_obj)
|
|
||||||
self.local_upgrade_data.adjust_pkgs += adjust_pkgs
|
|
||||||
new_install_pkgs_list = []
|
|
||||||
for pkg in install_pkg_obj:
|
|
||||||
if pkg.marked_install:
|
|
||||||
continue
|
|
||||||
new_install_pkgs_list.append(pkg.name)
|
|
||||||
|
|
||||||
#进行交集 升级列表
|
#进行交集 升级列表
|
||||||
upgrade_intersection_pkgs = list(set(pkgs_upgrade) & set(upgrade_pkgs_list))
|
new_upgrade_list = list(set(pkgs_upgrade) & set(upgrade_pkgs_list))
|
||||||
|
|
||||||
|
#进行源过滤
|
||||||
|
new_install_list,new_upgrade_list = self._make_fiter([cache[pkg] for pkg in new_install_list + new_upgrade_list])
|
||||||
|
|
||||||
|
for pkg in [cache[pkg] for pkg in new_install_list]:
|
||||||
|
if pkg.marked_install:
|
||||||
|
new_install_list.remove(pkg.name)
|
||||||
|
|
||||||
#判断当前是否可升级或者新装的包
|
#判断当前是否可升级或者新装的包
|
||||||
if len(new_install_pkgs_list) == 0 and len(upgrade_intersection_pkgs) == 0:
|
if len(new_install_list) == 0 and len(new_upgrade_list) == 0:
|
||||||
continue
|
continue
|
||||||
#在总升级列表中移除这些包
|
#在总升级列表中移除这些包
|
||||||
for pkg in upgrade_intersection_pkgs:
|
for pkg in new_upgrade_list:
|
||||||
pkgs_upgrade.remove(pkg)
|
pkgs_upgrade.remove(pkg)
|
||||||
#3、生成升级的包列表JSON
|
#3、生成升级的包列表JSON
|
||||||
upgrade_pkgs_json = self._make_pkg_info_json(cache,upgrade_intersection_pkgs)
|
upgrade_pkgs_json = self._make_pkg_info_json(cache,new_upgrade_list)
|
||||||
#2、生成安装的软件列表
|
#2、生成安装的软件列表
|
||||||
install_pkgs_json = self._make_pkg_info_json(cache,new_install_pkgs_list)
|
install_pkgs_json = self._make_pkg_info_json(cache,new_install_list)
|
||||||
#输出JSON配置文件
|
#输出JSON配置文件
|
||||||
self._make_group_output_json(data,data_yaml,upgrade_pkgs_json,install_pkgs_json)
|
self._make_group_output_json(data,data_yaml,upgrade_pkgs_json,install_pkgs_json)
|
||||||
|
|
||||||
#添加到字典维护的升级列表
|
#添加到字典维护的升级列表
|
||||||
self.local_upgrade_data.upgrade_groups.append(group_name)
|
self.local_upgrade_data.upgrade_groups.append(group_name)
|
||||||
self.local_upgrade_data.upgrade_groups_pkgs.update({group_name:{"pkgs_upgrade":upgrade_intersection_pkgs,"pkgs_install":new_install_pkgs_list}})
|
self.local_upgrade_data.upgrade_groups_pkgs.update({group_name:{"pkgs_upgrade":new_upgrade_list,"pkgs_install":new_install_list}})
|
||||||
logging.info("group(%s) upgrade:%d install:%d",group_name,len(upgrade_intersection_pkgs),len(new_install_pkgs_list))
|
logging.info("group(%s) upgrade:%d install:%d",group_name,len(new_upgrade_list),len(new_install_list))
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -400,9 +408,6 @@ class UpdateList():
|
||||||
|
|
||||||
logging.info("System all upgradeable packages:upgrade:%d ",len(pkgs_upgrade))
|
logging.info("System all upgradeable packages:upgrade:%d ",len(pkgs_upgrade))
|
||||||
|
|
||||||
#源过滤 对升级列表
|
|
||||||
pkgs_upgrade,self.local_upgrade_data.adjust_pkgs = self.fu.check_in_allowed_origin(pkgs_upgrade)
|
|
||||||
|
|
||||||
success,group_important_list,self.local_upgrade_data.single_pkgs,header,desc = self._read_important_list(cache,pkgs_upgrade)
|
success,group_important_list,self.local_upgrade_data.single_pkgs,header,desc = self._read_important_list(cache,pkgs_upgrade)
|
||||||
|
|
||||||
#important_list 为空时此次不需要升级
|
#important_list 为空时此次不需要升级
|
||||||
|
|
|
@ -158,9 +158,9 @@ class UpdateManagerDbusController(dbus.service.Object):
|
||||||
local_upgrade_groups = self.parent.update_list.local_upgrade_data.upgrade_groups
|
local_upgrade_groups = self.parent.update_list.local_upgrade_data.upgrade_groups
|
||||||
local_single_pkgs = self.parent.update_list.local_upgrade_data.single_pkgs
|
local_single_pkgs = self.parent.update_list.local_upgrade_data.single_pkgs
|
||||||
|
|
||||||
upgrade_intersection_pkgs = list(set(partial_upgrade_list) & set(local_upgrade_groups + local_single_pkgs))
|
new_upgrade_list = list(set(partial_upgrade_list) & set(local_upgrade_groups + local_single_pkgs))
|
||||||
|
|
||||||
if upgrade_intersection_pkgs:
|
if new_upgrade_list:
|
||||||
logging.info('dbus partial_upgrade(%s),is_install:%r',partial_upgrade_list,is_install)
|
logging.info('dbus partial_upgrade(%s),is_install:%r',partial_upgrade_list,is_install)
|
||||||
self.parent.start_install(MODE_UPGRADE_PARTIAL,is_install,partial_upgrade_list)
|
self.parent.start_install(MODE_UPGRADE_PARTIAL,is_install,partial_upgrade_list)
|
||||||
return True,'dbus upgrading'
|
return True,'dbus upgrading'
|
||||||
|
|
|
@ -158,6 +158,7 @@ class InstallBackend():
|
||||||
pkgs_install = []
|
pkgs_install = []
|
||||||
pkgs_upgrade = []
|
pkgs_upgrade = []
|
||||||
pkgs_remove = []
|
pkgs_remove = []
|
||||||
|
#获取调整包列表 去掉版本号
|
||||||
adjust_pkgs = [i.split("=")[0] for i in self.local_upgrade_data.adjust_pkgs]
|
adjust_pkgs = [i.split("=")[0] for i in self.local_upgrade_data.adjust_pkgs]
|
||||||
for pkg in cache:
|
for pkg in cache:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue