Skip to content

Commit 4cde1f2

Browse files
committed
更新构建配置以支持新的 Linux x86和arm32v7 架构和改进文档说明。
1 parent a768479 commit 4cde1f2

File tree

2 files changed

+99
-22
lines changed

2 files changed

+99
-22
lines changed

.github/workflows/build.yml

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
include:
15+
# ----- Native Builds -----
1516
# ===== Linux =====
1617
- os: linux
1718
arch: x86_64
@@ -46,6 +47,20 @@ jobs:
4647
py_arch: arm64
4748
desc: macos-arm64
4849

50+
# ----- Emulated Builds (都运行在 ubuntu-22.04 x86_64 上) -----
51+
- os: linux
52+
arch: x86
53+
runs_on: ubuntu-22.04
54+
desc: linux-x86
55+
image: i386/debian:12
56+
platform: linux/386
57+
- os: linux
58+
arch: armv7
59+
runs_on: ubuntu-22.04
60+
desc: linux-armv7
61+
image: arm32v7/ubuntu:22.04
62+
platform: linux/arm/v7
63+
4964
runs-on: ${{ matrix.runs_on }}
5065

5166
permissions:
@@ -57,27 +72,96 @@ jobs:
5772
with:
5873
fetch-depth: 0
5974

60-
# 安装对应架构的 Python
61-
- name: Set up Python
75+
# ===================================================================
76+
# 分支 1: Native Builds (x86_64, arm64, windows, macos)
77+
# ===================================================================
78+
- name: Set up Python (Native)
79+
if: "!matrix.image" # 只在没有定义 matrix.image 的原生构建上运行
6280
uses: actions/setup-python@v5
6381
with:
6482
python-version: '3.12'
6583
architecture: ${{ matrix.py_arch }}
6684

67-
- name: Install dependencies
85+
- name: Install dependencies (Native)
86+
if: "!matrix.image"
6887
run: |
6988
python -m pip install --upgrade pip
7089
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
7190
pip install pyinstaller
7291
shell: bash
7392

74-
- name: Build with PyInstaller
93+
- name: Build with PyInstaller (Native)
94+
if: "!matrix.image"
7595
run: |
7696
mkdir -p dist
7797
pyinstaller --onefile --name TJUEcardSetup setup.py
7898
pyinstaller --onefile --noconsole --name TJUEcard TJUEcard_main.py
7999
shell: bash
80100

101+
# ===================================================================
102+
# 分支 2: Emulated Builds (x86, armv7)
103+
# ===================================================================
104+
- name: Set up QEMU
105+
if: "matrix.image"
106+
uses: docker/setup-qemu-action@v3
107+
108+
- name: Build with PyInstaller (Emulated)
109+
if: "matrix.image"
110+
run: |
111+
# 根据 matrix.arch 的值,决定 PIP_FLAG 的内容
112+
PIP_FLAG_VALUE=""
113+
if [ "${{ matrix.arch }}" = "x86" ]; then
114+
PIP_FLAG_VALUE="--break-system-packages"
115+
fi
116+
117+
# 将 PIP_FLAG_VALUE 作为环境变量传入容器
118+
docker run --rm --privileged \
119+
--platform ${{ matrix.platform }} \
120+
-v "${{ github.workspace }}":/workspace \
121+
-w /workspace \
122+
-e PIP_FLAG="${PIP_FLAG_VALUE}" \
123+
${{ matrix.image }} \
124+
sh -c ' \
125+
set -ex; \
126+
apt-get update; \
127+
apt-get install -y \
128+
python3 \
129+
python3-pip \
130+
git \
131+
build-essential \
132+
libffi-dev \
133+
python3-cryptography; \
134+
\
135+
ln -s /usr/bin/python3 /usr/bin/python || true; \
136+
\
137+
# 直接使用从外部传入的 PIP_FLAG 环境变量
138+
python -m pip install --upgrade pip ${PIP_FLAG}; \
139+
\
140+
if [ -f requirements.txt ]; then \
141+
if [ "${{ matrix.arch }}" = "x86" ]; then \
142+
echo "==> i386 environment: Installing dependencies from requirements.txt, excluding cryptography"; \
143+
grep -v "^cryptography" requirements.txt | xargs -r python -m pip install ${PIP_FLAG}; \
144+
else \
145+
echo "==> armv7 environment: Installing all dependencies from requirements.txt"; \
146+
python -m pip install -r requirements.txt ${PIP_FLAG}; \
147+
fi; \
148+
fi; \
149+
\
150+
pip install pyinstaller ${PIP_FLAG}; \
151+
\
152+
pyinstaller --onefile --name TJUEcardSetup setup.py; \
153+
pyinstaller --onefile --noconsole --name TJUEcard TJUEcard_main.py \
154+
'
155+
156+
- name: Fix file ownership
157+
if: "matrix.image" # 只在 Emulated 构建后运行
158+
run: |
159+
# The files created inside the container are owned by root.
160+
# Change ownership to the current runner user to avoid permission errors.
161+
sudo chown -R "$(id -u):$(id -g)" .
162+
shell: bash
163+
# ============ 从这里开始,所有分支的步骤合并 ============
164+
81165
# ===== 验证架构 =====
82166
- name: Check binary arch (Linux)
83167
if: runner.os == 'Linux'

README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
| 操作系统 | 支持架构 |
6767
|---------------|-------------------------------------------|
6868
| Windows 10+ | x86_64 |
69-
| Ubuntu 22.04+ | x86_64, arm64 |
69+
| Ubuntu 22.04+ | x86_64, arm64, x86, arm32v7 |
7070
| ~~macOS 13+~~ | ~~x86_64 (Intel), arm64 (Apple Silicon)~~ |
7171

7272
> ⚠ 其他 Linux 发行版未经验证,不保证能正常使用。
@@ -181,31 +181,24 @@
181181

182182
- **查询定时任务**
183183

184-
打开终端,输入以下命令查看当前 root 用户的 `LaunchAgent` 任务列表:
184+
打开终端,输入以下命令查看当前 root 用户的 `crontab` 任务列表:
185185

186186
```zsh
187-
sudo launchctl list
187+
sudo crontab -l
188188
```
189189

190190
- **取消定时任务**
191191

192-
1. 使用 `launchctl bootout` 命令停止并移除任务:
192+
打开终端,输入以下命令编辑当前 root 用户的 `crontab` 文件,并移除包含 `TJUEcard` 的相关行:
193+
```zsh
194+
sudo crontab -e
195+
```
193196

194-
```zsh
195-
sudo launchctl bootout system /Library/LaunchDaemons/com.tjuecard.automatic.plist
196-
```
197+
验证是否已移除:
197198

198-
2. 找到对应的配置文件并删除:
199-
200-
```zsh
201-
sudo rm /Library/LaunchDaemons/com.tjuecard.automatic.plist
202-
```
203-
204-
3. 验证是否已移除:
205-
206-
```zsh
207-
sudo launchctl list | grep tjuecard
208-
```
199+
```zsh
200+
sudo crontab -l | grep TJUEcard
201+
```
209202

210203
## ❗注意事项
211204

0 commit comments

Comments
 (0)