summaryrefslogtreecommitdiff
path: root/tools/packages/debian.sh
blob: 58d0260281689b5fc4138c73626b0c021b1ba108 (plain)
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
#!/bin/sh

PWD=`pwd`
VERSION=`cat PORTABLE_VERSION | perl -ne 'chomp and print'`
DEB_VERSION=`cat PORTABLE_VERSION | perl -ne 'chomp and print' | sed 's/-/~/'`
BUILD=`cat PORTABLE_BUILD | perl -ne 'chomp and print'`
ARCH=`uname -m | perl -ne 'chomp and print'`
INDIR=$PWD/static/$ARCH/deadbeef-$VERSION
TEMPDIR=$PWD/package_temp/$ARCH/debian-$VERSION
OUTDIR=$PWD/package_out/$ARCH/debian

if [ "$ARCH" = "i686" ] ; then
    DEB_ARCH=i386
elif [ "$ARCH" = "x86_64" ] ; then
    DEB_ARCH=amd64
else
    DEB_ARCH=unknown
fi

# make dirs
rm -rf $TEMPDIR
mkdir -p $TEMPDIR
mkdir -p $OUTDIR

# copy files
cp -r $INDIR/* $TEMPDIR/
# rm unneeded files
rm $TEMPDIR/opt/deadbeef/lib/deadbeef/*.la
for i in $TEMPDIR/opt/deadbeef/lib/deadbeef/*.so.0.0.0; do
    n=$TEMPDIR/opt/deadbeef/lib/deadbeef/`basename $i .0.0.0`
    mv $i $n
    strip --strip-unneeded $n
done
strip --strip-unneeded $TEMPDIR/opt/deadbeef/bin/deadbeef

rm $TEMPDIR/opt/deadbeef/lib/deadbeef/*.so.*
rm $TEMPDIR/opt/deadbeef/lib/deadbeef/*.a

# move icons and other shit to /usr
mkdir -p $TEMPDIR/usr/share/
mv $TEMPDIR/opt/deadbeef/share/applications $TEMPDIR/usr/share/
sed -i 's/Exec=deadbeef/Exec=\/opt\/deadbeef\/bin\/deadbeef/g' $TEMPDIR/usr/share/applications/deadbeef.desktop 
mv $TEMPDIR/opt/deadbeef/share/icons $TEMPDIR/usr/share/

# generate debian-binary
echo "2.0" >$TEMPDIR/debian-binary

# generate control
echo "Version: $VERSION-$BUILD" >$TEMPDIR/control
echo "Installed-Size: `du -sb $TEMPDIR | awk '{print int($1/1024)}'`" >>$TEMPDIR/control
echo "Architecture: $DEB_ARCH" >>$TEMPDIR/control
cat $PWD/tools/packages/deb_control >>$TEMPDIR/control

# copy postinst and postrm
cp $PWD/tools/packages/deb_postinst $TEMPDIR/postinst
cp $PWD/tools/packages/deb_postrm $TEMPDIR/postrm

# generate md5sums
cd $TEMPDIR
rm $TEMPDIR/md5sums
find ./opt -type f | while read i ; do
    md5sum "$i" | sed 's/\.\///g' >>$TEMPDIR/md5sums
done
cd $PWD

# generate shlibs
pwd
rm $TEMPDIR/shlibs
ls $TEMPDIR/opt/deadbeef/lib/deadbeef/*.so | while read i ; do
echo "`basename $i .so` 0 deadbeef" >>shlibs
done

# archive control
cd $TEMPDIR
chmod 644 control md5sums shlibs
chmod 755 postrm postinst
fakeroot -- tar zcvf ./control.tar.gz ./control ./md5sums ./postrm ./postinst ./shlibs
# archive data
fakeroot -- tar zcvf ./data.tar.gz ./opt ./usr

# make final archive
fakeroot -- ar cr $OUTDIR/deadbeef-static_${DEB_VERSION}-${BUILD}_$DEB_ARCH.deb debian-binary control.tar.gz data.tar.gz