Skip to content

Feat:添加 RHEL 兼容 RPM Package#6352

Open
Lingbou wants to merge 3 commits into
HMCL-dev:mainfrom
Lingbou:rpm-packaging
Open

Feat:添加 RHEL 兼容 RPM Package#6352
Lingbou wants to merge 3 commits into
HMCL-dev:mainfrom
Lingbou:rpm-packaging

Conversation

@Lingbou

@Lingbou Lingbou commented Jul 9, 2026

Copy link
Copy Markdown

摘要

关联 Issue:#5937

新的 :HMCL:makeRpm 任务使用 rpmbuild 构建 RPM 包,并尽量沿用现有 Debian 包的安装布局,包括按发布渠道区分的启动命令、desktop entry、图标安装,以及通过 alternatives 注册通用的 hmcl 命令。

主要改动

  • 新增 CreateRpm Gradle task。
  • 抽出 Debian 和 RPM 共用的 Linux 包路径与启动脚本生成逻辑。
  • 新增独立的 GitHub Actions RPM job,使用 Rocky Linux 9 容器构建。
  • RPM 安装启动时设置 HMCL_PACKAGE_MANAGED=rpm,避免内置更新流程和系统包管理器安装的版本冲突。

说明

  • RPM 打包任务是可选任务,没有加入默认 build 流程。
  • 现有 Debian/Ubuntu 打包行为保持不变。
  • RPM 当前沿用现有 Debian 包的轻依赖策略,没有额外声明 Java runtime dependency。

验证

本地已验证:

  • ./gradlew :HMCL:compileJava --no-daemon --stacktrace
  • ./gradlew :HMCL:checkTranslations --no-daemon --stacktrace
  • ./gradlew :HMCL:makeDeb --no-daemon --stacktrace
  • ./gradlew :HMCL:checkstyleMain --no-daemon --stacktrace

Docker 中已验证:

  • rockylinux:9 容器内执行 ./gradlew :HMCL:makeRpm --no-daemon --stacktrace,构建成功。
  • 在干净的 rockylinux:9 容器内使用 dnf 安装并卸载生成的 RPM,安装和卸载均成功。
  • 验证生成的包可安装为 hmcl-nightly-3.16.snapshot-1.noarch
  • 验证 /usr/bin/hmcl-nightly 可执行。
  • 验证 hmcl alternatives 指向 /usr/bin/hmcl-nightly
  • 验证 wrapper 会导出 HMCL_PACKAGE_MANAGED="rpm"

@Lingbou Lingbou changed the title 添加 RHEL 兼容 RPM 打包任务 Feat:添加 RHEL 兼容 RPM Package Jul 9, 2026
@Lingbou Lingbou marked this pull request as ready for review July 9, 2026 09:08
@Minecraft269

Copy link
Copy Markdown

/gemini review

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

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.

Code Review

This pull request introduces RPM package generation support and integrates package manager detection to prevent package-managed installations from performing self-updates. It refactors Linux packaging logic by extracting shared paths and launcher script generation into a new LinuxPackageFiles helper class. The review feedback suggests adding explicit attributes to the /usr/share/java/hmcl directory in the RPM spec to prevent permission issues in strict umask environments, and expanding the boolean parser in PackageManagerIntegration to recognize "no" and "off" as disabled values.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread buildSrc/src/main/java/org/jackhuang/hmcl/gradle/pack/CreateRpm.java Outdated
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/upgrade/PackageManagerIntegration.java Outdated
Lingbou added 2 commits July 13, 2026 15:16
Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
@Lingbou

Lingbou commented Jul 13, 2026

Copy link
Copy Markdown
Author

/gemini review

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

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.

Code Review

This pull request introduces support for building RPM packages for HMCL by adding a new CreateRpm Gradle task and refactoring the packaging logic into a shared LinuxPackageFiles helper. It also implements a PackageManagerIntegration utility to disable automatic updates when the launcher is installed via a system package manager. The review feedback suggests several key improvements to the CreateRpm task, including ensuring cross-platform compatibility by checking for POSIX file system support before setting file permissions, properly handling process interruption to prevent leaks, removing redundant directory creation handled automatically by Gradle, and leveraging Gradle's built-in file deletion API to simplify the code.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread buildSrc/src/main/java/org/jackhuang/hmcl/gradle/pack/CreateRpm.java Outdated
Comment thread buildSrc/src/main/java/org/jackhuang/hmcl/gradle/pack/CreateRpm.java Outdated
Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
@Lingbou

Lingbou commented Jul 13, 2026

Copy link
Copy Markdown
Author

@Glavo xd看看还有没有需要我修改的地方了 ^_^

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