增加安装配置文件的功能 在更新cache完成后 判断配置文件是否需要安装升级 获取新的配置

This commit is contained in:
wangsong 2021-09-06 20:49:13 +08:00
parent 940c78f41a
commit 7a8200b8f3
4 changed files with 47 additions and 7 deletions

View File

@ -219,6 +219,9 @@ class UpdateList():
self.pkgs_upgrade = []
#需要移除的包列表
self.pkgs_remove = []
#FIXME: 最好将这个常量通过配置文件读
self.GROUPS_JSON_PKG = 'kylin-calculator'
# a stable machine uniq id
try:
@ -485,11 +488,28 @@ class UpdateList():
return app_groups + pkg_groups
def update(self, cache, eventloop_callback=None):
def update(self, cache,start_install_alone, eventloop_callback=None):
self.held_back = []
#来判断将要删除的包 如果存在要删除的break的包的话 会从dist-upgrade切换到upgrade 目前此功能不使用 默认使用dist-upgrade
'''
dist-upgrade 标记在此处进行
来判断将要删除的包 如果存在要删除的break的包的话 会从dist-upgrade切换到upgrade 目前此功能不使用 默认使用dist-upgrade
'''
self.distUpgradeWouldDelete = cache.saveDistUpgrade()
#安装JSON分组配置文件包 安装完毕会重新调start_available --> update --> here FIXME: 在此加入判断是否安装失败多次安装 重复次数 超出退出
try:
pkg_json = cache[self.GROUPS_JSON_PKG]
#是否安装
if pkg_json.is_installed:
#是否可升级
if pkg_json.is_upgradable:
start_install_alone(pkgs_install = [],pkgs_upgrade = [self.GROUPS_JSON_PKG],pkgs_remove = [])
else:
start_install_alone(pkgs_install = [self.GROUPS_JSON_PKG],pkgs_upgrade = [],pkgs_remove = [])
except KeyError:
pass
# Find all upgradable packages
for pkg in cache:
try:

View File

@ -116,13 +116,24 @@ class UpdateManager():
def start_install(self):
#FIXME: 此功能未完善
#检查磁盘的状态
if self.check_free_space(self.cache) == False:
return
# if self.check_free_space(self.cache) == False:
# return
self.is_upgrading = True
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL)
install_backend.start()
#进行升级的操作-传入包列表
def start_install_alone(self,pkgs_install = [], pkgs_upgrade = [], pkgs_remove = []):
#FIXME: 此功能未完善
#检查磁盘的状态
# if self.check_free_space(self.cache) == False:
# return
self.is_upgrading = True
install_backend = get_backend(self, InstallBackend.ACTION_INSTALL)
install_backend.start_alone(pkgs_install,pkgs_upgrade,pkgs_remove)
#更新结束之后会调到此获取要升级的列表 and 安装完成后也会再重新调此方法更新cache
def start_available(self, cancelled_update=False):
self.refresh_cache()
@ -158,7 +169,7 @@ class UpdateManager():
self.update_list = UpdateList(self)
try:
self.update_list.update(self.cache)
self.update_list.update(self.cache,self.start_install_alone)
except SystemError as e:
header = _("Could not calculate the upgrade")
desc = _("An unresolvable problem occurred while "

View File

@ -107,9 +107,9 @@ class InstallBackendAptdaemon(InstallBackend):
#update 更新完成的时候的回调
trans.connect("finished", self._on_finished, action)
trans.connect("medium-required", self._on_medium_required)
trans.connect("progress-changed", self._on_progress_changed)
# trans.connect("progress-changed", self._on_progress_changed)
trans.connect("download-changed", self._on_download_changed)
# trans.connect("download-changed", self._on_download_changed)
#trans.connect("config-file-conflict", self._on_config_file_conflict)

View File

@ -59,6 +59,15 @@ class InstallBackend():
else:
self.update()
def start_alone(self,pkgs_install = [], pkgs_upgrade = [], pkgs_remove = []):
os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
if self.action == self.ACTION_INSTALL:
# Get the packages which should be installed and update
self.commit(pkgs_install, pkgs_upgrade, pkgs_remove)
else:
self.update()
def update(self):
"""Run a update to refresh the package list"""
raise NotImplementedError