summaryrefslogtreecommitdiffstats
path: root/python/pygame/pygame.SlackBuild
blob: e35ca2750d2797135706ea57a5ca9dbd13912d02 (plain)
#!/bin/sh

## Written by hollywoodb (hollywoodb@fastmail.fm)
# Modified by the SlackBuilds.org project
# Maintained by Bojan Popovic (bocke@slackware-srbija.org), 2014-2017
# Contribution by B.Watson (yalhcru@gmail.com), 11 apr. 2017.

PRGNAM=pygame
VERSION=${VERSION:-1.9.1}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

SRCVERSION=${VERSION}release

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
else
  SLKCFLAGS="-O2"
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP || exit 1
rm -rf $PRGNAM-$SRCVERSION
tar xvf $CWD/$PRGNAM-$SRCVERSION.tar.?z* || exit 1
cd $PRGNAM-$SRCVERSION || exit 1
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
 -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;

# A patch borrowed from Arch community repo
patch -p1 < $CWD/pygame-v4l.patch

# Contributed by B.Watson (yalhcru@gmail.com).
# Gets rid of the call to remove_old_files() during packaging.
# TLDR: Stops packaging scripts from messing with a local PyGame install.
sed -i '/^if "install"/,$d' setup.py

python -u config.py
CFLAGS="$SLKCFLAGS" \
python setup.py install --root=$PKG

find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a WHATSNEW README.txt $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n -p $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}