#!/bin/sh
# Set initial variables:

VERSION=$1

cd $TMP
rm -rf fileutils-*
tar xzf $ORIGPATH/fileutils-$VERSION.tar.gz
cd fileutils-*

mkdir -p /usr/doc/fileutils-$VERSION
install -m644 ABOUT-NLS AUTHORS COPYING INSTALL NEWS README THANKS TODO \
             /usr/doc/fileutils-$VERSION

# We're adding back the Slackware-color-ls version of dircolors, since the
# GNU version is missing some nice options.
> src/dircolors.c
> src/dircolors.c.orig
zcat $ORIGPATH/fileutils.dircolors.diff.gz | patch -p0 --verbose
zcat $ORIGPATH/fileutils.man.diff.gz | patch -p1 --verbose
zcat $ORIGPATH/fileutils-4.1.rm.diff.gz | patch -p1 --verbose

# Compile
CFLAGS="${ARMCFLAGS}"  ${ARMCONFIGURE}   \
              --prefix=/usr     \
              --sysconfdir=/etc 

# Make will fail when it tries to execute its copy of 'mv'.
# although I'm not sure if this is a problem -- does it miss anything ?
# If it does then I can just do the same as I do in floppy.build
make -e


( cd src
  # I suppose I could do 'make install' but since I have the exact
  # locations listed in the original SlackBuild, I may as well just use this
  # instead to save me missing something.
  mv chgrp     /bin/
  mv chmod     /bin/
  mv chown     /bin/
  mv cp        /bin/
  mv dd        /bin/
  mv df        /bin/
  mv dircolors /bin/
  mv du        /bin/
  mv ginstall  /usr/bin/
  mv ln        /bin/
  mv ls        /bin/
  mv mkdir     /bin/
  mv mkfifo    /bin/
  mv mknod     /bin/
  mv mv        /bin/
  mv rm        /bin/
  mv rmdir     /bin/
  mv shred     /bin/
  mv sync      /bin/
  mv touch     /bin/
)

tar xzvf $ORIGPATH/fileutils.man.tar.gz man/dircolors.1 -C /usr/man/man1/ 

# Install man pages
( cd man ;  install -m644 *.1 /usr/man/man1/ )

install -m644 doc/fileutils.info /usr/info/ 

( cd po
  for locale in *.gmo ; do
      mkdir -p /usr/share/locale/`basename $locale .gmo`/LC_MESSAGES
      cat $locale > /usr/share/locale/`basename $locale .gmo`/LC_MESSAGES/fileutils.mo
  done )

mkdir /etc
zcat $ORIGPATH/DIR_COLORS.gz > ${SLACKTRACKFAKEROOT}/etc/DIR_COLORS

mkdir -p /install
install -m644 ${ORIGPATH}/slack-desc /install/

#EOF
