#!/bin/sh # Heavily based on the Slackware 13.1 SlackBuild # http://www.mono-project.com # Packager Andrea Sciucca ( gohanz at infinito.it) # Thanks to Menno Duursma SlackBuilds.org project # Modified by Aaron W. Hsu # Thanks to gustavo.zuliani at iet.unipi.it # http://www.slacky.eu # # 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. # # # # Exit on most errors set -e # Set variables: CWD=`pwd` OUTPUT=${OUTPUT:-$CWD} PKGNAME=lua TMP=${TMP:-/tmp/txz/$PKGNAME} PKG=$TMP/package VERSION=${VERSION:-5.1.4} PATCH=${PATCH:-2} ARCH=${ARCH:-i486} JOBS=${JOBS:--j2} BUILD=${BUILD:-1} TAG=${TAG:-sl} SOURCE="http://www.lua.org/ftp/$PKGNAME-$VERSION.tar.gz" # Download sorce tarball if still not present if [ ! -e $PKGNAME-$VERSION.tar.gz ]; then wget -c $SOURCE fi SOURCE="http://www.lua.org/ftp/patch-$PKGNAME-$VERSION-2" # Download Patch if still not present if [ ! -e patch-$PKGNAME-$VERSION-2 ]; then wget -c $SOURCE fi # Set compiling FLAGS if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686"; SLKLDFLAGS=""; LIBDIRSUFFIX=""; CHOST="i486" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686"; SLKLDFLAGS=""; LIBDIRSUFFIX=""; CHOST="i686" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC"; SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"; CHOST="x86_64" fi rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT # Decompress the source tarball cd $TMP tar xvzf $CWD/$PKGNAME-$VERSION.tar.gz echo -e "\E[0;32m+----------------------+\E[0;0m" echo -e "\E[0;32m| Start SlackBuild Lua |\E[0;0m" echo -e "\E[0;32m+----------------------+\E[0;0m" # Patch the source -A bug-fix- cd $PKGNAME-$VERSION/src patch < $CWD/patch-$PKGNAME-$VERSION-2 # Adjust permissions and ownerships cd .. chmod -R u+w,go+r-w,a-s . chown -R root:root . # Fix up a to-be-installed header and the pkgconfig file sed -i "s|/usr/local|/usr|" src/luaconf.h sed -i "s|lib/lua|lib$LIBDIRSUFFIX/lua|" src/luaconf.h sed -i "s|/usr/local|/usr|" etc/lua.pc sed -i "s|prefix}/lib|prefix}/lib${LIBDIRSUFFIX}|g" etc/lua.pc # Building Lua package make linux \ CFLAGS="$SLKCFLAGS \$(MYCFLAGS)" \ INSTALL_TOP=/usr \ INSTALL_LIB=/usr/lib${LIBDIRSUFFIX} \ INSTALL_LMOD=/usr/share/lua/5.1 \ INSTALL_CMOD=/usr/lib${LIBDIRSUFFIX}/lua/5.1 make linux install \ CFLAGS="$SLKCFLAGS \$(MYCFLAGS)" \ INSTALL_TOP=$PKG/usr \ INSTALL_LIB=$PKG/usr/lib${LIBDIRSUFFIX} \ INSTALL_LMOD=$PKG/usr/share/lua/5.1 \ INSTALL_CMOD=$PKG/usr/lib${LIBDIRSUFFIX}/lua/5.1 # Now let's build the shared library mkdir -p shared cd shared ar -x $PKG/usr/lib${LIBDIRSUFFIX}/liblua.a gcc -ldl -lreadline -lhistory -lncurses -lm -shared *.o -o liblua.so.5.1.4 cp -a liblua.so.5.1.4 $PKG/usr/lib${LIBDIRSUFFIX} ( cd $PKG/usr/lib${LIBDIRSUFFIX} ln -s liblua.so.5.1.4 liblua.so.5.1 ln -s liblua.so.5.1.4 liblua.so.5 ln -s liblua.so.5.1.4 liblua.so ) cd - # Installing the pkgconfig file mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig cat etc/lua.pc > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/lua.pc # Strip binaries and shared objects, if present ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true ) # Compress the man pages if present if [ -d $PKG/usr/man ]; then ( cd $PKG/usr/man find . -type f -exec gzip -9 {} \; for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done ) fi #Add documentation files: readme, changelog and so on mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION/{SlackBuild,extras,html} cp -a COPYRIGHT HISTORY INSTALL README $PKG/usr/doc/$PKGNAME-$VERSION cp -a doc/*.html doc/logo.gif doc/lua.css $PKG/usr/doc/$PKGNAME-$VERSION/html cp -a etc test $PKG/usr/doc/$PKGNAME-$VERSION/extras chmod -R 644 $PKG/usr/doc/$PKGNAME-$VERSION/* # Also add the slack-desk file and this slackbuild to the package mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/slack-desc > $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/slack-desc cat $CWD/$PKGNAME.SlackBuild > $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/$PKGNAME.SlackBuild # Find and print dependencies into slack-required file cd $PKG chown -R root:root $PKG if [ -x /usr/bin/requiredbuilder ];then requiredbuilder -y -v -s $CWD $PKG fi # Create txz package /sbin/makepkg -l y -c n $OUTPUT/$PKGNAME-$VERSION.$PATCH-$ARCH-$BUILD$TAG.${PKGTYPE:-txz} # Cleanup if enabled if [ "$1" = "--cleanup" ]; then rm -rf $TMP fi