changelog:3.0.0.0-ok29

This commit is contained in:
wangsong 2024-07-22 09:54:27 +08:00
parent 1156aa96bc
commit ae20343253
4 changed files with 53 additions and 30 deletions

View File

@ -53,8 +53,8 @@ class UpdateManager():
#进行更新的操作
def start_update(self):
try:
def _download_info(parent,fetched,requested,bytes_transferred,bytes_sec):
self.dbus_send.UpdateDownloadInfo(fetched,requested,bytes_transferred,10000,bytes_sec)
def _download_info(parent,fetched,requested,bytes_transferred,download_all,bytes_sec):
self.dbus_send.UpdateDownloadInfo(fetched,requested,bytes_transferred,download_all,bytes_sec)
def _update_finished(parent,trans):
if parent.exit:
@ -78,8 +78,8 @@ class UpdateManager():
def start_download(self):
try:
def _download_info(parent,fetched,requested,bytes_transferred,bytes_sec):
self.dbus_send.UpdateDownloadInfo(fetched,requested,bytes_transferred,10000,bytes_sec)
def _download_info(parent,fetched,requested,bytes_transferred,download_all,bytes_sec):
self.dbus_send.UpdateDownloadInfo(fetched,requested,bytes_transferred,download_all,bytes_sec)
def _download_finished(parent,trans):
self.dbus_send.UpdateDownloadFinishedNext(parent.exit,[SYSTEM_UPDATE_GROUPS],parent.error_code)
@ -180,8 +180,8 @@ class UpdateManager():
groups_base_info.update({"update-name":update_name})
groups_base_info.update({"description":data.setdefault("description","")})
groups_base_info.update({"changelog":data.setdefault("changelog","")})
groups_base_info.update({"total_download_size":data.setdefault("total_download_size","")})
groups_base_info.update({"total_install_size":data.setdefault("total_install_size","")})
groups_base_info.update({"total_download_size":int(data.setdefault("ostree.incrementsize",0))})
groups_base_info.update({"total_install_size":int(data.setdefault("ostree.incrementsize",0))})
groups_base_info.update({"icon":data.setdefault("icon","/usr/share/upgrade/icon/kylin-update-desktop-system.png")})
output_json.update(groups_base_info)

View File

