forked from yeongpin/cursor-free-vip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
87 lines (72 loc) · 1.81 KB
/
build.sh
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
#!/bin/bash
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查并安装必要的依赖
check_dependencies() {
echo -e "${YELLOW}检查系统依赖...${NC}"
# 检查是否为 Ubuntu/Debian
if [ -f /etc/debian_version ]; then
# 检查并安装必要的包
PACKAGES="python3 python3-pip python3-venv"
for pkg in $PACKAGES; do
if ! dpkg -l | grep -q "^ii $pkg "; then
echo -e "${YELLOW}安装 $pkg...${NC}"
sudo apt-get update
sudo apt-get install -y $pkg
fi
done
else
echo -e "${RED}不支持的系统,请手动安装 python3, pip3 和 python3-venv${NC}"
exit 1
fi
}
# 创建并激活虚拟环境
setup_venv() {
echo -e "${GREEN}正在创建虚拟环境...${NC}"
python3 -m venv venv
echo -e "${GREEN}启动虚拟环境...${NC}"
. ./venv/bin/activate || source ./venv/bin/activate
}
# 安装依赖
install_dependencies() {
echo -e "${GREEN}安装依赖...${NC}"
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
}
# 构建程序
build_program() {
echo -e "${GREEN}开始构建...${NC}"
python3 build.py
}
# 清理
cleanup() {
echo -e "${GREEN}清理虚拟环境...${NC}"
deactivate 2>/dev/null || true
rm -rf venv
}
# 主程序
main() {
# 检查依赖
check_dependencies
# 设置虚拟环境
setup_venv
# 安装依赖
install_dependencies
# 构建
build_program
# 清理
cleanup
echo -e "${GREEN}完成!${NC}"
echo "按任意键退出..."
# 使用兼容的方式读取输入
if [ "$(uname)" = "Linux" ]; then
read dummy
else
read -n 1
fi
}
# 运行主程序
main