source: npl/internetserver/php/p

Last change on this file was f33f781, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

php7 and deps

  • Property mode set to 100755
File size: 10.5 KB
Line 
1#!/bin/bash
2
3# Build and package mod_php on Slackware.
4# by:  David Cantrell <david@slackware.com>
5# Modified for PHP 4-5 by volkerdi@slackware.com
6# Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2017, 2019, 2020, 2021  Patrick Volkerding, Sebeka, MN, USA
7# All rights reserved.
8#
9# Redistribution and use of this script, with or without modification, is
10# permitted provided that the following conditions are met:
11#
12# 1. Redistributions of this script must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14#
15#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
18#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26cd $(dirname $0) ; CWD=$(pwd)
27
28PKGNAM=php
29VERSION=${VERSION:-$(echo php-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
30ALPINE=2.25
31BUILD=${BUILD:-1}
32
33# Automatically determine the architecture we're building on:
34if [ -z "$ARCH" ]; then
35  case "$( uname -m )" in
36    i?86) export ARCH=i586 ;;
37    arm*) export ARCH=arm ;;
38    # Unless $ARCH is already set, use uname -m for all other archs:
39       *) export ARCH=$( uname -m ) ;;
40  esac
41fi
42
43# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
44# the name of the created package would be, and then exit. This information
45# could be useful to other scripts.
46if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
47  echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz"
48  exit 0
49fi
50
51NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}
52
53TMP=${TMP:-/tmp}
54PKG=$TMP/package-php/
55rm -rf $PKG
56mkdir -p $TMP $PKG
57
58if [ "$ARCH" = "i386" ]; then
59  SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
60  LIBDIRSUFFIX=""
61elif [ "$ARCH" = "i486" ]; then
62  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
63  LIBDIRSUFFIX=""
64elif [ "$ARCH" = "i586" ]; then
65  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
66  LIBDIRSUFFIX=""
67elif [ "$ARCH" = "s390" ]; then
68  SLKCFLAGS="-O2"
69  LIBDIRSUFFIX=""
70elif [ "$ARCH" = "x86_64" ]; then
71  SLKCFLAGS="-O2 -fPIC"
72  LIBDIRSUFFIX="64"
73else
74  SLKCFLAGS="-O2"
75  LIBDIRSUFFIX=""
76fi
77
78# Look for Kerberos on the machine and in any precompiled c-client.a:
79if /bin/ls /lib${LIBDIRSUFFIX}/libkrb5.so.? 1> /dev/null 2> /dev/null ; then
80  # Remove the c-client library if it doesn't contain Kerberos support:
81  if ! grep -q krb5_ /usr/local/lib${LIBDIRSUFFIX}/c-client/lib${LIBDIRSUFFIX}/c-client.a 2> /dev/null ; then
82    rm -rf /usr/local/lib${LIBDIRSUFFIX}/c-client
83  fi
84else
85  # Remove the c-client library if it contains Kerberos support:
86  if grep -q krb5_ /usr/local/lib${LIBDIRSUFFIX}/c-client/lib${LIBDIRSUFFIX}/c-client.a 2> /dev/null ; then
87    rm -rf /usr/local/lib${LIBDIRSUFFIX}/c-client
88  fi
89fi
90
91# we need to compile alpine to get c-client.a for IMAP support:
92IMAPLIBDIR=/usr/local/lib${LIBDIRSUFFIX}/c-client
93if [ -r $IMAPLIBDIR/lib${LIBDIRSUFFIX}/c-client.a ]; then
94  echo "Using IMAP library:"
95  ls -l $IMAPLIBDIR/lib${LIBDIRSUFFIX}/c-client.a
96  sleep 5
97else
98  ( cd $CWD/../alpine ; VERSION=${ALPINE} ; ./alpine.SlackBuild || exit 1 ) || exit 1
99  ( cd $TMP/alpine-${ALPINE}/imap/c-client
100    strip -g c-client.a
101    mkdir -p $IMAPLIBDIR/lib${LIBDIRSUFFIX}
102    cp c-client.a $IMAPLIBDIR/lib${LIBDIRSUFFIX}
103    mkdir -p $IMAPLIBDIR/include
104    cp *.h $IMAPLIBDIR/include
105  )
106fi
107
108# Set Kerberos build option:
109if /bin/ls /lib${LIBDIRSUFFIX}/libkrb5.so.? 1> /dev/null 2> /dev/null ; then
110  KRB5_OPTION="--with-kerberos"
111else
112  unset KRB5_OPTION
113fi
114
115mkdir -p $PKG/etc/httpd
116mkdir -p $PKG/etc/php.d
117# A trick from DaMouse to enable building php into $PKG.
118# We'll remove this later on.
119cat /etc/httpd/original/httpd.conf > $PKG/etc/httpd/httpd.conf
120if [ ! -e /etc/httpd/original/httpd.conf ]; then
121  echo "FATAL:  no /etc/httpd/original/httpd.conf found."
122  exit 1
123fi
124
125cd $TMP
126rm -rf php-$VERSION
127tar xvf $CWD/php-$VERSION.tar.xz || exit 1
128cd php-$VERSION || exit 1
129
130# cleanup:
131find . -name "*.orig" -delete
132
133if [ "$ARCH" = "s390" ]; then
134  zcat $CWD/php.configure.s390.diff.gz | patch -p1 || exit
135fi
136
137# Fixup perms/owners:
138chown -R root:root .
139find . \
140  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
141  -exec chmod 755 {} \+ -o \
142  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
143  -exec chmod 644 {} \+
144
145find . -name "*.h" -exec chmod 644 {} \+
146
147# Sometimes they ship a few of these:
148find . -name "*.orig" -exec rm {} \+
149
150# Patch ini files:
151zcat $CWD/php.ini-development.diff.gz | patch -p1 --verbose || exit 1
152zcat $CWD/php.ini-development.diff.gz | patch -p1 --verbose php.ini-production || exit 1
153zcat $CWD/php-fpm.conf.diff.gz | patch -p1 --verbose || exit 1
154
155# Fix for imap API change:
156zcat $CWD/php.imap.api.diff.gz | patch -p1 --verbose || exit 1
157
158# Use enchant-2:
159zcat $CWD/php.enchant-2.patch.gz | patch -p1 --verbose || exit 1
160export ENCHANT_CFLAGS="-I/usr/include/enchant-2"
161export ENCHANT_LIBS="-lenchant-2"
162
163# Install the build folder into /usr/lib$LIBDIRSUFFIX/php/build
164# and adapt phpize accordingly:
165sed -i "s|build$|php/build|" scripts/Makefile.frag
166sed -i "s|build\"$|php/build\"|" scripts/phpize.in
167
168# NOTE: Added -DU_USING_ICU_NAMESPACE=1 to CXXFLAGS, which should be a temporary
169# requirement. See the link below:
170# http://site.icu-project.org/download/61#TOC-Migration-Issues
171
172# -DU_DEFINE_FALSE_AND_TRUE=1 since recent icu4c no longer defines these otherwise.
173
174# Generic "kitchen sink" configure function, with as many things as possible (and
175# maybe then some ;-) compiled as shared extensions:
176EXTENSION_DIR=/usr/lib${LIBDIRSUFFIX}/php/extensions \
177CFLAGS="$SLKCFLAGS -DU_DEFINE_FALSE_AND_TRUE=1" \
178CXXFLAGS="$SLKCFLAGS -DU_USING_ICU_NAMESPACE=1 -DU_DEFINE_FALSE_AND_TRUE=1" \
179./configure \
180  --prefix=/usr \
181  --libdir=/usr/lib${LIBDIRSUFFIX} \
182  --with-libdir=lib${LIBDIRSUFFIX} \
183  --localstatedir=/var \
184  --sysconfdir=/etc \
185  --datarootdir=/usr/share \
186  --datadir=/usr/share \
187  --infodir=/usr/info \
188  --mandir=/usr/man \
189  --with-apxs2=/usr/bin/apxs \
190  --enable-fpm \
191  --with-fpm-user=apache \
192  --with-fpm-group=apache \
193  --enable-maintainer-zts \
194  --enable-pcntl \
195  --enable-mbregex \
196  --enable-tokenizer=shared \
197  --with-config-file-scan-dir=/etc/php.d \
198  --with-config-file-path=/etc \
199  --with-layout=PHP \
200  --disable-sigchild \
201  --with-libxml \
202  --with-xmlrpc=shared \
203  --with-expat \
204  --enable-simplexml \
205  --enable-xmlreader=shared \
206  --enable-dom=shared \
207  --enable-filter \
208  --disable-debug \
209  --with-openssl=shared \
210  $KRB5_OPTION \
211  --with-external-pcre \
212  --with-zlib=shared,/usr \
213  --enable-bcmath=shared \
214  --with-bz2=shared,/usr \
215  --enable-calendar=shared \
216  --enable-ctype=shared \
217  --with-curl=shared \
218  --enable-dba=shared \
219  --with-gdbm=/usr \
220  --with-db4=/usr \
221  --enable-exif=shared \
222  --enable-ftp=shared \
223  --enable-gd=shared \
224  --with-external-gd \
225  --with-jpeg \
226  --with-xpm \
227  --with-gettext=shared,/usr \
228  --with-gmp=shared,/usr \
229  --with-iconv=shared \
230  --with-imap-ssl=/usr \
231  --with-imap=$IMAPLIBDIR \
232  --with-ldap=shared \
233  --enable-mbstring=shared \
234  --enable-mysqlnd=shared \
235  --with-mysqli=shared,mysqlnd \
236  --with-mysql-sock=/var/run/mysql/mysql.sock \
237  --with-iodbc=shared,/usr \
238  --enable-pdo=shared \
239  --with-pdo-mysql=shared,mysqlnd \
240  --with-pdo-sqlite=shared,/usr \
241  --with-pdo-odbc=shared,iODBC,/usr \
242  --with-pspell=shared,/usr \
243  --with-enchant=shared,/usr \
244  --enable-shmop=shared \
245  --with-snmp=shared,/usr \
246  --enable-soap=shared \
247  --enable-sockets \
248  --with-sqlite3=shared \
249  --enable-sysvmsg \
250  --enable-sysvsem \
251  --enable-sysvshm \
252  --with-xsl=shared,/usr \
253  --with-zip=shared \
254  --with-tsrm-pthreads \
255  --enable-intl=shared \
256  --enable-opcache \
257  --enable-shared=yes \
258  --enable-static=no \
259  --with-gnu-ld \
260  --with-pic \
261  --enable-phpdbg \
262  --with-sodium \
263  --with-password-argon2 \
264  --without-readline \
265  --with-libedit \
266  --with-pear \
267  --with-tidy=shared \
268  --build=$ARCH-slackware-linux || exit 1
269
270# I am told this option is worse than nothing.  :-)
271#  --enable-safe-mode
272#
273# I would recommend *against* and will take no responbility for turning on
274# "safe" mode.
275
276make $NUMJOBS || make || exit 1
277make install INSTALL_ROOT=$PKG || exit 1
278
279# Don't include the c-client library in php-config output:
280sed -i "s| -L/usr/local/lib${LIBDIRSUFFIX}/c-client/lib${LIBDIRSUFFIX}||g" $PKG/usr/bin/php-config
281sed -i "s|  -lc-client||g" $PKG/usr/bin/php-config
282
283mkdir -p $PKG/etc/{rc.d,php-fpm.d}
284cp sapi/fpm/init.d.php-fpm $PKG/etc/rc.d/rc.php-fpm.new
285chmod 644 $PKG/etc/rc.d/rc.php-fpm.new
286
287# PHP (used to) install Pear with some strange permissions.
288chmod 755 $PKG/usr/bin/pear
289
290# PHP sometimes puts junk in the root directory:
291( cd $PKG
292  rm -rf .channels .depdb .depdblock .filemap .lock .registry
293)
294
295# We do not package static extension libraries:
296rm -f $PKG/usr/lib${LIBDIRSUFFIX}/php/extensions/*.a
297
298# Fix $PKG/usr/lib/php perms:
299( cd $PKG/usr/lib${LIBDIRSUFFIX}/php
300  find . \
301   \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
302   -exec chmod 755 {} \+ -o \
303   \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
304   -exec chmod 644 {} \+
305)
306
307mkdir -p $PKG/usr/doc/php-$VERSION
308cp -a \
309  CODING_STANDARDS* CONTRIBUTING* EXTENSIONS* LICENSE* NEWS* README* UPGRADING* \
310  $PKG/usr/doc/php-$VERSION
311
312mkdir -p $PKG/etc/httpd
313cat $CWD/mod_php.conf.example | sed -e "s#lib/httpd#lib${LIBDIRSUFFIX}/httpd#" > $PKG/etc/httpd/mod_php.conf.new
314chmod 644 $PKG/etc/httpd/*
315chown root:root $PKG/etc/httpd/*
316
317cp -a php.ini-development php.ini-production $PKG/etc
318chmod 755 $PKG/etc/php.d $PKG/etc/php-fpm.d $PKG/etc/httpd
319chown root:root $PKG/etc/*
320
321# This can go now.
322rm -f $PKG/etc/httpd/httpd*
323
324# Session directory for PHP:
325mkdir -p $PKG/var/lib/php
326chmod 770 $PKG/var/lib/php
327chown root:apache $PKG/var/lib/php
328
329# Strip ELF objects.
330find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
331  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
332
333gzip -9 $PKG/usr/man/man?/*.?
334
335mkdir -p $PKG/install
336zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
337cat $CWD/slack-desc > $PKG/install/slack-desc
338
339#if [ -d "$IMAPLIBDIR" ]; then
340#  ( cd $IMAPLIBDIR && rm -rf * )
341#  rmdir $IMAPLIBDIR
342#fi
343
344cd $PKG
345/sbin/makepkg -l y -c n $TMP/php-$VERSION-$ARCH-$BUILD.txz
346
Note: See TracBrowser for help on using the repository browser.