Skip to content

Commit 2fb251a

Browse files
committed
feat: Test
1 parent f0a3ede commit 2fb251a

File tree

11 files changed

+191
-11
lines changed

11 files changed

+191
-11
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: CMake build release for linux
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release
8+
9+
env:
10+
BUILD_TYPE: Release
11+
12+
jobs:
13+
build-release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
with:
19+
submodules: 'recursive'
20+
token: ${{ secrets.CONTRIBUTORS_TOKEN }}
21+
- name: Install Qt
22+
# Installs the Qt SDK
23+
uses: jurplel/install-qt-action@v3
24+
with:
25+
version: 6.8.1
26+
host: 'linux'
27+
target: 'desktop'
28+
arch: 'linux_gcc_64'
29+
tools: 'tools_ninja'
30+
cache: true
31+
32+
- name: Install Ninja
33+
run: sudo apt install ninja-build clang -y
34+
35+
- name: Configure CMake
36+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
37+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
38+
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/package -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
39+
40+
# - name: Build
41+
# # Build your program with the given configuration
42+
# run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install
43+
44+
- uses: actions/upload-artifact@v4
45+
with:
46+
name: WingHexExplorer2-linux-release-build-cache
47+
path: ${{github.workspace}}/build
48+
49+
# - name: Install Packing Tools
50+
# run: sudo apt install fakeroot patchelf -y
51+
#
52+
# - name: Setup Python
53+
# uses: actions/setup-python@v2
54+
# with:
55+
# python-version: '3.8'
56+
# cache: 'pip'
57+
#
58+
# - name: Install Python packages
59+
# run: pip install -r ${{github.workspace}}/mkinstaller/linuxdeploy/requirements.txt
60+
#
61+
# - name: Deploy WingHexExplorer2
62+
# run: python ${{github.workspace}}/mkinstaller/linuxdeploy/deploy.py ${{github.workspace}}/build
63+
#
64+
# - name: +x for ld-linux
65+
# run: sudo ${{github.workspace}}/mkinstaller/linuxdeploy/add-ld-x.sh ${{github.workspace}}/build/package
66+
#
67+
# - name: create installer
68+
# run: bash ${{github.workspace}}/mkinstaller/linuxdeploy/build.sh ${{github.workspace}}/build/package
69+
#
70+
# - uses: actions/upload-artifact@v4
71+
# with:
72+
# name: WingHexExplorer2-linux-release-build-cache
73+
# path: ${{github.workspace}}/mkinstaller/linuxdeploy/build
74+
#
75+
# - name: Release
76+
# uses: softprops/action-gh-release@v2
77+
# if: startsWith(github.ref, 'refs/tags/')
78+
# with:
79+
# files: ${{github.workspace}}/mkinstaller/linuxdeploy/build/*.run
80+

.github/workflows/qt-build-test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: CMake build check
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
410

511
env:
612
BUILD_TYPE: Release

mkinstaller/deb/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
colorama==0.4.6
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
colorama==0.4.6

mkinstaller/linuxdeploy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
这个警告尤其注意,它在你打包目录的`lib`目录下,你必须将警告中的文件加上可执行权限,否则部署之后的程序因该文件没有可执行权限导致无法执行。 **为啥不放到自动化脚本是因为修改权限需要 root,除非你用桌面的文件属性设置。**
1414

15-
完成部署之后,你就可以打包了,执行`build.sh`这个脚本,要把你 **打包的目录** 作为参数,执行完之后,它会在打包工具目录下创建`build`目录生成一个`WingHexExplorer2-installer.run`文件和一个`payload.tar.gz`文件,前者是安装包,后者是生成安装包中间产物,是对你打包目录进行压缩的一个压缩包。
15+
完成部署之后,你就可以打包了,执行`build.sh`这个脚本,要把你 **打包的目录** 作为参数,执行完之后,它会在打包工具目录下创建`build`目录生成一个文件名格式与`WingHexExplorer2-vx.x.x-xxx-installer.run`类似的文件和一个`payload.tar.gz`文件,前者是安装包,后者是生成安装包中间产物,是对你打包目录进行压缩的一个压缩包。

mkinstaller/linuxdeploy/WingHexExplorer2.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@
22

33
SCRIPT_DIR="/opt/WingHexExplorer2"
44
cd "$SCRIPT_DIR" || exit 1
5-
env LD_LIBRARY_PATH="$SCRIPT_DIR/lib" "$SCRIPT_DIR/WingHexExplorer2" "$@"
5+
6+
ABS_PATHS=()
7+
8+
# Iterate through each argument
9+
for path in "$@"; do
10+
abs_path=$(realpath "$path" 2>/dev/null)
11+
12+
if [ -z "$abs_path" ]; then
13+
abs_path=$(readlink -f "$path" 2>/dev/null || echo "$path")
14+
fi
15+
16+
ABS_PATHS+=("$abs_path")
17+
done
18+
19+
env LD_LIBRARY_PATH="$SCRIPT_DIR/lib" "$SCRIPT_DIR/WingHexExplorer2" "${ABS_PATHS[@]}"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
F_RED="\e[31m"
4+
A_DEFAULT="\033[0m"
5+
6+
BUILD_PATH="$1"
7+
8+
if [ "$(id -u)" -ne 0 ]; then
9+
echo -e "$F_RED Please run this script as root or using sudo! $A_DEFAULT"
10+
exit 1
11+
fi
12+
13+
if [ ! -d "$BUILD_PATH" ]; then
14+
echo -e "$F_RED Not exists: $BUILD_PATH$A_DEFAULT"
15+
fi
16+
17+
LD_FILE="$BUILD_PATH/LD_PATH"
18+
ld_file=$(<"$LD_FILE")
19+
20+
if [ -z "$ld_file" ]; then
21+
echo -e "$F_RED LD_PATH not exists $A_DEFAULT"
22+
exit 1
23+
fi
24+
25+
ld_path="$BUILD_PATH/lib/$ld_file"
26+
27+
if [ ! -e "$ld_path" ]; then
28+
echo -e "$F_RED LD_PATH is INVALID $A_DEFAULT"
29+
exit 1
30+
fi
31+
32+
chattr +x "$ld_path"
33+
34+
exit 0

