fix conflict

This commit is contained in:
luoxueyi 2022-02-23 15:35:58 +08:00
commit b20cdb3fc7
11 changed files with 341 additions and 96 deletions

View File

@ -0,0 +1,232 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import logging
import sqlite3
from operator import itemgetter
from gettext import gettext as _
from optparse import OptionParser
def dateMigration(options):
print(_("Loading Sqlite3Server..."))
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()
except Exception as e:
print(e)
sql_commnd = ""
old_cfg_dict = {}
new_cfg_dict = {}
# step 1: 更新旧配置数据
try:
sql_commnd = "SELECT * FROM display where id=1"
old_db_cursor.execute(sql_commnd)
old_cfg = old_db_cursor.fetchone()
for od in old_db_cursor.description:
old_cfg_dict.update({str(od[0]):old_cfg[old_db_cursor.description.index(od)]})
new_db_cursor.execute(sql_commnd)
new_cfg = new_db_cursor.fetchone()
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("目标数据库有更新的配置项")
else:
sql_commnd = "UPDATE display set check_time='"+old_cfg_dict['check_time']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
new_db.commit()
sql_commnd = "UPDATE display set update_time='"+old_cfg_dict['update_time']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
new_db.commit()
sql_commnd = "UPDATE display set auto_check='"+old_cfg_dict['auto_check']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
new_db.commit()
sql_commnd = "UPDATE display set system_version='"+old_cfg_dict['system_version']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
new_db.commit()
if old_cfg_dict['auto_backup'] != None:
sql_commnd = "UPDATE display set auto_backup='"+old_cfg_dict['auto_backup']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
new_db.commit()
if 'download_limit' in old_cfg_dict.keys() and old_cfg_dict['download_limit'] != None:
sql_commnd = "UPDATE display set download_limit='"+old_cfg_dict['download_limit']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
new_db.commit()
if 'download_limit_value' in old_cfg_dict.keys() and old_cfg_dict['download_limit_value'] != None:
sql_commnd = "UPDATE display set download_limit_value='"+old_cfg_dict['download_limit_value']+"' Where id=1"
new_db_cursor.execute(sql_commnd)
new_db.commit()
except Exception as e:
print(e)
print("更新配置文件错误")
return
# step 2: 更新installed
try:
update_record_dict = {}
tmp_update_record_dict = []
sql_commnd = "SELECT * FROM installed"
old_db_cursor.execute(sql_commnd)
update_record = old_db_cursor.fetchall()
sql_commnd = "SELECT * FROM updateinfos"
new_db_cursor.execute(sql_commnd)
new_update_record = new_db_cursor.fetchall()
for ur in update_record:
id,appname,version,time,description,icon,statue,keyword,errorcode = ur
if errorcode in range(200):
errorcode = 'null'
update_record_dict.clear()
update_record_dict.update({"appname":appname})
update_record_dict.update({"version":version})
update_record_dict.update({"time":time})
update_record_dict.update({"description":description})
update_record_dict.update({"icon":icon})
update_record_dict.update({"statue":statue})
update_record_dict.update({"keyword":'1'})
update_record_dict.update({"errorcode":errorcode})
tmp_update_record_dict.append(update_record_dict.copy())
for ur in new_update_record:
id,appname,version,description,date,status,keyword,errorcode = ur
if errorcode in range(200):
errorcode = 'null'
update_record_dict.clear()
update_record_dict.update({"appname":appname})
update_record_dict.update({"version":version})
update_record_dict.update({"time":date})
update_record_dict.update({"description":description})
update_record_dict.update({"icon":None})
update_record_dict.update({"statue":status})
update_record_dict.update({"keyword":'1'})
update_record_dict.update({"errorcode":errorcode})
tmp_update_record_dict.append(update_record_dict.copy())
# 按时间排序
tmp_update_record_dict = sorted(tmp_update_record_dict, key=itemgetter('time'))
except Exception as e:
print(e)
print("更新安装记录错误")
return
try:
# 删除 tmp
DeleteTable(options.new_path+':'+'tmp')
# 创建表
sql_commnd = "create table IF NOT EXISTS tmp('id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,\
'appname' TEXT,\
'version' TEXT,\
'description' TEXT,\
'date' TEXT,\
'status' TEXT,\
'keyword' TEXT,\
'errorcode' TEXT) "
new_db_cursor.execute(sql_commnd)
# 更新数据
for urd in tmp_update_record_dict:
new_db_cursor.execute(
"insert into tmp (appname, version, description, date, status, keyword, errorcode) values(?,"
"?,?,?,?,?,?)",
(urd['appname'], urd['version'], urd['description'], urd['time'], urd['statue'], urd['keyword'], urd['errorcode']))
new_db.commit()
# 删除updateinfos
sql_commnd = "drop table updateinfos"
new_db_cursor.execute(sql_commnd)
new_db.commit()
# 修改表名
sql_commnd = "alter table tmp rename to updateinfos"
new_db_cursor.execute(sql_commnd)
new_db.commit()
except Exception as e:
print(e)
print("安装记录迁移错误")
return
print("数据迁移成功.")
def CleanTable(db_table):
db_path, table_name = str(db_table).split(":")
if not os.path.isfile(db_path):
print("db path error.")
exit(-1)
print(_("Loading Sqlite3Server..."))
try:
db = sqlite3.connect(db_path, check_same_thread=False)
db_cursor = db.cursor()
sql_commnd = 'delete from '+table_name
db_cursor.execute(sql_commnd)
db.commit()
print("clean %s success."%table_name)
except Exception as e:
print(e)
print("clean %s error."%table_name)
def DeleteTable(db_table):
db_path, table_name = str(db_table).split(":")
if not os.path.isfile(db_path):
print("db path error.")
exit(-1)
print(_("Loading Sqlite3Server..."))
try:
db = sqlite3.connect(db_path, check_same_thread=False)
db_cursor = db.cursor()
sql_commnd = 'drop table '+table_name
db_cursor.execute(sql_commnd)
db.commit()
print("delete %s success."%table_name)
except Exception as e:
print("delete %s error: %s"%(table_name,e))
if __name__ == "__main__":
# Begin parsing of options
parser = OptionParser()
parser.add_option ("-d", "--debug", action="store_true", default=False,
help=_("Show debug messages"))
parser.add_option ("-o", "--old-path", dest="old_path",
help=_("Enter the old database address"))
parser.add_option ("-n", "--new-path", dest="new_path",
help=_("Enter the new database address"))
parser.add_option ("-c", "--clean-table", dest="clean_table",
help=_("Clear the table"))
parser.add_option ("-r", "--delete-table", dest="delete_table",
help=_("Delete the table"))
(options, args) = parser.parse_args()
if options.clean_table:
if ":" not in options.clean_table:
print("format error: <database:table>")
else:
CleanTable(str(options.clean_table))
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.old_path or options.new_path:
# 检查文件
if not options.old_path or not options.new_path:
print("parameter error")
exit(-1)
if not os.path.isfile(options.old_path):
print("The source database file does not exist")
exit(-1)
if not os.path.isfile(options.new_path):
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

@ -13,6 +13,7 @@ from gettext import gettext as _
import apt_pkg
from ..backend import InstallBackend
DB_FILE = os.path.join("/var/cache/kylin-system-updater/kylin-system-updater.db")
UMDB_FILE = os.path.join("/var/cache/kylin-system-updater/kylin-system-updater.db")
INSTALLED_LIST = [{"item": "errorcode", "type": "int", "default": "0"}]
DISPALY_LIST = []
@ -413,7 +414,7 @@ class Sqlite3Server(object):
# print("\n")
# except Exception as e:
# logging.error("Get update error: %s", str(e))
def listtojsonstr(lists):
import json
jsonfile = json.dumps(lists)

View File

@ -1,28 +1,5 @@
# UpdateList.py
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
#
# Copyright (c) 2004-2013 Canonical
#
# Author: Michael Vogt <mvo@debian.org>
# Dylan McCall <dylanmccall@ubuntu.com>
# Michael Terry <michael.terry@canonical.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
from __future__ import print_function
from gettext import gettext as _
import logging
import os

View File

@ -515,12 +515,14 @@ def get_broken_details(cache,now=True):
(not now and pkg.is_inst_broken)):
continue
msg += "%s: " % pkg.name
#获取出现问题的包的版本
if now:
version = pkg.installed
else:
version = pkg.candidate
indent = " " * (len(pkg.name) + 2)
dep_msg = ""
#拿取依赖关系
for dep in version.dependencies:
or_msg = ""
for base_dep in dep.or_dependencies:

View File

