summaryrefslogtreecommitdiff
path: root/packaging/make-deb.sh
blob: a7e7817b04dfad95aeca54307c01a937dafa2c62 (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
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
#!/bin/bash

# Checks

DEBIAN_DIR=packaging/debian
VERSION=`cat version.txt`
PKG_REVISION=1
ARCH=amd64
if [ `uname -i` != 'x86_64' ]
then
    ARCH=i386
fi
echo "Arch: $ARCH"

DEBROOT=freshmemory_${VERSION}-${PKG_REVISION}_${ARCH}

if [ ! -x freshmemory ]
then
    echo "Error: Executable 'freshmemory' doesn't exist"
    exit 1
fi

if [ -x ${DEBROOT} ]
then
    sudo rm -rf ${DEBROOT}
fi

strip freshmemory

lrelease -silent freshmemory.pro

mkdir -p $DEBROOT/DEBIAN
cp ${DEBIAN_DIR}/control $DEBROOT/DEBIAN
cp ${DEBIAN_DIR}/conffiles $DEBROOT/DEBIAN
cp ${DEBIAN_DIR}/postinst $DEBROOT/DEBIAN
cp ${DEBIAN_DIR}/prerm $DEBROOT/DEBIAN

mkdir -p $DEBROOT/usr/bin
cp freshmemory $DEBROOT/usr/bin

mkdir -p $DEBROOT/etc/xdg/freshmemory
cp doc/config/freshmemory.ini $DEBROOT/etc/xdg/freshmemory

mkdir -p $DEBROOT/usr/share/freshmemory
cp --parents tr/*.qm $DEBROOT/usr/share/freshmemory

cp ${DEBIAN_DIR}/freshmemory.xml $DEBROOT/usr/share/freshmemory

# Copying Linux platform files

DEBDOCDIR=$DEBROOT/usr/share/doc/freshmemory
mkdir -p $DEBDOCDIR
cp AUTHORS $DEBDOCDIR
cp ${DEBIAN_DIR}/copyright $DEBDOCDIR
cp README $DEBDOCDIR
cp ${DEBIAN_DIR}/changelog.Debian $DEBDOCDIR
gzip --best $DEBDOCDIR/changelog.Debian

DEBMANDIR=$DEBROOT/usr/share/man/man1
mkdir -p $DEBMANDIR
cp ${DEBIAN_DIR}/freshmemory.1 $DEBMANDIR
gzip --best $DEBMANDIR/freshmemory.1

mkdir -p $DEBROOT/usr/share/applications
cp ${DEBIAN_DIR}/freshmemory.desktop $DEBROOT/usr/share/applications
mkdir -p $DEBROOT/usr/share/pixmaps
cp images/freshmemory.png $DEBROOT/usr/share/pixmaps

# Patching control file

PKGSIZE=`du -s --exclude DEBIAN $DEBROOT| cut -f1`
echo "Package size: $PKGSIZE"

CONTROL_TARGET=$DEBROOT/DEBIAN/control
CONTROL_DIFF=${DEBIAN_DIR}/control.diff
cp /dev/null $CONTROL_DIFF

VERSION_NUMSTR=`grep "Version" -n $CONTROL_TARGET`
VERSION_LINE=`echo $VERSION_NUMSTR | cut -d: -f1`
VERSION_STR=`echo $VERSION_NUMSTR | cut -d: -f2-3`
echo "@@ -$VERSION_LINE,1 +$VERSION_LINE,1 @@" >> $CONTROL_DIFF
echo "-$VERSION_STR" >> $CONTROL_DIFF
echo "+Version: $VERSION-1" >> $CONTROL_DIFF

SIZE_NUMSTR=`grep "Installed-Size" -n $CONTROL_TARGET`
SIZE_LINE=`echo $SIZE_NUMSTR | cut -d: -f1`
SIZE_STR=`echo $SIZE_NUMSTR | cut -d: -f2-3`
echo "@@ -$SIZE_LINE,1 +$SIZE_LINE,1 @@" >> $CONTROL_DIFF
echo "-$SIZE_STR" >> $CONTROL_DIFF
echo "+Installed-Size: $PKGSIZE" >> $CONTROL_DIFF

ARCH_NUMSTR=`grep "Architecture" -n $CONTROL_TARGET`
ARCH_LINE=`echo $ARCH_NUMSTR | cut -d: -f1`
ARCH_STR=`echo $ARCH_NUMSTR | cut -d: -f2-3`
echo "@@ -$ARCH_LINE,1 +$ARCH_LINE,1 @@" >> $CONTROL_DIFF
echo "-$ARCH_STR" >> $CONTROL_DIFF
echo "+Architecture: $ARCH" >> $CONTROL_DIFF

patch $CONTROL_TARGET < $CONTROL_DIFF

# Patching desktop file

DESKTOP_TARGET=$DEBROOT/usr/share/applications/freshmemory.desktop
DESKTOP_DIFF=${DEBIAN_DIR}/desktop.diff
cp /dev/null $DESKTOP_DIFF

VERSION_NUMSTR=`grep "Version" -n $DESKTOP_TARGET`
VERSION_LINE=`echo $VERSION_NUMSTR | cut -d: -f1`
VERSION_STR=`echo $VERSION_NUMSTR | cut -d: -f2-3`
echo "@@ -$VERSION_LINE,1 +$VERSION_LINE,1 @@" >> $DESKTOP_DIFF
echo "-$VERSION_STR" >> $DESKTOP_DIFF
echo "+Version=$VERSION" >> $DESKTOP_DIFF

patch $DESKTOP_TARGET < $DESKTOP_DIFF

# Access rights

sudo chown root:root -R ${DEBROOT}
sudo chmod g-w -R ${DEBROOT}
sudo chmod -x ${DEBROOT}/etc/xdg/freshmemory/freshmemory.ini

# Make deb

dpkg-deb -b ${DEBROOT} ${DEBROOT}.deb
lintian ${DEBROOT}.deb