diff options
author | Parabola <dev@list.parabolagnulinux.org> | 2011-04-05 14:26:38 +0000 |
---|---|---|
committer | Parabola <dev@list.parabolagnulinux.org> | 2011-04-05 14:26:38 +0000 |
commit | 415856bdd4f48ab4f2732996f0bae58595092bbe (patch) | |
tree | ede2018b591f6dfb477fe9341ba17b9bc000fab9 /community/preload |
Tue Apr 5 14:26:38 UTC 2011
Diffstat (limited to 'community/preload')
-rw-r--r-- | community/preload/PKGBUILD | 38 | ||||
-rw-r--r-- | community/preload/preload.install | 30 | ||||
-rw-r--r-- | community/preload/rc.preload | 97 |
3 files changed, 165 insertions, 0 deletions
diff --git a/community/preload/PKGBUILD b/community/preload/PKGBUILD new file mode 100644 index 000000000..e5457727c --- /dev/null +++ b/community/preload/PKGBUILD @@ -0,0 +1,38 @@ +# Contributor: Jaroslaw Swierczynski <swiergot@aur.archlinux.org> +# Contributor: William Rea <sillywilly@gmail.com> + +pkgname=preload +pkgver=0.6.4 +pkgrel=2 +arch=('i686' 'x86_64') +pkgdesc="Makes applications run faster by prefetching binaries and shared objects" +url="http://sourceforge.net/projects/preload" +license=('GPL2') +makedepends=('help2man' 'pkgconfig') +depends=('glib2') +backup=('etc/preload.conf') +options=('!makeflags') +install=$pkgname.install +source=(http://downloads.sourceforge.net/sourceforge/preload/$pkgname-$pkgver.tar.gz \ + rc.preload) +md5sums=('10786287b55afd3a2b433b4f898809f4' + 'bde0dd7867c77e7c4d10b481b5cddcd3') + +build() { + cd $startdir/src/$pkgname-$pkgver + ./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man --localstatedir=/var + make || return 1 + make DESTDIR=$startdir/pkg install + + install -D -m755 ../rc.preload $startdir/pkg/etc/rc.d/preload + rm -rf $startdir/pkg/etc/rc.d/init.d + + rm -rf $startdir/pkg/var/lib/preload/preload.state + rm -rf $startdir/pkg/var/log/preload.log + + mkdir $startdir/pkg/etc/conf.d + mv $startdir/pkg/etc/sysconfig/* $startdir/pkg/etc/conf.d + rm -rf $startdir/pkg/etc/sysconfig + + sed -r -i 's#^((map|exe)prefix =) (.+)$#\1 /opt;\3#' $startdir/pkg/etc/preload.conf +} diff --git a/community/preload/preload.install b/community/preload/preload.install new file mode 100644 index 000000000..2c758c265 --- /dev/null +++ b/community/preload/preload.install @@ -0,0 +1,30 @@ +PRELOAD_STATE=/var/lib/preload/preload.state + +# arg 1: the new package version +# arg 2: the old package version +pre_upgrade() { + if [ `vercmp $2 0.6.3-2` -lt 0 ]; then + echo "Backing up your state file..." + cp -af ${PRELOAD_STATE} ${PRELOAD_STATE}.backup + fi +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + if [ `vercmp $2 0.6.3-2` -lt 0 -a -f ${PRELOAD_STATE}.backup ]; then + echo "Restoring the state file..." + mv -f ${PRELOAD_STATE}.backup ${PRELOAD_STATE} + fi +} + +# arg 1: the old package version +post_remove() { + echo + echo "Leaving ${PRELOAD_STATE} intact in case one day you want to" + echo "install preload again. If you are sure you don't need it anymore, please" + echo "remove it manually. Log files in /var/log have not been removed as well." + echo +} + +# vim:set ts=2 sw=2 et: diff --git a/community/preload/rc.preload b/community/preload/rc.preload new file mode 100644 index 000000000..a3cb01ba0 --- /dev/null +++ b/community/preload/rc.preload @@ -0,0 +1,97 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/preload +# +# Starts the preload daemon +# +# Heavily modified for Arch Linux by Leslie P. Polzer <polzer@gnu.org>. + +. /etc/rc.conf +. /etc/rc.d/functions + +PID=`pidof -o %PPID /usr/sbin/preload` + +if [ -f /etc/conf.d/preload ]; then + . /etc/conf.d/preload +fi + +MIN_MEMORY=${MIN_MEMORY:-256} +# Check for > MIN_MEMORY MB +free -m | awk '/Mem:/ {exit ($2 >= ('"$MIN_MEMORY"'))?0:1}' || exit 0 + +RETVAL=0 + +# +# See how we were called. +# + +start() { + if [ -z "$PID" ]; then + stat_busy "Starting preload daemon: " + /usr/sbin/preload $PRELOAD_OPTS + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + if [ -n $IONICE_OPTS ]; then + /usr/bin/ionice $IONICE_OPTS -p "`pidof -o %PPID /usr/sbin/preload`" + fi + add_daemon preload + stat_done + else + stat_fail + fi + fi + return $RETVAL +} + +stop() { + stat_busy "Stopping preload daemon: " + kill $PID &>/dev/null + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + rm_daemon preload + stat_done + PID="" + else + stat_fail + fi + return $RETVAL +} + + +restart() { + $0 stop + sleep 1 + $0 start +} + +reload() { + trap "" SIGHUP + kill -HUP $PID +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + reload) + reload + ;; + restart) + restart + ;; + condrestart) + if [ ! -z $PID ]; then + restart + else + stat_fail + fi + ;; + *) + echo "Usage: $0 {start|stop|restart|condrestart|reload}" + exit 1 +esac + +exit $RETVAL |