Skip to content

Release 1.12.2#1626

Merged
dengbo11 merged 3 commits intoOpenAtom-Linyaps:release/1.12from
dengbo11:release-1.12
Mar 21, 2026
Merged

Release 1.12.2#1626
dengbo11 merged 3 commits intoOpenAtom-Linyaps:release/1.12from
dengbo11:release-1.12

Conversation

@dengbo11
Copy link
Copy Markdown
Collaborator

No description provided.

dengbo11 and others added 3 commits March 21, 2026 21:19
Added RISC-V 64 architecture support to the package architecture system.
This includes:
1. Added RISCV64 enum value to Architecture class
2. Implemented toString() method returning "riscv64"
3. Implemented getTriplet() method returning "riscv64-linux-gnu"
4. Added parsing support for "riscv64" string input
5. Updated test cases to include RISC-V 64 architecture

This change enables the package system to properly handle RISC-V 64
architecture, which is necessary for supporting applications built
for RISC-V 64 platforms. The architecture follows the same pattern as
other supported architectures with proper string conversion and triplet
generation.

Influence:
1. Verify Architecture::toString() returns "riscv64" for RISCV64 enum
2. Test Architecture::getTriplet() returns "riscv64-linux-gnu" for
RISCV64
3. Validate Architecture constructor parses "riscv64" string correctly
4. Confirm existing architecture tests still pass with new RISCV64
addition
5. Test error handling for unknown architecture strings remains
functional
- Parse protocol/hostname/display/screen from DISPLAY environment variable
- Add unit tests for display parsing edge cases

Signed-off-by: reddevillg <reddevillg@gmail.com>
Release 1.12.2.
@deepin-ci-robot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dengbo11

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

@dengbo11 dengbo11 merged commit 8ad8355 into OpenAtom-Linyaps:release/1.12 Mar 21, 2026
13 of 14 checks passed
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on enhancing the robustness and flexibility of XOrg display handling within the application by completely refactoring the display parsing logic. It also incorporates support for the RISCV64 architecture, expanding the range of supported platforms. These changes are accompanied by a version increment and new unit tests to ensure the reliability of the updated display parsing mechanism.

Highlights

  • Version Bump: The project version has been updated from 1.12.1 to 1.12.2 in CMakeLists.txt.
  • XOrg Display Parsing Refactor: The getXOrgDisplay function has been significantly refactored to provide more robust and detailed parsing of XOrg display strings, including support for various protocols, hosts, display numbers, and screen numbers. This introduces a new XOrgDisplayConf struct to hold parsed display configuration.
  • RISCV64 Architecture Support: Added support for the RISCV64 architecture, including its string representation, triplet, and recognition in the Architecture class.
  • Improved Container Display System Handling: The ContainerCfgBuilder now directly parses the DISPLAY environment variable using the new getXOrgDisplay logic to dynamically configure XOrg display mounts, removing the need for a separate bindXOrgSocket method.
  • New Unit Tests for XOrg Display: A comprehensive set of unit tests has been added for the refactored getXOrgDisplay function, covering a wide range of valid and invalid display string formats.
  • Copyright Year Updates: Copyright years have been updated across several files to reflect the current year range.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@deepin-ci-robot
Copy link
Copy Markdown
Collaborator

deepin pr auto review

Git Diff 代码审查报告

总体评价

本次提交主要包含三个方面的修改:

  1. 更新了版本号和版权年份
  2. 重构了 X11 显示系统处理逻辑,从返回路径改为返回结构化配置
  3. 添加了 RISCV64 架构支持

整体代码质量较高,逻辑清晰,但有一些可以改进的地方。

详细审查

1. CMakeLists.txt 文件修改

优点:

  • 版本号更新正确
  • 版权年份范围更新合理

建议:

  • 无明显问题

2. libs/common/CMakeLists.txt 修改

优点:

  • 正确添加了 linglong::utils 依赖

建议:

  • 无明显问题

3. libs/common/src/linglong/common/display.cpp 修改

优点:

  • 重构了 getXOrgDisplay 函数,从返回路径改为返回结构化配置
  • 使用了 utils::error::Result 替代 tl::expected,与项目错误处理保持一致
  • 添加了详细的错误处理和日志记录
  • 使用了 common::strings::starts_with 替代手动字符串比较

问题和建议:

  1. 代码复杂度问题

    • getXOrgDisplay 函数变得较长,建议考虑将其拆分为更小的辅助函数,例如:
      // 可以拆分为这些辅助函数
      utils::error::Result<XOrgDisplayConf> parseUnixDisplay(std::string_view display);
      utils::error::Result<XOrgDisplayConf> parseNetworkDisplay(std::string_view display);
  2. 错误处理改进

    • std::stoi 转换时,可以考虑使用更严格的错误检查,例如检查是否有额外的非数字字符
    • 可以添加对显示号和屏幕号范围的限制检查
  3. 性能优化

    • 字符串处理中多次使用 substr 创建新字符串,可以考虑使用 string_view 来减少内存分配
    • 例如:
      // 当前代码
      result.displayNo = std::stoi(std::string(display), &s);
      display = display.substr(s);
      
      // 优化建议
      auto [displayNo, remaining] = parseDisplayNumber(display);
      if (!displayNo) {
          return LINGLONG_ERR(displayNo.error());
      }
      result.displayNo = *displayNo;
      display = remaining;
  4. 安全性改进

    • 对于绝对路径的显示配置,应该添加路径规范化处理,防止路径遍历攻击
    • 例如:
      // 添加路径规范化
      if (result.host) {
          auto normalized = std::filesystem::canonical(*result.host, ec);
          if (!ec) {
              result.host = normalized.string();
          }
      }

4. libs/common/src/linglong/common/display.h 修改

