#!/usr/bin/bash # This script assumes it will be launched within "/NAME/VERSION/src" dir. # With all sources in "src" Your Vector Linux .tlz package, slack-desc, # and slack-required will be found in "VERSION" dir. The extraction and # build will be in a temp dir created in "NAME" dir, and then removed on exit. # Comment out second to last line to keep this dir intact. # Based on Slaclware build script by: # David Cantrell # Modified for PHP 4-5 by volkerdi@slackware.com # Copyright 2007, 2008 Patrick Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NAME="php" #Enter package Name! VERSION=${VERSION:-"5.2.8"} #Enter package Version! VL_PACKAGER=${VL_PACKAGER:-"rbistolfi"} #Enter your Name! LINK=${LINK:-"http://ar.$NAME.net/get/$NAME-$VERSION.tar.bz2/from/us.$NAME.net/mirror"} #Enter URL for package here! #SYSTEM VARIABLES #---------------------------------------------------------------------------- BUILDNUM=${BUILDNUM:-"1"} VL_VERSION=${VL_VERSION:-"$(ls /var/log/packages/|grep vlconfig2|cut -d "-" -f4|cut -c 2-5)"} BUILD=${BUILD:-"$BUILDNUM""$VL_VERSION"} ARCH=${ARCH:-"$(uname -m)"} CONFIG_OPTIONS=${CONFIG_OPTIONS:-"--disable-safe-mode --enable-apc --enable-apc-mmap --enable-memory-limit --enable-suhosin --disable-magic-quotes --enable-zend-multibyte --enable-mbregex --enable-tokenizer=shared --with-config-file-scan-dir=/etc/php -with-config-file-path=/etc/httpd --with-mod_charset --with-layout=PHP --enable-sigchild --enable-xml --with-libxml-dir=/usr --enable-simplexml --enable-spl --enable-filter --with-openssl=shared --with-pcre-regex=/usr --with-zlib=shared,/usr --enable-bcmath=shared --with-bz2=shared,/usr --enable-calendar=shared --enable-ctype=shared --with-curl=shared --with-curlwrappers --enable-dba=shared -with-gdbm=/usr --with-db4=/usr --enable-dbase=shared --enable-exif=shared --enable-ftp=shared --with-gd=shared --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --with-t1lib=/usr --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext=shared,/usr --with-gmp=shared,/usr --with-iconv=shared --with-imap-ssl=/usr --with-ldap=shared --enable-mbstring=shared --with-hash --with-mhash=shared,/usr --with-mysql=shared,/usr --with-mysqli=shared,/usr/bin/mysql_config --enable-pdo=shared --with-pdo-mysql=shared,/usr --with-pdo-sqlite=shared --with-pspell=shared,/usr --with-mm=/usr --enable-shmop=shared --with-snmp=shared,/usr --enable-soap=shared --enable-sockets --with-sqlite=shared --enable-sqlite-utf8 --with-regex=php --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx=shared --with-xsl=shared,/usr --enable-zip=shared --with-tsrm-pthreads --enable-shared=yes --enable-static=no --with-gnu-ld --with-pic"} LDFLAG_OPTIONS=${LDFLAG_OPTIONS:-""} #---------------------------------------------------------------------------- #SETUP PACKAGING ENVIRONMENT #-------------------------------------------- CWD=$(pwd) cd ../ RELEASEDIR=$(pwd) cd $CWD mkdir -p $RELEASEDIR/tmp TMP=$RELEASEDIR/tmp PKG=$TMP/package-$NAME #-------------------------------------------- if [ $UID != 0 ]; then echo "You are not authorized to run this script. Please login as root" exit 1 fi if [ ! -x /usr/bin/requiredbuilder ]; then echo "Requiredbuilder not installed, or not executable." exit 1 fi if [ $VL_PACKAGER = "YOURNAME" ]; then echo 'Who are you? Please edit VL_PACKAGER=${VL_PACKAGER:-YOURNAME} in this script. Change the word "YOURNAME" to your VectorLinux packager name. You may also export VL_PACKAGER, or call this script with VL_PACKAGER="YOUR NAME HERE"' exit 1 fi #CFLAGS SETUP #-------------------------------------------- if [[ "$ARCH" = i?86 ]]; then ARCH=i586 SLKCFLAGS="-O2 -march=i586 -mtune=i686" CONFIGURE_TRIPLET="i486-slackware-linux" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fpic" CONFIGURE_TRIPLET="x86_64-pc-linux" elif [ "$ARCH" = "powerpc" ]; then SLKCFLAGS="-O2" CONFIGURE_TRIPLET="powerpc-slackware-linux" fi export CFLAGS="$SLKCFLAGS $CFLAG_OPTIONS" export CXXFLAGS=$CFLAGS export LDFLAGS="$LDFLAGS $LDFLAG_OPTIONS" #-------------------------------------------- #GET THE SOURCE #-------------------------------------------- if [ ! -f $CWD/$NAME-$VERSION.tar.* ] then wget $LINK fi #-------------------------------------------- rm -rf $PKG mkdir -p $PKG cd $TMP rm -rf $NAME-$VERSION #EXTRACT SOURCES #----------------------------------------------------- echo "Extracting source..." tar xvf $CWD/$NAME-$VERSION.tar.* || exit 1 #----------------------------------------------------- cd $TMP/$NAME-$VERSION # Put any Patches here #----------------------------------------------------- # Sometimes they ship a few of these: find . -name "*.orig" -exec rm {} \; # Patch ini files: zcat $CWD/php.ini.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1 zcat $CWD/php.recommended.ini.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit 1 #----------------------------------------------------- #SET PERMISSIONS #----------------------------------------- echo "Setting permissions..." chown -R root:root . find . -perm 664 -exec chmod 644 {} \; find . -perm 777 -exec chmod 755 {} \; find . -perm 2777 -exec chmod 755 {} \; find . -perm 775 -exec chmod 755 {} \; find . -perm 2755 -exec chmod 755 {} \; find . -perm 774 -exec chmod 644 {} \; find . -perm 666 -exec chmod 644 {} \; find . -perm 600 -exec chmod 644 {} \; find . -perm 444 -exec chmod 644 {} \; find . -perm 400 -exec chmod 644 {} \; find . -perm 440 -exec chmod 644 {} \; find . -perm 511 -exec chmod 755 {} \; find . -perm 711 -exec chmod 755 {} \; find . -perm 555 -exec chmod 755 {} \; #----------------------------------------- #CONFIGURE & MAKE #---------------------------------------------------------------------- # If you are building a KDE-related app, then change the following # arguments in the script below: # --prefix=$(kde-config -prefix) \ # --sysconfdir=/etc/kde \ # # Making these changes will ensure that your package will build in the # correct path and that it will work seamlessly within the KDE environment. # #----------------------------------------------------------------------- configure() { echo "Configuring source..." ./configure --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var \ --mandir=/usr/man \ --disable-debug \ --program-prefix="" \ --program-suffix="" \ --build=$CONFIGURE_TRIPLET \ $CONFIG_OPTIONS } # Make the Apache2 module version of PHP: configure \ --with-apxs2=/usr/sbin/apxs || exit 1 make -j3 || exit 1 make install INSTALL_ROOT=$PKG || exit 1 # Make the CLI version of PHP: make distclean configure \ --enable-force-cgi-redirect \ --enable-fastcgi \ --enable-pcntl \ --enable-readline \ --enable-sigchild || exit 1 make -j3 || exit 1 mkdir -p $PKG/usr/bin cat ./sapi/cli/php > $PKG/usr/bin/php chmod 755 $PKG/usr/bin/php # Make the FastCGI interpreter: make distclean configure \ --enable-force-cgi-redirect \ --enable-fastcgi \ --enable-pcntl \ --enable-readline \ --enable-sigchild || exit 1 make -j3 || exit 1 mkdir -p $PKG/usr/bin cat sapi/cgi/php-cgi > $PKG/usr/bin/php-cgi chmod 755 $PKG/usr/bin/php-cgi # PHP (used to) install Pear with some strange permissions. chmod 755 $PKG/usr/bin/pear # PHP sometimes puts junk in the root directory: ( cd $PKG rm -rf .channels .depdb .depdblock .filemap .lock .registry ) # Fix $PKG/usr/lib/php perms: ( cd $PKG/usr/lib/php find . -perm 666 -exec chmod 644 {} \; find . -perm 664 -exec chmod 644 {} \; find . -perm 600 -exec chmod 644 {} \; find . -perm 444 -exec chmod 644 {} \; find . -perm 400 -exec chmod 644 {} \; find . -perm 440 -exec chmod 644 {} \; find . -perm 777 -exec chmod 755 {} \; find . -perm 775 -exec chmod 755 {} \; find . -perm 511 -exec chmod 755 {} \; find . -perm 711 -exec chmod 755 {} \; find . -perm 555 -exec chmod 755 {} \; ) ####################################################################### #Miscellenious tweaks and things outside a normal ./configure go here # ####################################################################### mkdir -p $PKG/etc/httpd cp -a php.ini-dist php.ini-recommended $PKG/etc/httpd cp -a $CWD/mod_php.conf.example $PKG/etc/httpd chmod 644 $PKG/etc/httpd/* chown root:root $PKG/etc/httpd/* # This can go now. rm -f $PKG/etc/httpd/httpd* # Session directory for PHP: mkdir -p $PKG/var/lib/php chmod 770 $PKG/var/lib/php chown root:apache $PKG/var/lib/php #mkdir -p $PKG/usr/share/applications #cp $CWD/$NAME.desktop $PKG/usr/share/applications/$NAME.desktop #mkdir -p $PKG/usr/share/pixmaps #cp $CWD/$NAME.png $PKG/usr/share/pixmaps/$NAME.png mkdir -p $PKG/usr/doc/$NAME-$VERSION cp -a AUTHORS COPYING ChangeLog Credits MANIFEST README TODO \ $PKG/usr/doc/$NAME-$VERSION cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild #---------------------------------------------------------------------- if [ -d $PKG/usr/share/man ] ; then mkdir -p $PKG/usr/man mv $PKG/usr/share/man/* $PKG/usr/man rm -rf $PKG/usr/share/man fi find $PKG/usr/man -type f -exec gzip -9 {} \; if [ -d $PKG/usr/share/info ] ; then mkdir -p $PKG/usr/info mv $PKG/usr/share/info/* $PKG/usr/info rm -rf $PKG/usr/share/info fi find $PKG/usr/info -type f -exec gzip -9 {} \; mkdir -p $PKG/install #if there is a slack-desc in src dir use it if test -f $CWD/slack-desc; then cp $CWD/slack-desc $RELEASEDIR/slack-desc else # This creates the white space in front of "handy-ruler" in slack-desc below. LENGTH=$(expr length "$NAME") SPACES=0 SHIM="" until [ "$SPACES" = "$LENGTH" ]; do SHIM="$SHIM " let SPACES=$SPACES+1 done # Fill in the package summary between the () below. # Then package the description, License, Author and Website. # There may be no more then 11 $NAME: lines in a valid slack-desc. cat > $RELEASEDIR/slack-desc << EOF # HOW TO EDIT THIS FILE: # The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' # on the right side marks the last column you can put a character in. You must # make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':'. $SHIM|-----handy-ruler------------------------------------------------------| $NAME: $NAME () $NAME: $NAME: $NAME: $NAME: $NAME: $NAME: $NAME: License: GPL $NAME: Authors: $NAME: Website: EOF fi cat >> $RELEASEDIR/slack-desc << EOF #---------------------------------------- BUILDDATE: $(date) PACKAGER: $VL_PACKAGER HOST: $(uname -srm) DISTRO: $(cat /etc/vector-version) CFLAGS: $CFLAGS LDFLAGS: $LDFLAGS CONFIGURE: $(awk "/\.\/configure\ /" $TMP/$NAME-$VERSION/config.log) EOF cat $RELEASEDIR/slack-desc > $PKG/install/slack-desc #STRIPPING #------------------------------------------------------------------------------------------------------------------ cd $PKG echo " " echo "Stripping...." echo " " find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null #------------------------------------------------------------------------------------------------------------------ #FINISH PACKAGE #-------------------------------------------------------------- echo "Finding dependencies..." requiredbuilder -v -y -s $RELEASEDIR $PKG echo "Creating package $NAME-$VERSION-$ARCH-$BUILD.tlz" makepkg -l y -c n $RELEASEDIR/$NAME-$VERSION-$ARCH-$BUILD.tlz mv $RELEASEDIR/slack-required $RELEASEDIR/slack-required_${ARCH}_${BUILD} cd $CWD echo "Cleaning up temp files..." && rm -rf $TMP echo "Package Complete" #-------------------------------------------------------------- # vim: set tabstop=4 shiftwidth=4 foldmethod=marker : ##