Skip to content

Commit 895006f

Browse files
committed
Merge branch 'main' of github.com:600888/ems_simulate
2 parents 2a2f2f5 + f9e173b commit 895006f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

scripts/build_deb.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
# 配置
55
APP_NAME="ems-simulate"
66
VERSION="1.0.0"
7-
BUILD_DIR="build_deb"
7+
BUILD_DIR="build/build_deb"
88
OUTPUT_DIR="dist"
99
DEB_DIR="${BUILD_DIR}/${APP_NAME}_${VERSION}_amd64"
1010
# 修改为 /usr/share (对应 onedir 资源+二进制)
@@ -32,8 +32,12 @@ fi
3232

3333
# 3. 准备 Debian 包结构 (直接复制骨架)
3434
echo ">>> 准备 Debian 包结构..."
35+
# 创建构建目录
36+
mkdir -p "${DEB_DIR}"
37+
mkdir -p "${INSTALL_DIR}"
38+
mkdir -p "${DEB_DIR}/usr/bin"
3539
# 复制 debian 下的所有内容到构建目录
36-
cp -r debian/* "build/${DEB_DIR}/"
40+
cp -r debian/* "${DEB_DIR}/"
3741

3842
# 4. 构建后端 (PyInstaller)
3943
echo ">>> 构建后端 (PyInstaller)..."
@@ -50,7 +54,7 @@ pyinstaller --noconfirm --onedir --name "${APP_NAME//-/_}" --clean \
5054
--distpath "build/dist" \
5155
--workpath "build/build_pyinstaller" \
5256
--specpath "build" \
53-
--add-data "${PROJECT_ROOT}/config.ini:etc" \
57+
--add-data "${PROJECT_ROOT}/config.ini:." \
5458
--add-data "${PROJECT_ROOT}/www:www" \
5559
--hidden-import="uvicorn.logging" \
5660
--hidden-import="uvicorn.loops" \
@@ -66,25 +70,25 @@ pyinstaller --noconfirm --onedir --name "${APP_NAME//-/_}" --clean \
6670
# 5. 组装内容
6771
echo ">>> 组装 Debian 包..."
6872
# 复制 PyInstaller 生成的内容到 /usr/share/ems-simulate
69-
cp -r "build/dist/${APP_NAME//-/_}/"* "build/$INSTALL_DIR/"
73+
cp -r "build/dist/${APP_NAME//-/_}/"* "$INSTALL_DIR/"
7074

7175
# 创建 /usr/bin 下的软链接
72-
ln -sf "../share/${APP_NAME}/ems_simulate" "build/${DEB_DIR}/usr/bin/${APP_NAME}"
76+
ln -sf "../share/${APP_NAME}/ems_simulate" "${DEB_DIR}/usr/bin/${APP_NAME}"
7377

7478
# 权限设置和 Control 更新在后面...
7579
# 更新 Control 文件中的 Installed-Size
7680
# INSTALLED_SIZE=$(du -s "$INSTALL_DIR" | cut -f1)
7781
# echo "Installed-Size: $INSTALLED_SIZE" >> "${DEB_DIR}/DEBIAN/control"
7882

7983
# 5. 设置权限
80-
chmod 755 "build/${DEB_DIR}/DEBIAN/postinst" 2>/dev/null || true
81-
chmod 755 "build/${DEB_DIR}/DEBIAN/prerm" 2>/dev/null || true
82-
chmod 755 "build/${DEB_DIR}/DEBIAN/postrm" 2>/dev/null || true
84+
chmod 755 "${DEB_DIR}/DEBIAN/postinst" 2>/dev/null || true
85+
chmod 755 "${DEB_DIR}/DEBIAN/prerm" 2>/dev/null || true
86+
chmod 755 "${DEB_DIR}/DEBIAN/postrm" 2>/dev/null || true
8387

8488
# 6. 生成 .deb
8589
echo ">>> 生成 .deb 文件..."
8690
mkdir -p build/dist_deb
87-
dpkg-deb --build "build/$DEB_DIR" "build/dist_deb/${APP_NAME}_${VERSION}_amd64.deb"
91+
dpkg-deb --build "$DEB_DIR" "build/dist_deb/${APP_NAME}_${VERSION}_amd64.deb"
8892

8993
# 定义颜色
9094
RED='\033[0;31m'
@@ -114,4 +118,3 @@ else
114118
echo -e "${RED}❌ deb包构建失败${NC}"
115119
exit 1
116120
fi
117-

0 commit comments

Comments
 (0)