diff --git a/pkg/config/upgrader/data.go b/pkg/config/upgrader/data.go index 7496118..a90f15e 100644 --- a/pkg/config/upgrader/data.go +++ b/pkg/config/upgrader/data.go @@ -14,6 +14,7 @@ type Target struct { Backup_list []string `yaml:"backup_list"` Hold_list []string `yaml:"hold_list"` After_run string `yaml:"after_run"` + Plymouth_theme string `yaml:"plymouth_theme"` } type CommitTarget struct { diff --git a/pkg/config/upgrader/repo.go b/pkg/config/upgrader/repo.go index d1a51f4..5c83136 100644 --- a/pkg/config/upgrader/repo.go +++ b/pkg/config/upgrader/repo.go @@ -32,6 +32,7 @@ type RepoConfig struct { ConfigDir string `json:"config_dir"` StageDir string `json:"stage_dir"` AfterRun string `json:"Afer_Run"` + PlymouthTheme string `json:"Plymouth_Theme"` SubscribeList []string `json:"subscribe_list"` FilterList []string `json:"filter_list"` @@ -200,6 +201,7 @@ func (c *Config) LoadData(path string) { c.AppendCommit(dataCf.Target.Backup_list, true) c.AppendFilter(dataCf.Target.Hold_list, true) c.RepoList[0].AfterRun = dataCf.Target.After_run + c.RepoList[0].PlymouthTheme = dataCf.Target.Plymouth_theme const versionManager = "/var/lib/deepin-boot-kit" for _, v := range c.RepoList[0].SubscribeList { if strings.HasPrefix(c.RepoList[0].RepoMountPoint, v) { diff --git a/pkg/upgrader/upgrader.go b/pkg/upgrader/upgrader.go index f1a4345..af49317 100644 --- a/pkg/upgrader/upgrader.go +++ b/pkg/upgrader/upgrader.go @@ -219,7 +219,7 @@ func NewUpgrader(conf *config.Config, return &info, nil } -func setPlymouthTheme() error { +func setPlymouthTheme(theme string) error { path := "/var/cache/system-rollback-theme" if _, err := os.Stat(path); err != nil { err = os.Mkdir(path, 0755) @@ -249,7 +249,7 @@ func setPlymouthTheme() error { if err != nil { return err } - out, err := exec.Command("/usr/sbin/plymouth-set-default-theme", "-R", "deepin-recovery").CombinedOutput() + out, err := exec.Command("/usr/sbin/plymouth-set-default-theme", "-R", theme).CombinedOutput() if err != nil { logger.Warning("failed to set upgrade plymouth theme:", string(out)) return err @@ -347,6 +347,7 @@ func (c *Upgrader) Commit(newVersion, subject string, useSysData bool, evHandler func(op, state int32, target, desc string)) (excode int, err error) { exitCode := _STATE_TY_SUCCESS var isClean bool + var theme string c.SendingSignal(evHandler, _OP_TY_COMMIT_START, _STATE_TY_RUNING, newVersion, "") if len(newVersion) == 0 { @@ -366,7 +367,11 @@ func (c *Upgrader) Commit(newVersion, subject string, useSysData bool, subject = fmt.Sprintf("Release %s", newVersion) } logger.Info("the version number of this submission is:", newVersion) - err = setPlymouthTheme() + theme = c.conf.RepoList[0].PlymouthTheme + if len(theme) == 0 { + theme = "deepin-recovery" + } + err = setPlymouthTheme(theme) if err != nil { logger.Warning("failed to set plymouth theme:", err) } @@ -1556,21 +1561,12 @@ func (c *Upgrader) AfterRollbackOper(backVersion string, isSuccessful bool) erro } func (c *Upgrader) UpdateProgress(progress int) { - upgrade_tool_theme := "/usr/share/plymouth/themes/deepin-recovery" - var theme progressTheme - if util.IsExists(upgrade_tool_theme) { - theme = _UPGRADE_TOOL - } else { - theme = _NO_THEME - } - if theme == _UPGRADE_TOOL { - if progress == 0 { - logger.Debugf("activate the upgrade roll back progress theme") - util.ExecCommand("/usr/bin/plymouth", []string{"change-mode", "--system-upgrade"}) - } - logger.Infof("update progress %d", progress) - plymouth.UpdateProgress(progress) - } + if progress == 0 { + logger.Debugf("activate the upgrade roll back progress theme") + util.ExecCommand("/usr/bin/plymouth", []string{"change-mode", "--system-upgrade"}) + } + logger.Infof("update progress %d", progress) + plymouth.UpdateProgress(progress) fmt.Println("update progress:", progress) }