Blame SOURCES/ghc-doc-index

a43873
#!/bin/sh
a43873
a43873
LOCKFILE=/var/lock/ghc-doc-index.lock
a43873
a43873
# the lockfile is not meant to be perfect, it's just in case
a43873
# two cron scripts get run close to each other to keep
a43873
# them from stepping on each other's toes.
a43873
if [ -f $LOCKFILE ]; then
a43873
  echo "Locked with $LOCKFILE"
a43873
  exit 0
a43873
fi
a43873
a43873
if [ "$(id -u)" != "0" ]; then
a43873
  echo Need to be root!
a43873
  exit 1
a43873
fi
a43873
a43873
trap "{ rm -f $LOCKFILE ; exit 255; }" EXIT
a43873
touch $LOCKFILE
a43873
a43873
PKGDIRCACHE=/var/lib/ghc/pkg-dir.cache
a43873
LISTING="env LANG=C ls -dl"
a43873
a43873
# only re-index ghc docs when there are changes
a43873
cd /usr/share/doc/ghc/html/libraries
a43873
if [ -r "$PKGDIRCACHE" ]; then
a43873
  $LISTING */ > $PKGDIRCACHE.new
a43873
  DIR_DIFF=$(diff $PKGDIRCACHE $PKGDIRCACHE.new)
a43873
else
a43873
  $LISTING */ > $PKGDIRCACHE
a43873
fi
a43873
if [ -x "gen_contents_index" -a ! -r "$PKGDIRCACHE.new" -o -n "$DIR_DIFF" ]; then
a43873
  ./gen_contents_index
a43873
fi
a43873
a43873
if [ -f $PKGDIRCACHE.new ]; then
a43873
  mv -f $PKGDIRCACHE.new $PKGDIRCACHE
a43873
fi