@ -32,8 +32,6 @@ class UpdateManager():
SELF_PKG_NAME = 'kylin-system-updater'
GROUPS_PKG_NAME = 'kylin-update-desktop-config'
INSTALL_ALONE_PROGRESS = "alone"
SOURCE_PARTS_PATH = "/etc/apt/"
SOURCE_FILE_NAME = "sources.list"
RUN_UNATTENDED_UPGRADE = '/var/run/unattended-upgrades.pid'
def __init__(self,options):
@ -123,28 +121,6 @@ class UpdateManager():
except Exception as e:
logging.error(str(e))
#读取source.list 内容
def _read_source_list(self):
try:
source_file_content = ''
source_file_path = os.path.join(self.SOURCE_PARTS_PATH,self.SOURCE_FILE_NAME)
with open(source_file_path) as source_file:
source_file_content = source_file.read()
return source_file_content
except Exception as e:
logging.error(str(e))
return ''
#判断是否为光盘源
def _is_disc_source(self):
logging.info("Check: Whether to use CD-ROM source updates Successfully...")
source_file_content = self._read_source_list()
if "deb file:" in source_file_content:
logging.info("Current use of CD-ROM source without network check...")
return True
else:
return False
#进行更新的操作
def start_update(self):
_success = True
@ -156,7 +132,7 @@ class UpdateManager():
self.configs.reReadConfigFiles()
#光盘源的话
if self._is_disc_source() == True:
if self._check_disc_source() == True:
logging.info("Turn off NetworkCheck and CloseFiter and UpdateSource...")
#关闭网络检查
self.options.no_check_network = True
@ -192,7 +168,25 @@ class UpdateManager():
except Exception as e:
logging.error(e)
#判断是否为光盘源
def _check_disc_source(self):
logging.info("Check: Whether to use CD-ROM source updates Successfully...")
try:
slist = apt_pkg.SourceList()
slist.read_main_list()
for uri in [lis.uri for lis in slist.list]:
#找到属于
if "file:" in uri:
logging.info("Current use of CD-ROM source without network check...")
return True
#没有找到返回False
return False
except Exception as e:
logging.error(e)
return False
# 进行本地deb包安装的操作
def start_deb_install(self, deb_path = "", _check_local_dep = False, _auto_satisfy = False):
# _check_local_dep : 是否查询本地依赖
@ -730,21 +724,6 @@ class UpdateManager():
pass
except Exception as e:
logging.error(str(e))
# # 需要降级
# try:
# pkg = deb_cache[debname.split('_')[0]]
# # 判断":"在版本号中的情况
# if "%3a" in debname:
# debname=debname.replace("%3a",":")
# if pkg.is_installed and (pkg.installed.source_version > debname.split('_')[1]):
# logging.info("Downgrade deb %s, from %s to %s.",\
# debname.split('_')[0], pkg.installed.source_version,debname.split('_')[1])
# self._need_downgrade = True
# else:
# self._need_downgrade = False
# except Exception as e:
# logging.error(str(e))
# self._need_downgrade = False
self._need_downgrade = False
# 不满足的依赖列表
depends = deb.depends
@ -795,7 +774,7 @@ class UpdateManager():
_group_satify = True
else:
pkg = deb_cache[debname]
if pkg.installed and apt_pkg.check_dep(pkg.installed.source_version, oper, ver) and _group_satify == False:
if (pkg.installed and apt_pkg.check_dep(pkg.installed.version, oper, ver)) or (not pkg.installed and apt_pkg.check_dep(pkg.candidate.version, oper, ver)) and _group_satify == False:
_group_satify = True
except Exception as e:
logging.error(str(e))

View File

