Merge branch 'backend_dev' into 'dev_test'
Backend dev See merge request kylin-desktop/update-manager-group/kylin-system-updater!339
This commit is contained in:
commit
bca260587f
|
@ -203,7 +203,6 @@ def _has_first_migration(new_db, new_db_cursor):
|
|||
for rv in retval:
|
||||
if "firstmigration" in str(rv):
|
||||
return True
|
||||
return False
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
@ -221,6 +220,42 @@ def _is_first_migration(new_db, new_db_cursor):
|
|||
print(e)
|
||||
return False
|
||||
|
||||
def _is_display_exist_fields(field, db, db_cursor):
|
||||
try:
|
||||
sql_commnd = "select * from sqlite_master where type='table' and name='display';"
|
||||
db_cursor.execute(sql_commnd)
|
||||
retval = db_cursor.fetchone()
|
||||
for rv in retval:
|
||||
if field in str(rv):
|
||||
return True
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
return False
|
||||
|
||||
def _add_display_fields(fields_default):
|
||||
try:
|
||||
if "=" not in fields_default:
|
||||
print("format: field=value")
|
||||
return False
|
||||
field, value = fields_default.split('=')
|
||||
print(_("Loading Sqlite3Server..."))
|
||||
db = sqlite3.connect(DB_UPGRADE, check_same_thread=False)
|
||||
db_cursor = db.cursor()
|
||||
if _is_display_exist_fields(field, db, db_cursor):
|
||||
print("field %s is exist."%field)
|
||||
return False
|
||||
# 字段不存在,新增字段
|
||||
sql_commnd = "alter table display add column "+field+" Text;"
|
||||
db_cursor.execute(sql_commnd)
|
||||
sql_commnd = "UPDATE display SET "+field+"="+value
|
||||
db_cursor.execute(sql_commnd)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
print("Succeeded in adding field: '%s' "%field)
|
||||
return True
|
||||
|
||||
def CopyData():
|
||||
try:
|
||||
# 判断新字段是否存在
|
||||
|
@ -276,6 +311,8 @@ if __name__ == "__main__":
|
|||
help=_("Delete the table"))
|
||||
parser.add_option ("-m", "--data-migration", default=False, action="store_true",
|
||||
dest="data_migration", help=_("data migration"))
|
||||
parser.add_option ("-f", "--add-display-fields",
|
||||
dest="add_display_fields", help=_("add display fields"))
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.clean_table:
|
||||
|
@ -289,6 +326,9 @@ if __name__ == "__main__":
|
|||
print("format error: <database:table>")
|
||||
else:
|
||||
DeleteTable(str(options.delete_table))
|
||||
|
||||
if options.add_display_fields:
|
||||
_add_display_fields(str(options.add_display_fields))
|
||||
|
||||
if options.data_migration:
|
||||
CopyData()
|
||||
|
|
|
@ -360,61 +360,16 @@ class Sqlite3Server(object):
|
|||
return pkgs_install,pkgs_upgrade,pkgs_remove
|
||||
|
||||
#查找数据库
|
||||
def find_msg_from_datebase(self, action = 'check',table = 'updateinfos', cid = 0):
|
||||
# 查询table
|
||||
def find_msg_from_datebase(self, table, field, action = 'check', cid = 0):
|
||||
# 查询数据
|
||||
try:
|
||||
self.cursor.execute("select sql from sqlite_master")
|
||||
count_tables = 0
|
||||
while True:
|
||||
all_table = self.cursor.fetchone()
|
||||
if all_table == None:
|
||||
break
|
||||
tmpstr = str(all_table)
|
||||
if ("sqlite_sequence") in tmpstr or '(None,)' in tmpstr:
|
||||
continue
|
||||
else:
|
||||
# logging.info(tmpstr)
|
||||
count_tables = count_tables + 1
|
||||
pass
|
||||
logging.info("%d tables were found.", count_tables)
|
||||
except Exception as e:
|
||||
logging.error("Check tables error: %s", str(e))
|
||||
|
||||
# 检测历史更新升级
|
||||
try:
|
||||
sql = "SELECT COUNT(*) FROM updateinfos "
|
||||
sql = "select "+field+" from "+table
|
||||
self.cursor.execute(sql)
|
||||
update_count = self.cursor.fetchone()[0]
|
||||
logging.info("%d history updates detected.", update_count)
|
||||
except Exception as e:
|
||||
logging.error("Check update error: %s", str(e))
|
||||
|
||||
# 获取第cid次更新
|
||||
# if cid != 0 and cid > 0:
|
||||
# sql = "SELECT * FROM updateinfos where id='"+str(cid-1)+"'"
|
||||
# try:
|
||||
# self.cursor.execute(sql)
|
||||
# update_count = self.cursor.fetchone()
|
||||
# logging.info("\n\n### Update %d =============>\n### date:%s\n### status:%s\n### keyword:%s\n### errorcode:%s", \
|
||||
# update_count[0]+1, \
|
||||
# update_count[2], \
|
||||
# update_count[3], \
|
||||
# update_count[4], \
|
||||
# update_count[5])
|
||||
# updatelists = json.loads(update_count[1])
|
||||
# logging.info("update_lists: ------------------------>")
|
||||
# for i in updatelists:
|
||||
# for key in i:
|
||||
# logging.info("package name:\n[ %s ].\n----- version: %s\n----- description: %s\n----- icon: %s\n----- action: %s\n", \
|
||||
# key, \
|
||||
# i[key]['version'], \
|
||||
# i[key]['description'], \
|
||||
# i[key]['icon'], \
|
||||
# i[key]['action'])
|
||||
# print("\n")
|
||||
# except Exception as e:
|
||||
# logging.error("Get update error: %s", str(e))
|
||||
|
||||
def listtojsonstr(lists):
|
||||
import json
|
||||
jsonfile = json.dumps(lists)
|
||||
|
|
|
@ -63,13 +63,15 @@ class UpdateList():
|
|||
for base in data_dirs.split(':')]
|
||||
|
||||
#是否关闭源过滤
|
||||
if parent.options.close_filter == True or parent.configs.getWithDefault("SystemStatus", "isclosefilter", False) == True:
|
||||
logging.info("Close to Allowed origin fiter...")
|
||||
self.is_close_filter = True
|
||||
else:
|
||||
# if (parent.options.close_filter == True or parent.configs.getWithDefault("SystemStatus", "isclosefilter", False) == True) and self.parent.is_disc_source == True:
|
||||
|
||||
if self.parent.options.close_filter == False and self.parent.is_disc_source == False:
|
||||
#开启原过滤
|
||||
self.is_close_filter = False
|
||||
self.fu = UpdateListFilterCache(self.parent)
|
||||
else:
|
||||
logging.info("Close to Allowed origin fiter...")
|
||||
self.is_close_filter = True
|
||||
|
||||
|
||||
#清空上次输出的分组JSON文件
|
||||
|
|
|
@ -64,6 +64,9 @@ class UpdateManager():
|
|||
#失败后重启进行安装的限制次数 目前在自适应升级上面使用
|
||||
self.retry_limit = self.RETRY_LIMIT_NUM
|
||||
|
||||
#是否使用光盘源
|
||||
self.is_disc_source = False
|
||||
|
||||
|
||||
#检查是否需要重新启动aptdeamon 目前需要重启的有限速功能
|
||||
def check_restart_aptdeamon(self):
|
||||
|
@ -136,17 +139,14 @@ class UpdateManager():
|
|||
self.configs.reReadConfigFiles()
|
||||
self.retry_limit = self.RETRY_LIMIT_NUM
|
||||
|
||||
#光盘源的话
|
||||
#检查 光盘源
|
||||
if self._check_disc_source() == True:
|
||||
logging.info("Turn off NetworkCheck and CloseFiter and UpdateSource...")
|
||||
#关闭网络检查
|
||||
self.options.no_check_network = True
|
||||
#当判断为光盘源时 关闭源过滤
|
||||
self.options.close_filter = True
|
||||
#关闭 更新源模板
|
||||
self.options.no_update_source = True
|
||||
self.is_disc_source = True
|
||||
else:
|
||||
self.is_disc_source = False
|
||||
|
||||
if self.options.no_check_network is False:
|
||||
if self.options.no_check_network is False and self.is_disc_source == False:
|
||||
#进行检查网络
|
||||
self.dbusController.UpdateDetectStatusChanged(5,_("Checking network connection"))
|
||||
_success,header,desc = self.dbusController.check_connectivity()
|
||||
|
@ -155,7 +155,7 @@ class UpdateManager():
|
|||
return
|
||||
|
||||
#从服务器端更新摸板
|
||||
if self.options.no_update_source is False:
|
||||
if self.options.no_update_source is False and self.is_disc_source == False:
|
||||
self.dbusController.UpdateDetectStatusChanged(10,_("Updating Source Template"))
|
||||
_success,header,desc = self.dbusController.on_update_important_list()
|
||||
if _success == False:
|
||||
|
@ -183,7 +183,7 @@ class UpdateManager():
|
|||
|
||||
for uri in [lis.uri for lis in slist.list]:
|
||||
#找到属于
|
||||
if "file:" in uri:
|
||||
if "file://" in uri and os.path.exists(uri.split("://")[1]):
|
||||
logging.info("Current use of CD-ROM source without network check...")
|
||||
return True
|
||||
|
||||
|
|
|
@ -144,6 +144,11 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
|
||||
#多个源 也只循环一次
|
||||
for uri in [lis.uri for lis in slist.list]:
|
||||
#只要是使用光盘源 就不进行检查了 默认检查网络成功 进行之后的动作
|
||||
if "file://" in uri:
|
||||
logging.info("Current exites of CD-ROM source in sources.list and return network ok...")
|
||||
return True,header,desc
|
||||
|
||||
if "localhost:9977" in uri:
|
||||
#deb http://localhost:9977/172.17.126.249:8098/deb/kylin/ 需要去除localhost:9977 在apt-p2p的模式下
|
||||
network_uri = uri.split("//")[1].split("/")[1]
|
||||
|
@ -586,6 +591,20 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
logging.error(str(e))
|
||||
return False
|
||||
return True
|
||||
|
||||
# 获取数据库值
|
||||
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', out_signature='s')
|
||||
def GetDatabaseInfo(self, table, field):
|
||||
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' GetDatabaseInfo, table name is %s, field is %s', table, field)
|
||||
Text = 'NULL'
|
||||
try:
|
||||
if table == 'display':
|
||||
Text = self.parent.sqlite3_server.select_from_display(str(field))
|
||||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
return Text
|
||||
logging.info("Get %s:%s < %s > ", table, field, Text)
|
||||
return Text
|
||||
|
||||
#更新进度信息 0~100 进度信息 101为非预期的信号
|
||||
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='is')
|
||||
|
|
|
@ -20,11 +20,12 @@ import dbus,time
|
|||
from gi.repository import GLib
|
||||
import os
|
||||
from importlib import reload
|
||||
from SystemUpdater.Core.utils import unLockedEnableShutdown
|
||||
|
||||
# # 超时检测 秒单位
|
||||
# UPDATER_IDLE_CHECK_INTERVAL = 10
|
||||
# #超过15分钟的安装时间则退出
|
||||
# UPDATER_IDLE_TIMEOUT = 15 * 60
|
||||
# 超时检测 秒单位
|
||||
UPDATER_IDLE_CHECK_INTERVAL = 5
|
||||
#超过15分钟的安装时间则退出
|
||||
UPDATER_IDLE_TIMEOUT = 15 * 60
|
||||
|
||||
import dbus
|
||||
from SystemUpdater.Core.utils import (LockedPreventShutdown)
|
||||
|
@ -59,14 +60,14 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
self.trans_cancelable = False
|
||||
|
||||
# 活跃性检查
|
||||
# self.last_action_timestamp = time.time()
|
||||
# self.check_progress = 0
|
||||
self.last_action_timestamp = time.time()
|
||||
self.check_progress = 0
|
||||
|
||||
# if self.action == self.ACTION_INSTALL:
|
||||
# #超时检查轮询
|
||||
# logging.info("ACTION_INSTALL timeout_add_seconds init...")
|
||||
# GLib.timeout_add_seconds(UPDATER_IDLE_CHECK_INTERVAL,
|
||||
# self._check_for_inactivity)
|
||||
if self.action == self.ACTION_INSTALL:
|
||||
#超时检查轮询
|
||||
logging.info("ACTION_INSTALL timeout_add_seconds init...")
|
||||
GLib.timeout_add_seconds(UPDATER_IDLE_CHECK_INTERVAL,
|
||||
self._check_for_inactivity)
|
||||
|
||||
#定时模拟发送进度 为了让进度更加线性
|
||||
if self.action == self.ACTION_UPDATE:
|
||||
|
@ -82,34 +83,37 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
self._dist_status_changed(self.action,[],self.simulation_progress,self.trans_status,self.details)
|
||||
return True
|
||||
|
||||
# def _check_for_inactivity(self):
|
||||
# """Shutdown the daemon if it has been inactive for time specified
|
||||
# in UPDATER_IDLE_TIMEOUT.
|
||||
# """
|
||||
# logging.info("Checking for inactivity...")
|
||||
def _check_for_inactivity(self):
|
||||
"""Shutdown the daemon if it has been inactive for time specified
|
||||
in UPDATER_IDLE_TIMEOUT.
|
||||
"""
|
||||
logging.info("Checking for inactivity...")
|
||||
|
||||
# if self.window_main.is_working == self.ACTION_DEFUALT_STATUS:
|
||||
# logging.info("Installing to exit and timeout check quit...")
|
||||
# return False
|
||||
# #进度不同时 更新时间戳
|
||||
# if self.trans_progress != self.check_progress:
|
||||
# self.check_progress = self.trans_progress
|
||||
# self.last_action_timestamp = time.time()
|
||||
if self.window_main.is_working == self.ACTION_DEFUALT_STATUS:
|
||||
logging.info("Installing to exit and timeout check quit...")
|
||||
return False
|
||||
#进度不同时 更新时间戳
|
||||
if self.trans_progress != self.check_progress:
|
||||
self.check_progress = self.trans_progress
|
||||
self.last_action_timestamp = time.time()
|
||||
|
||||
# #只有安装的时候启用 下载时候不使用
|
||||
# timestamp = self.last_action_timestamp
|
||||
# if (time.time() - timestamp > UPDATER_IDLE_TIMEOUT
|
||||
# and self.check_progress > 50):
|
||||
# logging.error("Quitting due to inactivity(%s)",self.details)
|
||||
# self._action_done(self.ACTION_INSTALL,
|
||||
# is_cancelled=False, success=False,
|
||||
# #FIXME: 安装超时退出
|
||||
# error_string=_("Could not install the upgrades"),
|
||||
# error_desc=_("Installtion timeout to exit Due to inactivity") + self.details)
|
||||
#只有安装的时候启用 下载时候不使用
|
||||
timestamp = self.last_action_timestamp
|
||||
if (time.time() - timestamp > UPDATER_IDLE_TIMEOUT
|
||||
and self.check_progress > 50):
|
||||
logging.error("Quitting due to inactivity(%s)",self.details)
|
||||
|
||||
#超时只单独进行解锁关机
|
||||
unLockedEnableShutdown()
|
||||
# self._action_done(self.ACTION_INSTALL,
|
||||
# is_cancelled=False, success=False,
|
||||
# #FIXME: 安装超时退出
|
||||
# error_string=_("Could not install the upgrades"),
|
||||
# error_desc=_("Installtion timeout to exit Due to inactivity") + self.details)
|
||||
|
||||
# self.window_main.dbusController.Quit(None)
|
||||
# return False
|
||||
# return True
|
||||
# self.window_main.dbusController.Quit(None)
|
||||
return False
|
||||
return True
|
||||
|
||||
@inline_callbacks
|
||||
def update(self):
|
||||
|
|
Binary file not shown.
|
@ -9,6 +9,7 @@ date >> updaterlog/base-info
|
|||
dpkg -l | grep kylin-system-updater >> updaterlog/base-info
|
||||
dpkg -l | grep ukui-control-center >> updaterlog/base-info
|
||||
dpkg -l | grep kylin-update-manager >> updaterlog/base-info
|
||||
dpkg -l | grep aptdaemon >> updaterlog/base-info
|
||||
echo $1 >> updaterlog/base-info
|
||||
echo "记录BUG产生时间(系统当前时间)以及升级相关的版本信息:"
|
||||
cat updaterlog/base-info
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
kylin-system-updater (1.4.16kord) v101; urgency=medium
|
||||
|
||||
* BUG: #108277 【自适应升级】更新升级过程中提示“ukui-kwin-common”缺少依赖
|
||||
#109095 【自适应升级】【更新升级】 0326arm版本安装system-updater 1.4.14升级后,系统自适应升级过程超时,控制面板中未结束更新一直停留在安装中的状态
|
||||
#108665 【自适应升级】【更新升级】0326arm进行版本升级后提示升级成功,实际有部分包未安装成功
|
||||
#109032 【自适应升级】【更新升级】公网不可访问时不能获取更新列表进行更新
|
||||
#109036 【自适应升级】【更新升级】 自适应升级后,全部更新中包含缺依赖的包,更新完成后在历史记录中缺依赖的包也显示更新成
|
||||
# 105722 【安装器】【龙芯3A5000】安装器安装用户手册deb时提示依赖错误,但是用dpkg命令可以安装
|
||||
# 103939 【安装器】安装高版本用户手册后,安装低版本,提示安装失败,dpkg可以安装成功
|
||||
# 100272 【安装器】双击deb包无法安装,日志中提示存在依赖,但通过dpkg可以安装
|
||||
* 需求号: 无
|
||||
* 其他改动说明: 无
|
||||
* 其他改动影响域:系统更新
|
||||
|
||||
-- luoxueyi <luoxueyi@kylinos.cn> Wed, 09 Mar 2022 17:57:25 +0800
|
||||
|
||||
kylin-system-updater (1.4.15kord) v101; urgency=medium
|
||||
|
||||
* BUG: #108555:【自适应升级】【更新升级】升级系统更新进度在85%卡住,重启控制面板显示英文提示,不显示检测的更新内容,重启后恢复
|
||||
|
|
|
@ -24,6 +24,7 @@ systemctl enable unattended-upgrades-install.timer
|
|||
systemctl enable kylin-unattended-upgrades.service
|
||||
if [ -f /usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py ];then
|
||||
echo "Database record migration"
|
||||
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -f autoupdate_allow=true
|
||||
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -c /var/cache/kylin-system-updater/kylin-system-updater.db:installed
|
||||
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -m
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue