Merge branch 'backend_manual' of gitlab2.kylin.com:kylin-desktop/update-manager-group/kylin-system-updater into backend_manual

This commit is contained in:
Xueyi Luo 2022-05-27 15:15:11 +08:00
commit f0bbc43b21
7 changed files with 39 additions and 10 deletions

View File

@ -505,10 +505,14 @@ class Sqlite3Server(object):
sql = "select display_name_cn from application where display_name='"+name+"'" sql = "select display_name_cn from application where display_name='"+name+"'"
cursor.execute(sql) cursor.execute(sql)
connect.commit() connect.commit()
if cursor.fetchone():
return str(cursor.fetchone()[0])
else:
return ''
except Exception as e: except Exception as e:
logging.error(_("Failed to initialize the database: %s"), str(e)) logging.error(_("Failed to initialize the database: %s"), str(e))
return False
return str(cursor.fetchone()[0])
def listtojsonstr(lists): def listtojsonstr(lists):
import json import json

View File

@ -24,8 +24,7 @@ class UpgradeConfig(SafeConfigParser):
# defaults are read first # defaults are read first
self.config_files = [] self.config_files = []
if defaults_dir: if defaults_dir:
for cfg in glob.glob(defaults_dir + "/*.cfg"): self.config_files.append(os.path.join(datadir, defaults_dir))
self.config_files.append(cfg)
# our config file # our config file
self.config_files += [maincfg] self.config_files += [maincfg]
# overrides are read later # overrides are read later

View File

@ -290,6 +290,13 @@ def url_downloadable(uri, debug_func=None):
return False return False
return False return False
def emulate_calcul_broken(pkgs):
args = ["apt-get", "install","--simulate"]
args = args + pkgs
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
logging.error(str(p.stdout))
def is_chinese(string): def is_chinese(string):
""" """
检查整个字符串是否包含中文 检查整个字符串是否包含中文

View File

@ -38,7 +38,7 @@ class UpdateManager():
GROUPS_PKG_NAME = 'kylin-update-desktop-config' GROUPS_PKG_NAME = 'kylin-update-desktop-config'
APTD_PKG_NAME = "aptdaemon" APTD_PKG_NAME = "aptdaemon"
RUN_UNATTENDED_UPGRADE = '/var/run/unattended-upgrades.pid' RUN_UNATTENDED_UPGRADE = '/var/run/unattended-upgrades.pid'
RETRY_LIMIT_NUM = 1 RETRY_LIMIT_NUM = 2
def __init__(self,options): def __init__(self,options):
self.options = options self.options = options

View File

@ -19,6 +19,8 @@ from apt import Cache
import subprocess import subprocess
from SystemUpdater.Core.UpdateList import LocalUpgradeDataList from SystemUpdater.Core.UpdateList import LocalUpgradeDataList
from SystemUpdater.Core.errors import * from SystemUpdater.Core.errors import *
import threading
from SystemUpdater.Core.utils import emulate_calcul_broken
class NowUpgradeMeta: class NowUpgradeMeta:
""" """
@ -529,6 +531,8 @@ class InstallBackend():
logging.info('Resolver calculation Packages List: '+pkg_string+'\n') logging.info('Resolver calculation Packages List: '+pkg_string+'\n')
desc ='\n' + msg desc ='\n' + msg
logging.error('\n' + msg) logging.error('\n' + msg)
threading_emulate = threading.Thread(target=emulate_calcul_broken,args=(pkgs_install + pkgs_upgrade,))
threading_emulate.start()
return _success,[],[],header,desc return _success,[],[],header,desc
def _emulate_calcul_delete(self,pkg,cache): def _emulate_calcul_delete(self,pkg,cache):
@ -797,7 +801,7 @@ class InstallBackend():
#判断是否是源过滤调整的包 调整的话 判断安装版本 来解决是否安装成功 #判断是否是源过滤调整的包 调整的话 判断安装版本 来解决是否安装成功
if pkg in adjust_pkgs: if pkg in adjust_pkgs:
if pkg_obj.is_installed == True and pkg_obj.name + '=' + pkg_obj.installed.source_version in self.upgrade_data.adjust_pkgs: if pkg_obj.is_installed == True and pkg_obj.is_now_broken == False and pkg_obj.name + '=' + pkg_obj.installed.source_version in self.upgrade_data.adjust_pkgs:
self.window_main.sqlite3_server.insert_info(self.action_mode,[pkg],[],self.upgrade_data.adjust_pkgs,True,'', '') self.window_main.sqlite3_server.insert_info(self.action_mode,[pkg],[],self.upgrade_data.adjust_pkgs,True,'', '')
else: else:
false_num += 1 false_num += 1
@ -805,7 +809,7 @@ class InstallBackend():
self.window_main.sqlite3_server.insert_info(self.action_mode,[pkg],[],self.upgrade_data.adjust_pkgs,False,error_string, error_desc) self.window_main.sqlite3_server.insert_info(self.action_mode,[pkg],[],self.upgrade_data.adjust_pkgs,False,error_string, error_desc)
else: else:
#非调整版本的计算方式 #非调整版本的计算方式
if pkg_obj.is_installed == True and pkg_obj.is_upgradable == False: if pkg_obj.is_installed == True and pkg_obj.is_upgradable == False and pkg_obj.is_now_broken == False:
self.window_main.sqlite3_server.insert_info(self.action_mode,[pkg],[],self.upgrade_data.adjust_pkgs,True,'', '') self.window_main.sqlite3_server.insert_info(self.action_mode,[pkg],[],self.upgrade_data.adjust_pkgs,True,'', '')
else: else:
false_num += 1 false_num += 1
@ -822,12 +826,12 @@ class InstallBackend():
for pkg in pkgs_install + pkgs_upgrade: for pkg in pkgs_install + pkgs_upgrade:
pkg_obj = fresh_cache[pkg] pkg_obj = fresh_cache[pkg]
if pkg in adjust_pkgs: if pkg in adjust_pkgs:
if pkg_obj.is_installed == True and pkg_obj.installed.source_version + pkg_obj.name in self.upgrade_data.adjust_pkgs: if pkg_obj.is_installed == True and pkg_obj.is_now_broken == False and pkg_obj.installed.source_version + pkg_obj.name in self.upgrade_data.adjust_pkgs:
total_pkg.remove(pkg) total_pkg.remove(pkg)
else: else:
install_error_pkgs.append(pkg) install_error_pkgs.append(pkg)
else: else:
if pkg_obj.is_installed == True and pkg_obj.is_upgradable == False: if pkg_obj.is_installed == True and pkg_obj.is_upgradable == False and pkg_obj.is_now_broken == False:
total_pkg.remove(pkg) total_pkg.remove(pkg)
else: else:
install_error_pkgs.append(pkg) install_error_pkgs.append(pkg)

View File

@ -0,0 +1,15 @@
[AutoUpgrade]
upgradelist =
[SystemStatus]
abnormal_reboot = False
close_source_filter = False
[ConfigPkgStatus]
check_resover_remove = False
check_frontend_pkg = True
[InstallMode]
shutdown_install = False
manual_install = False
auto_install = False

View File

@ -10,6 +10,6 @@ check_resover_remove = False
check_frontend_pkg = True check_frontend_pkg = True
[InstallMode] [InstallMode]
shutdown_install = True shutdown_install = False
manual_install = False manual_install = False
auto_install = False auto_install = False