#!/bin/sh
#
# Copyright 2004, 200, 2008 Dagmar d'Surreal <rivyqntzne@tznvy.pbz>
# Available under the terms of the GNU GPL.
#

NAME="krb5"
VERSION="1.6.3"
REVISION="4"
PKG_SOURCEURL='http://dagmar.droplinegnome.org/2.22/sources/$NAME-$VERSION.tar.gz'
PKG_PATCH[0]='man2htmlfix.diff'

PKG_BUILDDIR="src"

. $DLG_ROOT/config
. $DLG_ROOT/SCRIPTS/dropline-functions.sh

PKG_OPTLEVEL="${PKG_OPTLEVEL:+$PKG_OPTLEVEL }-fstack-protector-all"
cflags
cxxflags
prepare
applypatch 0 1
analyzesource
configure --enable-shared --enable-dns --mandir=$PKG_PREFIX/man
make
makeinstall install-strip

# We really want to avoid collisions with existing named binaries.
( spewdo "cd $PKG_STAGEROOT"
  for tmp in ftpd telnetd; do
    spewdo "mv usr/sbin/$tmp usr/sbin/k$tmp"
    spewdo "mv usr/man/man8/$tmp.8 usr/man/man8/k$tmp.8"    
  done

  for tmp in rsh rcp rlogin ftp telnet; do
    spewdo "mv usr/bin/$tmp usr/bin/k$tmp"
    spewdo "mv usr/man/man1/$tmp.1 usr/man/man1/k$tmp.1"
  done
)
# Bring the shared libraries in line with the way all the others are.
spewdo "find $PKG_STAGEROOT -type f -name "*.so*" ! -perm 755 -exec chmod 755 \{\} \\;"

spewdo "mkdir -p $PKG_STAGEROOT$PKG_SYSCONFDIR/krb5kdc"
spewdo "cp $PKG_SRCROOT/config-files/krb.conf $PKG_STAGEROOT$PKG_SYSCONFDIR/krb.conf-sample"
spewdo "cp $PKG_SRCROOT/config-files/kdc.conf $PKG_STAGEROOT$PKG_SYSCONFDIR/krb5kdc/kdc.conf-sample"

tidydocumentation

# There's a whole mess of documentation that comes with this baby.
spewdo "cp -adR $PKG_SRCROOT/doc/* $PKG_STAGEROOT$PKG_DOCDIR/"
# ...and some examples that otherwise wind up in a stupid place.
spewdo "mv $PKG_STAGEROOT$PKG_DATADIR/examples $PKG_STAGEROOT$PKG_DOCDIR/examples"

analyzebinaries
finalizepackage
packagize
cleanup
