#!/bin/sh
#
# Copyright 2005 Zach Borgerding <zborgerd@gmail.com>
# Available under the terms of the GNU GPL.
#

NAME="cracklib"
VERSION="2.8.3"
REVISION="2"

PKG_SOURCEURL='http://switch.dl.sourceforge.net/sourceforge/$NAME/$NAME-$VERSION.tar.gz'

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

cflags
prepare
analyzesource

# Make the installation directories
spewdo "mkdir -p $PKG_STAGEROOT/usr/include"
spewdo "mkdir -p $PKG_STAGEROOT/usr/lib"
spewdo "mkdir -p $PKG_STAGEROOT/usr/sbin"
spewdo "mkdir -p $PKG_STAGEROOT/usr/share/cracklib"

# Install the wordlist from:
# http://switch.dl.sourceforge.net/sourceforge/cracklib/cracklib-words.gz
spewdo "mkdir -p $PKG_STAGEROOT/usr/share/dict"
findpatch filename wordslist.gz
spewdo "zcat $filename > $PKG_STAGEROOT/usr/share/dict/wordslist"

configure --with-pic
make
makeinstall install-strip

spewdo "mkdir -p $PKG_STAGEROOT/usr/include"
spewdo "cp $PKG_BUILDROOT/lib/packer.h $PKG_STAGEROOT/usr/include/"
spewdo "cp $PKG_BUILDROOT/lib/crack.h $PKG_STAGEROOT/usr/include/"
spewdo "chmod 644 $PKG_STAGEROOT/usr/include/packer.h"
spewdo "chmod 644 $PKG_STAGEROOT/usr/include/crack.h"

# create,format and pack the dicts
spewdo "export LD_LIBRARY_PATH=$PKG_STAGEROOT/usr/lib"
spewdo "$PKG_STAGEROOT/usr/sbin/cracklib-format $PKG_STAGEROOT/usr/share/dict/wordslist | $PKG_STAGEROOT/usr/sbin/cracklib-packer $PKG_STAGEROOT/usr/share/cracklib/cracklib_dict"
spewdo "unset LD_LIBRARY_PATH"

tidydocumentation
analyzebinaries
finalizepackage
packagize
cleanup
