forked from pilight/pilight
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen_package.sh
116 lines (84 loc) · 3.25 KB
/
gen_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
#!/usr/bin/env bash
#
# pilight core
#
ARCH=$1;
NAME="pilight"
if [ $# -eq 2 ] && [ "$2" = "debug" ]; then
NAME="pilight-dbg"
fi
mkdir -p deb
mv *.deb deb
cd deb
DEBVER=$(git describe --always | sed -e 's/^v//g');
VERSION=$(echo $DEBVER | sed -e 's/-g.*//g');
WEBGUI=$(cat ../libs/webgui/version.txt)
dpkg -X pilight-8.0.10-Linux-pilight.deb source
dpkg -e pilight-8.0.10-Linux-pilight.deb control
mkdir -p source/etc/init.d
mkdir -p source/etc/systemd/system
mkdir -p source/etc/init
cp ../res/init/pilight.sysv source/etc/init.d/pilight
cp ../res/init/pilight.systemd source/etc/systemd/system/pilight.service
cp ../res/init/pilight.upstart source/etc/init/pilight.conf
cp ../res/pilight.pem source/etc/pilight/pilight.pem
cp ../res/deb/pilight/* control/
mv source/usr/local/lib/libpilight.so.* source/usr/local/lib/libpilight.so.$VERSION 2>/dev/null
SIZE=$(du -sk source | cut -f1)
if [ $# -eq 2 ] && [ "$2" = "debug" ]; then
CONFLICTS="pilight"
else
CONFLICTS="pilight-dbg"
fi
sed -i "s/@package@/$NAME/g" control/control
sed -i "s/@version@/$DEBVER/g" control/control
sed -i "s/@version@/$VERSION/g" control/postinst
sed -i "s/@version@/$VERSION/g" control/postrm
sed -i "s/@webgui@/$WEBGUI/g" control/control
sed -i "s/@arch@/$ARCH/g" control/control
sed -i "s/@size@/$SIZE/g" control/control
sed -i "s/@conflicts@/$CONFLICTS/g" control/control
if [ $# -eq 1 ] || [ "$2" != "debug" ]; then
if [[ $ARCH =~ amd64 ]]; then
find source/usr -type f -exec strip {} \; 2>/dev/null;
elif [[ $ARCH =~ armhf ]]; then
find source/usr -type f -exec arm-linux-gnueabihf-strip {} \; 2>/dev/null;
elif [[ $ARCH =~ i386 ]]; then
find source/usr -type f -exec strip {} \; 2>/dev/null;
elif [[ $ARCH =~ mips ]]; then
find source/usr -type f -exec mipsel-linux-gnu-strip {} \; 2>/dev/null;
fi
fi
find source -type f -exec md5sum {} \; | sed -e 's@source/@@g' -e "s/ / /g" > control/md5sums
tar -C control -czf control.tar.gz control md5sums postinst postrm preinst prerm
chmod 755 source/usr/local/sbin/*
chmod 755 source/usr/local/bin/*
chmod 644 source/etc/pilight/*
chown -R 0:0 source/usr
chown -R 0:0 source/etc
tar -C source -czf data.tar.gz usr etc
echo "2.0" > debian-binary
ar rcv tmp.deb debian-binary control.tar.gz data.tar.gz
mv tmp.deb $NAME""$DEBVER"_"$ARCH".deb";
rm -r control source debian-binary control.tar.gz data.tar.gz 1>/dev/null 2>/dev/null
#
# pilight webgui
#
dpkg -X pilight-8.0.10-Linux-webgui.deb source
dpkg -e pilight-8.0.10-Linux-webgui.deb control
cp ../res/deb/webgui/* control/
SIZE=$(du -sk source | cut -f1)
sed -i "s/@version@/$DEBVER/g" control/control
sed -i "s/@webgui@/$WEBGUI/g" control/control
sed -i "s/@arch@/$ARCH/g" control/control
sed -i "s/@size@/$SIZE/g" control/control
find source -type f -exec md5sum {} \; | sed -e 's@source/@@g' -e "s/ / /g" > control/md5sums
tar -C control -czf control.tar.gz control md5sums postinst postrm preinst prerm
chmod -R 755 source/usr/local/share/pilight/webgui/*
chown -R 33:33 source/usr/local/share/pilight/webgui/*
tar -C source -czf data.tar.gz usr
echo "2.0" > debian-binary
ar rcv tmp.deb debian-binary control.tar.gz data.tar.gz
mv tmp.deb "pilight-webgui"$WEBGUI"_"$ARCH".deb";
rm pilight-*-Linux-*.deb
rm -r control source debian-binary control.tar.gz data.tar.gz 1>/dev/null 2>/dev/null