From 6d9c5e45347a3d6a1c1e9cf500669db4c2914c82 Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Mon, 30 Mar 2026 14:25:43 +0800 Subject: [PATCH] fix: Process for adapting v25 command line to set grub background Process for adapting v25 command line to set grub background Log: Process for adapting v25 command line to set grub background pms: BUG-353671 --- adjust-grub-theme/adjust_grub_theme_test.go | 14 ++++----- adjust-grub-theme/main.go | 35 +++++++-------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/adjust-grub-theme/adjust_grub_theme_test.go b/adjust-grub-theme/adjust_grub_theme_test.go index bab6241..6f842e0 100644 --- a/adjust-grub-theme/adjust_grub_theme_test.go +++ b/adjust-grub-theme/adjust_grub_theme_test.go @@ -183,18 +183,16 @@ func (s *su) TestGetFallbackDir() { func (s *su) TestSetBackground() { defer func() { _ = os.RemoveAll(filepath.Join("testdata/deepin", "background.jpg")) + _ = os.RemoveAll(filepath.Join("testdata/deepin", "background_in_theme.jpg")) _ = os.RemoveAll(filepath.Join("testdata/deepin", "background_source")) _ = os.RemoveAll(filepath.Join("testdata/deepin-fallback", "background.jpg")) + _ = os.RemoveAll(filepath.Join("testdata/deepin-fallback", "background_in_theme.jpg")) }() - filenamePrefix := "menu" setBackground("testdata/deepin/background.origin.jpg") - for _, name := range items { - fileName := strings.Join([]string{filenamePrefix, "_", name, ".png"}, "") - fileNamePath := filepath.Join("testdata/deepin", fileName) - assert.FileExists(s.T(), fileNamePath) - _ = os.RemoveAll(fileNamePath) - } - + assert.FileExists(s.T(), filepath.Join("testdata/deepin", "background.jpg")) + assert.FileExists(s.T(), filepath.Join("testdata/deepin", "background_in_theme.jpg")) + assert.FileExists(s.T(), filepath.Join("testdata/deepin-fallback", "background.jpg")) + assert.FileExists(s.T(), filepath.Join("testdata/deepin-fallback", "background_in_theme.jpg")) } func (s *su) TestAdjustThemeNormal() { diff --git a/adjust-grub-theme/main.go b/adjust-grub-theme/main.go index bce6727..b721bea 100644 --- a/adjust-grub-theme/main.go +++ b/adjust-grub-theme/main.go @@ -243,7 +243,7 @@ func setBackground(bgFile string) { logger.Fatal(err) } - bgImg, err := loadBackgroundImage() + bgImg, themeBgImg, err := loadV25BackgroundImage() if err != nil { logger.Fatal(err) } @@ -266,33 +266,22 @@ func setBackground(bgFile string) { } themeOutputDir := filepath.Join(optThemeOutputDir, themeNameNormal) - bgImg, err = adjustBackground(themeOutputDir, bgImg) + err = saveJpeg(bgImg, filepath.Join(themeOutputDir, "background.jpg")) if err != nil { logger.Fatal(err) } - - themeTxtFile := filepath.Join(themeOutputDir, "theme.txt") - theme, err := tt.ParseThemeFile(themeTxtFile) - if err != nil { - logger.Warning(err) - return - } - - var bmComp *tt.Component - for _, comp := range theme.Components { - if comp.Type == tt.ComponentTypeBootMenu { - bmComp = comp - break + if themeBgImg != nil { + err = saveJpeg(themeBgImg, filepath.Join(themeOutputDir, "background_in_theme.jpg")) + if err != nil { + logger.Fatal(err) + } + } else { + _, err = copyFile(filepath.Join(themeOutputDir, "background.jpg"), + filepath.Join(themeOutputDir, "background_in_theme.jpg")) + if err != nil { + logger.Fatal(err) } } - if bmComp == nil { - logger.Warning("not found boot_menu component") - return - } - - convertPropRel2Abs(bmComp, "left", orientationHorizontal) - convertPropRel2Abs(bmComp, "top", orientationVertical) - adjustBootMenuPixmapStyle(themeOutputDir, bmComp, bgImg) } func adjustTheme() {