@TOC
QT安装包建立
准备工具
- qt-installer-framework 下载地址
安装完成后,添加环境变量
添加到Qt Creator帮助文档
打开 Qt Creator,选择【工具】–>【选项】–>【帮助】–>【文档】–>【添加】
选择Qt IFW安装目录doc下的ifw.qch文件。
创建安装包工程
创建工程目录
mkdir -p AidTool_Installer
mkdir -p AidTool_Installer/config
mkdir -p AidTool_Installer/packages
mkdir -p AidTool_Installer/packages/com.man.ifw
mkdir -p AidTool_Installer/packages/data
mkdir -p AidTool_Installer/packages/meta
.
├── AidTool_Installer
├── AidTool.exe
├── config
│ └── config.xml
└── packages
└── com.man.ifw
├── data
│ ├── AidTool.exe
│ ├── D3Dcompiler_47.dll
│ ├── Qt5Core.dll
│ ├── Qt5Gui.dll
│ ├── Qt5SerialPort.dll
│ ├── Qt5Svg.dll
│ ├── Qt5Widgets.dll
│ ├── iconengines
│ │ └── qsvgicon.dll
│ ├── imageformats
│ │ ├── qgif.dll
│ │ ├── qicns.dll
│ │ ├── qico.dll
│ │ ├── qjpeg.dll
│ │ ├── qsvg.dll
│ │ ├── qtga.dll
│ │ ├── qtiff.dll
│ │ ├── qwbmp.dll
│ │ └── qwebp.dll
│ ├── libEGL.dll
│ ├── libGLESV2.dll
│ ├── libgcc_s_seh-1.dll
│ ├── libstdc++-6.dll
│ ├── libwinpthread-1.dll
│ ├── opengl32sw.dll
│ ├── platforms
│ │ └── qwindows.dll
│ ├── startmenu
│ │ ├── README
│ │ ├── config
│ │ │ └── config.xml
│ │ ├── packages
│ │ │ └── org.qtproject.ifw.example
│ │ │ ├── data
│ │ │ │ └── README.txt
│ │ │ └── meta
│ │ │ ├── installscript.qs
│ │ │ └── package.xml
│ │ ├── startmenu.pro
│ │ └── startmenu.pro.user
│ ├── styles
│ │ └── qwindowsvistastyle.dll
│ └── translations
│ ├── qt_ar.qm
│ ├── qt_bg.qm
│ ├── qt_ca.qm
│ ├── qt_cs.qm
│ ├── qt_da.qm
│ ├── qt_de.qm
│ ├── qt_en.qm
│ ├── qt_es.qm
│ ├── qt_fi.qm
│ ├── qt_fr.qm
│ ├── qt_gd.qm
│ ├── qt_he.qm
│ ├── qt_hu.qm
│ ├── qt_it.qm
│ ├── qt_ja.qm
│ ├── qt_ko.qm
│ ├── qt_lv.qm
│ ├── qt_pl.qm
│ ├── qt_ru.qm
│ ├── qt_sk.qm
│ ├── qt_uk.qm
│ └── qt_zh_TW.qm
└── meta
├── installscript.qs
└── package.xml
创建配置文件
在config目录下创建名为config.xml的文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>AidTool Installer</Name>
<Version>1.0.0</Version>
<Title>AidTool Installer</Title>
<Publisher>man</Publisher>
<StartMenuDir>AidTool</StartMenuDir>
<TargetDir>@HomeDir@/AidTool</TargetDir>
</Installer>
配置文件指定了安装界面上显示的如下信息:
- < Title > 标题栏上安装程序名称
- < Name > 显示在安装页面上应用程序的名称
- < Version > 应用程序的版本号
- < Publisher > 软件发布者
- < StartMenuDir > 添加到开始菜单默认程序组名称
- < TargetDir > 应用程序的安装目录
创建包信息文件
在packages
目录下com.man.ifw/meta目录下,package.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>AidTool</DisplayName>
<Description>Aid Device Tool</Description>
<Version>1.0.0-1</Version>
<ReleaseDate>2020-12-29</ReleaseDate>
<Default>true</Default>
<Script>installscript.qs</Script>
<Licenses>
<License name="Beer Public License Agreement" file="license.txt" />
</Licenses>
</Package>
各个元素分别表示如下含义:
- < DisplayName > 指定组件的名称
- < Description > 显示选中组件的描述信息
- < Version > 组件的版本号信息,可用作后期版本更新
- < ReleaseDate > 组件发布的日期
- < Default > 安装过程中组件是否默认选中,true表示默认选中,false默认补选中。
- < Script > JavaScript文件名,执行一些个性化的安装操作
- < Licenses > 添加许可文件,如果没有可以删除此段
license.txt文件创建
创建脚本文件
在packages
目录下com.man.ifw/meta目录下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()
{
gui.pageWidgetByObjectName("LicenseAgreementPage").entered.connect(changeLicenseLabels);
}
changeLicenseLabels = function()
{
page = gui.pageWidgetByObjectName("LicenseAgreementPage");
page.AcceptLicenseLabel.setText("Yes I do!");
page.RejectLicenseLabel.setText("No I don't!");
}
Component.prototype.createOperations = function()
{
//调用默认实现
component.createOperations();
if (systemInfo.productType === "windows") {
//添加桌面快捷方式
component.addOperation("CreateShortcut",
"@TargetDir@/AidTool.exe",
"@DesktopDir@/AidTool.lnk",
"workingDirectory=@TargetDir@");
//添加开始菜单快捷方式
component.addOperation("CreateShortcut",
"@TargetDir@/AidTool.exe",
"@StartMenuDir@/AidTool.lnk",
"workingDirectory=@TargetDir@");
}
}
准备库文件
打开Powershell
工具
cd build生成的xxx.exe目录下
#复制xx.exe文件到data目录下
cp ./xxx.exe AidTool_Installer/packages/data
cd AidTool_Installer/packages/data
C:\Qt\Qt5.13.2\5.13.2\mingw73_64\bin\windeployqt.exe AidTool.exe
#windeployqt.exe 工具依据编译工程选择的工具链确定
生成安装包
cd AidTool_Installer
binarycreator.exe -c .\config\config.xml -p .\packages AidTool -v
参考