2010-11-04 08:41:32 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
if [ -e /etc/sysconfig/ghc-doc-index ]; then
|
|
|
|
. /etc/sysconfig/ghc-doc-index
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$CRON" = "no" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
LOCKFILE=/var/lock/ghc-doc-index.lock
|
|
|
|
|
|
|
|
# the lockfile is not meant to be perfect, it's just in case the
|
2010-12-30 02:06:23 +00:00
|
|
|
# two cron scripts get run close to each other to keep
|
|
|
|
# them from stepping on each other's toes.
|
2010-11-04 08:41:32 +00:00
|
|
|
[ -f $LOCKFILE ] && exit 0
|
|
|
|
|
|
|
|
trap "{ rm -f $LOCKFILE ; exit 255; }" EXIT
|
|
|
|
touch $LOCKFILE
|
|
|
|
|
2010-12-30 02:06:23 +00:00
|
|
|
PKGDIRCACHE=/var/lib/ghc/pkg-dir.cache
|
|
|
|
LISTING="env LANG=C ls -dl"
|
|
|
|
|
2010-11-04 08:41:32 +00:00
|
|
|
# only re-index ghc docs when there are changes
|
|
|
|
cd /usr/share/doc/ghc/html/libraries
|
2010-12-30 02:06:23 +00:00
|
|
|
if [ -r "$PKGDIRCACHE" ]; then
|
|
|
|
$LISTING */ > $PKGDIRCACHE.new
|
|
|
|
DIR_DIFF=$(diff $PKGDIRCACHE $PKGDIRCACHE.new)
|
2010-11-04 08:41:32 +00:00
|
|
|
else
|
2010-12-30 02:06:23 +00:00
|
|
|
$LISTING */ > $PKGDIRCACHE
|
2010-11-04 08:41:32 +00:00
|
|
|
fi
|
2010-12-30 02:06:23 +00:00
|
|
|
if [ -x "gen_contents_index" -a ! -r "$PKGDIRCACHE.new" -o -n "$DIR_DIFF" ]; then
|
2010-11-04 08:41:32 +00:00
|
|
|
./gen_contents_index --batch
|
|
|
|
fi
|
|
|
|
|
2010-12-30 02:06:23 +00:00
|
|
|
if [ -f $PKGDIRCACHE.new ]; then
|
|
|
|
mv -f $PKGDIRCACHE{.new,}
|
2010-11-04 08:41:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|