Skip to content

Commit 9bd45e0

Browse files
committed
feat: Test
1 parent f0a3ede commit 9bd45e0

File tree

11 files changed

+193
-19
lines changed

11 files changed

+193
-19
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
cache: true
30+
31+
- name: Configure CMake
32+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
33+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
34+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/package
35+
36+
- name: Build
37+
# Build your program with the given configuration
38+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install
39+
40+
- name: Install Packing Tools
41+
run: sudo apt install fakeroot patchelf -y
42+
43+
- name: Setup Python
44+
uses: actions/setup-python@v2
45+
with:
46+
python-version: '3.8'
47+
cache: 'pip'
48+
49+
- name: Install Python packages
50+
run: pip install -r ${{github.workspace}}/mkinstaller/linuxdeploy/requirements.txt
51+
52+
- name: Deploy WingHexExplorer2
53+
run: python ${{github.workspace}}/mkinstaller/linuxdeploy/deploy.py ${{github.workspace}}/build
54+
55+
- name: +x for ld-linux
56+
run: sudo ${{github.workspace}}/mkinstaller/linuxdeploy/add-ld-x.sh ${{github.workspace}}/build/package
57+
58+
- name: create installer
59+
run: bash ${{github.workspace}}/mkinstaller/linuxdeploy/build.sh ${{github.workspace}}/build/package
60+
61+
- uses: actions/upload-artifact@v4
62+
with:
63+
name: WingHexExplorer2-linux-release-build-cache
64+
path: ${{github.workspace}}/mkinstaller/linuxdeploy/build
65+
66+
- name: Release
67+
uses: softprops/action-gh-release@v2
68+
if: startsWith(github.ref, 'refs/tags/')
69+
with:
70+
files: ${{github.workspace}}/mkinstaller/linuxdeploy/build/*.run

.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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
exit 1
16+
fi
17+
18+
LD_FILE="$BUILD_PATH/LD_PATH"
19+
ld_file=$(<"$LD_FILE")
20+
21+
if [ -z "$ld_file" ]; then
22+
echo -e "$F_RED LD_PATH not exists $A_DEFAULT"
23+
exit 0
24+
fi
25+
26+
ld_path="$BUILD_PATH/lib/$ld_file"
27+
28+
if [ ! -e "$ld_path" ]; then
29+
echo -e "$F_RED LD_PATH is INVALID $A_DEFAULT"
30+
exit 1
31+
fi
32+
33+
chattr +x "$ld_path"
34+
35+
exit 0

mkinstaller/linuxdeploy/build.sh

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +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 [ -n "$ld_file" ]; then
38+
ld_path="$BUILD_PATH/lib/$ld_file"
39+
40+
if [ ! -e "$ld_path" ]; then
41+
echo -e "$F_RED LD_PATH is INVALID $A_DEFAULT"
42+
exit 1
43+
fi
44+
45+
if [ ! -x "$ld_path" ]; then
46+
echo -e "$F_RED $ld_file is not EXECUTABLE !!! $A_DEFAULT"
47+
exit 1
48+
fi
49+
50+
rm "$LD_FILE"
51+
fi
52+
53+
rm "$VERSION_FILE"
54+
2355
set -e
2456

25-
fakeroot tar czvf payload.tar.gz -C "$1" .
57+
fakeroot tar czvf payload.tar.gz -C "$BUILD_PATH" .
2658

2759
arch=$(uname -m)
2860

29-
PACKAGE_NAME="WingHexExplorer2-$arch-installer.run"
61+
PACKAGE_NAME="WingHexExplorer2-v$version-$arch-installer.run"
3062

31-
cat "$SCRIPT_DIR/installheader.sh" payload.tar.gz > "$PACKAGE_NAME"
63+
cat "$SCRIPT_DIR/installheader.sh" payload.tar.gz >"$PACKAGE_NAME"
3264

3365
echo -e "$F_GREEN>> $PACKAGE_NAME was created under build.$A_DEFAULT"
3466

mkinstaller/linuxdeploy/deploy.py

Lines changed: 23 additions & 11 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

@@ -175,17 +178,23 @@ def main():
175178
# in the end, start patching
176179
ld_execs = [filename for filename in os.listdir(os.path.join(
177180
installer_path_exec, "lib")) if filename.startswith("ld-linux")]
178-
if (len(ld_execs) != 1):
181+
182+
ld_count = len(ld_execs)
183+
if (ld_count > 1):
179184
print(
180185
Fore.RED + "[Error] dynamic linker/loader can not be determined!" + Style.RESET_ALL)
181186
exit(-3)
182187

183-
ret = run_command_interactive(
184-
["patchelf", "--set-interpreter", f"./lib/{ld_execs[0]}", exemain_src])
185-
if (ret != 0):
186-
print(
187-
Fore.RED + "[Error] patchelf error!" + Style.RESET_ALL)
188-
exit(-4)
188+
ld_exec = ""
189+
190+
if (ld_count == 1):
191+
ld_exec = ld_execs[0]
192+
ret = run_command_interactive(
193+
["patchelf", "--set-interpreter", f"./lib/{ld_exec}", exemain_src])
194+
if (ret != 0):
195+
print(
196+
Fore.RED + "[Error] patchelf error!" + Style.RESET_ALL)
197+
exit(-4)
189198

190199
print(Fore.GREEN + ">> Calculating checksum..." + Style.RESET_ALL)
191200

@@ -201,10 +210,13 @@ def main():
201210

202211
print(Fore.GREEN + ">> Deployment finished..." + Style.RESET_ALL)
203212

204-
ld_path = os.path.join(installer_path_exec, "lib", ld_execs[0])
205-
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)
213+
if(ld_count == 1):
214+
ld_path = os.path.join(installer_path_exec, "lib", ld_exec)
215+
if (os.access(ld_path, os.X_OK) == False):
216+
print(Fore.YELLOW + f"[Warn] {ld_exec} has no executable permission! You should set it for running a deployed program!" + Style.RESET_ALL)
217+
218+
with open(os.path.join(installer_path_exec, "LD_PATH"), "w") as ld_file:
219+
ld_file.write(ld_exec)
208220

209221
exit(0)
210222

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)