-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·89 lines (80 loc) · 2.72 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·89 lines (80 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
echo "========================================"
echo " Email Server 构建脚本 (Linux/Mac)"
echo "========================================"
# 检测操作系统
OS_TYPE=""
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS_TYPE="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS_TYPE="mac"
else
echo "[警告] 未知操作系统: $OSTYPE"
fi
# Linux 上检查并安装 binutils (提供 objdump)
if [[ "$OS_TYPE" == "linux" ]]; then
if ! command -v objdump &> /dev/null; then
echo "[依赖] objdump 未找到,正在尝试安装 binutils..."
# 检测包管理器并安装(优先使用 sudo,没有则直接运行)
INSTALL_CMD=""
if command -v apt-get &> /dev/null; then
INSTALL_CMD="apt-get update && apt-get install -y binutils"
elif command -v yum &> /dev/null; then
INSTALL_CMD="yum install -y binutils"
elif command -v dnf &> /dev/null; then
INSTALL_CMD="dnf install -y binutils"
elif command -v pacman &> /dev/null; then
INSTALL_CMD="pacman -S --noconfirm binutils"
elif command -v zypper &> /dev/null; then
INSTALL_CMD="zypper install -y binutils"
fi
if [[ -n "$INSTALL_CMD" ]]; then
# 检查是否有 sudo 且可用
if command -v sudo &> /dev/null && sudo -n true 2>/dev/null; then
eval "sudo $INSTALL_CMD"
elif [[ $EUID -eq 0 ]]; then
# 已经是 root 用户
eval "$INSTALL_CMD"
else
echo "[提示] 需要 root 权限安装 binutils,请手动执行:"
echo ""
echo " sudo $INSTALL_CMD"
echo ""
echo "安装完成后重新运行此脚本。"
exit 1
fi
else
echo "[错误] 无法识别包管理器,请手动安装 binutils"
exit 1
fi
if ! command -v objdump &> /dev/null; then
echo "[错误] binutils 安装失败"
exit 1
fi
echo "[依赖] binutils 安装成功"
fi
fi
# 检查 uv 是否安装
if ! command -v uv &> /dev/null; then
echo "[错误] uv 未安装,请先安装: pip install uv"
exit 1
fi
# 同步依赖
echo "[1/2] 同步依赖..."
uv sync
if [ $? -ne 0 ]; then
echo "[错误] 依赖同步失败"
exit 1
fi
# 构建 exe
echo "[2/2] 构建可执行文件..."
uv run pyinstaller EmailServer.spec --noconfirm
if [ $? -ne 0 ]; then
echo "[错误] 构建失败"
exit 1
fi
echo ""
echo "========================================"
echo " 构建成功!"
echo " 输出文件: dist/EmailServer"
echo "========================================"