IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=2.7
PROGNAME="slocate $VERSION"
DESC="\
slocate (Secure Locate)                                                \n\
                                                                       \n\
Slocate is an enhanced version of locate, a command to help you locate \n\
files on the system.  Like the original version of locate, Slocate     \n\
maintains a database of files on the system, updating it nightly.      \n\
Unlike the original, Slocate indexes every file on the machine rather  \n\
than only the ones that can be seen by everyone.  The "secure" part of \n\
slocate is that it will only return matches if the user is allowed to  \n\
see the files."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=ftp://ftp.geekreview.org/slocate/src/
PKGNAME=slocate-$VERSION-s390-$BUILD
TAG=REC

compile() {
   tar -zxvf $CWD/slocate-$VERSION.tar.gz

   cd slocate-$VERSION/
   cat $CWD/makefile.in.diff | patch -p1
   chown -R root.root .
   find . -perm 664 -exec chmod 644 {} \;
   find . -perm 600 -exec chmod 644 {} \;
   find . -perm 444 -exec chmod 644 {} \;
   find . -perm 400 -exec chmod 644 {} \;
   find . -perm 440 -exec chmod 644 {} \;
   find . -perm 777 -exec chmod 755 {} \;
   find . -perm 775 -exec chmod 755 {} \;
   find . -perm 511 -exec chmod 755 {} \;
   find . -perm 711 -exec chmod 755 {} \;
   find . -perm 555 -exec chmod 755 {} \;
   CFLAGS=-O2 ./configure --prefix=/usr

   # Pat says: Developers SHOULD NOT require a certain version of autoconf/make!
   make -i clean
   make -i
}

install() {
   mkdir -p /package-slocate/usr/man/man1
   make -i install DESTDIR=/package-slocate

   ( cd /package-slocate/usr/bin;
     rm -f updatedb locate
     ln -s slocate locate
     ln -s slocate updatedb
   )

   ( cd /package-slocate/usr/man/man1
     rm -f locate.1.gz
     ln -s slocate.1.gz locate.1.gz
   )

   ( cd /package-slocate/; tar -zxvf $CWD/_slocate.tar.gz etc/ )

   mkdir -p /package-slocate/usr/doc/slocate-$VERSION
   cp AUTHORS ChangeLog INSTALL LICENSE README \
      /package-slocate/usr/doc/slocate-$VERSION
}

attributes() {
   chown -R root.bin $PKG/package-slocate/usr/bin
   chown root.slocate $PKG/package-slocate/usr/bin/slocate \
                      $PKG/package-slocate/var/lib/slocate/
   chmod 2755 $PKG/package-slocate/usr/bin/slocate
   chmod 640 $PKG/package-slocate/usr/doc/slocate-$VERSION/*
   chmod 750 $PKG/package-slocate/var/lib/slocate/
}

special() {
   cd $PKG
   mv package-slocate/* ./
   rmdir package-slocate

   cd $CTL
   cat $CWD/slack-desc > slack-desc

   cat $CWD/group.sh >> doinst.sh
   sed -e 's%package-slocate/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new

   cat $CWD/config.sh >> doinst.sh
   echo config etc/updatedb.conf.new >> doinst.sh

   cat >> doinst.sh << EOF
if ! grep ^slocate: etc/group 1> /dev/null 2> /dev/null ; then
  echo "slocate::21:" >> etc/group
  chown root.slocate usr/bin/slocate
  chown root.slocate var/lib/slocate
fi
EOF
}