@ -100,6 +100,18 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.error(str(e))
return False,header,desc
#设置aptdeamon的环境变量
def set_aptdeamon_environ(self,key,value):
try:
logging.info("Set aptdeaom environment variables %s = %s...",key,value)
obj = self.bus.get_object('org.debian.apt', '/org/debian/apt')
interface = dbus.Interface(obj, dbus_interface='org.debian.apt')
retval = interface.SetEnviron(key,value)
return retval
except Exception as e:
logging.error(str(e))
return False
def check_connectivity(self):
header = ''
desc = ''
@ -112,6 +124,7 @@ class UpdateManagerDbusController(dbus.service.Object):
if retval == 4:
return True,header,desc
else:
#当检查失败时 再切换到ping再进行一次检查
logging.info("Check: network connectivity to use ping...")
response = os.system("ping -c 2 -w2 www.baidu.com 2>&1 >/dev/null")
if response == 0:
@ -158,7 +171,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.warning('Clean In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' Clean ...')
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' Clean ...')
self.parent.start_clean()
return True
except Exception:
@ -168,7 +181,7 @@ class UpdateManagerDbusController(dbus.service.Object):
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='s',out_signature='i')
def GetBackendStatus(self,user_lang):
try:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' GetBackendStatus and user_lang = %s ...',str(user_lang))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' GetBackendStatus and user_lang = %s ...',str(user_lang))
#当传入为空时 直接返回
if str(user_lang) == '':
logging.info("The incoming language is null...")
@ -176,7 +189,7 @@ class UpdateManagerDbusController(dbus.service.Object):
(lang, encoding) = locale._parse_localename(str(user_lang))
#合法性的校验
if lang not in "zh_CN:en" or lang == None or lang == '':
if lang == None or lang == '':
logging.info("The incoming language is Illegal...")
return self.parent.is_working
@ -186,7 +199,8 @@ class UpdateManagerDbusController(dbus.service.Object):
os.environ["LANGUAGE"] = lang
return self.parent.is_working
except Exception:
except Exception as e:
logging.error(str(e))
return False
#apt install -f
@ -198,7 +212,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.warning('FixBrokenDepends In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' FixBrokenDepends ...')
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' FixBrokenDepends ...')
self.parent.start_fix_broken()
return True
except Exception:
@ -213,7 +227,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.warning('FixIncompleteInstall In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' FixIncompleteInstall ...')
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' FixIncompleteInstall ...')
self.parent.start_fix_incomplete()
return True
except Exception:
@ -228,7 +242,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.warning('UpdateDetect In the process of Updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' UpdateDetect ...')
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' UpdateDetect ...')
self.parent.start_update()
return True
except Exception:
@ -248,7 +262,7 @@ class UpdateManagerDbusController(dbus.service.Object):
return False,'In the process of updating or Upgrading...'
else:
partial_upgrade_list = [str(i) for i in _partial_upgrade_list]
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradePartial and is_install:%r, partial_upgrade_list:%s. ',is_install,",".join(partial_upgrade_list))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistUpgradePartial and is_install:%r, partial_upgrade_list:%s. ',is_install,",".join(partial_upgrade_list))
local_upgrade_groups = self.parent.update_list.local_upgrade_data.upgrade_groups
local_single_pkgs = self.parent.update_list.local_upgrade_data.single_pkgs
@ -276,7 +290,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.warning('DistUpgradeAll In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradeAll and is_install:%r...',is_install)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistUpgradeAll and is_install:%r...',is_install)
self.parent.start_install(InstallBackend.MODE_UPGRADE_ALL,is_install)
return True,'success'
except Exception as e:
@ -292,7 +306,7 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.warning('DistUpgradeSystem In the process of updating or Upgrading...')
return False,'In the process of updating or Upgrading...'
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistUpgradeSystem and is_install:%r...',is_install)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistUpgradeSystem and is_install:%r...',is_install)
self.parent.start_install(InstallBackend.MODE_UPGRADE_SYSTEM,is_install)
return True,'success'
except Exception as e:
@ -300,18 +314,24 @@ class UpdateManagerDbusController(dbus.service.Object):
return (False, str(e))
#卸载包
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='as',out_signature='b')
def PurgePackages(self,_purge_list):
@dbus.service.method(UPDATER_DBUS_INTERFACE,in_signature='ass',out_signature='b')
def PurgePackages(self,_purge_list,cur_user):
try:
purge_list = [str(pkg) for pkg in _purge_list]
#目前只有360使用这个环境变量 当其他包也使用时 可以将这个权限放开
if "360epp" in purge_list:
#需要对aptdeamon加这两个环境变量 才可以提示弹窗
self.set_aptdeamon_environ("XAUTHORITY","/home/"+str(cur_user)+"/.Xauthority")
self.set_aptdeamon_environ("DISPLAY",":11.0")
# 处于更新和升级中的话 不进行升级
if self.parent.is_working != InstallBackend.ACTION_DEFUALT_STATUS:
self.PurgePackagesFinished(False,_("Other tasks are being updated and upgraded, please uninstall them later."),'')
logging.warning('PurgePackages In the process of updating or Upgrading...')
return False
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DistPurgePackages and purge list is:%s...',purge_list)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DistPurgePackages and purge list is:%s...',purge_list)
self.parent.start_purge_pkgs(purge_list)
return True
except Exception as e:
@ -322,7 +342,7 @@ class UpdateManagerDbusController(dbus.service.Object):
def CancelDownload(self):
status = False
try:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' CancelDownload...')
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' CancelDownload...')
#空时直接返回
if self.transaction == None:
@ -350,7 +370,7 @@ class UpdateManagerDbusController(dbus.service.Object):
check_local_dep = bool(_check_local_dep)
auto_satisfy = bool(_auto_satisfy)
deb_path = str(path)
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' InstallDebFile and check_local_dep:%r, auto_satisfy:%r.',\
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InstallDebFile and check_local_dep:%r, auto_satisfy:%r.',\
check_local_dep,auto_satisfy)
logging.info("Will install: %s.",path)
self.parent.start_deb_install(deb_path, _check_local_dep, _auto_satisfy)
@ -363,7 +383,7 @@ class UpdateManagerDbusController(dbus.service.Object):
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', sender_keyword='sender')
def InsertInstallState(self, item, value, sender=None):
try:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' InsertInstallState, options:%svalue:%s' % (item, value))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' InsertInstallState, options:%svalue:%s' % (item, value))
self.parent.sqlite3_server.insert_into_display(item, value)
logging.info("Database inserted successfullyoptions:%svalue:%s" % (item, value))
return True
@ -374,7 +394,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# # download certain package and its dependencies
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='asi', out_signature='b')
def DownloadPackages(self, pkgs=[], try_times=1):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DownloadPackages: %s',pkgs)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DownloadPackages: %s',pkgs)
if try_times > 0:
pass
else:
@ -392,13 +412,13 @@ class UpdateManagerDbusController(dbus.service.Object):
return False, 'Please input [\"set\", \"value\"] to set. \nor [\"get\"] to get whether updates are allowed before shutdown.'
if operation == "set":
try:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' UnattendedUpgradeValue is going to %s [allow_unattended_upgrades_shutdown] value to %s.'%(operation,value))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' UnattendedUpgradeValue is going to %s [allow_unattended_upgrades_shutdown] value to %s.'%(operation,value))
self.parent.sqlite3_server.insert_into_display("allow_unattended_upgrades_shutdown", value.lower())
except Exception as e:
logging.error(str(e))
return False,str(e)
else:
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' UnattendedUpgradeValue is going to %s [allow_unattended_upgrades_shutdown] value.'%(operation))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' UnattendedUpgradeValue is going to %s [allow_unattended_upgrades_shutdown] value.'%(operation))
try:
value = self.parent.sqlite3_server.select_from_display("allow_unattended_upgrades_shutdown")
logging.info("[allow_unattended_upgrades_shutdown] value is %s."%(value))
@ -410,7 +430,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# 设置自动更新时间
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='s', out_signature='bs')
def SetAutoUpgradePeriod(self, period):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetAutoUpgradePeriod will be set value %s.'%(period))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' SetAutoUpgradePeriod will be set value %s.'%(period))
try:
self.parent.sqlite3_server.insert_into_display("update_period", period.lower())
except Exception as e:
@ -420,7 +440,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# # dbus接口改变apt下载速度
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='sb', out_signature='b')
def SetDownloadspeedMax(self, speed, set):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' SetDownloadspeedMax, speed:%s, set:%r.'%(speed, set))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' SetDownloadspeedMax, speed:%s, set:%r.'%(speed, set))
#来重启Aptdeamon
self.parent.set_restart_aptdeamon = True
@ -432,22 +452,27 @@ class UpdateManagerDbusController(dbus.service.Object):
#更改数据库值
self.parent.sqlite3_server.insert_into_display("download_limit","true")
self.parent.sqlite3_server.insert_into_display("download_limit_value",str(speed))
#发送信号
self.DownloadSpeedChanged(str(speed))
return True
except Exception as e:
logging.error(e)
return False
else:
if os.path.exists("/etc/apt/apt.conf.d/80apt-download"):
os.remove("/etc/apt/apt.conf.d/80apt-download")
self.parent.sqlite3_server.insert_into_display("download_limit","false")
return False
self.DownloadSpeedChanged("0")
return True
else:
self.parent.sqlite3_server.insert_into_display("download_limit","false")
return False
self.DownloadSpeedChanged("0")
return True
# # dbus接口获取apt下载速度
@dbus.service.method(UPDATER_DBUS_INTERFACE, out_signature='bs')
def GetDownloadspeedLimitValue(self):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' GetDownloadspeedLimitValue...')
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' GetDownloadspeedLimitValue...')
try:
download_limit = self.parent.sqlite3_server.select_from_display("download_limit")
if download_limit == "true":
@ -461,7 +486,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# # dbus接口: 后端大数据采集
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='ss', out_signature='b')
def DataBackendCollect(self, messageType, uploadMessage):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' DataBackendCollect, messageType is %s ...',messageType)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' DataBackendCollect, messageType is %s ...',messageType)
try:
self.parent.collector.UpdateMsg(messageType, uploadMessage)
except AttributeError as e:
@ -473,7 +498,7 @@ class UpdateManagerDbusController(dbus.service.Object):
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='s', out_signature='b', sender_keyword='sender')
def InstallSnap(self, path, sender=None):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+" Install Snap Packages(%s)...",path)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+" Install Snap Packages(%s)...",path)
try:
status= subprocess.getstatusoutput("snap install " +path+" --dangerous")
except Exception as e:
@ -508,7 +533,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# 监控是否需要重启的操作
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='s', out_signature='b')
def CheckRebootRequired(self, model):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' CheckRebootRequired is be %s',str(model))
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' CheckRebootRequired is be %s',str(model))
try:
#更新完成之后检查是否需要重启
if self.is_reboot_required() == True:
@ -527,7 +552,7 @@ class UpdateManagerDbusController(dbus.service.Object):
# kill 进程
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='i')
def KillProcessSignal(self, pid):
logging.info(COLORMETHOR_PREFIX+'method'+COLORLOG_SUFFIX+' KillProcessSignal is %d', pid)
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' KillProcessSignal is %d', pid)
try:
# 判断文件是否存在
if (os.path.exists(RUN_UNATTENDED_UPGRADE)):
@ -639,4 +664,9 @@ class UpdateManagerDbusController(dbus.service.Object):
#重启和注销请求信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='s')
def RebootLogoutRequired(self,required_status=''):
logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " RebootLogoutRequired required_status = %s",required_status)
logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " RebootLogoutRequired required_status = %s",required_status)\
#限速修改信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='s')
def DownloadSpeedChanged(self,limit_value=''):
logging.info(COLORLOG_PREFIX + "Emitting"+ COLORLOG_SUFFIX + " DownloadSpeedChanged limit_value = %s",limit_value)

View File

@ -361,6 +361,13 @@ class InstallBackendAptdaemon(InstallBackend):
#增加取消信号的频发机制
self.trans_cancelable = Cancelable
def _on_config_file_conflict(self, transaction, old, new):
logging.info("Config file conflict oldconf = %s , newconf = %s...",str(old),str(new))
logging.info("Default To Replace Old Configfile...")
#默认替换旧的配置文件
transaction.resolve_config_file_conflict(old, "replace")
# transaction.resolve_config_file_conflict(old, "keep")
#增加记录当产生错误的时候 详细信息
def _on_error_changed(self, trans,error_code, error_details):
# error_string = get_error_string_from_enum(error_code)
@ -380,6 +387,9 @@ class InstallBackendAptdaemon(InstallBackend):
trans.connect("progress-details-changed", self._on_progress_download_changed)
trans.connect("status-details-changed", self._on_details_changed)
trans.connect("error", self._on_error_changed)
trans.connect("config-file-conflict", self._on_config_file_conflict)
# yield trans.set_locale(os.environ["LANGUAGE"] + ".UTF-8")
yield trans.run()

View File

@ -13,7 +13,6 @@ from SystemUpdater.Core.utils import (
check_free_space,
get_broken_details
)
import time
from apt import Cache
from SystemUpdater.Core.UpdateList import LocalUpgradeDataList

Binary file not shown.

10
debian/changelog vendored
View File

@ -1,3 +1,13 @@
kylin-system-updater (1.4.10kord) v101; urgency=medium
* BUG: #101864: 【自适应更新】【自动更新】自动更新下载阶段或者备份前阶段打开控制面板,自动更新服务均不能自动退出
#104699: 【自适应更新】【自动更新】自动更新过滤掉了非正式源只能获取archive正式源的包其余源的更新内容不能获取到
* 需求号: 无
* 其他改动说明: 无
* 其他改动影响域:系统更新
-- luoxueyi <luoxueyi@kylinos.cn> Tue, 22 Feb 2022 09:10:12 +0800
kylin-system-updater (1.4.9kord) v101; urgency=medium
* BUG: #105336: 【更新升级】【重启提示】自动更新安装开始和结束的弹窗内容显示不明确

5
debian/postinst vendored
View File

@ -22,3 +22,8 @@ chmod +x /usr/bin/kylin-unattended-upgrade-shutdown
systemctl enable unattended-upgrades-download.timer
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
fi