Skip to content

fix: Process for adapting v25 command line to set grub background#183

Open
pengfeixx wants to merge 1 commit intolinuxdeepin:masterfrom
pengfeixx:fix-353671
Open

fix: Process for adapting v25 command line to set grub background#183
pengfeixx wants to merge 1 commit intolinuxdeepin:masterfrom
pengfeixx:fix-353671

Conversation

@pengfeixx
Copy link
Copy Markdown

@pengfeixx pengfeixx commented Mar 30, 2026

Process for adapting v25 command line to set grub background

Log: Process for adapting v25 command line to set grub background
pms: BUG-353671

Summary by Sourcery

Update GRUB background handling for v25 by simplifying background image generation and aligning outputs with the new command-line behavior.

Bug Fixes:

  • Fix background setup for GRUB themes on v25 by using the new background loading logic and ensuring a theme background file is always generated.

Tests:

  • Adjust setBackground tests to validate creation of the new background files for both primary and fallback theme directories.

Process for adapting v25 command line to set grub background

Log: Process for adapting v25 command line to set grub background
pms: BUG-353671
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 30, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the grub background-setting process for v25 by using a new loader that may produce two background images, saving them directly instead of adjusting theme components, and updating tests accordingly.

Sequence diagram for updated v25 grub background setting process

sequenceDiagram
    participant SetBackground
    participant ImageLoader as loadV25BackgroundImage
    participant FS as FileSystem

    SetBackground->>FS: os.MkdirAll(themeOutputDir)
    FS-->>SetBackground: error or nil
    SetBackground->>ImageLoader: loadV25BackgroundImage()
    ImageLoader-->>SetBackground: bgImg, themeBgImg, error

    alt error from loadV25BackgroundImage
        SetBackground->>SetBackground: logger.Fatal(err)
    end

    SetBackground->>FS: saveJpeg(bgImg, themeOutputDir/background.jpg)
    FS-->>SetBackground: error or nil

    alt themeBgImg is not nil
        SetBackground->>FS: saveJpeg(themeBgImg, themeOutputDir/background_in_theme.jpg)
        FS-->>SetBackground: error or nil
    else themeBgImg is nil
        SetBackground->>FS: copyFile(themeOutputDir/background.jpg, themeOutputDir/background_in_theme.jpg)
        FS-->>SetBackground: error or nil
    end

    Note over SetBackground,FS: Previous flow parsing theme.txt and adjusting components is removed
Loading

Class diagram for updated background handling in adjust_grub_theme

classDiagram
    class AdjustGrubTheme {
        +setBackground(bgFile string)
        +adjustTheme()
    }

    class ImageLoader {
        +loadV25BackgroundImage() (bgImg Image, themeBgImg Image, err error)
    }

    class ImageUtils {
        +saveJpeg(img Image, path string) error
        +copyFile(src string, dst string) (written int64, err error)
    }

    class Image

    AdjustGrubTheme ..> ImageLoader : uses
    AdjustGrubTheme ..> ImageUtils : uses
    AdjustGrubTheme ..> Image : background images

    %% Previous responsibilities removed from setBackground:
    %% - Parsing theme.txt via tt.ParseThemeFile
    %% - Locating boot_menu component
    %% - convertPropRel2Abs
    %% - adjustBootMenuPixmapStyle
Loading

File-Level Changes

Change Details Files
Use new v25 background loader and save background images directly instead of adjusting theme components
  • Replace call to the generic background loader with loadV25BackgroundImage returning both primary and theme-specific background images
  • Write the primary background image as background.jpg in the theme output directory using saveJpeg
  • If a theme-specific background image exists, save it as background_in_theme.jpg; otherwise copy background.jpg to background_in_theme.jpg
  • Remove parsing of theme.txt, boot_menu component lookup, and boot menu pixmap adjustment logic, simplifying setBackground
adjust-grub-theme/main.go
Adapt background-setting tests to the new output files and behavior
  • Extend TestSetBackground cleanup to remove generated background_in_theme.jpg files for both theme and fallback
  • Update TestSetBackground assertions to check for existence of background.jpg and background_in_theme.jpg in both deepin and deepin-fallback directories instead of menu_*.png assets
adjust-grub-theme/adjust_grub_theme_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The string literal "background_in_theme.jpg" is used multiple times; consider extracting it into a shared constant to avoid typos and ease future changes.
  • In setBackground, when themeBgImg is nil and you fall back to copying background.jpg, consider adding a debug/info log so it's easier to distinguish between the primary and fallback paths during troubleshooting.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The string literal "background_in_theme.jpg" is used multiple times; consider extracting it into a shared constant to avoid typos and ease future changes.
- In `setBackground`, when `themeBgImg` is nil and you fall back to copying `background.jpg`, consider adding a debug/info log so it's easier to distinguish between the primary and fallback paths during troubleshooting.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants