Skip to content

分支合一,部分v20修改pick及Qt5编译兼容#101

Merged
deepin-bot[bot] merged 3 commits intolinuxdeepin:masterfrom
itsXuSt:v25
Dec 18, 2025
Merged

分支合一,部分v20修改pick及Qt5编译兼容#101
deepin-bot[bot] merged 3 commits intolinuxdeepin:masterfrom
itsXuSt:v25

Conversation

@itsXuSt
Copy link
Contributor

@itsXuSt itsXuSt commented Dec 16, 2025

  • fix: bash command hardening
  • feat: Support creating bootable USB drives from unpartitioned USB disks
  • feat: Add Qt5 compilation compatibility

Please do not send pull requests to the linuxdeepin/*

see https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers

Thanks!

Summary by Sourcery

Improve USB drive handling and add Qt5 build compatibility across the project.

New Features:

  • Support formatting and using previously unpartitioned USB disks by creating a partition before formatting.

Bug Fixes:

  • Harden diskutil command invocation to avoid unsafe bash -c usage on macOS.

Enhancements:

  • Refine Linux device discovery by parsing lsblk size output, using 64-bit size fields, and enriching logging around df/lsblk execution and USB device filtering.
  • Exclude network filesystems and network-like devices when enumerating candidate USB drives on Linux to avoid hangs and irrelevant devices.
  • Improve USB drive listing output with clearer device attributes and selection logic for usable partitions or whole disks.

Build:

  • Add conditional linkage against dtkcore/polkit-qt5-1 for Qt5 and dtk6core/polkit-qt6-1 for Qt6 to support building against both Qt versions.
  • Include Qt5-specific headers and namespace usage to restore/ensure Qt5 compilation compatibility in the application and service targets.

lzwind and others added 3 commits December 16, 2025 13:59
bash command hardening

Log: bash command hardening
Task: https://pms.uniontech.com/task-view-362031.html
- Add automatic partition creation for unpartitioned USB disks using fdisk
- Optimize df command to exclude network filesystems (NFS, CIFS, SMBFS, SSHFS, FTPFS, DAVFS)
- Improve device scanning logic to skip network-related devices

Log: Enable creating bootable USB drives from unpartitioned USB disks and improve disk querying efficiency

Bug: https://pms.uniontech.com/bug-view-338629.html
- Add conditional compilation for dtk6core/dtkcore in libdbm and service
- Add conditional compilation for polkit-qt6-1/polkit-qt5-1 in service
- Add Qt5 compatible QString::SkipEmptyParts for Qt < 5.14
- Add DApplicationSettings header include for Qt5
- Add Dtk::Gui namespace for Qt5 DGuiApplicationHelper usage

Log: Enable project to compile with both Qt5 and Qt6 environments
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @itsXuSt, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@itsXuSt itsXuSt marked this pull request as draft December 16, 2025 07:17
@itsXuSt itsXuSt marked this pull request as ready for review December 17, 2025 09:05
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个diff进行详细的代码审查:

  1. 兼容性改进:
  • 在debian/control中添加了Qt5的备选依赖,这是一个很好的兼容性改进
  • 在vendor.pri中增加了对Qt5的支持,使项目可以同时支持Qt5和Qt6
  • 在main.cpp中增加了对Qt5的条件编译支持
  1. 设备处理逻辑改进:
  • qtbaseinstaller.cpp中增加了对磁盘设备的自动分区处理,这是一个重要的改进
  • DiskUtil.cpp中新增了CreatePartition函数,使用fdisk创建分区表
  • 改进了设备检测和挂载点的处理逻辑
  1. 代码质量改进:
  • 修复了一些格式问题,如空格、换行等
  • 增加了更多的日志输出,便于调试
  • 优化了错误处理逻辑
  1. 性能优化:
  • 在df命令中排除了网络文件系统,避免因远程挂载导致的卡死
  • 优化了设备检测和遍历逻辑
  1. 安全性改进:
  • 增加了对分区创建的验证
  • 改进了设备卸载逻辑

建议改进:

  1. 错误处理:
// 在CreatePartition函数中建议增加更详细的错误处理
if (!result.isSuccess()) {
    qWarning() << "Failed to create partition table with fdisk for" << diskDev;
    qWarning() << "Error output:" << result.result();  // 添加错误输出
    return false;
}
  1. 资源管理:
// 在CommandLsblkParse函数中建议使用QScopedPointer管理资源
QScopedPointer<QProcess> lsblk(new QProcess);
lsblk->start("lsblk", QStringList{"-b", "-p", "-P", "-o", "name,label,size,uuid,fstype,type"});
  1. 代码复用:
// 建议将设备过滤逻辑抽取为单独的函数
bool isValidDevice(const QString& fileName) {
    return fileName.contains(QRegularExpression("^usb-\\S{1,}$")) || 
           fileName.contains(QRegularExpression("^mmc-\\S{1,}$"));
}
  1. 性能优化:
// 在ListUsbDrives函数中建议使用QHash替代QMap以提高查找性能
QHash<QString, DeviceInfo> dfDeviceInfos = CommandDfParse();
  1. 安全性:
// 在处理设备路径时建议增加路径验证
bool isValidDevicePath(const QString& path) {
    QRegularExpression re("^/dev/[a-zA-Z0-9]+$");
    return re.match(path).hasMatch();
}
  1. 代码规范:
// 建议统一命名风格,如m_strPartionName改为m_partitionName
QString partitionName;  // 替代 m_strPartionName
  1. 文档完善:
/**
 * @brief CreatePartition 创建磁盘分区
 * @param diskDev 磁盘设备路径,如"/dev/sdb"
 * @return 成功返回true,失败返回false
 * @note 仅支持Linux系统
 */
bool CreatePartition(const QString& diskDev);

这些改进将使代码更加健壮、安全和可维护。总体来说,这个diff的改进是积极的,特别是在兼容性和设备处理逻辑方面。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: itsXuSt, lzwind

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

@itsXuSt
Copy link
Contributor Author

itsXuSt commented Dec 18, 2025

/merge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 18, 2025

This pr cannot be merged! (status: unstable)

@itsXuSt
Copy link
Contributor Author

itsXuSt commented Dec 18, 2025

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 18, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 790875b into linuxdeepin:master Dec 18, 2025
17 of 18 checks passed
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