-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-deb.sh
executable file
·92 lines (76 loc) · 3.54 KB
/
create-deb.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
#!/bin/bash
WORK_DIR=/tmp/jasmin-packager-deb
COMMONS_DIR=./commons
if [ $# -ne 2 ]; then
echo "Usage: $0 pypi-version debian-version"
echo "Example:"
echo "$0 0.6b19 0.6.19-1"
echo
echo "Tips:"
echo " - changelog have to be updated manually."
echo
exit 1
fi
PYPI_JASMIN_URL="http://jookies.net/jasmin-packaging/jasmin-$1.tar.gz"
[ -d $COMMONS_DIR ] || exit 10
# Reset work folder
[ -d $WORK_DIR ] && rm -rf $WORK_DIR
mkdir $WORK_DIR $WORK_DIR/package $WORK_DIR/jasmin
# Download and build jasmin
curl -o $WORK_DIR/jasmin.tgz "$PYPI_JASMIN_URL" || exit 11
tar zxf $WORK_DIR/jasmin.tgz -C $WORK_DIR
cd $WORK_DIR/jasmin-$1
python setup.py bdist || exit 12
cd -
# Prepare work folder
cp -r $COMMONS_DIR/DEBIAN $WORK_DIR/package/
## Documentation
mkdir -p $WORK_DIR/package/usr/share/doc/python-jasmin
cp $COMMONS_DIR/changelog $COMMONS_DIR/copyright $WORK_DIR/package/usr/share/doc/python-jasmin
cp $WORK_DIR/package/usr/share/doc/python-jasmin/changelog $WORK_DIR/package/usr/share/doc/python-jasmin/changelog.Debian
cp $WORK_DIR/jasmin-$1/README.rst $WORK_DIR/package/usr/share/doc/python-jasmin/
gzip --best $WORK_DIR/package/usr/share/doc/python-jasmin/changelog
gzip --best $WORK_DIR/package/usr/share/doc/python-jasmin/changelog.Debian
gzip --best $WORK_DIR/package/usr/share/doc/python-jasmin/README.rst
# Update package version
sed -i "s/%debversion%/$2/" $WORK_DIR/package/DEBIAN/control
## /etc folder
mkdir -p $WORK_DIR/package/etc/jasmin/resource $WORK_DIR/package/etc/jasmin/store
cp $WORK_DIR/jasmin-$1/misc/config/jasmin.cfg $WORK_DIR/package/etc/jasmin/
cp $WORK_DIR/jasmin-$1/misc/config/interceptor.cfg $WORK_DIR/package/etc/jasmin/
cp $WORK_DIR/jasmin-$1/misc/config/dlrlookupd.cfg $WORK_DIR/package/etc/jasmin/
cp $WORK_DIR/jasmin-$1/misc/config/dlr.cfg $WORK_DIR/package/etc/jasmin/
cp $WORK_DIR/jasmin-$1/misc/config/resource/* $WORK_DIR/package/etc/jasmin/resource/
## /usr folder
mkdir -p $WORK_DIR/package/usr/bin $WORK_DIR/package/usr/lib/python2.7/dist-packages
cp -r $WORK_DIR/jasmin-$1/build/lib.*/jasmin $WORK_DIR/package/usr/lib/python2.7/dist-packages/jasmin
cp $WORK_DIR/package/usr/lib/python2.7/dist-packages/jasmin/bin/jasmind.py $WORK_DIR/package/usr/bin/
cp $WORK_DIR/package/usr/lib/python2.7/dist-packages/jasmin/bin/interceptord.py $WORK_DIR/package/usr/bin/
cp $WORK_DIR/package/usr/lib/python2.7/dist-packages/jasmin/bin/dlrd.py $WORK_DIR/package/usr/bin/
cp $WORK_DIR/package/usr/lib/python2.7/dist-packages/jasmin/bin/dlrlookupd.py $WORK_DIR/package/usr/bin/
## /lib folder
mkdir -p $WORK_DIR/package/lib/systemd/system
cp $WORK_DIR/jasmin-$1/misc/config/systemd/*.service $WORK_DIR/package/lib/systemd/system/
# Remove unneeded files
find $WORK_DIR/package -name ".gitignore" | xargs rm -f
# Create md5sums
cd $WORK_DIR/package;
find usr -type f -exec md5sum {} \; > md5sums
find lib -type f -exec md5sum {} \; >> md5sums
cd -
mv $WORK_DIR/package/md5sums $WORK_DIR/package/DEBIAN
# Fix file & folder permissions
find $WORK_DIR/package -type d | xargs chmod 755
find $WORK_DIR/package -type f | xargs chmod 644
chmod 755 $WORK_DIR/package/DEBIAN/preinst
chmod 755 $WORK_DIR/package/DEBIAN/postinst
chmod 755 $WORK_DIR/package/DEBIAN/prerm
chmod 755 $WORK_DIR/package/DEBIAN/postrm
chmod 755 $WORK_DIR/package/usr/bin/jasmind.py
chmod 755 $WORK_DIR/package/usr/bin/interceptord.py
chmod 755 $WORK_DIR/package/usr/bin/dlrd.py
chmod 755 $WORK_DIR/package/usr/bin/dlrlookupd.py
# Build package
fakeroot dpkg-deb --build $WORK_DIR/package
mv $WORK_DIR/package.deb packages/python-jasmin-$2_all.deb
lintian packages/python-jasmin-$2_all.deb