-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_debian_package.sh
executable file
·226 lines (185 loc) · 6.25 KB
/
build_debian_package.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/bin/bash
# ARCH=$(dpkg --print-architecture)
# make clean
# make
VERSION=0.1.4
TAG=v${VERSION}
if [ -d deb_root ]; then
rm -rf deb_root
fi
function create_debian_folder() {
PKG_ARCH=$1
DEB_PKG_ROOT=$2
if [ -d ${DEB_PKG_ROOT} ]; then
rm -rf ${DEB_PKG_ROOT}
fi
mkdir -pv ${DEB_PKG_ROOT}/{DEBIAN,etc/{gwc,default,systemd/user},usr/sbin}
cat > ${DEB_PKG_ROOT}/DEBIAN/control<< EOF
Package: gst-webrtc-camera
Version: ${VERSION}
Architecture: ${PKG_ARCH}
Maintainer: Michael Liu <yjdwbj@gmail.com>
Installed-Size: 1421
Depends: libglib2.0-0 (>= 2.74),
gstreamer1.0-nice,
gstreamer1.0-x (>= 1.22),
gstreamer1.0-opencv (>= 1.22),
gstreamer1.0-plugins-bad (>= 1.22),
gstreamer1.0-plugins-good (>= 1.22),
gstreamer1.0-plugins-base (>= 1.22),
gstreamer1.0-plugins-ugly (>= 1.22),
libgstreamer-plugins-bad1.0-0 (>= 1.22),
libgstreamer-plugins-base1.0-0 (>= 1.22),
libgstreamer-opencv1.0-0 (>= 1.22),
libgstreamer1.0-0 (>= 1.22),
libsoup-3.0-0 (>= 3.2.2),
libjson-glib-1.0-0 (>= 1.6),
sqlite3 (>= 3.40),
libudev1
Section: misc
Priority: optional
Homepage: https://github.com/yjdwbj/
Description: webrtc camera base on gstreamer,
Gst-webrtc-camera project base on gstreamer,project function cover the offical's tutorial and more.
ex: hlssink,udpsink,appsink,splitmuxsink, and webrtc. It's privider offer webrtc camera and hls access
and also record audio and video to file triggered by timer or some signal.
EOF
if [ ${PKG_ARCH} == "arm" ]; then
sed -i "/^Architecture:/!b;cArchitecture: armhf" ${DEB_PKG_ROOT}/DEBIAN/control
fi
cat > ${DEB_PKG_ROOT}/DEBIAN/postinst <<EOF
#!/bin/bash
GWC_USER_PATH=/home/\${SUDO_USER}/.config/gwc/webroot
USER_SYSTEMD=/home/\${SUDO_USER}/.config/systemd/user/default.target.wants
if [ ! -d \${USER_SYSTEMD} ]; then
mkdir -pv \${USER_SYSTEMD}
fi
chown \${SUDO_USER}:\${SUDO_USER} -R /home/\${SUDO_USER}/.config
if [ ! -d \${GWC_USER_PATH} ]; then
echo "Not found old config files, then create new."
mkdir -pv \${GWC_USER_PATH}
cp -a /etc/gwc/config.example \${GWC_USER_PATH}/config.json
cp -a /etc/gwc/webroot/* \${GWC_USER_PATH}/webroot/
cp -a /etc/gwc/*.sh \${GWC_USER_PATH}/
cd \${GWC_USER_PATH}/
./create-server-cert.sh
./add_user.sh -u test -p test -r lcy-gsteramer-camera -d \${GWC_USER_PATH}/webrtc.db
chown \${SUDO_USER}:\${SUDO_USER} -R \${GWC_USER_PATH}
else
cp -a /etc/gwc/webroot/* \${GWC_USER_PATH}/webroot/
fi
su - \${SUDO_USER} \
-c "export XDG_RUNTIME_DIR=/run/user/\${SUDO_UID} DBUS_SESSION_BUS_ADDRESS='unix:path=\${XDG_RUNTIME_DIR}/bus' ;\
systemctl --user daemon-reload; systemctl --user start gwc; systemctl --user start webrtc-gwc"
exit 0
EOF
chmod 755 ${DEB_PKG_ROOT}/DEBIAN/postinst
cat > ${DEB_PKG_ROOT}/etc/default/rtsp-gwc<<EOF
# Default settings for rtsp-gwc.
# systemctl --user status rtsp-gwc
RTSP_URL=http://192.168.1.30
RTSP_USER=admin
RTSP_PWD=admin
RTSP_PORT=9002
EOF
cat > ${DEB_PKG_ROOT}/etc/default/webrtc-gwc<<EOF
# Default settings for webrtc-sendonly.
# systemctl --user status webrtc-gwc
CAPS=video/x-raw,width=1280,height=720,framerate=10/1,format=YUY2
VIDEO_PATH=/mnt/nfs
UDPHOST=127.0.0.1
WEB_PORT=9001
AUTH_USER=admin
AUTH_PWD=admin
# 10 mintues
MAX_TIME=10
EOF
cat > ${DEB_PKG_ROOT}/etc/systemd/user/webrtc-gwc.service <<EOF
[Unit]
Description=Gstreamer webrtc camera
Documentation=https://github.com/yjdwbj/gst-webrtc-camera
After=multi-user.target
[Service]
EnvironmentFile=/etc/default/webrtc-gwc
ExecStart=/usr/sbin/webrtc-sendonly -c \${CAPS} -u \${AUTH_USER} -p \${AUTH_PWD} --port=\${WEB_PORT} --udphost=\${UDPHOST}
Type=simple
StandardOutput=append:/tmp/webrtc-sendoly.log
StandardError=append:/tmp/webrtc-sendoly.log
[Install]
WantedBy=default.target
EOF
chmod 755 ${DEB_PKG_ROOT}/etc/systemd/user/webrtc-gwc.service
cat > ${DEB_PKG_ROOT}/etc/systemd/user/gwc.service <<EOF
[Unit]
Description=Gstreamer webrtc camera
Documentation=https://github.com/yjdwbj/gst-webrtc-camera
After=multi-user.target
[Service]
ExecStart=/usr/sbin/gwc
Restart=no
Type=simple
StandardOutput=append:/tmp/gwc.log
StandardError=append:/tmp/gwc.log
[Install]
WantedBy=default.target
EOF
chmod 755 ${DEB_PKG_ROOT}/etc/systemd/user/gwc.service
cat > ${DEB_PKG_ROOT}/etc/systemd/user/rtsp-gwc.service <<EOF
[Unit]
Description=Rtsp redirect by gstreamer webrtc
Documentation=https://github.com/yjdwbj/gst-webrtc-camera
After=multi-user.target
[Service]
EnvironmentFile=/etc/default/rtsp-gwc
ExecStart=/usr/sbin/rtspsrc-webrtc -c \${RTSP_URL} -u \${RTSP_USER} -p \${RTSP_PWD} --port=\${RTSP_PORT}
Restart=no
Type=simple
StandardOutput=append:/tmp/rtsp-gwc.log
StandardError=append:/tmp/rtsp-gwc.log
[Install]
WantedBy=default.target
EOF
chmod 755 ${DEB_PKG_ROOT}/etc/systemd/user/rtsp-gwc.service
}
function build_target() {
TARGET_ARCH=$1
case $TARGET_ARCH in
arm)
ARCH=${TARGET_ARCH}
CROSS_COMPILE=arm-linux-gnueabi-
CC=${CROSS_COMPILE}gcc
SYSROOT=${HOME}/3TB-DISK/gitlab/docker-cross-compile-qt5/builds/riotboard/debian-4.0-stable/debian-armhf
;;
arm64)
ARCH=${TARGET_ARCH}
CROSS_COMPILE=aarch64-linux-gnu-
CC=${CROSS_COMPILE}gcc
SYSROOT=${HOME}/3TB-DISK/gitlab/docker-cross-compile-qt5/builds/sun50i_a64-repo/debian-4.0-bookworm/debian-arm64
;;
amd64)
ARCH=${TARGET_ARCH}
unset CROSS_COMPILE
unset CC
unset SYSROOT
;;
*)
echo "build native mode"
esac
local DEB_PKG_ROOT=deb_root/${TARGET_ARCH}
make clean
make ARCH=${ARCH} SYSROOT=${SYSROOT}
create_debian_folder ${TARGET_ARCH} "${DEB_PKG_ROOT}"
cp gwc webrtc-sendonly rtspsrc-webrtc ${DEB_PKG_ROOT}/usr/sbin/
cp -a webroot create-server-cert.sh add_user.sh config.example ${DEB_PKG_ROOT}/etc/gwc
hash_tag=$(git rev-parse --short HEAD)
TARGET_FILE=../gwc-git-$(date +%Y-%m-%d)_${hash_tag}_${TAG}_${TARGET_ARCH}.deb
[ -f ${TARGET_FILE} ] && rm -rf ${TARGET_FILE}
dpkg-deb --root-owner-group -b ${DEB_PKG_ROOT} ${TARGET_FILE}
./upload-github-release-asset.sh tag="Latest" filename=${TARGET_FILE}
}
for arch in amd64 arm64 arm
do
build_target $arch
done
echo "package done!!!"
exit 0