/
package.sh
executable file
·227 lines (216 loc) · 8.95 KB
/
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
225
226
227
#!/bin/bash
scriptname=`readlink -e "$0"`
scriptpath=`dirname "$scriptname"`
scriptargs=("$@")
set -e
#options
strip=
while (( "$#" >= 1 )) ; do
case $1 in
--nostrip)
strip="_nostrip"
;;
--strip)
strip=
;;
*)
echo "Error invalid option $1"
echo valid options: --strip --nostrip
exit 2
;;
esac
shift||rc=$?
done
gitbasedir=`git rev-parse --show-toplevel`
# This will get projname and destdir
. "$scriptpath/getdestdir.source"
gitpath="$PWD"
sourcedir=$destdir
if [[ "$sourcedir" == "" ]] ; then
echo Before running this the latest version must be built
echo with --prefix=/usr --runprefix=/usr and installed
echo Parameter 1 = SUBRELEASE number
echo Run this from the git source directory
exit 2
fi
sourcedir=`readlink -f "$sourcedir"`
if [[ "$SUBRELEASE" == "" ]] ; then SUBRELEASE=0 ; fi
gitver=`git -C "$gitpath" describe --dirty|cut -c2-`
# gitbranch=`git branch|grep "^\* "|cut -b3-`
gitbranch=`git branch | grep '*'| cut -f2 -d' '`
if [[ "$gitbranch" == '(HEAD' ]] ; then
gitbranch=`git branch | grep '*'| cut -f3 -d' '`
fi
# example of packagever 30-Pre-545-g51d6fdf
packagever=`env LD_LIBRARY_PATH=$sourcedir/usr/lib $sourcedir/usr/bin/mythutil --version |grep "MythTV Version"|cut -d ' ' -f 4|cut -c2-`
packagebranch=`env LD_LIBRARY_PATH=$sourcedir/usr/lib $sourcedir/usr/bin/mythutil --version |grep "MythTV Branch"|cut -d ' ' -f 4`
echo Package branch: $packagebranch, git branch: $gitbranch
if [[ "$packagever" != "$gitver" && "$packagever" != "$gitver"-dirty ]] ; then
echo ERROR Package version $packagever does not match git version $gitver
exit 2
fi
# Change dash to tilde in some cases
# Note that according to debian (with any numbers or letters)
# 30-Pre > 30
# 30~Pre < 30
# 30-Pre < 30.0
packagever=`echo $packagever|sed 's/-pre/~pre/'`
# Skip this check for 30 because there are already
# some builds out there with 30-Pre.
# If the release version is 30.0 it will be OK.
if [[ "$packagever" != 30-Pre* ]] ; then
packagever=`echo $packagever|sed 's/-Pre/~Pre/'`
fi
packagever=`echo $packagever|sed 's/-rc/~rc/'`
packagerel=$packagever-$SUBRELEASE
gitbasedir=`git -C "$gitpath" rev-parse --show-toplevel`
installdir=`dirname "$gitbasedir"`
arch=`dpkg-architecture -q DEB_TARGET_ARCH`
codename=`lsb_release -c|cut -f 2`
source=
# This expects that remote tracking branches for official
# repositories start with "mythtv"
if [[ "$packagebranch" != master && "$packagebranch" != fixes* ]] ; then
source="test_"
fi
case $projname in
mythtv)
packagename=mythtv-light_${source}${packagerel}_${arch}_$codename$strip
echo Package $packagename
if [[ -f $installdir/$packagename.deb || -d $installdir/$packagename ]] ; then
echo $installdir/$packagename already exists - incrementing SUBRELEASE number
let SUBRELEASE=SUBRELEASE+1
export SUBRELEASE
exec "$scriptname" "${scriptargs[@]}"
fi
rm -rf $installdir/$packagename $installdir/$packagename.deb
cp -a "$sourcedir/" "$installdir/$packagename/"
mkdir -p $installdir/$packagename/DEBIAN
if [[ "$strip" != "_nostrip" ]] ; then
strip -g `find $installdir/$packagename/usr/bin/ -type f -executable`
strip -g `find $installdir/$packagename/usr/lib/ -type f -executable -name '*.so*'`
fi
deps="libexiv2-27, "
if [[ "$codename" == buster ]] ; then
deps="libexiv2-14, "
fi
cat >$installdir/$packagename/DEBIAN/control <<FINISH
Package: mythtv-light
Version: $packagerel
Section: graphics
Priority: optional
Architecture: $arch
Essential: no
Installed-Size: `du -B1024 -d0 $installdir/$packagename | cut -f1`
Maintainer: Peter Bennett <pbennett@mythtv.org>
Depends: $deps libtag1v5, libavahi-compat-libdnssd1, libqt5widgets5, libqt5script5, libqt5sql5-mysql, libqt5xml5, libqt5network5, libqt5webkit5, pciutils, libva-x11-1 | libva-x11-2, libva-glx1 | libva-glx2, libqt5opengl5, libdbi-perl, libdbd-mysql-perl, libnet-upnp-perl, libcec3 | libcec4 | libcec6, libfftw3-double3, libfftw3-single3, libass5 | libass9, libfftw3-3, libraw1394-11, libiec61883-0, libavc1394-0, fonts-liberation, libva-drm1 | libva-drm2, libmp3lame0, libxv1, libpulse0, libhdhomerun3 | libhdhomerun4, libxnvctrl0, libsamplerate0, libbluray1 | libbluray2, liblzo2-2, libio-socket-inet6-perl, libxml-simple-perl, python3-lxml, python3-mysqldb, python3-future , python3-requests, python3-requests-cache, libxinerama1, libzip4 | libzip5, libsoundtouch1
Conflicts: mythtv-common, mythtv-frontend, mythtv-backend
Homepage: http://www.mythtv.org
Description: MythTV Light
Lightweight package that installs MythTV in one package, front end
and backend. Does not install database or services.
FINISH
if [[ "$arch" != armhf ]] ; then
mkdir -p $installdir/$packagename/usr/share/applications/
cat >$installdir/$packagename/usr/share/applications/mythtv.desktop \
<<FINISH
[Desktop Entry]
Name=MythTV Frontend
Comment=A frontend for all content on a mythtv-backend
GenericName=MythTV Viewer
Exec=/usr/bin/mythfrontend --logpath /tmp
Type=Application
Encoding=UTF-8
Icon=/usr/share/pixmaps/mythtv.png
Categories=GNOME;Application;AudioVideo;Audio;Video
FINISH
cat >$installdir/$packagename/usr/share/applications/mythtv-setup.desktop \
<<FINISH
[Desktop Entry]
Name=MythTV Backend Setup
Comment=Used to configure a backend
GenericName=mythtv-setup
Exec=@env@/usr/bin/mythtv-setup --logpath /tmp
Type=Application
Encoding=UTF-8
Icon=/usr/share/pixmaps/mythtv.png
Categories=GTK;System;Settings
X-AppInstall-Package=mythtv
FINISH
mkdir -p $installdir/$packagename/usr/share/pixmaps/
cp -f $scriptpath/mythtv.png $installdir/$packagename/usr/share/pixmaps/
mkdir -p $installdir/$packagename/usr/share/menu/
cat >$installdir/$packagename/usr/share/menu/mythtv-frontend \
<<FINISH
?package(mythtv-frontend):needs="X11" section="Applications/Graphics" \
title="MythTV" command="/usr/bin/mythfrontend"
FINISH
fi
cd $installdir
chmod -R g-w,o-w $packagename
fakeroot dpkg-deb --build $packagename
# Do not rm $packagename because it is needed for plugins build
echo $PWD
ls -ld ${packagename}*
;;
mythplugins)
mythtvpackagename=mythtv-light_${source}${packagerel}_${arch}_$codename$strip
packagename=mythplugins-light_${source}${packagerel}_${arch}_$codename$strip
echo Package $packagename
if [[ -f $installdir/$packagename.deb ]] ; then
echo $installdir/$packagename already exists - incrementing SUBRELEASE number
let SUBRELEASE=SUBRELEASE+1
export SUBRELEASE
exec "$scriptname" "${scriptargs[@]}"
fi
if [[ ! -d $installdir/$mythtvpackagename ]] ; then
echo $installdir/$mythtvpackagename does not exist.
echo Build mythtv package first
exit 2
fi
rm -rf $installdir/$packagename $installdir/$packagename.deb
cp -a "$sourcedir/" "$installdir/$packagename/"
# Remove mythtv files so that only plugin files remain
cd $installdir/$packagename
(cd $installdir/$mythtvpackagename ; find . \( -type f -o -type l \) -print0) | xargs -0 rm -f
rc=0
while [[ "$rc" == 0 ]] ; do
find . -type d -empty -print0 | xargs -0 rmdir -v || rc=$?
done
mkdir -p $installdir/$packagename/DEBIAN
if [[ "$strip" != "_nostrip" ]] ; then
strip -g -v `find $installdir/$packagename/usr/bin/ -type f -executable`
strip -g -v `find $installdir/$packagename/usr/lib/ -type f -executable`
fi
cat >$installdir/$packagename/DEBIAN/control <<FINISH
Package: mythplugins-light
Version: $packagerel
Section: graphics
Priority: optional
Architecture: $arch
Essential: no
Installed-Size: `du -B1024 -d0 $installdir/$packagename | cut -f1`
Maintainer: Peter Bennett <pbennett@mythtv.org>
Depends: mythtv-light, perl, libimage-size-perl, perlmagick, libxml-parser-perl, libxml-sax-perl, libcarp-clan-perl, libsoap-lite-perl, libdate-manip-perl, libdate-calc-perl, libwww-perl, libxml-simple-perl, libdatetime-format-iso8601-perl, libjson-perl, libxml-xpath-perl, mjpegtools, dvdauthor, genisoimage, dvd+rw-tools, python3-pil, python3-mysqldb, pmount, python3-feedparser, python3-pycurl
Conflicts: mythtv-common, mythtv-frontend, mythtv-backend
Homepage: http://www.mythtv.org
Description: MythTV Plugins Light
MythTV plugins for the MythTV Light package. MythTV Light must be installed
before this package. The following plugins are included:
MythArchive
MythBrowser
MythGallery
MythGame
MythMusic
MythNetvision
MythNews
MythWeather
MythZoneMinder
FINISH
cd $installdir
chmod -R g-w,o-w $packagename
fakeroot dpkg-deb --build $packagename
echo $PWD
ls -ld ${packagename}*
;;
esac