From 161e2a07a932709868fcc6fe202715fdc815ba5b Mon Sep 17 00:00:00 2001 From: wangsong Date: Sat, 1 Jun 2024 15:20:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B6=85=E8=BF=875=E4=B8=AA?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E4=B9=8B=E5=90=8E=E9=83=A8=E7=BD=B2=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/BackendOstreeNext.py | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/backend-immutable/SystemUpdater/backend/BackendOstreeNext.py b/backend-immutable/SystemUpdater/backend/BackendOstreeNext.py index 0f0391f..cee496c 100644 --- a/backend-immutable/SystemUpdater/backend/BackendOstreeNext.py +++ b/backend-immutable/SystemUpdater/backend/BackendOstreeNext.py @@ -281,32 +281,30 @@ class DeployBackend(BackendBaseOstree): self._progress_to_plymouth(60) logging.info("start deploy available_refs:%s new_revision:%s...",refs,new_revision) - ret,new_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,self.origin,self.merge_deployment,None,None) # 进行部署时 保留历史部署 flags = OSTree.SysrootSimpleWriteDeploymentFlags.RETAIN - sysroot.simple_write_deployment(self.osname,new_deployment,self.merge_deployment,flags,None) + sysroot.simple_write_deployment(self.osname,upgrade_deployment,self.merge_deployment,flags,None) self._progress_to_plymouth(90) - # 获取当前部署 数量 - cur_deployment = [] - cur_deployment.append(new_deployment) + special_deployment = [] + has_deployment = [] old_deployments = sysroot.get_deployments() - - # 部署的列表 for deploys in old_deployments: - # 对为hotfix和pin的部署进行过滤 + # 放hotfix和pin 部署 if deploys.get_unlocked() == OSTree.DeploymentUnlockedState.HOTFIX and deploys.is_pinned(): - continue + special_deployment.append(special_deployment) + # 其他升级保存的部署 + elif not upgrade_deployment.equal(deploys): + has_deployment.append(deploys) - if not new_deployment.equal(deploys): - cur_deployment.append(deploys) - - logging.info("Number of current deployments:%d and all:%d",len(cur_deployment),len(old_deployments)) - if len(cur_deployment) > 5: + 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...") - ret = sysroot.write_deployments(cur_deployment[:5],None) + new_deployment = [upgrade_deployment] + special_deployment + has_deployment[:5] + ret = sysroot.write_deployments(new_deployment,None) self._progress_to_plymouth(95) # 健全性检查