290 lines
9.3 KiB
Plaintext
290 lines
9.3 KiB
Plaintext
|
|
================================================================================
|
|||
|
|
Qt Screen Lock Demo - DEB 打包配置完成总结
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
项目名称: Qt Screen Lock Demo
|
|||
|
|
打包类型: DEB (Debian/Ubuntu)
|
|||
|
|
版本: 1.0.0
|
|||
|
|
架构: amd64
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
已创建的文件清单
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
【核心打包脚本】
|
|||
|
|
✓ make_deb.sh - 快速打包脚本(推荐日常使用)
|
|||
|
|
✓ build_deb.sh - 完整打包脚本(详细日志,推荐发布)
|
|||
|
|
✓ create_icon.sh - 图标生成辅助脚本
|
|||
|
|
|
|||
|
|
【配置文件】
|
|||
|
|
✓ screenlockdemo.desktop - 桌面快捷方式配置
|
|||
|
|
✓ debian/control - DEB 包元数据信息
|
|||
|
|
✓ debian/copyright - 版权和许可证信息
|
|||
|
|
✓ debian/changelog - 版本更新日志
|
|||
|
|
✓ debian/rules - 构建规则(Makefile 格式)
|
|||
|
|
✓ debian/compat - Debian 兼容性版本(9)
|
|||
|
|
|
|||
|
|
【文档】
|
|||
|
|
✓ DEB_PACKAGE.md - 详细打包文档(460+ 行,包含所有细节)
|
|||
|
|
✓ PACKAGING_README.md - 快速入门指南
|
|||
|
|
✓ PACKAGING_CHECKLIST.md - 打包测试检查清单(347 行)
|
|||
|
|
✓ PACKAGING_SUMMARY.txt - 本总结文档
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
快速开始指南
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
【第一步:环境检查】
|
|||
|
|
|
|||
|
|
1. 检查 linuxdeployqt 工具:
|
|||
|
|
$ ls -lh $HOME/dev/sunvpack-py/bin/linuxdeployqt
|
|||
|
|
|
|||
|
|
2. 检查 Qt 5.15.2:
|
|||
|
|
$ ls -d $HOME/sdk/qt-5.15.2
|
|||
|
|
|
|||
|
|
3. 检查打包工具:
|
|||
|
|
$ dpkg-deb --version
|
|||
|
|
|
|||
|
|
【第二步:执行打包】
|
|||
|
|
|
|||
|
|
方法1 - 快速打包(推荐):
|
|||
|
|
$ chmod +x make_deb.sh
|
|||
|
|
$ ./make_deb.sh
|
|||
|
|
|
|||
|
|
方法2 - 详细打包:
|
|||
|
|
$ chmod +x build_deb.sh
|
|||
|
|
$ ./build_deb.sh
|
|||
|
|
|
|||
|
|
【第三步:测试安装】
|
|||
|
|
|
|||
|
|
$ sudo dpkg -i deb_package/screenlockdemo_1.0.0_amd64.deb
|
|||
|
|
$ screenlockdemo
|
|||
|
|
|
|||
|
|
【第四步:卸载】
|
|||
|
|
|
|||
|
|
$ sudo dpkg -r screenlockdemo
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
打包原理说明
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
【linuxdeployqt 的作用】
|
|||
|
|
1. 扫描可执行文件的动态链接依赖
|
|||
|
|
2. 自动复制所有 Qt 5.15.2 库到打包目录
|
|||
|
|
3. 复制 Qt 插件(platforms, imageformats 等)
|
|||
|
|
4. 复制其他系统依赖库
|
|||
|
|
5. 设置正确的 RPATH,确保程序使用打包的库
|
|||
|
|
|
|||
|
|
【打包流程】
|
|||
|
|
[1/6] 清理目录
|
|||
|
|
[2/6] 编译项目(如需要)
|
|||
|
|
[3/6] 创建 AppDir 结构
|
|||
|
|
[4/6] 使用 linuxdeployqt 收集所有依赖 ← 核心步骤
|
|||
|
|
[5/6] 创建 DEB 包目录结构
|
|||
|
|
[6/6] 构建 DEB 包
|
|||
|
|
|
|||
|
|
【最终 DEB 包结构】
|
|||
|
|
/opt/screenlockdemo/
|
|||
|
|
├── bin/ScreenLockDemo - 主程序
|
|||
|
|
├── lib/ - Qt 和依赖库(所有 .so 文件)
|
|||
|
|
├── plugins/ - Qt 插件
|
|||
|
|
└── screenlockdemo.sh - 启动包装脚本
|
|||
|
|
|
|||
|
|
/usr/bin/screenlockdemo - 系统命令(链接)
|
|||
|
|
/usr/share/applications/ - 桌面快捷方式
|
|||
|
|
/usr/share/icons/ - 应用图标
|
|||
|
|
|
|||
|
|
【为什么这样打包?】
|
|||
|
|
✓ 隔离依赖:所有 Qt 库打包在 /opt 下,不依赖系统 Qt
|
|||
|
|
✓ 避免冲突:不会与系统已安装的 Qt 版本冲突
|
|||
|
|
✓ 易于部署:一个包包含所有依赖,可在不同 Ubuntu 版本运行
|
|||
|
|
✓ 便于维护:应用程序自带所有必需库,减少部署问题
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
DEB 包信息
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
包名: screenlockdemo
|
|||
|
|
版本: 1.0.0-1
|
|||
|
|
架构: amd64
|
|||
|
|
预计大小: 50-80 MB(包含完整 Qt 5.15.2)
|
|||
|
|
|
|||
|
|
依赖:
|
|||
|
|
- dbus
|
|||
|
|
- libx11-6
|
|||
|
|
- libxext6
|
|||
|
|
- libxrender1
|
|||
|
|
- libfontconfig1
|
|||
|
|
- libfreetype6
|
|||
|
|
- libglib2.0-0
|
|||
|
|
- libgl1
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
测试要点
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
【安装后必须测试】
|
|||
|
|
□ 命令行启动: screenlockdemo
|
|||
|
|
□ 应用菜单启动
|
|||
|
|
□ 主界面显示正常
|
|||
|
|
□ 动画效果正常
|
|||
|
|
□ 锁屏检测(Ctrl+Alt+L)- 动画应停止
|
|||
|
|
□ 解锁后动画自动恢复
|
|||
|
|
□ 手动控制按钮功能正常
|
|||
|
|
□ 无错误信息和崩溃
|
|||
|
|
|
|||
|
|
【验证依赖正确】
|
|||
|
|
$ ldd /opt/screenlockdemo/bin/ScreenLockDemo
|
|||
|
|
应看到 Qt 库路径指向 /opt/screenlockdemo/lib/
|
|||
|
|
|
|||
|
|
【卸载后检查】
|
|||
|
|
$ sudo dpkg -r screenlockdemo
|
|||
|
|
$ ls /opt/screenlockdemo/ # 应该不存在
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
常见问题速查
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
【问题1】linuxdeployqt 未找到
|
|||
|
|
检查: ls $HOME/dev/sunvpack-py/bin/linuxdeployqt
|
|||
|
|
修改: 编辑脚本中的 LINUXDEPLOYQT 变量
|
|||
|
|
|
|||
|
|
【问题2】Qt 目录未找到
|
|||
|
|
检查: ls $HOME/sdk/qt-5.15.2
|
|||
|
|
修改: 编辑脚本中的 QT_DIR 变量
|
|||
|
|
|
|||
|
|
【问题3】程序无法启动
|
|||
|
|
诊断: /opt/screenlockdemo/bin/ScreenLockDemo
|
|||
|
|
检查: ldd /opt/screenlockdemo/bin/ScreenLockDemo
|
|||
|
|
修复: sudo apt-get install libgl1 libx11-6 libxcb-xinerama0
|
|||
|
|
|
|||
|
|
【问题4】Qt 平台插件错误
|
|||
|
|
错误: "Could not load the Qt platform plugin xcb"
|
|||
|
|
检查: ls /opt/screenlockdemo/plugins/platforms/libqxcb.so
|
|||
|
|
修复: sudo apt-get install libxcb-xinerama0 libxcb-icccm4
|
|||
|
|
|
|||
|
|
【问题5】图标不显示
|
|||
|
|
修复: sudo gtk-update-icon-cache -f /usr/share/icons/hicolor
|
|||
|
|
sudo update-desktop-database
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
修改版本号
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
需要修改以下文件中的版本号:
|
|||
|
|
|
|||
|
|
1. make_deb.sh (第7行)
|
|||
|
|
VERSION="1.0.0" → VERSION="1.0.1"
|
|||
|
|
|
|||
|
|
2. build_deb.sh (第14行)
|
|||
|
|
VERSION="1.0.0" → VERSION="1.0.1"
|
|||
|
|
|
|||
|
|
3. debian/changelog (第1行)
|
|||
|
|
screenlockdemo (1.0.0-1) → screenlockdemo (1.0.1-1)
|
|||
|
|
|
|||
|
|
4. CMakeLists.txt (第2行)
|
|||
|
|
project(ScreenLockDemo VERSION 1.0.0 ...)
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
优化建议
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
【减小包体积】
|
|||
|
|
- 使用 strip 命令去除调试符号
|
|||
|
|
- 排除不需要的 Qt 插件
|
|||
|
|
- 只包含必需的 Qt 模块
|
|||
|
|
|
|||
|
|
【添加真实图标】
|
|||
|
|
1. 创建 256x256 PNG 图标
|
|||
|
|
2. 保存为 icon.png
|
|||
|
|
3. 运行 ./create_icon.sh 或直接使用
|
|||
|
|
|
|||
|
|
【自定义包信息】
|
|||
|
|
编辑 debian/control:
|
|||
|
|
- Maintainer: 您的名字和邮箱
|
|||
|
|
- Description: 更详细的描述
|
|||
|
|
- Homepage: 项目主页
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
文档资源
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
详细文档:
|
|||
|
|
- DEB_PACKAGE.md - 完整打包指南(460+ 行)
|
|||
|
|
- PACKAGING_README.md - 快速参考(334 行)
|
|||
|
|
- PACKAGING_CHECKLIST.md - 测试检查清单(347 行)
|
|||
|
|
|
|||
|
|
项目文档:
|
|||
|
|
- README.md - 项目说明和使用指南
|
|||
|
|
- ARCHITECTURE.md - 架构设计文档
|
|||
|
|
- QUICKSTART.md - 快速开始指南
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
命令速查表
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
# 打包
|
|||
|
|
./make_deb.sh
|
|||
|
|
|
|||
|
|
# 查看包信息
|
|||
|
|
dpkg -I deb_package/screenlockdemo_1.0.0_amd64.deb
|
|||
|
|
dpkg -c deb_package/screenlockdemo_1.0.0_amd64.deb
|
|||
|
|
|
|||
|
|
# 安装
|
|||
|
|
sudo dpkg -i deb_package/screenlockdemo_1.0.0_amd64.deb
|
|||
|
|
sudo apt-get install -f # 修复依赖
|
|||
|
|
|
|||
|
|
# 运行
|
|||
|
|
screenlockdemo
|
|||
|
|
|
|||
|
|
# 检查依赖
|
|||
|
|
ldd /opt/screenlockdemo/bin/ScreenLockDemo
|
|||
|
|
|
|||
|
|
# 卸载
|
|||
|
|
sudo dpkg -r screenlockdemo
|
|||
|
|
|
|||
|
|
# 生成校验和
|
|||
|
|
md5sum deb_package/screenlockdemo_1.0.0_amd64.deb
|
|||
|
|
sha256sum deb_package/screenlockdemo_1.0.0_amd64.deb
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
发布流程建议
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
1. 更新版本号(见上文)
|
|||
|
|
2. 更新 debian/changelog
|
|||
|
|
3. 运行完整打包: ./build_deb.sh
|
|||
|
|
4. 在测试环境安装测试
|
|||
|
|
5. 运行完整功能测试(参考 PACKAGING_CHECKLIST.md)
|
|||
|
|
6. 生成校验和
|
|||
|
|
7. 准备发布说明
|
|||
|
|
8. 发布 DEB 包
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
结语
|
|||
|
|
================================================================================
|
|||
|
|
|
|||
|
|
✓ DEB 打包配置已完成!
|
|||
|
|
✓ 使用 linuxdeployqt 自动收集所有 Qt 5.15.2 依赖
|
|||
|
|
✓ 支持独立部署,无需系统安装 Qt
|
|||
|
|
✓ 包含完整的文档和测试清单
|
|||
|
|
|
|||
|
|
【下一步】
|
|||
|
|
1. 运行 ./make_deb.sh 生成 DEB 包
|
|||
|
|
2. 安装测试: sudo dpkg -i deb_package/screenlockdemo_1.0.0_amd64.deb
|
|||
|
|
3. 功能测试: screenlockdemo
|
|||
|
|
4. 查看详细文档: cat DEB_PACKAGE.md
|
|||
|
|
|
|||
|
|
【获取帮助】
|
|||
|
|
- 打包问题: 查看 DEB_PACKAGE.md 的"常见问题"章节
|
|||
|
|
- 测试指南: 使用 PACKAGING_CHECKLIST.md
|
|||
|
|
- 快速参考: 查看 PACKAGING_README.md
|
|||
|
|
|
|||
|
|
祝打包顺利!🚀
|
|||
|
|
|
|||
|
|
================================================================================
|
|||
|
|
创建日期: 2024-01-01
|
|||
|
|
最后更新: 2024-01-01
|
|||
|
|
版本: 1.0.0
|
|||
|
|
================================================================================
|