fix conflict

This commit is contained in:
luoxueyi 2022-03-01 09:24:10 +08:00
commit cb63810a08
5 changed files with 135 additions and 20 deletions

View File

@ -8,13 +8,22 @@ from operator import itemgetter
from gettext import gettext as _
from optparse import OptionParser
def dateMigration(options):
DB_UPDATER = "/var/cache/kylin-update-manager/kylin-update-manager.db"
DB_UPGRADE = "/var/cache/kylin-system-updater/kylin-system-updater.db"
VER_DB = "/usr/share/kylin-system-updater/kylin-system-updater.db"
def dateMigration(options=None, old_db=None, old_db_cursor=None, new_db=None, new_db_cursor=None):
print(_("Loading Sqlite3Server..."))
if options==None:
old_path = DB_UPDATER
new_path = DB_UPGRADE
try:
old_db = sqlite3.connect(options.old_path, check_same_thread=False)
old_db_cursor = old_db.cursor()
new_db = sqlite3.connect(options.new_path, check_same_thread=False)
new_db_cursor = new_db.cursor()
if old_db==None and old_db_cursor==None:
old_db = sqlite3.connect(old_path, check_same_thread=False)
old_db_cursor = old_db.cursor()
if new_db==None and new_db_cursor==None:
new_db = sqlite3.connect(new_path, check_same_thread=False)
new_db_cursor = new_db.cursor()
except Exception as e:
print(e)
@ -23,6 +32,7 @@ def dateMigration(options):
new_cfg_dict = {}
# step 1: 更新旧配置数据
try:
print("更新旧配置数据")
sql_commnd = "SELECT * FROM display where id=1"
old_db_cursor.execute(sql_commnd)
old_cfg = old_db_cursor.fetchone()
@ -33,8 +43,9 @@ def dateMigration(options):
for od in new_db_cursor.description:
new_cfg_dict.update({str(od[0]):new_cfg[new_db_cursor.description.index(od)]})
if new_cfg_dict['download_limit'] != None or new_cfg_dict['download_limit_value'] != None:
print("目标数据库有更新的配置项")
if "download_limit" in new_cfg_dict.keys() and "download_limit_value" in new_cfg_dict.keys():
if new_cfg_dict['download_limit'] != None or new_cfg_dict['download_limit_value'] != None:
print("目标数据库有更新的配置项")
else:
sql_commnd = "UPDATE display set check_time='"+old_cfg_dict['check_time']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
@ -68,6 +79,7 @@ def dateMigration(options):
# step 2: 更新installed
try:
print("更新installed")
update_record_dict = {}
tmp_update_record_dict = []
sql_commnd = "SELECT * FROM installed"
@ -108,6 +120,7 @@ def dateMigration(options):
# 按时间排序
tmp_update_record_dict = sorted(tmp_update_record_dict, key=itemgetter('time'))
print("更新installed success")
except Exception as e:
print(e)
@ -116,7 +129,7 @@ def dateMigration(options):
try:
# 删除 tmp
DeleteTable(options.new_path+':'+'tmp')
# DeleteTable(options.new_path+':'+'tmp')
# 创建表
sql_commnd = "create table IF NOT EXISTS tmp('id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,\
'appname' TEXT,\
@ -182,6 +195,72 @@ def DeleteTable(db_table):
except Exception as e:
print("delete %s error: %s"%(table_name,e))
def _has_first_migration(new_db, new_db_cursor):
try:
sql_commnd = "select * from sqlite_master where type='table' and name='display';"
new_db_cursor.execute(sql_commnd)
retval = new_db_cursor.fetchone()
for rv in retval:
if "firstmigration" in str(rv):
return True
return False
except Exception as e:
print(e)
return False
def _is_first_migration(new_db, new_db_cursor):
try:
sql_commnd = "select firstmigration from display;"
new_db_cursor.execute(sql_commnd)
retval = new_db_cursor.fetchone()
if "yes" in retval:
return True
else :
return False
except Exception as e:
print(e)
return False
def CopyData():
try:
# 判断新字段是否存在
if (os.path.exists(VER_DB) and os.path.exists(DB_UPGRADE)):
print(_("Loading Sqlite3Server..."))
try:
new_db = sqlite3.connect(DB_UPGRADE, check_same_thread=False)
new_db_cursor = new_db.cursor()
ver_db = sqlite3.connect(VER_DB, check_same_thread=False)
ver_db_cursor = ver_db.cursor()
except Exception as e:
print(e)
if (_has_first_migration(new_db, new_db_cursor)): # 存在 firstmigration
if (_is_first_migration(new_db, new_db_cursor)):
# 数据迁移
dateMigration(new_db=new_db, new_db_cursor=new_db_cursor)
sql_commnd = "UPDATE display SET firstmigration='no';"
new_db_cursor.execute(sql_commnd)
new_db.commit()
else:
print("No data migration is required ...")
else:# 不存在firstmigration
# 新增 firstmigration 字段
sql_commnd = "alter table display add column firstmigration text;"
new_db_cursor.execute(sql_commnd)
sql_commnd = "UPDATE display SET firstmigration='yes';"
new_db_cursor.execute(sql_commnd)
#数据迁移
dateMigration(new_db=new_db, new_db_cursor=new_db_cursor)
sql_commnd = "UPDATE display SET firstmigration='no';"
new_db_cursor.execute(sql_commnd)
new_db.commit()
else :
print("Not found kylin-system-updater.db, ensure that \'kylin-system-updater\' is successfully installed ... ")
exit(-1)
except Exception as e:
print(e)
if __name__ == "__main__":
# Begin parsing of options
parser = OptionParser()
@ -195,6 +274,8 @@ if __name__ == "__main__":
help=_("Clear the table"))
parser.add_option ("-r", "--delete-table", dest="delete_table",
help=_("Delete the table"))
parser.add_option ("-m", "--data-migration", default=False, action="store_true",
dest="data_migration", help=_("data migration"))
(options, args) = parser.parse_args()
if options.clean_table:
@ -206,10 +287,12 @@ if __name__ == "__main__":
if options.delete_table:
if ":" not in options.delete_table:
print("format error: <database:table>")
exit(-1)
else:
DeleteTable(str(options.delete_table))
exit(0)
if options.data_migration:
CopyData()
exit(0)
if options.old_path or options.new_path:
# 检查文件
@ -223,10 +306,3 @@ if __name__ == "__main__":
print("The destination database file does not exist")
exit(-1)
dateMigration(options)
# 排序test
# turd = []
# turd.append({'time':6})
# turd.append({'time':2})
# turd.append({'time':7})
# turd = sorted(turd, key=itemgetter('time'))