优点:

  • 新增的 XOrgDisplayConf 结构体设计合理,字段命名清晰
  • 使用 std::optional 表示可选字段

问题和建议:

  1. 结构体设计改进

    • 可以考虑添加默认构造函数,确保初始化:
      struct XOrgDisplayConf {
          std::optional<std::string> protocol;
          std::optional<std::string> host;
          int displayNo = 0;
          int screenNo = 0;
      };
  2. 文档改进

    • 可以添加结构体字段的文档注释,说明每个字段的含义和预期值

5. libs/linglong/src/linglong/package/architecture.cpp/h 修改

优点:

  • 正确添加了 RISCV64 架构支持
  • 测试用例也相应更新

问题和建议:

  • 无明显问题

6. libs/linglong/src/linglong/runtime/run_context.cpp 修改

优点:

  • 移除了旧的显示系统检测代码,逻辑更清晰

问题和建议:

  • 无明显问题

7. libs/oci-cfg-generators/src/linglong/oci-cfg-generators/container_cfg_builder.cpp/h 修改

优点:

  • 重构了显示系统构建逻辑,使用新的 XOrgDisplayConf 结构
  • 移除了不再需要的 bindXOrgSocket 方法
  • 处理了抽象套接字的情况

问题和建议:

  1. 代码复杂度问题

    • buildDisplaySystem 函数较长,可以考虑拆分为更小的函数
    • 例如:
      bool ContainerCfgBuilder::buildDisplaySystem() noexcept {
          displayMount = std::vector<Mount>{};
          
          if (auto *display = ::getenv("DISPLAY"); display != nullptr) {
              return buildXOrgDisplay(display);
          }
          
          return true;
      }
      
      bool ContainerCfgBuilder::buildXOrgDisplay(const char* display) noexcept {
          // X11 显示系统构建逻辑
      }
  2. 错误处理改进

    • std::filesystem::exists 失败时,应该记录错误日志
    • 例如:
      std::error_code ec;
      if (std::filesystem::exists(source, ec)) {
          // ...
      } else {
          if (ec) {
              LogW("Failed to check X11 socket {}: {}", source.string(), ec.message());
          }
      }
  3. 安全性改进

    • 对于显示号的硬编码值 1000,应该考虑是否足够安全,或者是否应该使用动态生成的值
    • 可以添加对环境变量 DISPLAY 的验证,防止注入攻击

8. 测试用例修改

优点:

  • 新增的 display_test.cpp 测试用例全面,覆盖了各种边界情况
  • 架构测试用例也相应更新

问题和建议:

  • 测试用例质量很高,无明显问题

总结

本次提交的代码整体质量较高,主要改进了显示系统的处理逻辑,使其更加灵活和可扩展。主要改进建议集中在:

  1. 将长函数拆分为更小的函数,提高可读性和可维护性
  2. 加强错误处理和日志记录
  3. 考虑性能优化,减少不必要的字符串拷贝
  4. 加强安全性检查,特别是路径处理和输入验证

这些改进建议不是必须的,但可以进一步提高代码质量和安全性。

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request bumps the project version to 1.12.2 and introduces several changes. The main functional change is a significant refactoring of the X11 DISPLAY environment variable parsing and handling. This includes a more robust parsing mechanism in libs/common/display.cpp and updated logic for setting up X11 socket mounts in the container configuration builder. Additionally, support for the riscv64 architecture has been added. The changes are accompanied by new unit tests for the display parsing logic. My review identifies a potential issue in the new display parsing logic that should be addressed.

Comment on lines +50 to 78
if (!display.empty() && display[0] == '/') {
result.protocol = "unix";
std::error_code ec;
if (std::filesystem::exists(display, ec)) {
result.host = display;
return result;
}

auto dot = display.find_last_of('.');
if (dot == std::string_view::npos) {
return LINGLONG_ERR(fmt::format("{} doesn't exist", display));
}

auto sub = display.substr(0, dot);
if (std::filesystem::exists(sub, ec)) {
result.host = sub;
try {
result.screenNo = std::stoi(std::string(display.substr(dot + 1)));
if (result.screenNo < 0) {
return LINGLONG_ERR(fmt::format("invalid screen No: {}", result.screenNo));
}
} catch (const std::exception &e) {
return LINGLONG_ERR(fmt::format("failed to get screen No: {}", e.what()));
}
return result;
}

return LINGLONG_ERR(fmt::format("{} doesn't exist", sub));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The logic for parsing a display string that is an absolute path (e.g., /tmp/.X11-unix/X1) does not correctly parse the display number. It appears to default to 0 because result.displayNo is not updated in this code block. For a path like /tmp/.X11-unix/X1, result.displayNo will be 0 instead of 1. The existing tests pass because they only use X0. This could lead to incorrect behavior in ContainerCfgBuilder::buildDisplaySystem, which relies on the parsed displayNo. The display number should be extracted from the path, for example by parsing the number after the last /X in the path.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 44.59459% with 41 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...glong/oci-cfg-generators/container_cfg_builder.cpp 0.00% 22 Missing ⚠️
libs/common/src/linglong/common/display.cpp 58.69% 7 Missing and 12 partials ⚠️
Files with missing lines Coverage Δ
...ibs/linglong/src/linglong/package/architecture.cpp 67.03% <100.00%> (+2.32%) ⬆️
libs/linglong/src/linglong/package/architecture.h 100.00% <ø> (ø)
libs/linglong/src/linglong/runtime/run_context.cpp 4.03% <ø> (+0.09%) ⬆️
...inglong/oci-cfg-generators/container_cfg_builder.h 0.00% <ø> (ø)
libs/common/src/linglong/common/display.cpp 38.15% <58.69%> (+38.15%) ⬆️
...glong/oci-cfg-generators/container_cfg_builder.cpp 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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