#!/bin/sh # # Slackware build script for Lost Labyrinth - A Rogue-like Game. # # Heavily based on the Slackware 13.0 SlackBuild # Written by Luigi "Reilly" Cozzolino # URL: http://www.lostlabyrinth.com # Packager: Luigi "Reilly" Cozzolino # Exit on most errors: set -e ######## SOURCE PACKAGE SECTION ############# SRCNAME="lostlabyrinth" SRCVER="3.5.2" SRCTYPE="tar.gz" SRCPKG="${SRCNAME}_${SRCVER}.${SRCTYPE}" SOURCEDIR="laby_${SRCVER}" ######## END SOURCE PACKAGE SECTION ######### ######## SLACKWARE PACKAGE SECTION ########## SLKNAM="${SRCNAME}" SLKVER="${SRCVER}" ARCH=${ARCH:-i586} BUILD="2lc" PKGTYPE="${PKGTYPE:-txz}" ######## END SLACKWARE PACKAGE SECTION ###### CWD=$(pwd) TMP=${TMP:-$HOME/PKGS/${SLKNAM}} PKG=$TMP/package-${SLKNAM} rm -rf $PKG mkdir -p $PKG cd $TMP rm -rf ${SOURCEDIR} clear sleep 1 echo ; echo ; echo echo "+===========================================================" echo -e "|\033[01;32m Building\033[00m \033[01;31m${SRCPKG}\033[00m" echo "+===========================================================" sleep 5 # Checking source package type... [ "${SRCTYPE}" = "tar.gz" -o "${SRCTYPE}" = "tgz" ] && EXTRACT_SRCPKG="tar -xvzf" [ "${SRCTYPE}" = "tar.bz2" -o "${SRCTYPE}" = "tbz" ] && EXTRACT_SRCPKG="tar -xvjf" [ "${SRCTYPE}" = "zip" -o "${SRCTYPE}" = "ZIP" ] && EXTRACT_SRCPKG="unzip" [ "${SRCTYPE}" = "rar" -o "${SRCTYPE}" = "RAR" ] && EXTRACT_SRCPKG="rar x" [ "${SRCTYPE}" = "7z" -o "${SRCTYPE}" = "7Z" ] && EXTRACT_SRCPKG="7z x" # and finally extract it: ${EXTRACT_SRCPKG} $CWD/${SRCPKG} || exit 1 cd ${SOURCEDIR} # Make sure ownerships and permissions are sane: chown -R root:root . 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 {} \; # Set some variable for installation package: PKG_DATADIR="/usr/share/games/${SLKNAM}" # Add directory installation: mkdir -p $PKG/${PKG_DATADIR} install -m 644 * $PKG/${PKG_DATADIR} || exit 1 # Change name: mv -v $PKG/${PKG_DATADIR}/laby.exe $PKG/${PKG_DATADIR}/laby.bin || exit 1 # Change perms: chmod -v 755 $PKG/${PKG_DATADIR}/laby.bin || exit 1 # Add a symlink: ( cd $PKG/${PKG_DATADIR} || exit 1 ln -s /usr/lib/libSDL_gfx.so libSDL_gfx.so.4 ) || exit 1 # Add a shell script necessary to run Lost Labyrinth properly: mkdir -p $PKG/usr/games cat > $PKG/usr/games/${SLKNAM} << "EOF" #!/bin/sh # Shell script for Lost Labyrinth # Author: Luigi "Reilly" Cozzolino - May 2008 # Set some variables: LOSTLABY_DIR="/usr/share/games/lostlabyrinth" LOSTLABY_BIN="laby.bin" # Enter in a `gamedir' environment and launch a program from here: cd $LOSTLABY_DIR LD_LIBRARY_PATH="./:$LD_LIBRARY_PATH" $LOSTLABY_BIN EOF # Change perms: chmod -v 755 $PKG/usr/games/* # Add a desktop file: mkdir -p $PKG/usr/share/applications cat > $PKG/usr/share/applications/${SLKNAM}.desktop << "EOF" [Desktop Entry] Encoding=UTF-8 Name=Lost Labyrinth GenericName=Rogue-like Game Exec=lostlabyrinth Icon=/usr/share/games/lostlabyrinth/laby.xpm Terminal=false Type=Application Categories=Game;RPG StartupNotify=false EOF # Strip binaries and libraries: ( cd $PKG 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 ) # Add a `slack-required': mkdir -p $PKG/install echo "sdl_gfx >= 2.0.20-i486-1as" > $PKG/install/slack-required echo "sdl_gfx >= 2.0.20-i486-1as" > $CWD/slack-required # Add a documentation directory: mkdir -p $PKG/usr/doc/${SLKNAM}-${SLKVER} ( cd $PKG/usr/doc/${SLKNAM}-${SLKVER} || exit 1 ln -s /${PKG_DATADIR}/{FAQ_deu.txt,FAQ_eng.txt,FAQ_esp.txt,ccl.txt,gpl.txt,leeme.txt,leeme_hechizos.txt,liesmich.txt,liesmich_zauber.txt,readme.txt,statement.txt} \ . ) || exit 1 cat $CWD/${SLKNAM}.SlackBuild > $PKG/usr/doc/${SLKNAM}-${SLKVER}/${SLKNAM}.SlackBuild mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG /sbin/makepkg -l y -c n $TMP/${SLKNAM}-${SLKVER}-${ARCH}-${BUILD}.${PKGTYPE} # Checksum `md5' file creation: ( cd $TMP ; md5sum ${SLKNAM}-${SLKVER}-${ARCH}-$BUILD.${PKGTYPE} > ${SLKNAM}-${SLKVER}-${ARCH}-${BUILD}.${PKGTYPE}.md5 ) # Final touches: ( cd $TMP ; cat $PKG/install/slack-desc | grep "^${SLKNAM}:" > ${SLKNAM}-${SLKVER}-$ARCH-$BUILD.txt ) # Clean up the extra stuff: if [ "$1" = "--cleanup" -o "$1" = "-c" ]; then rm -rf $TMP/${SOURCEDIR} rm -rf $PKG fi