Sunday, July 27, 2008

Slackbuild Scripts

This a gstreamer slackware build script ported to Slamd64. It's only a quick-hack. But it's working as expected. There is a downside though. I should've been setting the target MANPATH to /usr/man, but I set to /usr/share/man instead. Which is wrong.


#!/bin/bash
#
# gstreamer.SlackBuild
# code: Vicious (michal@scxd.info); improvements: Zielony (e-pl@o2.pl)
# adapted for x86_64 and local source Pinczakko (darmawan_salihun@yahoo.com)
# Pinczakko Note: Use at your own risk!
#
set -e
# PACKAGE GENERAL INFO [EDIT]
PKGNAME=gstreamer
VERSION=0.10.20
BUILD=1X
ARCH=x86_64
SRC_PATH=gstreamer-$VERSION.tar.bz2

CWD=`pwd`
TMP=/tmp/$PKGNAME
PKG=$TMP/package

if [ ! -d $TMP/$PKGNAME-$VERSION ]; then
rm -rf $PKG
mkdir -p $PKG/install

# PACKAGE DESCRIPTION [EDIT]
cat << 'SLACKDESC' | fmt -w $(( 80 - `echo $PKGNAME | wc -c` - 3 )) | perl -pe "s/^/$PKGNAME: /" > $PKG/install/slack-desc
GStreamer (multimedia framework)

GStreamer is a library that allows the construction of graphs of media-handling components,
ranging from simple Ogg/Vorbis playback to complex audio (mixing) and video (non-linear editing) processing.
Applications can take advantage of advances in codec and filter technology transparently.
Developers can add new codecs and filters by writing a simple plugin with a clean, generic interface.

Package prepared by Zielony (e-pl@o2.pl)
Adapted for Slamd64 by Pinczakko (darmawan_salihun@yahoo.com)
SLACKDESC


# step 1: COPY SOURCE
case "${SRC_PATH//*\/}" in
*.tar.bz2) EXTENSION="tar.bz2"; DECOMPRESS="tar jxvf" ;;
*.tar.gz) EXTENSION="tar.gz"; DECOMPRESS="tar zxvf" ;;
*.tgz) EXTENSION="tgz"; DECOMPRESS="tar zxvf" ;;
*.zip) EXTENSION="zip"; DECOMPRESS="unzip" ;;
esac
PKGFNAME="$PKGNAME-$VERSION.$EXTENSION"
cp -v $SRC_PATH $TMP

# Go to build directory
cd $TMP

# step 2: UNPACK SOURCE AND PREPARE PACKAGE
$DECOMPRESS $PKGFNAME

DIRNAME=`ls -c | head -1 | cut -d / -f 1`
if [ "$DIRNAME" != "$PKGNAME-$VERSION" ]; then mv $DIRNAME $PKGNAME-$VERSION; fi

chown root:root $TMP -R
fi

cd $TMP/$PKGNAME-$VERSION

case "$ARCH" in
"i686") SLKCFLAGS="-O2 -march=i686 -mtune=i686" ;;
"i486") SLKCFLAGS="-O2 -march=i486 -mtune=i686" ;;
"i386") SLKCFLAGS="-O2 -march=i386 -mcpu=i686" ;;
"s390") SLKCFLAGS="-O2" ;;
"x86_64") SLKCFLAGS="-O2 -fPIC" ;;
*) SLKCFLAGS="-O2" ;;
esac

if [ ! -e 'Makefile' ]; then
CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" ./configure \
--prefix=/usr \
--disable-debug \
--disable-static \
--libdir=/usr/lib64 \
--mandir=/usr/share/man \
--sysconfdir=/etc
# --sysconfdir=/etc \
# --program-prefix="" \
# --program-suffix="" \
# $ARCH-slamd64-linux
fi
make
make install DESTDIR=$PKG
rm $PKG/usr/bin/*-`echo $VERSION | perl -pe 's/^([0-9]+\.[0-9]+)\.?.*/$1/'`
for i in $PKG/usr/share/man/*/*-`echo $VERSION | perl -pe 's/^([0-9]+\.[0-9]+)\.?.*/$1/'`.1; do
mv -f $i ${i%-*}
done
rm -rf $PKG/usr/share/gtk-doc

# step 3: STRIP BINARIES & GZIP MANUALS
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
find . | xargs file | grep "current ar archive" | grep ELF | cut -f 1 -d : \
| xargs strip --strip-debug 2> /dev/null )

find $PKG/usr -regex '.+/man/\(.+?/\)?man./.+' -exec gzip -9 \{} \;

# step 4: CREATE PACKAGE & CLEAN TMP
if [ `find . | wc -l` -le 1 ]; then
echo "Brak plików pakietu!"
else
( requiredbuilder -y -s $PKG/install $PKG )
makepkg -l y -c n $CWD/$PKGNAME-$VERSION-$ARCH-$BUILD.tgz
if [ "$1" != "-nc" ]; then rm -rf $TMP; fi
fi

Post a Comment

No comments: