-
Notifications
You must be signed in to change notification settings - Fork 6
/
build_deb.sh
executable file
·58 lines (55 loc) · 3.19 KB
/
build_deb.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
#!/bin/sh
###############################################################################
# 定义Qt目录
QT_DIR=/opt/Qt6.2.0/6.2.0/gcc_64
# 定义opencv目录
OPENCV_DIR=/home/xiaoming/Desktop/opencv
###############################################################################
###############################################################################
# 定义版本号
YUVVIEWER_MAJARVERSION=$(< ./version.txt cut -d '.' -f 1)
YUVVIEWER_SUBVERSION=$(< ./version.txt cut -d '.' -f 2)
YUVVIEWER_REVISION=$(< ./version.txt cut -d '.' -f 3)
export PATH=$QT_DIR/bin:$PATH
export LD_LIBRARY_PATH=$OPENCV_DIR/lib:$QT_DIR/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$QT_DIR/plugins
export QML2_IMPORT_PATH=$QT_DIR/qml
# 合成版本号
YUVVIEWER_VERSION="V"$YUVVIEWER_MAJARVERSION$YUVVIEWER_SUBVERSION$YUVVIEWER_REVISION
# 编译
rm -rf .qmake.stash Makefile
lrelease ./YUVviewer.pro
qmake ./YUVviewer.pro -spec linux-g++ CONFIG+=qtquickcompiler
make clean
make -j8
# clean打包目录
rm -rf ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64
rm -f ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64.deb
# 构建打包目录
cp -r ./dpkg/YUVviewer ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64
# 使用linuxdeployqt拷贝依赖so库到打包目录
export QMAKE=$QT_DIR/bin/qmake
./tools/linuxdeploy-x86_64.AppImage --executable=./build_release/out/YUVviewer --appdir=./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt --plugin=qt
rm -rf ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/apprun-hooks
mv ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/usr ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer
mv ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/bin/YUVviewer ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/YUVviewer
mv ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/bin/qt.conf ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/qt.conf
rm -rf ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/bin
sed -i "s/Prefix = ..\//Prefix = .\//g" ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/qt.conf
chrpath -r "\$ORIGIN/./lib" ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/YUVviewer
rm -rf ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/share
cp ./img/ico.png ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/YUVviewer.png
mkdir -p ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer
cp -r ./test ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/opt/YUVviewer/test
# 配置打包信息
sed -i "s/#VERSION#/$YUVVIEWER_MAJARVERSION.$YUVVIEWER_SUBVERSION$YUVVIEWER_REVISION/g" ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/DEBIAN/control
cd ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64
SIZE=$(du -sh -B 1024 ./ | sed "s/.\///g")
cd -
InstalledSize=$SIZE
sed -i "s/#SIZE#/$InstalledSize/g" ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/DEBIAN/control
chmod 755 ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64/* -R
# 打包
dpkg -b ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64 ./dpkg/YUVviewer_Linux_"$YUVVIEWER_VERSION"_x86_64.deb
echo build success!
###############################################################################