View File

@ -380,8 +380,11 @@ class InstallBackend():
_success = False
header = _("Could not calculate the upgrade")
logging.error(header)
msg = get_broken_details(cache,False)
pkg_string = ''
for pkg in pkgs_install + pkgs_upgrade:
pkg_string = pkg_string + ' ' + pkg
logging.info('\n'+pkg_string+'\n')
desc ='\n' + msg
logging.error('\n' + msg)
return _success,[],[],header,desc

Binary file not shown.

36
debian/changelog vendored
View File

@ -1,3 +1,39 @@
kylin-system-updater (1.4.11.1kord) v101; urgency=medium
* BUG: #102172: 【自适应更新】【系统更新】从sp1 0722自适应升级到sp2 1223版本后更新设置会恢复默认
#102104: 【自适应更新】【系统更新】从sp1 0722自适应升级到sp2 1223版本后上次更新时间与更新历史被清空
#101852: 【用户手册】【更新升级】用户手册中设置下的更新升级内容与文档不一致
#104435: 【用例240562】设置-更新界面点击菜单栏-帮助,未直接定位到更新部分
#105336: 【更新升级】【重启提示】自动更新安装开始和结束的弹窗内容显示不明确
#105330 【更新升级】【重启提示】存在源中无所需依赖的包时,弹窗是否进行全盘更新,点击确认后控制面板闪退
# 105104 【更新升级】【重启提示】带按钮的强弹窗不应该出现在侧边栏,需修改弹窗类型
# 102465 【系统更新】缺依赖的包,单个更新提示缺依赖后点击全部更新提示更新成功
# 102175 【自适应更新】【系统更新】升级后,更新一个安装时间较长的包,重启控制面板,此时会一直等待收到安装完成的信号后,才能继续检测更新,影响用户体验
# 102015 【97888】【系统更新】使用光盘源更新缺依赖的包提示"没有找到需要升级和安装的包",未提示缺依赖
# 101864 【自适应更新】【自动更新】自动更新下载阶段或者备份前阶段打开控制面板,自动更新服务均不能自动退出
# 101852 【用户手册】【更新升级】用户手册中设置下的更新升级内容与文档不一致
# 101669 【自适应更新】【自动更新】自动更新过滤掉了非正式源只能获取archive正式源的包其余源的更新内容不能获取到
# 93555 【系统更新】【SP2 UI走查】更新-页面未按最新设计稿实现
# 90446 【更新升级-需求-9002】【系统更新】点击单个更新后取消更新按钮未上下对齐
# 89824 【更新升级-需求-9002】【系统更新】单个待更新包选择全部更新拒绝安装后不应该提示"部分更新失败"
* 需求号: 无
* 其他改动说明: 无
* 其他改动影响域:系统更新
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 01 Mar 2022 09:07:07 +0800
kylin-system-updater (1.4.11kord) v101; urgency=medium
* BUG: #102172: 【自适应更新】【系统更新】从sp1 0722自适应升级到sp2 1223版本后更新设置会恢复默认
#102104: 【自适应更新】【系统更新】从sp1 0722自适应升级到sp2 1223版本后上次更新时间与更新历史被清空
#101852: 【用户手册】【更新升级】用户手册中设置下的更新升级内容与文档不一致
#104435: 【用例240562】设置-更新界面点击菜单栏-帮助,未直接定位到更新部分
* 需求号: 无
* 其他改动说明: 无
* 其他改动影响域:系统更新
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 22 Feb 2022 09:10:12 +0800
kylin-system-updater (1.4.10kord) v101; urgency=medium
* BUG: #101864: 【自适应更新】【自动更新】自动更新下载阶段或者备份前阶段打开控制面板,自动更新服务均不能自动退出

4
debian/postinst vendored
View File

@ -24,6 +24,6 @@ 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 -c /var/cache/kylin-update-manager/kylin-update-manager.db:installed
/usr/share/kylin-system-updater/SystemUpdater/Core/DataMigration.py -o /var/cache/kylin-update-manager/kylin-update-manager.db -n /var/cache/kylin-update-manager/kylin-update-manager.db
/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