Skip to content

Commit

Permalink
[更新安装程序和打包脚本]: 主要更新了CMake的workflow,改进了macOS和Ubuntu的打包过程,增加了Windows平台的…
Browse files Browse the repository at this point in the history
…打包支持。

- 更新了`.github/workflows/cmake.yml`文件,移除了7z打包步骤,改为检查包内容并上传。
- 修改了`.gitignore`文件,增加了对打包目录的忽略。
- 新增了macOS打包相关的`distribution.xml`,提供了安装向导的配置。
- 更新了macOS的`package.sh`脚本,增加了7z和pkg打包方式,并删除了排除文件的处理。
- 新增了macOS安装完成和欢迎页面的HTML文件。
- 新增了macOS的`preinstall`和`postinstall`脚本,处理应用的启动和结束。
- 新增了macOS的`utils.sh`脚本,提供了文件删除和Plist处理功能。
- 新增了Ubuntu的`DEBIAN`控制文件,配置了包信息和依赖。
- 更新了Ubuntu的`postinst`、`postrm`、`preinst`和`prerm`脚本,处理了应用权限和删除操作。
- 更新了Ubuntu的`Qt-App.desktop`和`Qt-App.sh`文件,配置了桌面条目和启动脚本。
- 新增了Windows平台的Inno Setup语言文件`ChineseSimplified.isl`,提供了简体中文翻译。
- 新增了Windows平台的安装脚本`app.iss`,配置了安装过程和参数。
- 更新了Windows平台的打包PowerShell脚本`package.ps1`,增加了7z打包和Inno Setup编译命令。
  • Loading branch information
RealChuan committed May 23, 2024
1 parent b42cf68 commit add9c79
Show file tree
Hide file tree
Showing 21 changed files with 772 additions and 15 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,16 @@ jobs:
sudo chmod 755 ./packaging/ubuntu/package.sh
./packaging/ubuntu/package.sh
- name: 7z package
- name: Check packages
shell: bash
run: |
ls -al ${{ env.PACKET_DIR }}
CURRENT_DATE=$(date '+%Y%m%d')
filename=Qt-App_${{ runner.os }}_${{ matrix.arch }}_${CURRENT_DATE}.7z
echo "artifactPath=$filename" >> $GITHUB_ENV
7z a -t7z -r -mx=9 -mmt ${filename} ${{ env.PACKET_DIR }}/*
ls -al ${{ env.RELEASES_DIR }}
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{matrix.arch}}-${{ matrix.build_type }}
path: ${{ env.artifactPath }}
path: ${{ env.RELEASES_DIR }}

release:
name: Release
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ tags
.vscode
bin-*
build
packet
releases
31 changes: 31 additions & 0 deletions packaging/macos/distribution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
<title>Qt-App</title>
<organization>org.youth</organization>
<domains enable_localSystem="true"/>
<options customize="never" require-scripts="true" rootVolumeOnly="true" />
<!-- Define documents displayed at various steps -->
<welcome file="welcome.html" mime-type="text/html" />
<conclusion file="conclusion.html" mime-type="text/html" />
<!-- List all component packages -->
<pkg-ref id="org.qt-app.client"
version="0"
auth="root">tmp.pkg</pkg-ref>
<!-- List them again here. They can now be organized
as a hierarchy if you want. -->
<choices-outline>
<line choice="default">
<line choice="org.qt-app.client"/>
</line>
</choices-outline>
<!-- Define each choice above -->
<choice id="default"/>
<choice
id="org.qt-app.client"
visible="true"
title="Qt-App"
description="A qt Application template"
start_selected="true">
<pkg-ref id="org.qt-app.client"/>
</choice>
</installer-gui-script>
27 changes: 22 additions & 5 deletions packaging/macos/package.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash -ex

cd "$(dirname "$0")"
source utils.sh

cd ../..
project_dir="$(pwd)"
echo "Current directory: ${project_dir}"
Expand All @@ -15,14 +17,29 @@ macdeployqt "${packet_dir}/Qt-App.app" -always-overwrite

ls -al "${packet_dir}/Qt-App.app/Contents/Frameworks"

# package with 7z
zip_path="${releases_dir}/Qt-App.7z"
7z a -t7z -r -mx=9 -mmt "${zip_path}" "${packet_dir}/Qt-App.app"

# package with pkg
version="0.1.1"
mkdir -p ${packet_dir}/output
# process_plist "${project_dir}/packaging/macos/distribution.xml"
sudo chmod -R +x ${project_dir}/packaging/macos/scripts
pkgbuild --root ${packet_dir}/Qt-App.app --identifier org.qt-app.client \
--version ${version} \
--scripts ${project_dir}/packaging/macos/scripts \
--ownership recommended ${packet_dir}/output/tmp.pkg \
--install-location /Applications/Qt-App.app
productbuild --distribution ${project_dir}/packaging/macos/distribution.xml \
--resources resources --package-path ${packet_dir}/output \
--version ${version} ${releases_dir}/Qt-App.pkg

# package with dmg
pip3 install dmgbuild

cd "${packet_dir}"
dmgbuild -s "${project_dir}/packaging/macos/dmgbuild.py" "Qt-App.app" "Qt-App.dmg"

# 排除的文件名
EXCLUDE_FILE="Qt-App.dmg"
find . -maxdepth 1 ! -name "$EXCLUDE_FILE" ! -name "." ! -name ".." -exec rm -rf -- {} +
cd "${project_dir}"
mv -v "${packet_dir}/Qt-App.dmg" "${releases_dir}"

echo "Deployment macos completed."
1 change: 1 addition & 0 deletions packaging/macos/resources/conclusion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Qt-App has been successfully installed.
1 change: 1 addition & 0 deletions packaging/macos/resources/welcome.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Welcome to the installation of Qt-App 0.1.1. Please press continue to proceed with the installation.
5 changes: 5 additions & 0 deletions packaging/macos/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -ex

echo "Postinstall script is not implemented for macOS."

exit 0
8 changes: 8 additions & 0 deletions packaging/macos/scripts/preinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh -ex

echo "Preinstall script is not implemented for macOS."

sudo killall -9 Qt-App || true
sudo killall -9 CrashReport || true

exit 0
56 changes: 56 additions & 0 deletions packaging/macos/utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash -ex

delete_file_or_dir() {
local target=$1

if [ -e "$target" ]; then
if [ -d "$target" ]; then
rm -rf "$target"
echo "Directory deleted: $target"
else
rm -f "$target"
echo "File deleted: $target"
fi
else
echo "Error: $target does not exist."
fi
}

process_plist() {
local plist_path="$1"

if [ -z "$plist_path" ]; then
echo "Error: Plist file path is not provided."
return 1
fi

if [ ! -f "$plist_path" ]; then
echo "Error: Plist file does not exist at path: $plist_path"
return 1
fi

echo "Converting plist to XML format..."
plutil -convert xml1 "$plist_path" 2>/dev/null

echo "Linting plist file..."
plutil -lint "$plist_path" 2>/dev/null

if [ $? -eq 0 ]; then
echo "Plist file processed successfully."
else
echo "Error occurred while processing plist file."
return 2
fi
}

notarize_app() {
local target=$1
if [ ! -f "$target" ]; then
echo "Error: $target does not exist."
exit 1
fi

xcrun notarytool submit $target --apple-id "******" \
--team-id "******" --password "******" --wait
xcrun stapler staple $target
}
9 changes: 9 additions & 0 deletions packaging/ubuntu/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: qt-app
Version: 0.1.1
Architecture: amd64
Description: qt-app
Section: admin
Priority: optional
Maintainer: https://github.com/RealChuan
Homepage: https://github.com/RealChuan/Qt-App
Depends: libc6 (>= 2.35)
8 changes: 8 additions & 0 deletions packaging/ubuntu/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh -e

chmod +x /opt/Qt-App/Qt-App
chmod +x /opt/Qt-App/Qt-App.sh
chmod 777 /opt/Qt-App/app.png
chmod 744 /usr/share/applications/Qt-App.desktop

exit 0
20 changes: 20 additions & 0 deletions packaging/ubuntu/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh -e

delete_file_or_dir() {
local target=$1

if [ -e "$target" ]; then
if [ -d "$target" ]; then
rm -rf "$target"
else
rm "$target"
fi
fi
}

if [ "$1" = "remove" -o "$1" = "purge" ]; then
delete_file_or_dir ~/.config/Youth/Qt-App
delete_file_or_dir ~/.config/Youth/CrashReport
fi

exit 0
6 changes: 6 additions & 0 deletions packaging/ubuntu/DEBIAN/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

killall -q -9 Qt-App || true
killall -q -9 CrashReport || true

exit 0
6 changes: 6 additions & 0 deletions packaging/ubuntu/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

killall -q -9 Qt-App || true
killall -q -9 CrashReport || true

exit 0
9 changes: 5 additions & 4 deletions packaging/ubuntu/Qt-App.desktop
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[Desktop Entry]
Type=Application
Name=Qt-App
Comment=A qt Application template
GenericName=Qt-App
Exec=AppRun %F
Icon=app
Comment=Edit this default file
Terminal=true
Type=Application
StartupNotify=false
StartupWMClass=Qt-App
Categories=Utility;
X-AppImage-Version=9e82467
2 changes: 2 additions & 0 deletions packaging/ubuntu/Qt-App.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/Qt-App/Qt-App
24 changes: 24 additions & 0 deletions packaging/ubuntu/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,28 @@ linuxdeployqt ${packet_dir}/Qt-App \
sudo chmod +x *.AppImage
cd "${project_dir}"

mv -v "${packet_dir}"/*.AppImage "$releases_dir"/Qt-App.AppImage

# package with 7z
zip_path="${releases_dir}/Qt-App.7z"
7z a -t7z -r -mx=9 -mmt "${zip_path}" "${packet_dir}"/*

# package with deb
mkdir -p "${project_dir}"/packaging/Qt-App/
mv -v "${packet_dir}"/* "${project_dir}"/packaging/Qt-App
mkdir -p "${packet_dir}"/opt
mv -v "${project_dir}"/packaging/Qt-App "${packet_dir}"/opt/
cp -rv "${project_dir}"/packaging/ubuntu/DEBIAN "${packet_dir}"/
cp -rv "${project_dir}"/packaging/ubuntu/usr "${packet_dir}"/
cp -v "${project_dir}"/packaging/ubuntu/Qt-App.sh "${packet_dir}"/opt/Qt-App/

sudo chmod -R +x "${packet_dir}"/DEBIAN
sudo chmod 777 "${packet_dir}"/opt/Qt-App/app.png
sudo chmod 744 "${packet_dir}"/usr/share/applications/Qt-App.desktop

deb_path="${releases_dir}/Qt-App.deb"
sudo dpkg -b ${packet_dir}/. ${deb_path}

sudo chmod -R +x ${releases_dir}

echo "Deployment ubuntu completed."
10 changes: 10 additions & 0 deletions packaging/ubuntu/usr/share/applications/Qt-App.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Name=Qt-App
Comment=A qt Application template
GenericName=Qt-App
Exec=/opt/Qt-App/Qt-App
Icon=/opt/Qt-App/app.png
Type=Application
StartupNotify=false
StartupWMClass=Qt-App
Categories=Utility;
Loading

0 comments on commit add9c79

Please sign in to comment.