文章目录
- 打包
- control
- postinst
- postrm
- TestApp.sh
- TestApp.desktop
- 生成安装包
- 安装.deb
- 卸载
- [Qt 发布应用程序](https://blog.csdn.net/u012020854/article/details/52597226?spm=1001.2014.3001.5502)
新增文件夹 packages
打包
packages
├── DEBIAN
│ └── control #详情看下方目录
│ └── postinst #详情看下方目录
│ └── postrm #详情看下方目录
├── opt
└── TestApp
├── TestApp.sh #运行脚本(使用脚本启动程序更自由)
└── TestApp.png #桌面图标(如果不需要可以不要)
└── TestApp.desktop #桌面快捷方式 (如果不需要可以不要)
control
安装包描述
Package: TestApp
Version: 1.0.0
Section: devel
Depends:
Priority: optional
Architecture: amd64
Maintainer: Ye hai
Homepage: https://www.baidu.com/
Installed-Size: 19MB
Provides: TestApp
Conflicts: TestApp
Replaces: TestApp
Description: 2023-08-28 18 11:00 AM
postinst
安装时会执行该脚本
– 把快捷方式拷贝到开始菜单
– 把快捷方式拷贝到桌面
#!/bin/sh
chmod 777 /opt/TestApp/TestApp.desktop
cp /opt/TestApp/TestApp.desktop /usr/share/applications/
#cp /opt/TestApp/TestApp.desktop ~/Desktop/
postrm
卸载时执行
– 把开始菜单快捷方式文件删除
– 把桌面快捷方式文件删除
#!/bin/shif [ -f "/usr/share/applications/TestApp.desktop" ]
thenrm /usr/share/applications/TestApp.desktop
fiif [ -f "~/Desktop/TestApp.desktop" ]
thenrm ~/Desktop/TestApp.desktop
fi
TestApp.sh
#!/bin/shcurrentDir=`cd $(dirname $0); pwd -P`
cd "$currentDir"#system environment variable
export LD_LIBRARY_PATH=$currentDir/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$currentDir/plugins
#export QT_DEBUG_PLUGINS=1
sh -c `$currentDir/TestApp`
exit 0
TestApp.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Exec=/opt/TestApp/TestApp.sh log
Name=TestApp
Icon=/opt/TestApp/robot.png
生成安装包
cd 到 packages 上一层目录执行下面命令行
dpkg -b packages TestApp.deb
安装.deb
sudo dpkg -i TestApp.deb
卸载
sudo dpkg -r TestApp