Skip to content

fix: Notification warning "lastore-daemon is modifying the system read-only directory"#279

Merged
electricface merged 1 commit into
linuxdeepin:masterfrom
electricface:swt/fix-erofs-warn
Jan 6, 2026
Merged

fix: Notification warning "lastore-daemon is modifying the system read-only directory"#279
electricface merged 1 commit into
linuxdeepin:masterfrom
electricface:swt/fix-erofs-warn

Conversation

@electricface
Copy link
Copy Markdown
Member

@electricface electricface commented Jan 6, 2026

  • Occurs when continuing the upgrade after the backup system fails;
  • Add environment variable IMMUTABLE_DISABLE_REMOUNT=false for the
    apt-get check command.

@electricface electricface force-pushed the swt/fix-erofs-warn branch 3 times, most recently from 3e44546 to 51ade7d Compare January 6, 2026 12:29
read-only directory"

- Occurs when continuing the upgrade after the backup system fails;
- Add environment variable IMMUTABLE_DISABLE_REMOUNT=false for the
`apt-get check` command.

Task: https://pms.uniontech.com/task-view-385439.html
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

我来帮你审查这段代码的修改。这是一个关于在apt包管理器中添加环境变量的修改。让我从多个角度进行分析:

  1. 语法逻辑:
  • 语法正确,符合Go语言规范
  • 逻辑合理,当lock为true时设置环境变量IMMUTABLE_DISABLE_REMOUNT=false
  • 环境变量的追加使用了os.Environ(),保留了原有环境变量,这是正确的做法
  1. 代码质量:
  • 代码结构清晰,条件判断简洁明了
  • 注释说明了添加环境变量的目的,有助于代码理解
  • 变量命名合理,lock和cmd等名称具有自解释性
  1. 代码性能:
  • 这段代码的性能影响很小,只是在需要时追加一个环境变量
  • 使用bytes.Buffer作为输出缓冲区是高效的做法
  1. 代码安全:
  • 这里直接设置环境变量,需要考虑以下几点:
    • IMMUTABLE_DISABLE_REMOUNT=false 这个环境变量的值是硬编码的,建议考虑将其定义为常量
    • 环境变量的设置应该考虑是否有权限要求
    • 需要确保这个环境变量的设置不会带来安全风险

改进建议:

// 在文件开头定义常量
const (
    EnvImmutableDisableRemount = "IMMUTABLE_DISABLE_REMOUNT=false"
)

func CheckPkgSystemError(lock bool, indicator system.Indicator) error {
    // ... 其他代码 ...

    cmd := exec.Command("apt-get", args...)
    if lock {
        // Need remount to write data in /usr directory.
        // 使用预定义的常量而不是硬编码字符串
        cmd.Env = append(os.Environ(), EnvImmutableDisableRemount)
    }
    // ... 其他代码 ...
}

这样的改进可以:

  1. 提高代码的可维护性
  2. 避免魔法字符串(magic string)的使用
  3. 便于后续修改环境变量名称或值
  4. 增加代码的可测试性

另外,建议添加更多的错误处理,比如检查环境变量是否设置成功,以及添加相关的日志记录,以便于问题追踪和调试。

总体来说,这个修改是合理的,但可以通过使用常量和增加错误处理来提高代码质量。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: electricface, zhaohuiw42

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

@electricface electricface merged commit 3d7da21 into linuxdeepin:master Jan 6, 2026
15 of 16 checks passed
@electricface electricface deleted the swt/fix-erofs-warn branch January 6, 2026 13:13
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.

3 participants