mkinstaller/linuxdeploy/build.sh

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,56 @@ if [ "$#" -ne 1 ]; then
1111
echo "$F_GREEN Usage: $0 <Path>$A_DEFAULT"
1212
exit 1
1313
fi
14-
if [ ! -d "$1" ]; then
15-
echo -e "$F_RED Not exists: $1$A_DEFAULT"
14+
15+
BUILD_PATH="$1"
16+
17+
if [ ! -d "$BUILD_PATH" ]; then
18+
echo -e "$F_RED Not exists: $BUILD_PATH$A_DEFAULT"
1619
fi
1720
if [ ! -d build ]; then
1821
mkdir build
1922
fi
2023

2124
cd build || exit 1
2225

26+
VERSION_FILE="$BUILD_PATH/VERSION"
27+
LD_FILE="$BUILD_PATH/LD_PATH"
28+
29+
version=$(<"$VERSION_FILE")
30+
ld_file=$(<"$LD_FILE")
31+
32+
if [ -z "$version" ]; then
33+
echo -e "$F_RED VERSION file not exists $A_DEFAULT"
34+
exit 1
35+
fi
36+
37+
if [ -z "$ld_file" ]; then
38+
echo -e "$F_RED LD_PATH not exists $A_DEFAULT"
39+
exit 1
40+
fi
41+
42+
ld_path="$BUILD_PATH/lib/$ld_file"
43+
44+
if [ ! -e "$ld_path" ]; then
45+
echo -e "$F_RED LD_PATH is INVALID $A_DEFAULT"
46+
exit 1
47+
fi
48+
49+
if [ ! -x "$ld_path" ]; then
50+
echo -e "$F_RED $ld_file is not EXECUTABLE !!! $A_DEFAULT"
51+
exit 1
52+
fi
53+
54+
rm "$VERSION_FILE"
55+
rm "$LD_FILE"
56+
2357
set -e
2458

25-
fakeroot tar czvf payload.tar.gz -C "$1" .
59+
fakeroot tar czvf payload.tar.gz -C "$BUILD_PATH" .
2660

2761
arch=$(uname -m)
2862

29-
PACKAGE_NAME="WingHexExplorer2-$arch-installer.run"
63+
PACKAGE_NAME="WingHexExplorer2-v$version-$arch-installer.run"
3064

3165
cat "$SCRIPT_DIR/installheader.sh" payload.tar.gz > "$PACKAGE_NAME"
3266

mkinstaller/linuxdeploy/deploy.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def main():
146146
create_dir(os.path.join(installer_path_exec, "scripts"))
147147
create_dir(os.path.join(installer_path_exec, "aslib"))
148148

149+
shutil.copyfile(version_file_src, os.path.join(
150+
installer_path_exec, "VERSION"))
151+
149152
shutil.copytree(os.path.join(installer_path, "share"),
150153
os.path.join(installer_path_exec, "share"), dirs_exist_ok=True)
151154

@@ -180,8 +183,10 @@ def main():
180183
Fore.RED + "[Error] dynamic linker/loader can not be determined!" + Style.RESET_ALL)
181184
exit(-3)
182185

186+
ld_exec = ld_execs[0]
187+
183188
ret = run_command_interactive(
184-
["patchelf", "--set-interpreter", f"./lib/{ld_execs[0]}", exemain_src])
189+
["patchelf", "--set-interpreter", f"./lib/{ld_exec}", exemain_src])
185190
if (ret != 0):
186191
print(
187192
Fore.RED + "[Error] patchelf error!" + Style.RESET_ALL)
@@ -201,10 +206,12 @@ def main():
201206

202207
print(Fore.GREEN + ">> Deployment finished..." + Style.RESET_ALL)
203208

204-
ld_path = os.path.join(installer_path_exec, "lib", ld_execs[0])
209+
ld_path = os.path.join(installer_path_exec, "lib", ld_exec)
205210
if (os.access(ld_path, os.X_OK) == False):
206-
print(Fore.YELLOW + f"[Warn] {
207-
ld_execs[0]} has no executable permission! You should set it for running a deployed program!" + Style.RESET_ALL)
211+
print(Fore.YELLOW + f"[Warn] {ld_exec} has no executable permission! You should set it for running a deployed program!" + Style.RESET_ALL)
212+
213+
with open(os.path.join(installer_path_exec, "LD_PATH"), "w") as ld_file:
214+
ld_file.write(ld_exec)
208215

209216
exit(0)
210217

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
colorama==0.4.6

0 commit comments

Comments
 (0)