Skip to content

修复使用 Deb 安装时仍会提示更新的问题 & 支持手动禁用更新 & 支持在非官方版本显示更新已被禁用#6174

Draft
CiiLu wants to merge 9 commits into
HMCL-dev:mainfrom
CiiLu:curseforge
Draft

修复使用 Deb 安装时仍会提示更新的问题 & 支持手动禁用更新 & 支持在非官方版本显示更新已被禁用#6174
CiiLu wants to merge 9 commits into
HMCL-dev:mainfrom
CiiLu:curseforge

Conversation

@CiiLu

@CiiLu CiiLu commented Jun 14, 2026

Copy link
Copy Markdown
Contributor
image image image closes #6136

@Wulian233

Copy link
Copy Markdown
Contributor

这是否是#5571 (comment) 变相的实现😂😂😂

@CiiLu

CiiLu commented Jun 14, 2026

Copy link
Copy Markdown
Contributor 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 adds support for disabling update checks or delegating them to external package managers via system properties, updating the settings UI to display relevant status messages, and documenting these new options. The review feedback highlights a variable typo (alretLineButton instead of alertLineButton) in SettingsPage.java, suggests using the SHOULD_CHECK_UPDATE constant in UpdateChecker.java for better efficiency, and points out spelling errors in the JVM parameter names (uptate instead of update) across the documentation files.

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 HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java
Comment thread HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java
Comment thread docs/Contributing.md Outdated
Comment thread docs/Contributing_zh.md Outdated
Comment thread docs/Contributing_zh_Hant.md Outdated
Comment thread HMCL/src/main/resources/assets/lang/I18N_zh.properties Outdated
Comment thread HMCL/src/main/resources/assets/lang/I18N_zh.properties Outdated
Comment thread HMCL/src/main/resources/assets/lang/I18N_zh.properties Outdated
Comment thread HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties Outdated
Comment thread HMCL/src/main/resources/assets/lang/I18N.properties Outdated
Comment thread docs/Contributing.md

@3gf8jv4dv 3gf8jv4dv Jun 14, 2026

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.

乍一看感觉改了好多行,不太好审。要不只改新加的两行?下同。

Co-authored-by: 3gf8jv4dv <3gf8jv4dv@gmail.com>
Comment thread HMCL/src/main/resources/assets/lang/I18N.properties Outdated
@Glavo

Glavo commented Jun 16, 2026

Copy link
Copy Markdown
Member

我希望在 #6122 完成后,通过引入新的配置文件来提供包管理器相关的元数据,而不是通过 JVM 参数传递这些内容。

@CiiLu CiiLu marked this pull request as draft June 16, 2026 13:39
@Minecraft269

Copy link
Copy Markdown

我希望在 #6122 完成后,通过引入新的配置文件来提供包管理器相关的元数据,而不是通过 JVM 参数传递这些内容。

所以...这个PR....? 算了我先赏个 /gemini review 哦 不对是 @CiiLu review

@Minecraft269

Copy link
Copy Markdown

@CiiLu 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 the ability to disable update checks or indicate that updates are managed by an external package manager (such as apt) via new JVM parameters (hmcl.update.disable and hmcl.update.packageManager). It updates the settings UI, update checker logic, Debian package build script, and documentation accordingly. However, appending all command-line arguments directly to JVM options in HMCLauncher.sh is highly risky and can cause JVM crashes when application arguments are passed. It is recommended to pass these configurations via environment variables instead of command-line JVM properties, and update UpdateChecker to read from both system properties and environment variables.

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 on lines +63 to +65
if [ $# -gt 0 ]; then
_HMCL_VM_OPTIONS="$_HMCL_VM_OPTIONS $*"
fi

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

HMCLauncher.sh 中,将 $*(所有命令行参数)直接追加到 _HMCL_VM_OPTIONS 是非常危险的。因为 _HMCL_VM_OPTIONS 会在 -jar 参数之前传递给 java 命令(作为 JVM 参数)。

如果用户在启动时传入了任何应用程序参数(例如自定义工作目录、版本选择等),JVM 会尝试将其解析为 JVM 参数,从而导致 Unrecognized option 错误并使 JVM 崩溃启动失败。

为了解决这个问题,建议不要通过命令行参数传递 -Dhmcl.update.packageManager=apt,而是改用环境变量(例如 HMCL_UPDATE_PACKAGE_MANAGER),这样既能避免污染命令行参数,又不需要在 HMCLauncher.sh 中使用这种不安全的追加方式。

export HMCL_DEPENDENCIES_DIR="$HMCL_USER_HOME/dependencies"
fi
exec %s "$@"
exec %s "$@" -Dhmcl.update.packageManager=apt

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

建议不要将 -Dhmcl.update.packageManager=apt 作为命令行参数传递给 %s(即 HMCLauncher.sh),因为这会污染命令行参数并导致前述的 JVM 崩溃问题。

我们可以通过在启动脚本中 export HMCL_UPDATE_PACKAGE_MANAGER=apt 来传递该配置,并在 UpdateChecker.java 中读取该环境变量。

                export HMCL_UPDATE_PACKAGE_MANAGER=apt
                exec %s "$@"

Comment on lines +41 to +42
public static final String PACKAGE_MANAGER_PROPERTY = System.getProperty("hmcl.update.packageManager", "");
public static final String DISABLE_UPDATE_PROPERTY = System.getProperty("hmcl.update.disable", "");

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

配合 CreateDeb.java 的修改,在 UpdateChecker 中同时支持从系统属性和环境变量中读取 hmcl.update.packageManagerhmcl.update.disable。这样既能解决 Deb 包安装时的更新提示问题,也为用户提供了通过环境变量禁用更新的灵活方式。

Suggested change
public static final String PACKAGE_MANAGER_PROPERTY = System.getProperty("hmcl.update.packageManager", "");
public static final String DISABLE_UPDATE_PROPERTY = System.getProperty("hmcl.update.disable", "");
public static final String PACKAGE_MANAGER_PROPERTY = System.getProperty("hmcl.update.packageManager", System.getenv("HMCL_UPDATE_PACKAGE_MANAGER") != null ? System.getenv("HMCL_UPDATE_PACKAGE_MANAGER") : "");
public static final String DISABLE_UPDATE_PROPERTY = System.getProperty("hmcl.update.disable", System.getenv("HMCL_UPDATE_DISABLE") != null ? System.getenv("HMCL_UPDATE_DISABLE") : "");

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.

[Bug] DEB 包无法进行自动更新

5 participants