@ -22,6 +22,7 @@ class BackendBaseOstree(GObject.GObject):
( GObject.TYPE_INT,
GObject.TYPE_INT,
GObject.TYPE_INT64,
GObject.TYPE_INT64,
GObject.TYPE_INT64
))
}
@ -130,7 +131,7 @@ class BackendBaseOstree(GObject.GObject):
if requested <= 2:
return
self.emit("download-info",fetched,requested,bytes_transferred,bytes_sec)
self.emit("download-info",fetched,requested,bytes_transferred,0,bytes_sec)
except Exception as excep:
tbk = traceback.format_exc()
logging.error(str(tbk))
@ -209,11 +210,14 @@ class DownloadBackend(BackendBaseOstree):
def __init__(self,parent,sysroot_path=None,osname=None):
"""Initialize a new AptWorker instance."""
BackendBaseOstree.__init__(self,parent,sysroot_path,osname)
self.download_size = 0
def _run_transaction(self, sysroot,trans):
ostree_repo = sysroot.repo()
refspec = self.origin.get_string("origin","refspec")
ret,origin_remote,origin_ref = OSTree.parse_refspec(refspec)
if trans.available_metadata:
self.download_size = int(trans.available_metadata.setdefault("ostree.incrementsize",0))
logging.info("start pull data from available_refs:%s...",trans.available_refs)
g_options = GLib.Variant("a{sv}",
@ -232,6 +236,27 @@ class DownloadBackend(BackendBaseOstree):
# 下载完成后检查下载的元数据的时间戳
# upgrader.check_timestamps(ostree_repo,from_revision,trans.new_revision)
def _on_async_progress(self,obj):
try:
start_time = obj.get_uint64("start-time")
bytes_transferred = obj.get_uint64("bytes-transferred")
fetched = obj.get_uint("fetched")
requested = obj.get_uint("requested")
# 下载速度
elapsed_secs=(GLib.get_monotonic_time()-start_time)/GLib.USEC_PER_SEC
bytes_sec = int(bytes_transferred / elapsed_secs)
if requested <= 2:
return
self.emit("download-info",fetched,requested,bytes_transferred,self.download_size,bytes_sec)
except Exception as excep:
tbk = traceback.format_exc()
logging.error(str(tbk))
class DeployBackend(BackendBaseOstree):
def __init__(self,parent,sysroot_path=None,osname=None):
"""Initialize a new AptWorker instance."""
@ -267,7 +292,8 @@ class DeployBackend(BackendBaseOstree):
# 修改origin 为当前部署新分支
origin_refspec = origin_remote+":"+refs
self.origin.set_string("origin","refspec",origin_refspec)
# 创建新的origin文件
deploy_origin = sysroot.origin_new_from_refspec(origin_refspec)
self._start_plymouth_splash()
self._check_plymouth_state()
@ -281,7 +307,7 @@ class DeployBackend(BackendBaseOstree):
self._progress_to_plymouth(60)
logging.info("start deploy available_refs:%s new_revision:%s...",refs,new_revision)
ret,upgrade_deployment = sysroot.deploy_tree(self.osname,new_revision,self.origin,self.merge_deployment,None,None)
ret,upgrade_deployment = sysroot.deploy_tree(self.osname,new_revision,deploy_origin,self.merge_deployment,None,None)
# 进行部署时 保留历史部署
flags = OSTree.SysrootSimpleWriteDeploymentFlags.RETAIN
@ -289,23 +315,23 @@ class DeployBackend(BackendBaseOstree):
self._progress_to_plymouth(90)
special_deployment = []
has_deployment = []
old_deployments = sysroot.get_deployments()
for deploys in old_deployments:
# 放hotfix和pin 部署
if deploys.get_unlocked() == OSTree.DeploymentUnlockedState.HOTFIX or deploys.is_pinned():
special_deployment.append(deploys)
# 其他升级保存的部署
elif not upgrade_deployment.equal(deploys):
has_deployment.append(deploys)
# special_deployment = []
# has_deployment = []
# old_deployments = sysroot.get_deployments()
# for deploys in old_deployments:
# # 放hotfix和pin 部署
# if deploys.get_unlocked() == OSTree.DeploymentUnlockedState.HOTFIX or deploys.is_pinned():
# special_deployment.append(deploys)
# # 其他升级保存的部署
# elif not upgrade_deployment.equal(deploys):
# has_deployment.append(deploys)
logging.info("Number of current deployments:%d and all:%d",len(has_deployment),len(old_deployments))
if len(has_deployment) > 5:
logging.info("The number of deployments exceed 5 and delete the 5 after the depoyment...")
new_deployment = [upgrade_deployment] + special_deployment + has_deployment[:5]
ret = sysroot.write_deployments(new_deployment,None)
self._progress_to_plymouth(95)
# logging.info("Number of current deployments:%d and all:%d",len(has_deployment),len(old_deployments))
# if len(has_deployment) > 5:
# logging.info("The number of deployments exceed 5 and delete the 5 after the depoyment...")
# new_deployment = [upgrade_deployment] + special_deployment + has_deployment[:5]
# ret = sysroot.write_deployments(new_deployment,None)
# self._progress_to_plymouth(95)
# 健全性检查
# rootfs_path = sysroot.get_deployment_dirpath(new_deployment)

View File

@ -26,4 +26,4 @@ BUILD_MASTER_BRACH="testos/buildmaster/newbranch"
http_port="8889"
process_name="python3 -m http.server "$http_port
metadata_string="--add-metadata=update-name_zh_CN='系统更新' --add-metadata=update-name_en_US='dddddddddd' --add-metadata=description='GalaxyKylinV10SP1SystemUpdate' --add-metadata-string='icon=/usr/share/kylin-update-desktop-config/icon/kylin-update-desktop-system.png' --add-metadata-string=changelog='initialcommit' --add-metadata-string=total_download_size='800MB' --add-metadata-string=total_install_size='1.2GB' --add-metadata-string=update-type='kylin-update-desktop-system'"
metadata_string="--add-metadata=ostree.incrementsize='1220202' --add-metadata=update-name_zh_CN='系统更新' --add-metadata=update-name_en_US='dddddddddd' --add-metadata=description='GalaxyKylinV10SP1SystemUpdate' --add-metadata-string='icon=/usr/share/kylin-update-desktop-config/icon/kylin-update-desktop-system.png' --add-metadata-string=changelog='initialcommit' --add-metadata-string=total_download_size='800MB' --add-metadata-string=total_install_size='1.2GB' --add-metadata-string=update-type='kylin-update-desktop-system'"

View File

@ -58,7 +58,6 @@ test_deploy_limit() {
gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$deploy_method > /dev/null
moniter_signal_success $deploy_finished_signal
ostree admin status
# 部署完成后的检查
assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf "${bootcsum}"
rev=$(${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse $new_brach)
@ -98,8 +97,6 @@ exec 3< <($updater_program -r -d --sysroot=$test_tmpdir/sysroot --os=testos 2>&1
# 等待dbus服务启动
sleep 3
ostree admin pin 0
test_deploy_limit 7
test_deploy_limit 1
echo "ok update and redirect"