#!/bin/sh # Heavily based on the Slackware 12.2 SlackBuild # most was copied from slackbuild hosted at SlackBuilds.org project # http://www.nethack.org/ # Packager gioco - gioco@slacky.it # Required: byacc CWD=`pwd` TMP=${TMP:-/tmp/tgz} PKG=$TMP/package NAME=nethack VERSION=3.4.3 CHOST=i486 ARCH=${ARCH:-i486} BUILD=2gc if [ "$ARCH" = "i386" ]; then SLKCFLAGS="-O2 -march=i386 -mcpu=i686" elif [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2" fi if [ ! -d $TMP ]; then mkdir -p $TMP fi if [ ! -d $PKG ]; then mkdir -p $PKG fi cd $TMP tar xzvf $CWD/$NAME-343-src.tgz cd $NAME-$VERSION find . \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) -exec chmod 755 {} \; find . \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; chown -R root:root . # fix for DESTDIR, installation paths and more patch -p1 < $CWD/nethack-enviro.patch # X11 patch patch -p1 < $CWD/$NAME-x11.patch # Global configuration file mkdir -p $PKG/etc/X11/app-defaults cat win/X11/NetHack.ad > $PKG/etc/X11/app-defaults/NetHack # We can avoid installing special fonts by using existing ones sed -i 's#nh10#-*-fixed-medium-r-*-*-12-*-*-*-*-*-*-*#' \ $PKG/etc/X11/app-defaults/NetHack # Enable the x11 tileset sed -i 's#^!NetHack.tile_file#NetHack.tile_file#' \ $PKG/etc/X11/app-defaults/NetHack mkdir -p $PKG/usr/share/applications mkdir -p $PKG/usr/share/pixmaps cp win/X11/nh_icon.xpm $PKG/usr/share/pixmaps/$NAME.xpm cat $CWD/$NAME.desktop > $PKG/usr/share/applications/$NAME.desktop # Add the TTY and X11 interface mkdir -p $PKG/usr/games cat $CWD/$NAME-tty > $PKG/usr/games/$NAME-tty chmod +x $PKG/usr/games/$NAME-tty cat $CWD/$NAME-x11 > $PKG/usr/games/$NAME-x11 chmod +x $PKG/usr/games/$NAME-x11 # .nethackrc suited for X11 client mkdir -p $PKG/etc/X11/nethack cat win/X11/nethack.rc > $PKG/etc/X11/nethack/nethackrc.x11 # Install nethack's fonts mkdir -p $PKG/usr/X11R6/lib/X11/fonts/misc bdftopcf win/X11/nh10.bdf > $PKG/usr/X11R6/lib/X11/fonts/misc/nh10.pcf bdftopcf win/X11/ibm.bdf > $PKG/usr/X11R6/lib/X11/fonts/misc/ibm.pcf gzip $PKG/usr/X11R6/lib/X11/fonts/misc/*.pcf # Qt patch patch -p1 < $CWD/$NAME-qt.patch # .nethackrc suited for Qt client cat $CWD/nethackrc.qt > $PKG/etc/X11/nethack/nethackrc.qt # Add the Qt interface cat $CWD/$NAME-qt > $PKG/usr/games/$NAME-qt chmod +x $PKG/usr/games/$NAME-qt sh sys/unix/setup.sh make all make install DESTDIR=$PKG chown -R root:games $PKG/var/games chmod 0664 $PKG/var/games/nethack/logfile chmod 0664 $PKG/var/games/nethack/perm chmod 0664 $PKG/var/games/nethack/record chmod 0775 $PKG/var/games/nethack chmod 0775 $PKG/var/games/nethack/save # NetHack's Makefile installs the binary suid root # We'll set it sgid games and all should be fine. chown root:games $PKG/usr/games/nethack chmod 0755 $PKG/usr/games/nethack chown -R root:games $PKG/usr/share/games/nethack chmod 2755 $PKG/usr/share/games/nethack/nethack chmod g+w $PKG/usr/share/games/nethack/nhdat # Install the man pages mkdir -p $PKG/usr/man/man6 cp -a doc/*.6 $PKG/usr/man/man6/ find $PKG/usr/man -type f -exec gzip -9 {} \; for i in $(find $PKG/usr/man -type l) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done mkdir -p $PKG/usr/doc/$NAME-$VERSION/history cp -a doc/Guidebook.tex $PKG/usr/doc/$NAME-$VERSION cp -a doc/*.txt $PKG/usr/doc/$NAME-$VERSION mv $PKG/usr/share/games/nethack/license $PKG/usr/doc/$NAME-$VERSION cp -a doc/fixes* $PKG/usr/doc/$NAME-$VERSION/history cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null mkdir -p $PKG/install cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild requiredbuilder -v -y -s $CWD $PKG makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz if [ "$1" = "--cleanup" ]; then rm -rf $TMP fi