Skip to content

Conversation

@shy129
Copy link
Contributor

@shy129 shy129 commented Nov 7, 2025

No description provided.

Copilot AI review requested due to automatic review settings November 7, 2025 06:08
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

TAG Bot

TAG: 3.1.0-2
EXISTED: no
DISTRIBUTION: unstable

@deepin-ci-robot
Copy link
Contributor

Hi @shy129. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in DKMS kernel removal scripts where parsing of dkms status output would fail when the output contains additional text like (original_module exists). The fix replaces IFS-based field splitting with explicit field extraction using shell utilities.

Key Changes

  • Replaced IFS-based parsing with line-by-line processing and explicit field extraction using cut and awk
  • Applied the fix to both kernel_prerm.d_dkms and kernel_prerm.d_dkms.in template files
  • Added changelog entries documenting the bug fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
kernel_prerm.d_dkms.in Updated parsing logic to handle status output with extra annotations like "(original_module exists)"
kernel_prerm.d_dkms Same parsing fix applied to the non-template version
debian/changelog Added two new changelog entries documenting the modifications and bug fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

debian/changelog Outdated
Comment on lines 4 to 5
*

Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

There is an empty bullet point (line 4) in the changelog entry. This should either be removed or filled with a meaningful description of the changes.

Suggested change
*

Copilot uses AI. Check for mistakes.
Comment on lines 9 to 12
name=$(echo "$line" | cut -d'/' -f1)
vers=$(echo "$line" | cut -d'/' -f2 | cut -d',' -f1)
arch=$(echo "$line" | awk -F', ' '{print $3}' | cut -d':' -f1)
status=$(echo "$line" | awk -F': ' '{print $2}' | awk '{print $1}')
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The parsing logic creates multiple subshells with echo commands and pipes for each variable extraction. This approach is inefficient as it spawns multiple processes (echo, cut, awk) for each line in the loop. Consider using a single awk command or bash parameter expansion to extract all fields at once, which would be more performant and maintainable.

For example:

dkms status -k "$inst_kern" 2>/dev/null | while IFS= read -r line; do
    # Extract fields using awk in a single call
    eval $(echo "$line" | awk -F'[/,:]' '{
        gsub(/^[ \t]+|[ \t]+$/, "", $1); gsub(/^[ \t]+|[ \t]+$/, "", $2);
        gsub(/^[ \t]+|[ \t]+$/, "", $3); gsub(/^[ \t]+|[ \t]+$/, "", $4);
        printf "name=\"%s\" vers=\"%s\" arch=\"%s\" status=\"%s\"", $1, $2, $3, $4
    }')
    status=$(echo "$status" | awk '{print $1}')
    # ... rest of logic
done

Or using bash parameter expansion:

dkms status -k "$inst_kern" 2>/dev/null | while IFS= read -r line; do
    # Extract module/version part
    mv="${line%%,*}"
    name="${mv%/*}"
    vers="${mv#*/}"
    # Extract remaining parts
    rest="${line#*, }"
    arch="${rest%%,*}"
    status="${rest#*, }"
    status="${status#*: }"
    status="${status%% *}"
    # ... rest of logic
done
Suggested change
name=$(echo "$line" | cut -d'/' -f1)
vers=$(echo "$line" | cut -d'/' -f2 | cut -d',' -f1)
arch=$(echo "$line" | awk -F', ' '{print $3}' | cut -d':' -f1)
status=$(echo "$line" | awk -F': ' '{print $2}' | awk '{print $1}')
# Efficient field extraction using Bash parameter expansion
mv="${line%%,*}"
name="${mv%/*}"
vers="${mv#*/}"
rest="${line#*, }"
arch="${rest%%,*}"
status="${rest#*: }"
status="${status%% *}"

Copilot uses AI. Check for mistakes.
Comment on lines 8 to 11
name=$(echo "$line" | cut -d'/' -f1)
vers=$(echo "$line" | cut -d'/' -f2 | cut -d',' -f1)
arch=$(echo "$line" | awk -F', ' '{print $3}' | cut -d':' -f1)
status=$(echo "$line" | awk -F': ' '{print $2}' | awk '{print $1}')
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The parsing logic creates multiple subshells with echo commands and pipes for each variable extraction. This approach is inefficient as it spawns multiple processes (echo, cut, awk) for each line in the loop. Consider using a single awk command or bash parameter expansion to extract all fields at once, which would be more performant and maintainable.

For example:

dkms status -k "$inst_kern" 2>/dev/null | while IFS= read -r line; do
    # Extract fields using awk in a single call
    eval $(echo "$line" | awk -F'[/,:]' '{
        gsub(/^[ \t]+|[ \t]+$/, "", $1); gsub(/^[ \t]+|[ \t]+$/, "", $2);
        gsub(/^[ \t]+|[ \t]+$/, "", $3); gsub(/^[ \t]+|[ \t]+$/, "", $4);
        printf "name=\"%s\" vers=\"%s\" arch=\"%s\" status=\"%s\"", $1, $2, $3, $4
    }')
    status=$(echo "$status" | awk '{print $1}')
    # ... rest of logic
done

Or using bash parameter expansion:

dkms status -k "$inst_kern" 2>/dev/null | while IFS= read -r line; do
    # Extract module/version part
    mv="${line%%,*}"
    name="${mv%/*}"
    vers="${mv#*/}"
    # Extract remaining parts
    rest="${line#*, }"
    arch="${rest%%,*}"
    status="${rest#*, }"
    status="${status#*: }"
    status="${status%% *}"
    # ... rest of logic
done
Suggested change
name=$(echo "$line" | cut -d'/' -f1)
vers=$(echo "$line" | cut -d'/' -f2 | cut -d',' -f1)
arch=$(echo "$line" | awk -F', ' '{print $3}' | cut -d':' -f1)
status=$(echo "$line" | awk -F': ' '{print $2}' | awk '{print $1}')
mv="${line%%,*}"
name="${mv%/*}"
vers="${mv#*/}"
rest="${line#*, }"
arch="${rest%%,*}"
status="${rest#*, }"
status="${status#*: }"
status="${status%% *}"

Copilot uses AI. Check for mistakes.
@shy129 shy129 force-pushed the master branch 2 times, most recently from 64ed847 to 4a69a90 Compare November 7, 2025 06:28
@opsiff
Copy link
Member

opsiff commented Nov 7, 2025

change to use patches.

Signed-off-by: shaoyang <shaoyang@uniontech.com>
@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: opsiff
Once this PR has been reviewed and has the lgtm label, please assign qaqland for approval. For more information see the Code Review Process.

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

@opsiff opsiff merged commit 9d6a69f into deepin-community:master Nov 7, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants