summaryrefslogtreecommitdiff
path: root/pkg/build_deb.sh
diff options
context:
space:
mode:
authorBen Fuhrmannek2014-10-01 15:13:30 +0200
committerBen Fuhrmannek2014-10-01 15:13:30 +0200
commit3159694378333c08c73d4fcd4b73725c02249750 (patch)
tree973bc2f3521bbf3b346b1dbb85f4dcf2bbf42fa6 /pkg/build_deb.sh
parent8f2433d78347b2f1542e95652fa74d38346fb6ec (diff)
added script to build binary debian package
Diffstat (limited to 'pkg/build_deb.sh')
-rwxr-xr-xpkg/build_deb.sh119
1 files changed, 119 insertions, 0 deletions
diff --git a/pkg/build_deb.sh b/pkg/build_deb.sh
new file mode 100755
index 0000000..d4a44fa
--- /dev/null
+++ b/pkg/build_deb.sh
@@ -0,0 +1,119 @@
1#!/bin/bash
2
3_exit() {
4 echo "[E] bye."
5 exit 1
6}
7
8yn_or_exit() {
9 echo -n "[?] OK? [y] "
10 read yn
11 if [ "$yn" != "" -a "$yn" != "y" ]; then
12 _exit
13 fi
14}
15
16##
17
18echo "[*] checking prerequisites..."
19for i in phpize make install fakeroot php-config dpkg-deb dpkg-architecture; do
20 if [ "`which $i`" == "" ]; then
21 echo "[E] please install '$i' and try again."
22 _exit
23 fi
24done
25
26##
27
28HERE=`(cd $(dirname $0); pwd)`
29SUHOSIN=$HERE/..
30ROOT=$HERE/tmp
31PKGDIR=$HERE
32PHP_EX=`php-config --extension-dir`
33eval `dpkg-architecture -l`
34VERSION=${SUHOSIN_VERSION:-$1}
35
36if [ "$VERSION" == "" ]; then
37 echo "[E] please set SUHOSIN_VERSION, e.g. $0 0.9.36-1~dev1"
38 _exit
39fi
40
41echo "[*] -----------------------------------------------------------"
42echo "[+] suhosin dir: $SUHOSIN"
43echo "[+] tmp dir: $ROOT"
44echo "[+] PHP extension dir: $PHP_EX"
45echo "[+] architecture: $DEB_HOST_ARCH"
46echo "[+] suhosin deb version: $VERSION"
47echo "[+] pkg output dir: $PKGDIR"
48yn_or_exit
49
50if [ ! -f "$SUHOSIN/modules/suhosin.so" ]; then
51 echo "[+] Cannot find suhosin.so. I will try to build it."
52 yn_or_exit
53
54 if [ ! -f "$SUHOSIN/configure" ]; then
55 echo "[*] phpize"
56 cd $SUHOSIN
57 phpize || _exit
58 fi
59
60 if [ ! -f "$SUHOSIN/Makefile" ]; then
61 echo "[*] configure"
62 cd $SUHOSIN
63 ./configure --enable-suhosin-experimental
64 fi
65
66 echo "[*] make"
67 make clean
68 make -C $SUHOSIN || _exit
69fi
70
71##
72
73echo "[*] deb"
74
75if [ -d "$ROOT" ]; then
76 echo "[+] tmp dir $ROOT already exists. Delete?"
77 yn_or_exit
78 rm -rf $ROOT
79fi
80
81##
82
83mkdir -p $ROOT/DEBIAN
84echo "9" >$ROOT/DEBIAN/compat
85cat >$ROOT/DEBIAN/control <<EOF
86Package: php5-suhosin-extension
87Section: php
88Priority: extra
89Maintainer: Ben Fuhrmannek <ben@sektioneins.de>
90Homepage: http://www.suhosin.org/
91Conflicts: php5-suhosin
92Description: advanced protection system for PHP5
93 This package provides a PHP hardening module.
94 .
95 Suhosin is an advanced protection system for PHP installations. It was
96 designed to protect servers and users from known and unknown flaws in PHP
97 applications and the PHP core. Suhosin comes in two independent parts, that
98 can be used separately or in combination. The first part is a small patch
99 against the PHP core, that implements a few low-level protections against
100 bufferoverflows or format string vulnerabilities and the second part is a
101 powerful PHP extension that implements all the other protections.
102 .
103 This Package provides the suhosin extension only.
104EOF
105
106echo "Architecture: $DEB_HOST_ARCH" >>$ROOT/DEBIAN/control
107echo "Version: $VERSION" >>$ROOT/DEBIAN/control
108
109install -d -g 0 -o 0 $ROOT$PHP_EX
110install -g 0 -o 0 $SUHOSIN/modules/suhosin.so $ROOT$PHP_EX
111install -d -g 0 -o 0 $ROOT/usr/share/doc/php5-suhosin-extension
112install -g 0 -o 0 -m 644 $SUHOSIN/suhosin.ini $ROOT/usr/share/doc/php5-suhosin-extension/suhosin.ini.example
113install -d -g 0 -o 0 $ROOT/etc/php5/mods-available
114sed -e 's/^;extension=/extension=/' $SUHOSIN/suhosin.ini >$ROOT/etc/php5/mods-available/suhosin.ini
115chown root:root $ROOT/etc/php5/mods-available/suhosin.ini
116
117fakeroot dpkg-deb -b $ROOT $PKGDIR
118
119echo "[*] done."