build: add Qt6 runtime detection when os-version is unavailable#288
Conversation
When /etc/os-version does not exist MAJOR_VERSION defaults to 99 Previously this always assumed Qt6 was available and set USE_QT6=yes Now uses pkg-config --exists Qt6Core to check actual Qt6 installation Falls back to Qt5 if Qt6Core is not found on the system Also outputs HAS_QT6 status in the diagnostic logging section Influence: 1. Build will correctly fallback to Qt5 when Qt6 is not installed 2. Prevents build failures on systems without /etc/os-version or Qt6 3. Diagnostic output now shows Qt6 detection result for debugging 4. MAJOR_VERSION >= 21 path remains unchanged build: 在 os-version 不可用时添加 Qt6 运行时检测 当 /etc/os-version 不存在时 MAJOR_VERSION 默认为 99 此前始终假设 Qt6 可用并设置 USE_QT6=yes 现在使用 pkg-config --exists Qt6Core 检测 Qt6 实际安装情况 如果系统未安装 Qt6Core 则回退到 Qt5 同时在诊断日志中输出 HAS_QT6 检测状态 Influence: 1. 未安装 Qt6 时构建将正确回退到 Qt5 2. 防止在缺少 /etc/os-version 或 Qt6 的系统上构建失败 3. 诊断输出现在显示 Qt6 检测结果便于调试 4. MAJOR_VERSION >= 21 的路径保持不变
|
Warning
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: liyigang1, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
87c5d9d
into
linuxdeepin:develop/tmp
deepin pr auto review这段代码主要是针对 Debian 打包规则文件 以下是对该代码的详细审查和改进意见: 1. 语法逻辑审查意见: 改进建议:
2. 代码质量审查意见:
改进建议:
3. 代码性能审查意见:
改进建议:
4. 代码安全审查意见:
改进建议:
5. 综合改进代码示例基于以上意见,优化后的代码片段如下: # 定义常量
OS_VERSION_UNKNOWN := 99
QT6_VERSION_THRESHOLD := 20
# ... (原有 MAJOR_VERSION 赋值逻辑) ...
# 版本判断: MajorVersion > THRESHOLD 使用 Qt6, 否则使用 Qt5
USE_QT6 := $(shell if [ "$(MAJOR_VERSION)" -gt "$(QT6_VERSION_THRESHOLD)" ] 2>/dev/null; then echo yes; else echo no; fi)
# MajorVersion 为 UNKNOWN 时,检查 Qt6 是否实际安装
ifeq ($(MAJOR_VERSION),$(OS_VERSION_UNKNOWN))
# 确保命令输出 yes 或 no,处理 pkg-config 不存在或失败的情况
HAS_QT6 := $(shell command -v pkg-config >/dev/null 2>&1 && pkg-config --exists Qt6Core 2>/dev/null && echo yes || echo no)
ifeq ($(HAS_QT6),yes)
USE_QT6 := yes
else
USE_QT6 := no
endif
endif
# ... (后续逻辑) ...总结这段代码修改逻辑正确,能够解决在无法读取系统版本号时回退到检测 Qt6 安装情况的问题。主要需要关注的是确保构建依赖中包含 |
When /etc/os-version does not exist MAJOR_VERSION defaults to 99 Previously this always assumed Qt6 was available and set USE_QT6=yes Now uses pkg-config --exists Qt6Core to check actual Qt6 installation Falls back to Qt5 if Qt6Core is not found on the system Also outputs HAS_QT6 status in the diagnostic logging section
Influence:
build: 在 os-version 不可用时添加 Qt6 运行时检测
当 /etc/os-version 不存在时 MAJOR_VERSION 默认为 99
此前始终假设 Qt6 可用并设置 USE_QT6=yes
现在使用 pkg-config --exists Qt6Core 检测 Qt6 实际安装情况
如果系统未安装 Qt6Core 则回退到 Qt5
同时在诊断日志中输出 HAS_QT6 检测状态
Influence: