利用 Qt installer framework制作run包 或者说是在linux下的使用教程
Qt install framework是qt官方的打包工具,可以将我们的软件打包成一个像window一样的单一安装包,或者说就是我们下载的qt的run包,双击就可以下一步下一步的安装。
下载,安装与配置 Qt install framework
下载地址:http://download.qt.io/official_releases/qt-installer-framework/
给于可执行权限后直接双击安装
建议进行环境变量配置
编辑 .bashrc,在后面追加:
export PATH=软件安装目录/bin:$PATH
打包前的准备
话不多说,上链接:https://blog.csdn.net/mars_xiaolei/article/details/83825447
一定要看才行,不然打包出来的软件运行不了就不好了。
重点:如何编写installscript.qs脚本
直接上我的installscript.qs脚本,看明白就会了!
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the FOO module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
function Component()
{
// default constructor
}
Component.prototype.createOperations = function()
{
// call default implementation to actually install README.txt!
component.createOperations();
/*
这儿是原来就有的,因为主要讲linux上怎么用,所以并没有修改这儿
实际使用的时候,可以删除这儿的if
*/
if (systemInfo.productType === "windows") {
component.addOperation("CreateShortcut", "@TargetDir@/README.txt", "@StartMenuDir@/README.lnk",
"workingDirectory=@TargetDir@", "iconPath=%SystemRoot%/system32/SHELL32.dll",
"iconId=2", "description=Open README file");
}
/* 这儿的判断有问题 */
/**************************************详解********************************************
QSysInfo 和 systemInfo 见qt installer framework 安装目录下 /doc/html/scripting-systeminfo.html
*************************************************************************************/
if (systemInfo.kernelType === "linux" || QSysInfo.productType === "debian" ) {
/***************************************路径说明****************************************
系统自带变量
TargetDir 目标安装目录,由用户选择
DesktopDir 用户桌面目录名(路径)。仅在Windows上可用
RootDir 文件系统根目录
HomeDir 当前用户的home目录
ApplicationsDir 应用程序目录。例如,Windows上的C:\Program Files,Linux上/opt以及OS X上/Applications
InstallerDirPath 包含安装程序可执行文件的目录
InstallerFilePath 安装程序可执行文件的文件路径
注意:变量是包含在“@@”中的,以@开始,必须要以@结尾
具体的其它信息可以参考 https://www.cnblogs.com/oloroso/p/6775318.html#7_3_2_3
**************************************************************************************/
/* 建立桌面图标 */
var exec = "Exec=" + "@TargetDir@/Ledger.sh " + "\n"; /* 执行程序 */
var icon = "Icon=" + "@TargetDir@/icon/logo.svg " + "\n"; /* 图标资源路径 */
var version = "Version=" + "1.5.0.0023 " + "\n" ; /* 版本号 */
var name = "Name=" + "盼盼簿" + "\n"; /* 桌面图标显示名称 */
var desktop = "Ledger" + ".desktop"; /* 桌面图标名 */
var comment = name + exec + icon + version + "Terminal=false\nEncoding=UTF-8\nType=Application\n";
component.addOperation("CreateDesktopEntry", desktop , comment);
/*******************************************卸载图标*************************************
一般来说,应该是有卸载图标的,但是这儿不想细讲,因为卸载图标你可以根据上面建立桌面图标进行。
只要类似下面即可:
var exec = "Exec=" + "@TargetDir@/maintenancetool" + "\n"; /* 卸载程序 不建议修改
var icon = "Icon=" + "@TargetDir@/icon/logo.svg " + "\n"; /* 图标资源路径 建议修改
var version = "Version=" + "1.5.0.0023 " + "\n" ; /* 版本号
var name = "Name=" + "盼盼簿" + "\n"; /* 桌面图标显示名称 可修改
var desktop = "Ledger_uninstall" + ".desktop"; /* 桌面图标名 可修改
var comment = name + exec + icon + version + "Terminal=false\nEncoding=UTF-8\nType=Application\n";
component.addOperation("CreateDesktopEntry", desktop , comment);
**************************************************************************************/
}
}
最后开始打包
命令
binarycreator -c config/config.xml -p packages 软件包名.run -v
网友评论