Skip to content

Commit

Permalink
修改qmake编译,以及各桌面端打包脚本;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Oct 25, 2023
1 parent 3c7f976 commit a8f76c1
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 268 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- macos-latest
- ubuntu-latest
qt_ver:
- 6.5.2
- 6.6.0
build_type:
- "RelWithDebInfo"
generators:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- macos-latest
- ubuntu-latest
qt_ver:
- 6.5.2
- 6.6.0

steps:
- name: Install Qt
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
},
"cmake.generator": "Ninja",
"cmake.environment": {
"PATH": "C:\\Qt\\6.5.2\\msvc2019_64\\bin;"
"PATH": "C:\\Qt\\6.6.0\\msvc2019_64\\bin;"
}
}
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ project(
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(CMAKE_HOST_WIN32)
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.5.2\\msvc2019_64")
list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.6.0\\msvc2019_64")
elseif(CMAKE_HOST_APPLE)

elseif(CMAKE_HOST_UNIX)
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.5.2/gcc_64")
list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.6.0/gcc_64")
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@

## [Bootstarp](Bootstarp/)--程序开机自启动设置和检测;

1. Windows下读写注册表(HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run)实现开机自启动;
1. Windows下读写注册表实现开机自启动,有两个位置可以写入;
```powershell
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run //对于所有用户
HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run // 对于当前用户
```
2. MacOS下拷贝plist文件到~/Library/LaunchAgents/,使用launchctl load/unload命令实现开机自启动;
3. Ubuntu下拷贝.service和.timer文件到~/.config/systemd/user/,使用systemctl --user enable/disable命令实现开机自启动;
1. systemctl命令用于.timer文件,.timer文件用于定时执行.service文件,防止图形界面启动后,出现qxcbconnection: could not connect to display错误;
2. 不需要定时执行的.service文件,可以直接使用systemctl --user enable/disable命令实现开机自启动;
3. 也可以把/usr/share/Application/下的.desktop文件拷贝到~/.config/autostart/下,实现开机自启动(未验证);
3. Ubuntu下有两种方式:
1. 使用systemctl --user enable/disable命令实现开机自启动;
1. 拷贝.service和.timer文件到~/.config/systemd/user/,使用systemctl --user enable/disable命令实现开机自启动;
2. systemctl命令用于.timer文件,.timer文件用于定时执行.service文件,防止图形界面启动后,出现qxcbconnection: could not connect to display错误;
2. 把/usr/share/Application/下的.desktop文件拷贝到~/.config/autostart/下,实现开机自启动(未验证);

## [BubbleWindow](BubbleWindow/)——气泡式对话框,也可作工具提示(ToolTip);

Expand Down Expand Up @@ -138,6 +143,11 @@
## [packaging](packaging/)——打包脚本;
1. [macos](packaging/macos/)——macos qmake编译、打包dmg包脚本(`python`/`appdmg`);
2. [ubuntu](packaging/ubuntu/)——ubuntu qmake编译、打包AppImage/deb包脚本(`linuxdeployqt-continuous-x86_64.AppImage`/`dpkg-deb`);
1. [使用root权限打开应用程序的一种方法](packaging/ubuntu/opt/MyApp/MyApp.sh)
```shell
#!/bin/sh
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/MyApp/MyApp
```
3. [windows](packaging/windows/)——windows qmake编译、打包安装脚本(`Innosetup`);
1. `Innosetup` `signtool`

Expand Down
4 changes: 2 additions & 2 deletions packaging/macos/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

build_list = [
{
"qmake": r"/Users/fxy/Qt/6.5.2/macos/bin/qmake",
"qmake": r"/Users/fxy/Qt/6.6.0/macos/bin/qmake",
"qmake_params": r'"CONFIG+=qml_debug"',
"make": r"make",
"project": r"/Users/fxy/myapp/MyApp.pro",
"build_directory": r"/Users/fxy/myapp/build-MyApp-Desktop_Qt_6_5_2_macos_64bit-Release",
"build_directory": r"/Users/fxy/myapp/build-MyApp-Desktop_Qt_6_6_0_macos_64bit-Release",
}
]

Expand Down
158 changes: 86 additions & 72 deletions packaging/macos/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,85 +10,99 @@
import utils


build.build(build.build_list)
os.chdir(sys.path[0])

build.execute("cp -af ./../../src/bin-64/release/MyApp.app/ ./../packet/MyApp.app/")
build.execute("rm -rf ./../releases/MyApp.app")
build.execute(
"{0} ./../packet/MyApp.app -always-overwrite".format(
r"/Users/fxy/Qt/5.15.2/clang_64/bin/macdeployqt"
def build_program():
build.build(build.build_list)

os.chdir(sys.path[0])
build.execute("cp -af ./../../src/bin-64/release/MyApp.app/ ./../packet/MyApp.app/")
build.execute("rm -rf ./../releases/MyApp.app")


def deploy(program_path):
macdeployqt = r"/Users/fxy/Qt/6.6.0/clang_64/bin/macdeployqt"
build.execute("{0} {1} -always-overwrite".format(macdeployqt, program_path))


def sign():
certificate = "Developer ID Application: ******(******)"
entitlements = "./entitlements.plist"
build.execute("plutil -convert xml1 {0}".format(entitlements))
build.execute(
'security unlock-keychain -p "password" "$HOME/Library/Keychains/login.keychain"'
)
)
build.execute("cp -af ./../packet/MyApp.app ./../releases/MyApp.app")

# sign app
certificate = "Developer ID Application: ******(******)"
entitlements = "./entitlements.plist"
# format entitlements
build.execute("plutil -convert xml1 {0}".format(entitlements))
# unlock keychain
build.execute(
'security unlock-keychain -p "password" "$HOME/Library/Keychains/login.keychain"'
)
build.execute(
'codesign --options=runtime --timestamp --deep --force --verify --verbose --sign "{0}" "{1}"'.format(
certificate, "./../releases/MyApp.app"
build.execute(
'codesign --options=runtime --timestamp --deep --force --verify --verbose --sign "{0}" "{1}"'.format(
certificate, "./../releases/MyApp.app"
)
)
)
build.execute(
'codesign --options=runtime --timestamp --force --verify --verbose --sign "{0}" --entitlements "{1}" "{2}"'.format(
certificate,
entitlements,
"./../releases/MyApp.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess",
build.execute(
'codesign --options=runtime --timestamp --force --verify --verbose --sign "{0}" --entitlements "{1}" "{2}"'.format(
certificate,
entitlements,
"./../releases/MyApp.app/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess",
)
)
)
build.execute(
'codesign --options=runtime --timestamp --force --verify --verbose --sign "{0}" "{1}"'.format(
certificate, "./../releases/MyApp.app/Contents/MacOS/MyApp"
build.execute(
'codesign --options=runtime --timestamp --force --verify --verbose --sign "{0}" "{1}"'.format(
certificate, "./../releases/MyApp.app/Contents/MacOS/MyApp"
)
)
)

miniversion = "0.0.1"
current_time = time.strftime("%Y%m%d", time.localtime())
dmg_name = "MyApp{0}_{1}.dmg".format(miniversion, current_time)
out_dmg_path = "./../releases/{0}".format(dmg_name)
build.execute("cp -f ./../../src/app.icns ./../releases/app.icns")
build.execute("cp -f ./dmg.json ./../releases/dmg.json")
build.execute("rm -f {0}".format(out_dmg_path))
build.execute("appdmg ./../releases/dmg.json {0}".format(out_dmg_path))

build.execute(
"""xcrun altool --notarize-app --primary-bundle-id "com.youth.myapp" --username "[email protected]" --password "password" --file {0}""".format(
out_dmg_path


def main():
build_program()

os.chdir(sys.path[0])
deploy(sys.path[0] + "/../packet/MyApp.app")
build.execute("cp -af ./../packet/MyApp.app ./../releases/MyApp.app")
sign()

version = "0.0.1"
current_time = time.strftime("%Y%m%d", time.localtime())
dmg_name = "MyApp{0}_{1}.dmg".format(version, current_time)
out_dmg_path = "./../releases/{0}".format(dmg_name)
build.execute("cp -f ./../../src/app.icns ./../releases/app.icns")
build.execute("cp -f ./dmg.json ./../releases/dmg.json")
build.execute("rm -f {0}".format(out_dmg_path))
build.execute("appdmg ./../releases/dmg.json {0}".format(out_dmg_path))

build.execute(
"""xcrun altool --notarize-app --primary-bundle-id "com.youth.myapp" --username "[email protected]" --password "password" --file {0}""".format(
out_dmg_path
)
)

# generate update.json
json_path = "./../releases/update.json"
utils.generate_json(
version,
out_dmg_path,
dmg_name,
json_path,
)

# upload file
utils.upload_file(
"http://192.168.1.111:80/webdav/admin/Packages/MyApp/MacOS/{0}".format(
dmg_name
),
"admin",
"password",
out_dmg_path,
)
utils.upload_file(
"http://192.168.1.111:80/webdav/admin/Packages/MyApp/MacOS/update.json",
"admin",
"password.",
json_path,
)
)

# generate update.json
json_path = "./../releases/update.json"
utils.generate_json(
miniversion,
out_dmg_path,
dmg_name,
json_path,
)

# upload file
utils.upload_file(
"http://192.168.50.87:80/webdav/admin/Packages/MyApp/MacOS/{0}".format(dmg_name),
"admin",
"password",
out_dmg_path,
)
utils.upload_file(
"http://192.168.50.87:80/webdav/admin/Packages/MyApp/MacOS/update.json",
"admin",
"password.",
json_path,
)


if __name__ == "__main__":
main()

# sudo spctl -vvv --assess --type execute /Applications/MyApp.app
# 输出如下:
# /Applications/MyApp.app: accepted
# source=Notarized Developer ID
# origin=*********** (******)
# origin=Developer ID Application: ******(******)
4 changes: 2 additions & 2 deletions packaging/ubuntu/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

build_list = [
{
"qmake": r"/opt/Qt/6.5.2/gcc_64/bin/qmake",
"qmake": r"/opt/Qt/6.6.0/gcc_64/bin/qmake",
"qmake_params": r'"CONFIG+=qtquickcompiler"',
"make": r"make",
"project": r"/home/fxy/myapp/MyApp.pro",
"build_directory": r"/home/fxy/myapp/build-MyApp-Desktop_Qt_6_5_2_GCC_64bit-Release",
"build_directory": r"/home/fxy/myapp/build-MyApp-Desktop_Qt_6_6_0_GCC_64bit-Release",
}
]

Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions packaging/ubuntu/opt/MyApp/MyApp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/MyApp/MyApp
97 changes: 65 additions & 32 deletions packaging/ubuntu/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,71 @@
import utils


build.build(build.build_list)
os.chdir(sys.path[0])

build.execute("cp -rf ./../../src/bin-64/release/. ./../packet/opt/MyApp/")
build.execute("cp -rf ./DEBIAN ./../packet")
build.execute("cp -f MyApp.desktop ./../packet/opt/MyApp/")
build.execute("cp -f logo.png ./../packet/opt/MyApp/")

build.execute(
"cd ./../packet/opt/MyApp/ \n"
"export LD_LIBRARY_PATH=/home/fxy/myapp/bin-64/release/. \n"
"'/home/fxy/下载/linuxdeployqt-continuous-x86_64.AppImage' MyApp -always-overwrite -no-translations -qmake=/opt/Qt/6.5.2/gcc_64/bin/qmake -unsupported-allow-new-glibc -appimage \n"
)

miniversion = "0.0.1"
current_time = time.strftime("%Y%m%d", time.localtime())
deb_name = "MyApp{0}_{1}.deb".format(miniversion, current_time)
out_deb_path = "./../releases/{0}".format(deb_name)

build.execute("sed -i '/X-AppImage-Version/d' ./../packet/opt/MyApp/MyApp.desktop")
build.execute("rm -f {0}".format(out_deb_path))
build.execute("echo 123456 | sudo -S dpkg -b ./../packet/. {0}".format(out_deb_path))
build.execute("sudo chmod -R 777 ./../releases/")

# update.json uploadfile
json_path = "./../releases/update.json"
utils.generate_json(
miniversion,
out_deb_path,
deb_name,
json_path,
)
def build_program():
build.build(build.build_list)

os.chdir(sys.path[0])
copy_exe_cmd = r"cp -rf ./../../code/bin-64/release/. ./../packet/opt/MyApp/"
build.execute(copy_exe_cmd)
copy_exe_cmd = r"cp -rf ./DEBIAN ./../packet/"
build.execute(copy_exe_cmd)
copy_exe_cmd = r"cp -rf ./opt ./../packet/"
build.execute(copy_exe_cmd)
copy_exe_cmd = r"cp -f logo.png ./../packet/opt/MyApp/"
build.execute(copy_exe_cmd)


def deploy():
build.execute(
"cd ./../packet/opt/MyApp/ \n"
"export LD_LIBRARY_PATH=/home/fxy/work/code/myapp/code/bin-64/release/. \n"
"'/home/fxy/下载/linuxdeployqt-continuous-x86_64.AppImage' MyApp -always-overwrite -no-translations -qmake=/opt/Qt/6.6.0/gcc_64/bin/qmake -unsupported-allow-new-glibc -appimage\n"
)


def main():
build_program()

os.chdir(sys.path[0])
deploy()

version = "0.0.1"
current_time = time.strftime("%Y%m%d", time.localtime())
deb_name = "MyApp{0}_{1}.deb".format(version, current_time)
out_deb_path = "./../releases/{0}".format(deb_name)

build.execute("sed -i '/X-AppImage-Version/d' ./../packet/opt/MyApp/MyApp.desktop")
build.execute("rm -f {0}".format(out_deb_path))
build.execute(
"echo 123456 | sudo -S dpkg -b ./../packet/. {0}".format(out_deb_path)
)
build.execute("sudo chmod -R 777 ./../releases/")

# update.json uploadfile
json_path = "./../releases/update.json"
utils.generate_json(
version,
out_deb_path,
deb_name,
json_path,
)

# upload file
utils.upload_file(
"http://192.168.1.111:80/apps/wanyoucloud/index.php/61646D696E/admin/Packages/MyApp/Ubuntu/{0}".format(
deb_name
),
"admin",
"password.",
out_deb_path,
)
utils.upload_file(
"http://192.168.1.111:80/apps/wanyoucloud/index.php/61646D696E/admin/Packages/MyApp/Ubuntu/update.json",
"admin",
"password.",
json_path,
)


# dpkg -r MyApp
# dpkg -i MyApp_0.0.1_20230810.deb
Expand Down
2 changes: 0 additions & 2 deletions packaging/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

import os
import sys
import time
import hashlib
import json
Expand Down
Loading

0 comments on commit a8f76c1

Please sign in to comment.