#!/bin/bash # # preload.SlackBuild # code: Vicious (michal@scxd.info); improvements: Zielony (e-pl@o2.pl) set -e # PACKAGE GENERAL INFO [EDIT] PKGNAME=preload VERSION=0.4 BUILD=1X ARCH=i686 URL=http://switch.dl.sourceforge.net/sourceforge/preload/preload-$VERSION.tar.gz CWD=`pwd` TMP=/tmp/$PKGNAME PKG=$TMP/package if [ -e $TMP/$PKGNAME-$VERSION/'Makefile' ]; then cd $TMP/$PKGNAME-$VERSION make else 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 preload (application memory cache) preload is an adaptive readahead daemon. It monitors applications that users run, and by analyzing this data, predicts what applications users might run, and fetches those binaries and their dependencies into memory for faster startup times. Package prepared by Zielony (e-pl@o2.pl) SLACKDESC cd $TMP # step 1: DOWNLOAD SOURCE PKGFNAME=`ls -t | grep "$PKGNAME-$VERSION." | head -1` ( wget -c $URL -P $TMP -O $PKGNAME-$VERSION.${URL//*.} ) PKGFNAME=`ls -t | grep "$PKGNAME-$VERSION." | head -1` # step 2: UNPACK SOURCE AND PREPARE PACKAGE EXTENSION=`echo ${PKGFNAME//*.}` if [ $EXTENSION = "bz2" ]; then tar jxvf $PKGFNAME -C $TMP else tar zxvf $PKGFNAME -C $TMP fi DIRNAME=`tar tf $PKGFNAME | head -1` echo $DIRNAME | grep '/' && DIRNAME=${DIRNAME%${DIRNAME#*/}} 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" ;; *) SLKCFLAGS="-O2" ;; esac if [ -s 'configure' ]; then CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" ./configure \ --prefix=/usr \ --disable-debug \ --mandir=/usr/man \ --sysconfdir=/etc \ --program-prefix="" \ --program-suffix="" \ $ARCH-slackware-linux fi make fi make install DESTDIR=$PKG mv -f $PKG/etc/preload.conf $PKG/etc/preload.conf.new mv -f $PKG/etc/sysconfig/preload $PKG/etc/sysconfig/preload.new mkdir -p $PKG/etc/rc.d/rc{3,4}.d cat << 'START' > $PKG/etc/rc.d/rc3.d/S.preload #!/bin/bash if [ -x /etc/rc.d/init.d/preload ]; then . /etc/rc.d/init.d/preload start fi START chmod 755 $PKG/etc/rc.d/rc3.d/S.preload ln -f $PKG/etc/rc.d/rc3.d/S.preload $PKG/etc/rc.d/rc4.d/ cat << 'STOP' > $PKG/etc/rc.d/rc3.d/K.preload #!/bin/bash if [ -x /etc/rc.d/init.d/preload ]; then . /etc/rc.d/init.d/preload stop fi STOP chmod 755 $PKG/etc/rc.d/rc3.d/K.preload ln -f $PKG/etc/rc.d/rc3.d/K.preload $PKG/etc/rc.d/rc4.d/ # 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