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

This commit is contained in:
luoxueyi 2022-08-19 16:17:57 +08:00
commit 5b6ab3e67e
5 changed files with 51 additions and 6 deletions

View File

@ -1,6 +1,6 @@
# UpdateManager.py
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
import os,apt
import os
import apt_pkg
import sys
import time
@ -77,7 +77,7 @@ class UpdateManager():
self.simulate_mode = SimulateTerminal()
#光盘源
self.source_info = UpdateSourceInfo()
self.source_info = MakeSourceInit()
self.install_mode = UpdateInstallMode(self)
@ -851,10 +851,36 @@ class UpdateEssentialItem():
logging.info("%s will be remove in remove pkg...",pkg)
remove_pkgs.remove(pkg)
class UpdateSourceInfo():
class MakeSourceInit():
DIR_MRDIA = "/media/"
MOUNT_SQUASHFS_PATH = "/media/kylin/kylin-test-upgrade/upgrade-pool/"
def __init__(self):
self.is_disc = False
self.is_mounted = False
def mount_squashfs(self,mount_source):
args = ["mount", "-o","loop",mount_source,self.MOUNT_SQUASHFS_PATH]
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
logging.info(str(p.stdout))
if p.returncode == 0:
self.is_mounted = True
return True,' '
else:
self.is_mounted = False
return False,str(p.stdout)
def check_mount(self):
if self.is_mounted == True:
args = ["umount",self.MOUNT_SQUASHFS_PATH]
logging.info("Will be to umount the offlinesource...")
p = subprocess.run(args, stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
logging.info(str(p.stdout))
if p.returncode == 0:
self.is_mounted = False
return True
else:
return False
#判断是否为光盘源
#光盘源格式 deb file:///home/someone/packs/

View File

@ -780,6 +780,17 @@ class UpdateManagerDbusController(dbus.service.Object):
logging.info('Current os_version: %s, release_id: %s .', os_version, update_version)
return os_version,update_version
@dbus.service.method(UPDATER_DBUS_INTERFACE, in_signature='s', out_signature='bs')
def MountSquashfsSource(self, mount_source):
logging.info(COLORMETHOR_PREFIX+'Method'+COLORLOG_SUFFIX+' MountSquashfsSource %s',str(mount_source))
try:
ret,dsc = self.parent.source_info.mount_squashfs(str(mount_source))
logging.info(COLORLOG_PREFIX+"Emitting"+COLORLOG_SUFFIX+" FixBrokenStatusChanged finished = %r dec = %s",ret,dsc)
return ret,dsc
except Exception as e:
logging.error(str(e))
return False,str(e)
#更新进度信息 0~100 进度信息 101为非预期的信号
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='is')
def UpdateDetectStatusChanged(self,progress,status):

View File

@ -673,6 +673,8 @@ class InstallBackend():
self.window_main.dbusController.UpdateInstallFinished(success,self.now_upgrade.upgrade_content,error_string,error_desc)
if success:
self.window_main.source_info.check_mount()
self.window_main.dbusController.CheckRebootRequired("self")
#安装完成之后 更新一次cache
logging.info("Install or Upgrade successful, so Now update Cache...")

View File

@ -335,6 +335,12 @@
#### MountSquashfsSource
- `简介:` 挂载离线源squashfs
- `入参:` `s:` 挂载文件的位置
- `出参:` `b:` True or False 执行的结果,`s:` 字符类型错误信息描述
### Signal列表

2
debian/control vendored
View File

@ -37,7 +37,7 @@ Depends: ${python3:Depends},
python3-psutil,
python3-gi (>= 3.8),
python3-yaml,
aptdaemon (>=1.1.1+bzr982-0kylin32.3k4.6),
aptdaemon (>=1.1.1+bzr982-0kylin32.3k5.2),
python3-distro-info,
python3-pyqt5,
python3-crypto,