#!/bin/bash
#
# Build file for package tclcrypt
#
# Copyright by Jan Kandziora <tkkasse@users.sf.net>
#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#


PRISTINE_SOURCE_PATH=..
INSTALL_PATH=/usr/
MODULE_NAME=tclcrypt
SOURCE_PATH=~/src/packages/SOURCES
VERSION=1.0
RELEASE=2


rm -r $SOURCE_PATH/${MODULE_NAME}*
cp -R $PRISTINE_SOURCE_PATH/$MODULE_NAME $SOURCE_PATH/${MODULE_NAME}-$VERSION
tar -cj -f $SOURCE_PATH/${MODULE_NAME}-$VERSION.tar.bz2 --exclude '.*' --exclude CVS -C $SOURCE_PATH ${MODULE_NAME}-$VERSION
cat >$SOURCE_PATH/${MODULE_NAME}.spec <<EOT
AutoReqProv:   yes
BuildRequires: bash binutils bzip2 coreutils diffutils gcc glibc glibc-devel make rpm tar tcl tcl-devel
BuildRoot:     %{_tmppath}/%{name}-%{version}-build
Group:         Development/Libraries/Tcl
License:       GPL
Name:          $MODULE_NAME
Packager:      Jan Kandziora <tkkasse@users.sf.net>
#Patch:
Release:       $RELEASE
Requires:      tcl >= 8.2-1
Summary:       Crypt and random functions for Tcl
Source:        http://prdownloads.sf.net/tkkasse//%{name}-%{version}.tar.bz2
URL:           http://tkkasse.sf.net/
Version:       $VERSION

%description
This Tcl extension provides access to the libcrypt and libc random
facilities. It is useful for Tcl applications that need some
simple password authentication and need to avoid clear
text passwords. Both DES and MD5 password hashes are supported.

The random functions included are intended to generate "salt"
for the passwords but can be used for other purposes, too.
The libc pseudo-random generator can be "seeded" by using a file
like /dev/random, so the resulting numbers are really random.

Author: Jan Kandziora <tkkasse@users.sf.net>

%prep
%setup -n %{name}-%{version}
#%patch

%build
rm -rf \$RPM_BUILD_ROOT
./configure --prefix $INSTALL_PATH
make

%install
rm -rf \$RPM_BUILD_ROOT
mkdir -p \$RPM_BUILD_ROOT$INSTALL_PATH/lib/tclcrypt
install -c -m 644 libtclcrypt1.0.so \$RPM_BUILD_ROOT$INSTALL_PATH/lib
tclsh mkIndex.tcl
mkdir -p \$RPM_BUILD_ROOT$INSTALL_PATH/include
install -c -m 644 tclcrypt.h \$RPM_BUILD_ROOT$INSTALL_PATH/include
mkdir -p \$RPM_BUILD_ROOT$INSTALL_PATH/man/mann
install -c -m 444 crypt.n \$RPM_BUILD_ROOT$INSTALL_PATH/man/mann

%clean
rm -rf \$RPM_BUILD_ROOT

%post

%files
%defattr(-,root,root)
%doc COPYING
$INSTALL_PATH/lib/libtclcrypt1.0.so
$INSTALL_PATH/lib/tclcrypt/pkgIndex.tcl
$INSTALL_PATH/include/tclcrypt.h
$INSTALL_PATH/man/mann/crypt.n.gz

%changelog -n %{name}
* Wed Oct 20 2004 - tkkasse@users.sf.net
- new build script
* Mon Sep 13 2004 - tkkasse@users.sf.net
- initial package
EOT

rpmbuild -ba -v $SOURCE_PATH/${MODULE_NAME}.spec

